Changeset 2787 for GTP/trunk/App
- Timestamp:
- 06/20/08 04:34:24 (17 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h
r2786 r2787 156 156 157 157 /// some flags 158 int mFlags;158 //int mFlags; 159 159 /// the depth of this node 160 160 unsigned char mDepth; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp
r2782 r2787 29 29 mDirection.Normalize(); 30 30 31 //Vector3 side = CrossProd(Vector3(0, 1, 0), mDirection); 32 Vector3 side = CrossProd(Vector3(0, 0, 1), mDirection); 33 31 /*Vector3 side = CrossProd(Vector3(0, 0, 1), mDirection); 34 32 mUp = -Normalize(CrossProd(side, mDirection)); 35 mRight = -Normalize(CrossProd(mDirection, mUp)); 36 37 /*float k = tan(mFovy/2);38 m Up *= k;39 m Right *= k*mWidth/mHeight;*/33 mRight = -Normalize(CrossProd(mDirection, mUp));*/ 34 35 mUp = Vector3(0, 0, 1); 36 mRight = -CrossProd(mDirection, mUp); 37 mUp = -Normalize(CrossProd(mRight, mDirection)); 40 38 } 41 39 … … 179 177 const float w_far = h_far * GetAspect(); 180 178 179 //const Vector3 view = mDirection; 181 180 const Vector3 view = mDirection; 182 181 const Vector3 fc = mPosition + view * z_far; 183 182 184 183 const Vector3 up = mUp; 185 186 184 const Vector3 right = mRight; 187 185 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h
r2786 r2787 79 79 */ 80 80 const TraversalStatistics &GetStats() const { return mStats; } 81 /** The current frame id 82 */ 83 int GetCurrentFrameId() const { return mFrameId; } 81 84 82 85 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.cpp
r2782 r2787 4 4 #include "SceneEntity.h" 5 5 #include "Bvh.h" 6 #include "RenderState.h" 7 6 8 #include <stack> 7 9 … … 22 24 Camera *vizCamera, 23 25 RenderState *renderState): 24 mBvh(bvh), mCamera(camera), mVizCamera(vizCamera), mRenderState(renderState) 26 mBvh(bvh), 27 mCamera(camera), 28 mVizCamera(vizCamera), 29 mRenderState(renderState), 30 mFrameId(0) 25 31 { 26 32 } … … 36 42 { 37 43 mRenderState = state; 44 } 45 46 47 void Visualization::SetFrameId(int frameId) 48 { 49 mFrameId = frameId; 38 50 } 39 51 … … 43 55 stack<BvhNode *> tStack; 44 56 tStack.push(mBvh->GetRoot()); 57 58 glEnableClientState(GL_VERTEX_ARRAY); 59 glEnableClientState(GL_NORMAL_ARRAY); 60 61 RenderFrustum(); 45 62 46 63 while (!tStack.empty()) … … 58 75 else 59 76 { 77 if (node->GetLastRenderedFrame() == mFrameId) 78 { 79 int geometrySize; 80 SceneEntity **entities = mBvh->GetGeometry(node, geometrySize); 81 82 for (int i = 0; i < geometrySize; ++ i) 83 { 84 SceneEntity *ent = entities[i]; 85 ent->Render(mRenderState); 86 } 87 } 60 88 //leaves.push_back(static_cast<BvhLeaf *>(node)); 61 89 } 62 90 } 91 92 mRenderState->Reset(); 93 94 glDisableClientState(GL_VERTEX_ARRAY); 95 glDisableClientState(GL_NORMAL_ARRAY); 63 96 } 64 97 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.h
r2782 r2787 39 39 */ 40 40 void SetRenderState(RenderState *state); 41 41 /** Sets the currentframe id 42 */ 43 void SetFrameId(int frameId); 42 44 43 45 protected: … … 63 65 /// the current render state 64 66 RenderState *mRenderState; 67 /// the current frame id 68 int mFrameId; 65 69 }; 66 70 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2786 r2787 85 85 bool useMultiQueries = true; 86 86 87 float rotation = 0; 88 89 Matrix4x4 visView = IdentityMatrix(); 90 87 91 88 92 void InitExtensions(); … … 108 112 void rightMotion(int x, int y); 109 113 void middleMotion(int x, int y); 110 void drawEyeView( void);111 void setupVisView( void);114 void drawEyeView(); 115 void setupVisView(); 112 116 void CalcDecimalPoint(std::string &str, int d); 113 117 void ResetTraverser(); … … 185 189 camera->SetPosition(Vector3(483.398f, 242.364f, 186.078f)); 186 190 191 visualization = new Visualization(bvh, camera, NULL, &state); 192 187 193 glutMainLoop(); 188 194 … … 229 235 glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuseColor); 230 236 glMaterialfv(GL_FRONT, GL_SPECULAR, specularColor); 231 //setupVisView();232 237 } 233 238 … … 409 414 SetupEyeView(); 410 415 411 //cout << camera->GetDirection() << " " << camera->GetPosition() << endl;412 416 // actually render the scene geometry using one of the specified algorithms 413 417 traverser->RenderScene(); 414 418 415 //if(visMode) displayVisualization();419 if (visMode) DisplayVisualization(); 416 420 417 421 DisplayStats(); … … 478 482 case '2': 479 483 visZoomFactor += 0.1; 480 setupVisView();481 484 break; 482 485 case '3': 483 486 visZoomFactor -= 0.1; 484 if(visZoomFactor < 0.1) visZoomFactor = 0.1; 485 486 setupVisView(); 487 if (visZoomFactor < 0.1) visZoomFactor = 0.1; 487 488 break; 488 489 case '8': … … 561 562 562 563 563 void special( const int c, const int x, constint y)564 void special(int c, int x, int y) 564 565 { 565 566 // used to avoid vertical motion with the keys … … 677 678 eyeXAngle = 0.2f * M_PI * (xEyeBegin - x) / 180.0; 678 679 680 rotation += eyeXAngle; 681 679 682 // rotate view vector 680 683 Matrix4x4 rot = RotationZMatrix(eyeXAngle); … … 802 805 803 806 804 // displays the visualisation of the kd tree node culling 805 void displayVisualization() 806 { 807 // displays the visualisation of culling algorithm 808 void DisplayVisualization() 809 { 810 setupVisView(); 811 812 visualization->SetFrameId(traverser->GetCurrentFrameId()); 813 807 814 begin2D(); 808 815 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); … … 816 823 glViewport(winWidth / 2, winHeight / 2, winWidth, winHeight); 817 824 glPushMatrix(); 818 //glLoadMatrixf((float *)visView.x); 819 825 //glMatrixMode(GL_PROJECTION); 826 glMatrixMode(GL_MODELVIEW); 827 glLoadIdentity(); 828 829 Vector3 pos(camera->GetPosition()); 830 pos.z = 10.0f * bvh->GetBox().Size().z; 831 pos.y = 800; 832 pos.x += 1000; 833 834 Matrix4x4 m = RotationZMatrix(-rotation); 835 Matrix4x4 t = TranslationMatrix(pos); 836 Matrix4x4 minust = TranslationMatrix(-pos); 837 838 glMultMatrixf((float *)visView.x); 839 840 glMultMatrixf((float *)t.x); 841 glMultMatrixf((float *)m.x); 842 glMultMatrixf((float *)minust.x); 843 820 844 glClear(GL_DEPTH_BUFFER_BIT); 821 845 822 846 //////////// 823 // --- visualization of the occlusion culling 847 //-- visualization of the occlusion culling 848 849 //traverser->RenderScene(); 824 850 visualization->Render(); 825 851 … … 835 861 void setupVisView() 836 862 { 837 const Vector3 up(0.0, 0.0, 1.0); 838 839 Vector3 visPos(24, 23, -6); 840 841 visPos[0] *= visZoomFactor; 842 visPos[1] *= visZoomFactor; 843 visPos[2] *= visZoomFactor; 844 845 Vector3 visDir = Vector3(-1.3f, -1, -1); 846 } 847 863 Vector3 pos(-camera->GetPosition()); 864 pos.z = -10.0f * bvh->GetBox().Size().z; 865 pos.y += 800; 866 pos.x -= 1000; 867 868 Vector3 dir(0, 0, 1); 869 Vector3 up(0, 1, 0); 870 //Vector3 up(camera->GetDirection());up.y = 0; 871 872 Vector3 left = Normalize(CrossProd(dir, up)); 873 up = Normalize(CrossProd(left, dir)); 874 875 visView = Matrix4x4(up, left, dir); 876 pos = visView * pos; 877 878 visView.x[3][0] = pos.x; 879 visView.x[3][1] = pos.y; 880 visView.x[3][2] = pos.z; 881 } 848 882 849 883 // cleanup routine after the main loop … … 855 889 DEL_PTR(bvh); 856 890 DEL_PTR(visualization); 891 DEL_PTR(camera); 857 892 } 858 893
Note: See TracChangeset
for help on using the changeset viewer.