From: ehofman Date: Sun, 3 Aug 2003 21:23:21 +0000 (+0000) Subject: Norman Vine: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=73a4994cace4a2a3605c9a86805525b13556c819;p=simgear.git Norman Vine: Note that SSG and OpenGL use different representations of Matrices. 1) SSG is row major and OpenGL is column major 2) SSG uses a Z is up whereas conventionally OpenGL uses Z is pointing into the screen ie this just requires swapping the Y and the Z axis < columns > and negating the new Y column 3) Now since SSG eventually calls OpenGL SSG must do this for us behind the scenes or else things just wouldn't work so inorder to get Clouds3D to render in the proper location we should just need to use the Matrix that SSG uses for a Camera Matrix and pass this directly to the Clouds3D Camers --- diff --git a/simgear/scene/sky/clouds3d/SkySceneLoader.cpp b/simgear/scene/sky/clouds3d/SkySceneLoader.cpp index 099eb54b..288133fc 100644 --- a/simgear/scene/sky/clouds3d/SkySceneLoader.cpp +++ b/simgear/scene/sky/clouds3d/SkySceneLoader.cpp @@ -197,54 +197,23 @@ void SkySceneLoader::Resize( double w, double h ) } void SkySceneLoader::Draw( sgMat4 mat ) -{/* need this if you want to look at FG matrix - if ( _ssgCurrentContext == NULL ) - { - cout<< "ssg: No Current Context: Did you forgot to call ssgInit()?" ; char x; cin >> x; - } - - ssgForceBasicState () ; - */ - sgMat4 test, m, *pm, viewmat, cameraMatrix; - pm = &m; - sgSetVec4(mat[3], cam_pos[0], cam_pos[1], cam_pos[2], SG_ONE); - // at this point the view matrix has the cloud camera position relative to cloud origin - // now transform to screen coordinates - sgTransposeNegateMat4 ( viewmat, mat ) ; - - sgCopyMat4 ( cameraMatrix, my_copy_of_ssgOpenGLAxisSwapMatrix ) ; - sgPreMultMat4 ( cameraMatrix, viewmat ) ; - - //sgCopyMat4 ( test, cameraMatrix ); - - //printf( "\nSkyworks ViewModel matrix\n" ); - //cout << test[0][0] << " " << test[1][0] << " " << test[2][0] << " " << test[3][0] << endl; - //cout << test[0][1] << " " << test[1][1] << " " << test[2][1] << " " << test[3][1] << endl; - //cout << test[0][2] << " " << test[1][2] << " " << test[2][2] << " " << test[3][2] << endl; - //cout << test[0][3] << " " << test[1][3] << " " << test[2][3] << " " << test[3][3] << endl; - - // this is the cameraview matrix used by flightgear to render scene - //_ssgCurrentContext->getModelviewMatrix( m ); - - glMatrixMode ( GL_MODELVIEW ) ; - glLoadIdentity () ; - glLoadMatrixf( (float *) cameraMatrix ); - - //sgCopyMat4( test, m ); +{ + sgMat4 cameraMatrix; - pCam->SetModelviewMatrix( (float *) cameraMatrix ); - - //printf( "\nFG modelview matrix\n" ); - //cout << test[0][0] << " " << test[1][0] << " " << test[2][0] << " " << test[3][0] << endl; - //cout << test[0][1] << " " << test[1][1] << " " << test[2][1] << " " << test[3][1] << endl; - //cout << test[0][2] << " " << test[1][2] << " " << test[2][2] << " " << test[3][2] << endl; - //cout << test[0][3] << " " << test[1][3] << " " << test[2][3] << " " << test[3][3] << endl; + // sgCopyMat4(cameraMatrix,mat); + // or just + ssgGetModelviewMatrix(cameraMatrix); - SceneManager::InstancePtr()->Display(*pCam); + glMatrixMode ( GL_MODELVIEW ) ; + glLoadIdentity () ; + glLoadMatrixf( (float *) cameraMatrix ); + + pCam->SetModelviewMatrix( (float *) cameraMatrix ); + + SceneManager::InstancePtr()->Display(*pCam); - //pLight->Display(); // draw the light position to debug with sun position - - glMatrixMode ( GL_MODELVIEW ) ; - glLoadIdentity () ; + //pLight->Display(); // draw the light position to debug with sun position + glMatrixMode ( GL_MODELVIEW ) ; + glLoadIdentity () ; }