Camera control

This commit is contained in:
Emmanuel BENOîT 2017-09-30 11:47:28 +02:00
parent f0b4f2d46e
commit 4ff19bffa6

24
main.cc
View file

@ -17,16 +17,18 @@ struct T_Main
const std::string projectFile; const std::string projectFile;
SDL_Window * window; SDL_Window * window;
SDL_GLContext gl; SDL_GLContext gl;
T_FilesWatcher watcher;
T_WatchedFiles shaderFiles;
GLuint prog;
std::string loadError;
bool done = false; bool done = false;
bool capture = false; bool capture = false;
ImVec2 mouseInitial; ImVec2 mouseInitial;
ImVec2 mouseMove; ImVec2 mouseMove;
T_Camera camera;
T_FilesWatcher watcher;
T_WatchedFiles shaderFiles;
GLuint prog;
void startIteration( ); void startIteration( );
void handleCapture( ); void handleCapture( );
void makeUI( ); void makeUI( );
@ -128,8 +130,7 @@ void T_Main::handleCapture( )
ImGui::SetMouseCursor( ImGuiMouseCursor_Arrow ); ImGui::SetMouseCursor( ImGuiMouseCursor_Arrow );
} else if ( capture ) { } else if ( capture ) {
ImGui::SetMouseCursor( ImGuiMouseCursor_Move ); ImGui::SetMouseCursor( ImGuiMouseCursor_Move );
//project->handleDND( mouseMove , ctrl , shift , lmb ); camera.handleDND( mouseMove , ctrl , shift , lmb );
// FIXME: D'n'D
} else if ( appCanGrab && mb ) { } else if ( appCanGrab && mb ) {
capture = true; capture = true;
mouseInitial = ImGui::GetMousePos( ); mouseInitial = ImGui::GetMousePos( );
@ -139,8 +140,7 @@ void T_Main::handleCapture( )
} }
if ( ( appCanGrab || capture ) && io.MouseWheel ) { if ( ( appCanGrab || capture ) && io.MouseWheel ) {
//project->handleWheel( io.MouseWheel , ctrl , shift ); camera.handleWheel( io.MouseWheel , ctrl , shift );
// FIXME wheel
} }
} }
@ -175,10 +175,10 @@ void T_Main::render( )
glUniform1f( U_TIME , 0 ); glUniform1f( U_TIME , 0 );
glUniform2f( U_RESOLUTION , dspSize.x , dspSize.y ); glUniform2f( U_RESOLUTION , dspSize.x , dspSize.y );
glUniform3f( U_CAM_POS , 0 , 0 , -15 ); glUniform3fv( U_CAM_POS , 1 , &camera.pos.x );
glUniform3f( U_LOOK_AT , 0 , 0 , 0 ); glUniform3fv( U_LOOK_AT , 1 , &camera.lookAt.x );
glUniform3f( U_CAM_UP , 0 , 1 , 0 ); glUniform3fv( U_CAM_UP , 1 , &camera.up.x );
glUniform1f( U_NEAR_PLANE , 1 ); glUniform1f( U_NEAR_PLANE , camera.np );
glUniform3f( U_LIGHT_DIR , 0 , 1 , 1 ); glUniform3f( U_LIGHT_DIR , 0 , 1 , 1 );
glUniform4f( U_RENDER , 128 , 0.9 , 0.001 , 100 ); glUniform4f( U_RENDER , 128 , 0.9 , 0.001 , 100 );