Changeset 2788 for GTP/trunk/App
- Timestamp:
- 06/20/08 06:15:17 (17 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp
r2786 r2788 222 222 if (mUseRenderQueue && (mRenderState->GetMode() == RenderState::RENDER)) 223 223 { 224 // cout<< "render queue: " << mRenderQueue.GetSize() << endl;224 //Debug << "render queue: " << mRenderQueue.GetSize() << endl; 225 225 mRenderQueue.Render(); 226 226 mRenderQueue.Clear(); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.cpp
r2787 r2788 14 14 namespace CHCDemoEngine 15 15 { 16 17 GLUquadric *mSphere; 16 18 17 19 /******************************************************/ … … 30 32 mFrameId(0) 31 33 { 34 mSphere = (GLUquadric *)gluNewQuadric(); 32 35 } 33 36 … … 56 59 tStack.push(mBvh->GetRoot()); 57 60 61 glDisable(GL_LIGHTING); 62 63 RenderViewPoint(); 64 RenderFrustum(); 65 RenderBox(mBvh->GetBox()); 66 67 glEnable(GL_LIGHTING); 68 58 69 glEnableClientState(GL_VERTEX_ARRAY); 59 70 glEnableClientState(GL_NORMAL_ARRAY); 60 61 RenderFrustum();62 71 63 72 while (!tStack.empty()) … … 146 155 147 156 glEnable(GL_CULL_FACE); 148 149 157 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 150 158 } … … 153 161 void Visualization::RenderFrustum() 154 162 { 163 glColor3f(1.0f, 0.0f, 0.0f); 164 155 165 Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr; 156 166 mCamera->ComputePoints(ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr); … … 202 212 203 213 204 } 214 215 void Visualization::RenderViewPoint() 216 { 217 glPushMatrix(); 218 Vector3 pos = mCamera->GetPosition(); 219 pos.z += 100; 220 glTranslatef(pos.x, pos.y, pos.z); 221 222 glScalef(5.0f, 5.0f, 5.0f); 223 glPushAttrib(GL_CURRENT_BIT); 224 225 glColor3f(1.0f, 0.0f, 0.0f); 226 227 gluSphere((::GLUquadric *)mSphere, 228 2e-3f * Magnitude(mBvh->GetBox().Size()), 6, 6); 229 230 glPopAttrib(); 231 glPopMatrix(); 232 } 233 234 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.h
r2787 r2788 52 52 void RenderBox(const AxisAlignedBox3 &box); 53 53 54 void RenderViewPoint(); 54 55 55 56 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2787 r2788 57 57 float winAspectRatio = 1.0f; 58 58 59 float visZoomFactor = 1.5f;60 61 59 double accumulatedTime = 1000; 62 60 float fps = 1e3f; … … 137 135 138 136 139 camera = new Camera(winWidth, winHeight );137 camera = new Camera(winWidth, winHeight, 60); 140 138 camera->SetNear(nearDist); 141 139 … … 267 265 "'V' - shows/hides bounding volumes", 268 266 "", 269 "'1' - shows/hides visualization", 270 "'2' - zooms out visualization", 271 "'3' - zooms in visualization", 267 "'1' - shows/hides bird eye view", 272 268 0, 273 269 }; … … 480 476 visMode = !visMode; 481 477 break; 482 case '2':483 visZoomFactor += 0.1;484 break;485 case '3':486 visZoomFactor -= 0.1;487 if (visZoomFactor < 0.1) visZoomFactor = 0.1;488 break;489 478 case '8': 490 479 { … … 630 619 631 620 gluPerspective(60.0f, 1.0f / winAspectRatio, nearDist, 2.0f * Magnitude(bvh->GetBox().Diagonal())); 621 632 622 glMatrixMode(GL_MODELVIEW); 633 623 … … 817 807 glColor4f(0.0,0.0,0.0,0.5); 818 808 819 glRecti(winWidth, 0, winWidth / 2, winHeight / 2);809 glRecti(winWidth, 0, winWidth - winWidth / 4, winHeight / 3); 820 810 glDisable(GL_BLEND); 821 811 end2D(); 822 823 glViewport(winWidth / 2, winHeight / 2, winWidth, winHeight); 812 813 glViewport(winWidth - winWidth / 4, winHeight - winHeight / 3, winWidth, winHeight); 814 815 816 glMatrixMode(GL_PROJECTION); 817 glLoadIdentity(); 818 819 //gluPerspective(60.0f, 1.0f / winAspectRatio, nearDist, 2.0f * Magnitude(bvh->GetBox().Diagonal())); 820 AxisAlignedBox3 box = bvh->GetBox(); 821 const float offs = 2000; 822 glOrtho(box.Min().y - offs, box.Max().y + offs, box.Min().y - offs, box.Max().y + offs, 0.1, 20.0f * Magnitude(bvh->GetBox().Diagonal())); 823 824 824 825 glPushMatrix(); 825 //glMatrixMode(GL_PROJECTION); 826 826 827 glMatrixMode(GL_MODELVIEW); 827 828 glLoadIdentity(); 828 829 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 830 glMultMatrixf((float *)visView.x); 839 831 840 glMultMatrixf((float *)t.x); 841 glMultMatrixf((float *)m.x); 842 glMultMatrixf((float *)minust.x); 832 //SetupLighting(); 833 GLfloat position[] = {0.8f, 1.0f, 1.5f, 0.0f}; 834 glLightfv(GL_LIGHT0, GL_POSITION, position); 835 836 GLfloat position1[] = {bvh->GetBox().Center().x, bvh->GetBox().Max().y, bvh->GetBox().Center().z, 1.0f}; 837 glLightfv(GL_LIGHT1, GL_POSITION, position1); 838 839 843 840 844 841 glClear(GL_DEPTH_BUFFER_BIT); … … 847 844 //-- visualization of the occlusion culling 848 845 849 //traverser->RenderScene();850 846 visualization->Render(); 851 847 … … 856 852 857 853 858 /** Sets up view matrix in order to get a good position 859 for viewing the kd tree node culling 854 /** Sets up view matrix for bird eye view 860 855 */ 861 856 void setupVisView() 862 857 { 863 Vector3 pos(-camera->GetPosition()); 864 pos.z = -10.0f * bvh->GetBox().Size().z; 865 pos.y += 800; 866 pos.x -= 1000; 858 Vector3 pos(-bvh->GetBox().Center()); 859 860 pos.z = -15.0f * bvh->GetBox().Size().z; 861 pos.y += 1400; 862 pos.x -= 1170; 867 863 868 864 Vector3 dir(0, 0, 1); 869 865 Vector3 up(0, 1, 0); 870 //Vector3 up(camera->GetDirection());up.y = 0;871 866 872 867 Vector3 left = Normalize(CrossProd(dir, up)); … … 879 874 visView.x[3][1] = pos.y; 880 875 visView.x[3][2] = pos.z; 876 877 //cout << visView<< endl; 881 878 } 882 879 … … 929 926 char msg4[200]; 930 927 char msg5[200]; 928 char msg6[200]; 931 929 932 930 … … 965 963 renderedNodes, bvh->GetNumVirtualNodes(), str.c_str(), str2.c_str()); 966 964 967 sprintf_s(msg4, "traversed: %5d, frustum culled: %5d, query culled: %5d, issued queries: %5d, state changes: %5d", 968 traversedNodes, frustumCulledNodes, queryCulledNodes, issuedQueries, stateChanges); 969 970 sprintf_s(msg5, "fps: %6.1f", fps); 965 sprintf_s(msg4, "traversed: %5d, frustum culled: %5d, query culled: %5d", 966 traversedNodes, frustumCulledNodes, queryCulledNodes); 967 968 sprintf_s(msg5, "issued queries: %5d, state changes: %5d", issuedQueries, stateChanges); 969 970 sprintf_s(msg6, "fps: %6.1f", fps); 971 971 //cout << "previously visible node queries: " << traverser->GetStats().mNumPreviouslyVisibleNodeQueries << endl; 972 972 … … 988 988 Output(20, 90, msg4); 989 989 Output(20, 120, msg5); 990 Output(20, 150, msg6); 990 991 } 991 992 }
Note: See TracChangeset
for help on using the changeset viewer.