Changeset 2760 for GTP/trunk/App/Demos/Vis/CHC_revisited/chcdemo.cpp
- Timestamp:
- 06/14/08 19:04:01 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/CHC_revisited/chcdemo.cpp
r2759 r2760 13 13 #include "Camera.h" 14 14 #include "Geometry.h" 15 #include "BvhLoader.h" 16 #include "FrustumCullingTraverser.h" 17 15 18 16 19 … … 30 33 /// the scene bounding box 31 34 AxisAlignedBox3 sceneBox; 35 /// the current render state 36 RenderState state; 32 37 33 38 // eye near plane distance 34 39 float nearDist = 0.1f; 35 int winWidth, winHeight; 40 int winWidth = 1024; 41 int winHeight = 768; 36 42 float winAspectRatio = 1.0f; 37 43 … … 44 50 bool showCreateParams = false; 45 51 46 47 Vector3 eyePos = Vector3(0.0f, 0.0f, 3.0f); // eye position 48 Vector3 viewDir = Vector3(0.0f, 0.0f, -1.0f); // eye view dir 49 Vector3 lightDir = Vector3(0.0f, 0.0f, 1.0f); // light dir 50 51 Matrix4x4 visView; // visualisation view matrix 52 int currentFrame = -1; 53 54 // visualisation view matrix 55 Matrix4x4 visView; 52 56 53 57 //mouse navigation state 54 58 int xEyeBegin, yEyeBegin, yMotionBegin, verticalMotionBegin, horizontalMotionBegin = 0; 55 59 //int renderMode = RenderTraverser::RENDER_COHERENT; 56 57 60 58 61 const int renderTimeSize = 100; … … 100 103 int main(int argc, char* argv[]) 101 104 { 102 camera = new Camera( 800, 600);103 104 glutInitWindowSize( 800, 600);105 camera = new Camera(winWidth, winHeight); 106 107 glutInitWindowSize(winWidth, winHeight); 105 108 glutInit(&argc, argv); 106 109 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); … … 124 127 125 128 //const string filename("house_test.dem"); 126 const string filename("city_demo.dem"); 129 //const string filename("city_demo.dem"); 130 const string filename("city.dem"); 127 131 128 132 if (loader.Load(filename, sceneEntities)) … … 131 135 cerr << "loading scene " << filename << " failed" << endl; 132 136 133 sceneBox.Initialize(); 134 135 SceneEntityContainer::const_iterator it, it_end = sceneEntities.end(); 136 137 for (it = sceneEntities.begin(); it != it_end; ++ it) 138 sceneBox.Include((*it)->GetBoundingBox()); 139 140 cout << "scene box: " << sceneBox << endl; 141 137 BvhLoader bvhLoader; 138 bvh = bvhLoader.Load("city.bvh", sceneEntities); 139 140 sceneBox = bvh->GetBox(); 141 142 traverser = new FrustumCullingTraverser(); 143 traverser->SetHierarchy(bvh); 144 traverser->SetRenderState(&state); 142 145 143 146 //SetupProjection(800, 600, 60, sceneBox); … … 162 165 void InitGLstate(void) 163 166 { 164 glClearColor(0. 0f, 0.0f, 0.0f, 0.0);167 glClearColor(0.5f, 0.5f, 0.8f, 0.0); 165 168 166 169 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); … … 171 174 SetupLighting(); 172 175 173 glColor3f(1.0f, 0.0f, 0.0f);176 glColor3f(1.0f, 1.0f, 1.0f); 174 177 glShadeModel(GL_SMOOTH); 175 176 178 177 179 glMaterialf(GL_FRONT, GL_SHININESS, 64); … … 190 192 glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuseColor); 191 193 glMaterialfv(GL_FRONT, GL_SPECULAR, specularColor); 192 193 glColor3f(1.0f, 0.0f, 0.0f);194 194 //setupVisView(); 195 195 } … … 277 277 GLfloat ambient[] = {0.2, 0.2, 0.2, 1.0}; 278 278 GLfloat diffuse[] = {1.0, 1.0, 1.0, 1.0}; 279 //GLfloat specular[] = {1.0, 1.0, 1.0, 1.0}; 279 280 GLfloat specular[] = {1.0, 1.0, 1.0, 1.0}; 280 281 … … 286 287 glLightfv(GL_LIGHT0, GL_SPECULAR, specular); 287 288 288 GLfloat position[] = { 0.0, 3.0, 3.0, 0.0};289 GLfloat position[] = {1.0, 1.0, 1.0, 0.0}; 289 290 glLightfv(GL_LIGHT0, GL_POSITION, position); 290 291 … … 293 294 //-- second light 294 295 295 GLfloat ambient1[] = {0.2, 0.2, 0.2, 1.0}; 296 GLfloat ambient1[] = {0.5, 0.5, 0.5, 1.0}; 297 //GLfloat diffuse1[] = {1.0, 1.0, 1.0, 1.0}; 296 298 GLfloat diffuse1[] = {0.5, 0.5, 0.5, 1.0}; 297 GLfloat specular1[] = {0. 0, 0.0, 0.0, 1.0};299 GLfloat specular1[] = {0.5, 0.5, 0.5, 1.0}; 298 300 299 301 glLightfv(GL_LIGHT1, GL_AMBIENT, ambient1); … … 314 316 void SetupEyeView(void) 315 317 { 316 317 318 glMatrixMode(GL_PROJECTION); 318 319 glLoadIdentity(); … … 323 324 glLoadIdentity(); 324 325 325 GLfloat position[] = {0.0f, 3.0f, 3.0f, 0.0f}; 326 camera->SetupCameraView(); 327 328 GLfloat position[] = {0.8f, 1.0f, 1.5f, 0.0f}; 326 329 glLightfv(GL_LIGHT0, GL_POSITION, position); 327 330 328 GLfloat position1[] = {sceneBox.Center().x, sceneBox.Center().y, sceneBox.Center().z, 1.0f}; 331 GLfloat position1[] = {sceneBox.Center().x, sceneBox.Max().y, sceneBox.Center().z, 1.0f}; 332 //GLfloat position1[] = {-2.0f, 1.0f, 0.0f, 0.0f}; 329 333 glLightfv(GL_LIGHT1, GL_POSITION, position1); 330 331 camera->SetupCameraView();332 333 334 334 } 335 335 … … 374 374 */ 375 375 376 ++ currentFrame; 376 377 377 378 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); … … 380 381 SetupEyeView(); 381 382 383 bvh->InitFrame(camera, currentFrame); 384 385 382 386 InitTiming(); 383 387 … … 389 393 glEnableClientState(GL_NORMAL_ARRAY); 390 394 395 traverser->Render(); 396 /* 391 397 bool usesTextures = false; 392 398 … … 412 418 entity->Render(); 413 419 } 414 420 */ 415 421 glDisableClientState(GL_VERTEX_ARRAY); 416 422 glDisableClientState(GL_NORMAL_ARRAY); … … 568 574 { 569 575 // used to avoid vertical motion with the keys 570 Vector3 hvec = Vector3(viewDir[0], 0, viewDir[2]);576 //Vector3 hvec = Vector3(viewDir[0], 0, viewDir[2]); 571 577 572 578 switch(c)
Note: See TracChangeset
for help on using the changeset viewer.