- Timestamp:
- 06/20/08 09:10:28 (17 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
r2786 r2790 967 967 } 968 968 969 } 969 970 971 972 static void RenderBoxForViz(const AxisAlignedBox3 &box) 973 { 974 glBegin(GL_LINE_LOOP); 975 glVertex3d(box.Min().x, box.Max().y, box.Min().z); 976 glVertex3d(box.Max().x, box.Max().y, box.Min().z); 977 glVertex3d(box.Max().x, box.Min().y, box.Min().z); 978 glVertex3d(box.Min().x, box.Min().y, box.Min().z); 979 glEnd(); 980 981 glBegin(GL_LINE_LOOP); 982 glVertex3d(box.Min().x, box.Min().y, box.Max().z); 983 glVertex3d(box.Max().x, box.Min().y, box.Max().z); 984 glVertex3d(box.Max().x, box.Max().y, box.Max().z); 985 glVertex3d(box.Min().x, box.Max().y, box.Max().z); 986 glEnd(); 987 988 glBegin(GL_LINE_LOOP); 989 glVertex3d(box.Max().x, box.Min().y, box.Min().z); 990 glVertex3d(box.Max().x, box.Min().y, box.Max().z); 991 glVertex3d(box.Max().x, box.Max().y, box.Max().z); 992 glVertex3d(box.Max().x, box.Max().y, box.Min().z); 993 glEnd(); 994 995 glBegin(GL_LINE_LOOP); 996 glVertex3d(box.Min().x, box.Min().y, box.Min().z); 997 glVertex3d(box.Min().x, box.Min().y, box.Max().z); 998 glVertex3d(box.Min().x, box.Max().y, box.Max().z); 999 glVertex3d(box.Min().x, box.Max().y, box.Min().z); 1000 glEnd(); 1001 1002 glBegin(GL_LINE_LOOP); 1003 glVertex3d(box.Min().x, box.Min().y, box.Min().z); 1004 glVertex3d(box.Max().x, box.Min().y, box.Min().z); 1005 glVertex3d(box.Max().x, box.Min().y, box.Max().z); 1006 glVertex3d(box.Min().x, box.Min().y, box.Max().z); 1007 glEnd(); 1008 1009 glBegin(GL_LINE_LOOP); 1010 glVertex3d(box.Min().x, box.Max().y, box.Min().z); 1011 glVertex3d(box.Max().x, box.Max().y, box.Min().z); 1012 glVertex3d(box.Max().x, box.Max().y, box.Max().z); 1013 glVertex3d(box.Min().x, box.Max().y, box.Max().z); 1014 1015 glEnd(); 1016 } 1017 1018 1019 void Bvh::RenderBoundsForViz(BvhNode *node, bool useTightBounds) 1020 { 1021 glDisable(GL_TEXTURE_2D); 1022 glDisable(GL_LIGHTING); 1023 glColor3f(1, 1, 1); 1024 1025 if (!useTightBounds) 1026 { 1027 RenderBoxForViz(node->GetBox()); 1028 } 1029 else 1030 { 1031 for (int i = 0; i < node->mNumTestNodes; ++ i) 1032 { 1033 RenderBoxForViz(mTestNodes[node->mTestNodesIdx + i]->GetBox()); 1034 } 1035 } 1036 1037 glEnable(GL_LIGHTING); 1038 glEnable(GL_TEXTURE_2D); 1039 } 1040 1041 1042 1043 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h
r2787 r2790 536 536 */ 537 537 int GetNumVirtualNodes() const { return mNumVirtualNodes; } 538 /** Render wireframe bvh for visualization purpose. 539 */ 540 void RenderBoundsForViz(BvhNode *node, bool useTightBounds); 538 541 539 542 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCPlusPlusTraverser.cpp
r2782 r2790 82 82 { 83 83 bool resultAvailable = false; 84 84 85 while (!mQueryQueue.empty() && 85 86 (mDistanceQueue.empty() || (resultAvailable = mQueryQueue.front()->ResultAvailable()))) -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp
r2788 r2790 47 47 mAssumedVisibleFrames(10), 48 48 mMaxBatchSize(50), 49 mUseTightBounds(false) 49 mUseTightBounds(false), mShowBounds(false) 50 50 { 51 51 } … … 72 72 { 73 73 RenderNode(node); 74 75 if (mShowBounds) 76 mBvh->RenderBoundsForViz(node, mUseTightBounds); 74 77 } 75 78 else … … 198 201 199 202 203 void RenderTraverser::SetShowBounds(bool showBounds) 204 { 205 mShowBounds = showBounds; 206 } 207 208 200 209 void RenderTraverser::SetUseTightBounds(bool useTightBounds) 201 210 { 202 211 mUseTightBounds = useTightBounds; 203 cout << "using tight bounds: " << useTightBounds << endl;212 //cout << "using tight bounds: " << useTightBounds << endl; 204 213 } 205 214 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h
r2787 r2790 115 115 */ 116 116 void SetUseTightBounds(bool useTightBounds); 117 /** If bounds should be shown 118 */ 119 void SetShowBounds(bool showBounds); 117 120 118 121 protected: … … 179 182 180 183 bool mUseTightBounds; 184 185 bool mShowBounds; 181 186 }; 182 187 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.cpp
r2788 r2790 15 15 { 16 16 17 GLUquadric *mSphere; 17 GLUquadric *mSphere; 18 19 20 static void RenderBoxForViz(const AxisAlignedBox3 &box) 21 { 22 glBegin(GL_LINE_LOOP); 23 glVertex3d(box.Min().x, box.Max().y, box.Min().z); 24 glVertex3d(box.Max().x, box.Max().y, box.Min().z); 25 glVertex3d(box.Max().x, box.Min().y, box.Min().z); 26 glVertex3d(box.Min().x, box.Min().y, box.Min().z); 27 glEnd(); 28 29 glBegin(GL_LINE_LOOP); 30 glVertex3d(box.Min().x, box.Min().y, box.Max().z); 31 glVertex3d(box.Max().x, box.Min().y, box.Max().z); 32 glVertex3d(box.Max().x, box.Max().y, box.Max().z); 33 glVertex3d(box.Min().x, box.Max().y, box.Max().z); 34 glEnd(); 35 36 glBegin(GL_LINE_LOOP); 37 glVertex3d(box.Max().x, box.Min().y, box.Min().z); 38 glVertex3d(box.Max().x, box.Min().y, box.Max().z); 39 glVertex3d(box.Max().x, box.Max().y, box.Max().z); 40 glVertex3d(box.Max().x, box.Max().y, box.Min().z); 41 glEnd(); 42 43 glBegin(GL_LINE_LOOP); 44 glVertex3d(box.Min().x, box.Min().y, box.Min().z); 45 glVertex3d(box.Min().x, box.Min().y, box.Max().z); 46 glVertex3d(box.Min().x, box.Max().y, box.Max().z); 47 glVertex3d(box.Min().x, box.Max().y, box.Min().z); 48 glEnd(); 49 50 glBegin(GL_LINE_LOOP); 51 glVertex3d(box.Min().x, box.Min().y, box.Min().z); 52 glVertex3d(box.Max().x, box.Min().y, box.Min().z); 53 glVertex3d(box.Max().x, box.Min().y, box.Max().z); 54 glVertex3d(box.Min().x, box.Min().y, box.Max().z); 55 glEnd(); 56 57 glBegin(GL_LINE_LOOP); 58 glVertex3d(box.Min().x, box.Max().y, box.Min().z); 59 glVertex3d(box.Max().x, box.Max().y, box.Min().z); 60 glVertex3d(box.Max().x, box.Max().y, box.Max().z); 61 glVertex3d(box.Min().x, box.Max().y, box.Max().z); 62 63 glEnd(); 64 } 65 18 66 19 67 /******************************************************/ … … 63 111 RenderViewPoint(); 64 112 RenderFrustum(); 65 RenderBox (mBvh->GetBox());113 RenderBoxForViz(mBvh->GetBox()); 66 114 67 115 glEnable(GL_LIGHTING); … … 106 154 107 155 108 void Visualization::RenderBox(const AxisAlignedBox3 &box)109 {110 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);111 glDisable(GL_CULL_FACE);112 glColor3f(1.0f, 0.0f, 0.0f);113 114 glBegin(GL_QUADS);115 glVertex3f(box.Min().x, box.Max().y, box.Min().z);116 glVertex3f(box.Max().x, box.Max().y, box.Min().z);117 glVertex3f(box.Max().x, box.Min().y, box.Min().z);118 glVertex3f(box.Min().x, box.Min().y, box.Min().z);119 glEnd();120 121 glBegin(GL_QUADS);122 glVertex3f(box.Min().x, box.Min().y, box.Max().z);123 glVertex3f(box.Max().x, box.Min().y, box.Max().z);124 glVertex3f(box.Max().x, box.Max().y, box.Max().z);125 glVertex3f(box.Min().x, box.Max().y, box.Max().z);126 glEnd();127 128 glBegin(GL_QUADS);129 glVertex3f(box.Max().x, box.Min().y, box.Min().z);130 glVertex3f(box.Max().x, box.Min().y, box.Max().z);131 glVertex3f(box.Max().x, box.Max().y, box.Max().z);132 glVertex3f(box.Max().x, box.Max().y, box.Min().z);133 glEnd();134 135 glBegin(GL_QUADS);136 glVertex3f(box.Min().x, box.Min().y, box.Min().z);137 glVertex3f(box.Min().x, box.Min().y, box.Max().z);138 glVertex3f(box.Min().x, box.Max().y, box.Max().z);139 glVertex3f(box.Min().x, box.Max().y, box.Min().z);140 glEnd();141 142 glBegin(GL_QUADS);143 glVertex3f(box.Min().x, box.Min().y, box.Min().z);144 glVertex3f(box.Max().x, box.Min().y, box.Min().z);145 glVertex3f(box.Max().x, box.Min().y, box.Max().z);146 glVertex3f(box.Min().x, box.Min().y, box.Max().z);147 glEnd();148 149 glBegin(GL_QUADS);150 glVertex3f(box.Min().x, box.Max().y, box.Min().z);151 glVertex3f(box.Max().x, box.Max().y, box.Min().z);152 glVertex3f(box.Max().x, box.Max().y, box.Max().z);153 glVertex3f(box.Min().x, box.Max().y, box.Max().z);154 glEnd();155 156 glEnable(GL_CULL_FACE);157 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);158 }159 160 161 void Visualization::RenderFrustum()162 {163 glColor3f(1.0f, 0.0f, 0.0f);164 165 Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr;166 mCamera->ComputePoints(ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr);167 168 glLineWidth(2);169 170 glBegin(GL_LINE_LOOP);171 glVertex3d(fbl.x, fbl.y, fbl.z);172 glVertex3d(fbr.x, fbr.y, fbr.z);173 glVertex3d(ftr.x, ftr.y, ftr.z);174 glVertex3d(ftl.x, ftl.y, ftl.z);175 glEnd();176 177 glBegin(GL_LINE_LOOP);178 glVertex3d(nbl.x, nbl.y, nbl.z);179 glVertex3d(nbr.x, nbr.y, nbr.z);180 glVertex3d(ntr.x, ntr.y, ntr.z);181 glVertex3d(ntl.x, ntl.y, ntl.z);182 glEnd();183 184 glBegin(GL_LINE_LOOP);185 glVertex3d(fbl.x, fbl.y, fbl.z);186 glVertex3d(ftl.x, ftl.y, ftl.z);187 glVertex3d(ntl.x, ntl.y, ntl.z);188 glVertex3d(nbl.x, nbl.y, nbl.z);189 glEnd();190 191 glBegin(GL_LINE_LOOP);192 glVertex3d(fbr.x, fbr.y, fbr.z);193 glVertex3d(ftr.x, ftr.y, ftr.z);194 glVertex3d(ntr.x, ntr.y, ntr.z);195 glVertex3d(nbr.x, nbr.y, nbr.z);196 glEnd();197 198 glBegin(GL_LINE_LOOP);199 glVertex3d(fbr.x, fbr.y, fbr.z);200 glVertex3d(fbl.x, fbl.y, fbl.z);201 glVertex3d(nbl.x, nbl.y, nbl.z);202 glVertex3d(nbr.x, nbr.y, nbr.z);203 glEnd();204 205 glBegin(GL_LINE_LOOP);206 glVertex3d(ftr.x, ftr.y, ftr.z);207 glVertex3d(ftl.x, ftl.y, ftl.z);208 glVertex3d(ntl.x, ntl.y, ntl.z);209 glVertex3d(ntr.x, ntr.y, ntr.z);210 glEnd();211 }212 213 214 215 156 void Visualization::RenderViewPoint() 216 157 { … … 232 173 } 233 174 234 } 175 176 void Visualization::RenderFrustum() 177 { 178 glColor3f(1.0f, 0.0f, 0.0f); 179 180 Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr; 181 mCamera->ComputePoints(ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr); 182 183 glLineWidth(2); 184 185 glBegin(GL_LINE_LOOP); 186 glVertex3d(fbl.x, fbl.y, fbl.z); 187 glVertex3d(fbr.x, fbr.y, fbr.z); 188 glVertex3d(ftr.x, ftr.y, ftr.z); 189 glVertex3d(ftl.x, ftl.y, ftl.z); 190 glEnd(); 191 192 glBegin(GL_LINE_LOOP); 193 glVertex3d(nbl.x, nbl.y, nbl.z); 194 glVertex3d(nbr.x, nbr.y, nbr.z); 195 glVertex3d(ntr.x, ntr.y, ntr.z); 196 glVertex3d(ntl.x, ntl.y, ntl.z); 197 glEnd(); 198 199 glBegin(GL_LINE_LOOP); 200 glVertex3d(fbl.x, fbl.y, fbl.z); 201 glVertex3d(ftl.x, ftl.y, ftl.z); 202 glVertex3d(ntl.x, ntl.y, ntl.z); 203 glVertex3d(nbl.x, nbl.y, nbl.z); 204 glEnd(); 205 206 glBegin(GL_LINE_LOOP); 207 glVertex3d(fbr.x, fbr.y, fbr.z); 208 glVertex3d(ftr.x, ftr.y, ftr.z); 209 glVertex3d(ntr.x, ntr.y, ntr.z); 210 glVertex3d(nbr.x, nbr.y, nbr.z); 211 glEnd(); 212 213 glBegin(GL_LINE_LOOP); 214 glVertex3d(fbr.x, fbr.y, fbr.z); 215 glVertex3d(fbl.x, fbl.y, fbl.z); 216 glVertex3d(nbl.x, nbl.y, nbl.z); 217 glVertex3d(nbr.x, nbr.y, nbr.z); 218 glEnd(); 219 220 glBegin(GL_LINE_LOOP); 221 glVertex3d(ftr.x, ftr.y, ftr.z); 222 glVertex3d(ftl.x, ftl.y, ftl.z); 223 glVertex3d(ntl.x, ntl.y, ntl.z); 224 glVertex3d(ntr.x, ntr.y, ntr.z); 225 glEnd(); 226 } 227 228 229 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.h
r2788 r2790 48 48 */ 49 49 void RenderFrustum(); 50 /** Renders a bounding box for visualization.50 /** Renders the current view point. 51 51 */ 52 void RenderBox(const AxisAlignedBox3 &box);53 54 52 void RenderViewPoint(); 55 53 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2788 r2790 72 72 bool showHelp = false; 73 73 bool showStatistics = true; 74 bool showOptions = true; 74 75 bool showBoundingVolumes = false; 75 76 bool visMode = false; … … 243 244 "", 244 245 "'F1' - shows/dismisses this message", 246 "'F2' - shows/hides statistics", 247 "'F3' - shows/hides bounds (boxes or tight bounds)", 248 "'F4' - shows/hides bird eye view", 249 "'f5', - load helpScreen", 250 "'SPACE' - cycles through occlusion culling algorithms", 245 251 "", 246 252 "'MOUSE-LEFT' - turn left/right, move forward/backward", … … 252 258 "'CURSOR LEFT' - turn left", 253 259 "", 254 "'SPACE' - cycles through occlusion culling algorithms",255 260 "'-' - decreases max batch size", 256 261 "'+' - increases max batch size", … … 261 266 "", 262 267 "'R' - use render queue", 263 "", 264 "'S' - shows/hides statistics", 265 "'V' - shows/hides bounding volumes", 266 "", 267 "'1' - shows/hides bird eye view", 268 "'B' - use tight bounds", 269 "'M' - use multiqueries", 268 270 0, 269 271 }; … … 441 443 showHelp = !showHelp; 442 444 break; 443 case 'v':444 case 'V':445 showBoundingVolumes = !showBoundingVolumes;446 //HierarchyNode::SetRenderBoundingVolume(showBoundingVolumes);447 break;448 case 'O':449 case 'o':450 showStatistics = !showStatistics;451 break;452 445 case '+': 453 446 maxBatchSize += 10; … … 472 465 useMultiQueries = !useMultiQueries; 473 466 traverser->SetUseMultiQueries(useMultiQueries); 474 break;475 case '1':476 visMode = !visMode;477 467 break; 478 468 case '8': … … 537 527 traverser->SetUseRenderQueue(useRenderQueue); 538 528 } 529 break; 539 530 case 'b': 540 531 case 'B': … … 543 534 traverser->SetUseTightBounds(useTightBounds); 544 535 } 536 break; 545 537 default: 546 538 return; … … 560 552 case GLUT_KEY_F1: 561 553 showHelp = !showHelp; 554 break; 555 case GLUT_KEY_F2: 556 showStatistics = !showStatistics; 557 break; 558 case GLUT_KEY_F3: 559 showBoundingVolumes = !showBoundingVolumes; 560 traverser->SetShowBounds(showBoundingVolumes); 561 break; 562 case GLUT_KEY_F4: 563 visMode = !visMode; 564 break; 565 case GLUT_KEY_F5: 566 showOptions = !showOptions; 562 567 break; 563 568 case GLUT_KEY_LEFT: … … 927 932 char msg5[200]; 928 933 char msg6[200]; 934 char msg7[200]; 929 935 930 936 … … 951 957 } 952 958 953 sprintf_s(msg2, "assumed visible frames: %4d, max batch size: %4d, using render queue: %d", 954 assumedVisibleFrames, maxBatchSize, useRenderQueue); 959 sprintf_s(msg2, "assumed visible frames: %4d, max batch size: %4d", 960 assumedVisibleFrames, maxBatchSize); 961 962 sprintf_s(msg3, "render queue: %d, multiqueries: %d, tight bounds: %d", 963 useRenderQueue, useMultiQueries, useTightBounds); 955 964 956 965 string str; … … 960 969 CalcDecimalPoint(str2, bvh->GetBvhStats().mTriangles); 961 970 962 sprintf_s(msg 3, "rendered nodes: %6d (of %6d), rendered triangles: %s (of %s)",971 sprintf_s(msg4, "rendered nodes: %6d (of %6d), rendered triangles: %s (of %s)", 963 972 renderedNodes, bvh->GetNumVirtualNodes(), str.c_str(), str2.c_str()); 964 973 965 sprintf_s(msg 4, "traversed: %5d, frustum culled: %5d, query culled: %5d",974 sprintf_s(msg5, "traversed: %5d, frustum culled: %5d, query culled: %5d", 966 975 traversedNodes, frustumCulledNodes, queryCulledNodes); 967 976 968 sprintf_s(msg 5, "issued queries: %5d, state changes: %5d", issuedQueries, stateChanges);969 970 sprintf_s(msg 6, "fps: %6.1f", fps);977 sprintf_s(msg6, "issued queries: %5d, state changes: %5d", issuedQueries, stateChanges); 978 979 sprintf_s(msg7, "fps: %6.1f", fps); 971 980 //cout << "previously visible node queries: " << traverser->GetStats().mNumPreviouslyVisibleNodeQueries << endl; 972 981 … … 982 991 Output(850, 30, msg[renderMode]); 983 992 993 984 994 if (showStatistics) 985 995 { 986 Output(20, 30, msg2); 987 Output(20, 60, msg3); 988 Output(20, 90, msg4); 989 Output(20, 120, msg5); 990 Output(20, 150, msg6); 996 Output(20, 30, msg4); 997 Output(20, 60, msg5); 998 Output(20, 90, msg6); 999 Output(20, 120, msg7); 1000 } 1001 1002 if (showOptions) 1003 { 1004 Output(20, 150, msg2); 1005 Output(20, 180, msg3); 991 1006 } 992 1007 }
Note: See TracChangeset
for help on using the changeset viewer.