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
This commit is contained in:
ehofman 2003-08-03 21:23:21 +00:00
parent c9a4a6975c
commit 73a4994cac

View File

@ -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 ) ;
{
sgMat4 cameraMatrix;
sgCopyMat4 ( cameraMatrix, my_copy_of_ssgOpenGLAxisSwapMatrix ) ;
sgPreMultMat4 ( cameraMatrix, viewmat ) ;
// sgCopyMat4(cameraMatrix,mat);
// or just
ssgGetModelviewMatrix(cameraMatrix);
glMatrixMode ( GL_MODELVIEW ) ;
glLoadIdentity () ;
glLoadMatrixf( (float *) cameraMatrix );
//sgCopyMat4 ( test, cameraMatrix );
pCam->SetModelviewMatrix( (float *) 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;
SceneManager::InstancePtr()->Display(*pCam);
// this is the cameraview matrix used by flightgear to render scene
//_ssgCurrentContext->getModelviewMatrix( m );
glMatrixMode ( GL_MODELVIEW ) ;
glLoadIdentity () ;
glLoadMatrixf( (float *) cameraMatrix );
//sgCopyMat4( test, m );
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;
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 () ;
}