Camera *pCam = new Camera();
// Need to add a light here until we figure out how to use the sun position and color
SkyLight::SkyLightType eType = SkyLight::SKY_LIGHT_DIRECTIONAL;
-SkyLight *pLight = new SkyLight(eType);
+SkyLight *pLight = 0;
// hack
sgMat4 my_copy_of_ssgOpenGLAxisSwapMatrix =
}
+
+//------------------------------------------------------------------------------
+// Function : SkySceneLoader::Load
+// Description :
+//------------------------------------------------------------------------------
+/**
+ * @fn SkySceneLoader::Load(std::string filename)
+ * @brief Loads a SkyWorks scene.
+ *
+ * This is a temporary fix, as it loads only limited scenes
+ * It can however, load any number of Cloud
+ +
+ */
+//bool SkySceneLoader::Load(std::string filepath)
+bool SkySceneLoader::Load( unsigned char *data, unsigned int size, double latitude, double longitude )
+{
+ if( !pLight)
+ pLight = new SkyLight(eType);
+
+ // Need to create the managers
+ cout << "GraphicsContext::Instantiate();" << endl;
+ GraphicsContext::Instantiate();
+ cout << " TextureManager::Instantiate();" << endl;
+ TextureManager::Instantiate();
+ cout << " DynamicTextureManager::Instantiate();" << endl;
+ DynamicTextureManager::Instantiate();
+ cout << " SceneManager::Instantiate();" << endl;
+ SceneManager::Instantiate();
+
+ float rScale = 40.0;
+ FAIL_RETURN(SceneManager::InstancePtr()->LoadClouds(data, size, rScale, latitude, longitude));
+
+ Vec3f dir(0, 0, 1);
+ pLight->SetPosition(Vec3f(0, 0, 17000));
+ pLight->SetDirection(dir);
+ pLight->SetAmbient(Vec4f( 0.0f, 0.0f, 0.0f, 0.0f));
+ pLight->SetDiffuse(Vec4f(1.0f, 1.0f, 1.0f, 0.0f));
+ //pLight->SetDiffuse(Vec4f(0.0f, 0.0f, 0.0f, 0.0f));
+ //pLight->SetSpecular(Vec4f(1.0f, 1.0f, 1.0f, 0.0f));
+
+ // No attenuation
+ pLight->SetAttenuation(1.0f, 0.0f, 0.0f);
+ SceneManager::InstancePtr()->AddLight(pLight);
+
+ SceneManager::InstancePtr()->ShadeClouds();
+
+ return true;
+}
+
//------------------------------------------------------------------------------
// Function : SkySceneLoader::Load
// Description :
+
*/
//bool SkySceneLoader::Load(std::string filepath)
-bool SkySceneLoader::Load( SGPath filename )
+bool SkySceneLoader::Load( SGPath filename, double latitude, double longitude )
{
SkyArchive archive;
unsigned int iNumFiles;
if (!SKYFAILED(archive.GetInfo("CloudFile", STRING_TYPE, &iNumFiles)))
{
+ iNumFiles = ulEndianLittle32(iNumFiles);
for (unsigned int i = 0; i < iNumFiles; ++i)
{
FAIL_RETURN(archive.FindString("CloudFile", &pFilename, i));
base.append( pFilename );
const char *FilePath = base.c_str();
- float rScale = 1.0;
- FAIL_RETURN(archive.FindFloat32("CloudScale", &rScale, i));
- rScale = 30.0;
+ //float rScale = 1.0;
+ //FAIL_RETURN(archive.FindFloat32("CloudScale", &rScale, i));
+ float rScale = 40.0;
SkyArchive cloudArchive;
+ cout << "Calling cloudArchive.Load(FilePath)" << endl;
FAIL_RETURN(cloudArchive.Load(FilePath));
- FAIL_RETURN(SceneManager::InstancePtr()->LoadClouds(cloudArchive, rScale));
+ cout << "Calling SceneManager::InstancePtr()->LoadClouds" << endl;
+ FAIL_RETURN(SceneManager::InstancePtr()->LoadClouds(cloudArchive, rScale, latitude, longitude));
}
}
+ cout << "After Load Clouds" << endl;
Vec3f dir(0, 0, 1);
+ if( !pLight)
+ pLight = new SkyLight(eType);
+
pLight->SetPosition(Vec3f(0, 0, 17000));
pLight->SetDirection(dir);
pLight->SetAmbient(Vec4f( 0.0f, 0.0f, 0.0f, 0.0f));
// No attenuation
pLight->SetAttenuation(1.0f, 0.0f, 0.0f);
+ cout << "Before SceneManager::InstancePtr()->AddLight(pLight)" << endl;
SceneManager::InstancePtr()->AddLight(pLight);
+ cout << "Before SceneManager::InstancePtr()->ShadeClouds()" << endl;
SceneManager::InstancePtr()->ShadeClouds();
+ cout << "After SceneManager::InstancePtr()->ShadeClouds()" << endl;
return true;
}
{
double wind_x, wind_y, wind_z;
- wind_x = -0.05; wind_z = 0.05;
- // just a dumb test to see if we can move the clouds en masse via the camera
+ wind_x = 0.0; wind_z = 0.0;
+ // just a dumb test to see what happens if we can move the clouds en masse via the camera
delta[0] += wind_x; delta[2] += wind_z;
sgdSubVec3( cam_pos, view_pos, delta );
}
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 () ;
}