- Timestamp:
- 06/27/08 01:43:45 (17 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 4 added
- 4 deleted
- 21 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.sln
r2785 r2800 2 2 Microsoft Visual Studio Solution File, Format Version 9.00 3 3 # Visual Studio 2005 4 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "chc_revisited", " chc_revisited.vcproj", "{03661866-4093-4B02-B26A-028EA91AF023}"4 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "chc_revisited", "FriendlyCulling.vcproj", "{03661866-4093-4B02-B26A-028EA91AF023}" 5 5 EndProject 6 6 Global -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
r2796 r2800 109 109 mIsFrustumCulled = false; 110 110 mIsNew = true; 111 mLastQueriedFrame = -1; 111 112 } 112 113 … … 609 610 GL_STATIC_DRAW_ARB); 610 611 611 //glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);612 glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); 612 613 613 614 // data handled by graphics driver from now on … … 904 905 } 905 906 } 907 908 ResetNodeClassifications(); 906 909 } 907 910 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h
r2792 r2800 52 52 /// if the node is newly processed with no prior history available 53 53 bool mIsNew; 54 /// the frame this node was last queried 55 int mLastQueriedFrame; 54 56 }; 55 57 … … 113 115 inline void SetTurnedVisibleFrame(int turnedVisibleFrame); 114 116 115 inline int GetLast TestedFrame();116 inline void SetLast TestedFrame(int lastTested);117 inline int GetLastQueriedFrame() const; 118 inline void SetLastQueriedFrame(int lastTested); 117 119 118 120 inline bool IsViewFrustumCulled() const; … … 155 157 ///////////// 156 158 157 /// some flags158 //int mFlags;159 159 /// the depth of this node 160 160 unsigned char mDepth; … … 217 217 218 218 219 219 220 ///////////////// 220 221 //-- public inline functions 221 222 223 222 224 int BvhNode::GetLastVisitedFrame() const 223 225 { … … 268 270 269 271 270 void BvhNode::SetViewFrustumCulled( constbool frustumCulled)272 void BvhNode::SetViewFrustumCulled(bool frustumCulled) 271 273 { 272 274 mVisibility.mIsFrustumCulled = frustumCulled; … … 280 282 281 283 282 void BvhNode::SetIsNew( constbool isNew)284 void BvhNode::SetIsNew(bool isNew) 283 285 { 284 286 mVisibility.mIsNew = isNew; … … 320 322 return mVisibility.mAssumedVisibleFrameId; 321 323 } 324 325 326 int BvhNode::GetLastQueriedFrame() const 327 { 328 return mVisibility.mLastQueriedFrame; 329 } 330 331 332 void BvhNode::SetLastQueriedFrame(int lastTested) 333 { 334 mVisibility.mLastQueriedFrame = lastTested; 335 } 336 322 337 323 338 … … 429 444 */ 430 445 inline int GetNumLeaves() const { return mNumNodes / 2 + 1;} 446 /** Returns number of 'virtual' nodes in the hierarchy, i.e. 447 the number of nodes actually used for traversal. 448 */ 449 int GetNumVirtualNodes() const { return mNumVirtualNodes; } 450 /** Returns number of bvh leaves. 451 */ 452 inline int GetNumVirtualLeaves() const { return mNumVirtualNodes / 2 + 1;} 431 453 /** Returns root node of the bvh. 432 454 */ … … 512 534 */ 513 535 void SetVirtualLeaves(int numTriangles); 514 536 515 537 516 538 //////// … … 526 548 void SetAreaRatioThresholdForTestingChildren(float ratio); 527 549 550 551 //////////////////////////// 552 528 553 /** Returns stats. 529 554 */ 530 555 const BvhStats &GetBvhStats() const { return mBvhStats; } 531 /** Returns number of 'virtual' nodes in the hierarchy, i.e.532 the number of nodes actually used for traversal.533 */534 int GetNumVirtualNodes() const { return mNumVirtualNodes; }535 556 /** Render wireframe bvh for visualization purpose. 536 557 */ -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp
r2796 r2800 103 103 bvh->PostProcess(); 104 104 105 const int trianglesPerVirtualLeaves = 1000;106 105 // set virtual leaves for specified number of triangles 107 bvh->SetVirtualLeaves( trianglesPerVirtualLeaves);106 bvh->SetVirtualLeaves(INITIAL_TRIANGLES_PER_VIRTUAL_LEAVES); 108 107 109 108 bvh->UpdateNumLeaves(bvh->mRoot); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCPlusPlusTraverser.cpp
r2795 r2800 15 15 void CHCPlusPlusTraverser::HandleQueryResult(OcclusionQuery *query) 16 16 { 17 waitTimer.Entry(); 18 17 19 // wait until result available 18 20 const int visible = query->GetQueryResult() > mVisibilityThreshold; 19 21 22 waitTimer.Exit(); 23 20 24 // multiquery 21 25 if (query->GetSize() > 1) … … 27 31 { 28 32 BvhNode *node = query->GetNodes()[i]; 33 #if 1 34 mIQueue.push_back(node); 35 node->SetLastQueriedFrame(mFrameId); 36 #else 29 37 OcclusionQuery *q = IssueOcclusionQuery(node); 30 38 mQueryQueue.push(q); 39 #endif 31 40 } 32 41 } … … 38 47 node->IncTimesTestedInvisible(); 39 48 node->SetVisible(false); 49 node->SetLastQueriedFrame(mFrameId); 40 50 } 41 51 … … 46 56 { 47 57 BvhNode *node = query->GetFrontNode(); 58 59 node->SetLastQueriedFrame(mFrameId); 48 60 49 61 // failed query: query individual nodes … … 100 112 mQueryQueue.pop(); 101 113 114 // waiting for query result 102 115 HandleQueryResult(query); 103 116 } … … 186 199 if (mUseRenderQueue) ApplyRenderQueue(); 187 200 201 restTimer.Entry(); 188 202 189 203 ////////////// … … 206 220 HandleQueryResult(query); 207 221 } 208 } 209 222 223 restTimer.Exit(); 224 } 210 225 211 226 212 227 void CHCPlusPlusTraverser::QueryPreviouslyInvisibleNodes(BvhNode *node) 213 228 { 214 mIQueue.push (node);229 mIQueue.push_back(node); 215 230 216 231 if (mIQueue.size() > mMaxBatchSize) … … 221 236 222 237 223 OcclusionQuery * CHCPlusPlusTraverser::GetNextMultiQuery(BvhNode Queue&iqueue)238 OcclusionQuery * CHCPlusPlusTraverser::GetNextMultiQuery(BvhNodeContainer &iqueue) 224 239 { 225 240 OcclusionQuery *query = mQueryHandler.RequestQuery(); … … 233 248 while (!iqueue.empty()) 234 249 { 235 BvhNode *node = iqueue.front(); 250 BvhNode *node = iqueue.back(); 251 252 // node was already part of a mulitquery => avoid recursion 253 if (node->GetLastQueriedFrame() == mFrameId) 254 newPBatch = 0; 255 else 236 256 newPBatch *= mVisibilityPredictor.GetProbability(node); 237 257 238 258 if (query->GetNodes().empty()) 239 259 { 240 // single node will anever cause a wasted query260 // single node will never cause a wasted query 241 261 newBatchVal = 1.0f; 242 262 } … … 250 270 break; 251 271 252 iqueue.pop ();272 iqueue.pop_back(); 253 273 query->AddNode(node); 254 274 … … 263 283 264 284 285 static inline bool lt(BvhNode *a, BvhNode *b) 286 { 287 return a->GetTimesTestedInvisible() < b->GetTimesTestedInvisible(); 288 } 289 290 265 291 void CHCPlusPlusTraverser::IssueMultiQueries() 266 292 { 267 while (!mIQueue.empty())268 { 269 OcclusionQuery *query;270 271 if (mUseMultiQueries) 272 {273 query = GetNextMultiQuery(mIQueue);293 if (mUseMultiQueries) 294 { 295 // sort queries by #times invisible 296 sort(mIQueue.begin(), mIQueue.end(), lt); 297 298 while (!mIQueue.empty()) 299 mQueryQueue.push(GetNextMultiQuery(mIQueue)); 274 300 } 275 301 else 276 302 { 277 BvhNode *node = mIQueue.front();278 mIQueue.pop(); 279 query = IssueOcclusionQuery(node);280 }281 282 m QueryQueue.push(query);283 } 284 } 285 286 287 } 303 BvhNodeContainer::const_iterator it, it_end = mIQueue.end(); 304 305 for (it = mIQueue.begin(); it != it_end; ++ it) 306 mQueryQueue.push(IssueOcclusionQuery(*it)); 307 308 mIQueue.clear(); 309 } 310 } 311 312 313 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCPlusPlusTraverser.h
r2782 r2800 33 33 34 34 CHCPlusPlusTraverser(); 35 //~CHCPlusPlusTraverser(); 35 36 virtual int GetType() const { return CHCPLUSPLUS;} 36 37 37 38 … … 45 46 /** Computes the next multiquery. 46 47 */ 47 OcclusionQuery *GetNextMultiQuery(BvhNode Queue&iqueue);48 OcclusionQuery *GetNextMultiQuery(BvhNodeContainer &iqueue); 48 49 /** Issues batched multiqueries. 49 50 */ … … 59 60 QueryQueue mQueryQueue; 60 61 61 BvhNodeQueue mIQueue;62 62 BvhNodeQueue mVQueue; 63 BvhNodeContainer mIQueue; 63 64 64 65 VisibilityPredictor mVisibilityPredictor; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCTraverser.h
r2792 r2800 14 14 public: 15 15 CHCTraverser(); 16 //~CHCTraverser(); 16 17 virtual int GetType() const { return CHC; } 17 18 18 19 19 20 protected: 21 20 22 /** Optimized query querying the node geometry instead 21 23 of the bounding box -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrustumCullingTraverser.h
r2782 r2800 16 16 FrustumCullingTraverser(); 17 17 18 virtual int GetType() const { return CULL_FRUSTUM; } 19 18 20 protected: 19 21 /** Traverses and renders the scene with the specified method -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/OcclusionQuery.cpp
r2786 r2800 65 65 QueryHandler::QueryHandler(): mCurrentQueryIdx(0) 66 66 { 67 Allocate( 1000);67 Allocate(500); 68 68 } 69 69 … … 99 99 { 100 100 CLEAR_CONTAINER(mOcclusionQueries); 101 101 102 mCurrentQueryIdx = 0; 102 103 mOcclusionQueries.clear(); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp
r2795 r2800 21 21 int tsize2 = t2 ? t2->GetByteSize() : 0; 22 22 23 return tsize1 <tsize2;23 return tsize1 > tsize2; 24 24 } 25 25 … … 88 88 Debug << "\nrq size: " << GetSize() << endl; 89 89 Debug << "texture size: " << endl; 90 90 91 // show ordering by texture size 91 92 for (sit = mEntities.begin(); sit != sit_end; ++ sit) … … 93 94 SceneEntity *ent = *sit; 94 95 Texture *t = ent->GetMaterial()->GetTexture(); 96 95 97 int tsize = t ? t->GetByteSize() : 0; 96 98 Debug << tsize << " "; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
r2782 r2800 9 9 10 10 11 /** Constructor setting render as default state.12 */13 11 RenderState::RenderState(): 14 12 mAlphaTestEnabled(false), … … 22 20 bool RenderState::SetState(Mode mode) 23 21 { 22 /////////// 24 23 //-- just change the modewhen necessary 24 25 25 if (mode == mMode) return false; 26 26 27 27 mMode = mode; 28 //++ state_changes;29 28 30 29 if (mode == QUERY) … … 62 61 { 63 62 mTexturesEnabled = true; 64 glEnable(GL_TEXTURE_2D);65 glEnableClientState(GL_TEXTURE_COORD_ARRAY);63 //glEnable(GL_TEXTURE_2D); 64 //glEnableClientState(GL_TEXTURE_COORD_ARRAY); 66 65 } 67 66 … … 74 73 { 75 74 mAlphaTestEnabled = true; 76 glEnable(GL_ALPHA_TEST);77 glAlphaFunc(GL_GEQUAL, 0.5f);75 //glEnable(GL_ALPHA_TEST); 76 //glAlphaFunc(GL_GEQUAL, 0.5f); 78 77 } 79 78 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h
r2782 r2800 48 48 inline int GetCurrentVboId() { return mCurrentVboId; } 49 49 50 50 51 protected: 51 52 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp
r2798 r2800 27 27 mNumIssuedQueries = 0; 28 28 mNumStateChanges = 0; 29 mNumBatches = 0; 29 30 30 31 mRenderTime = 0; 32 mWaitTime = 0; 33 mQueryTime = 0; 34 mRestTime = 0; 31 35 } 32 36 … … 132 136 PerfTimer timer; 133 137 138 glFinish(); 139 134 140 timer.Start(); 135 141 … … 154 160 // render the contents of the render queue 155 161 if (mUseRenderQueue) ApplyRenderQueue(); 162 163 // reset the render state 156 164 mRenderState->Reset(); 157 165 … … 159 167 glDisableClientState(GL_NORMAL_ARRAY); 160 168 169 glFinish(); 170 171 161 172 mStats.mRenderTime = timer.Elapsedms(); 162 173 174 //Debug << "type: " << GetType() << endl; 163 175 //if (mUseRenderQueue) Debug << "rq sort: " << 1e3f * mRenderQueue.sortTimer.TotalTime() << " ms" << endl; 176 /* 177 Debug << "wait time: " << 1e3f * waitTimer.TotalTime() << " ms" << endl; 178 Debug << "query time: " << 1e3f * queryTimer.TotalTime() << " ms" << endl; 179 Debug << "rest time: " << 1e3f * restTimer.TotalTime() << " ms" << endl; 180 */ 164 181 } 165 182 … … 219 236 OcclusionQuery *RenderTraverser::IssueOcclusionQuery(BvhNode *node) 220 237 { 238 queryTimer.Entry(); 239 221 240 OcclusionQuery *query = mQueryHandler.RequestQuery(); 222 241 query->AddNode(node); 223 242 224 243 IssueOcclusionQuery(*query); 244 245 queryTimer.Exit(); 225 246 226 247 return query; … … 254 275 ++ mStats.mNumStateChanges; 255 276 277 if (mRenderQueue.GetSize() > 0) 278 ++ mStats.mNumBatches; 279 256 280 mRenderQueue.Apply(); 257 281 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h
r2795 r2800 7 7 #include "Camera.h" 8 8 #include "RenderQueue.h" 9 #include "Timer/PerfTimer.h" 9 10 10 11 … … 37 38 int mNumIssuedQueries; 38 39 int mNumStateChanges; 40 int mNumBatches; 39 41 40 42 double mRenderTime; 43 44 double mWaitTime; 45 double mQueryTime; 46 double mRestTime; 41 47 }; 42 43 48 44 49 … … 49 54 public: 50 55 51 enum {CULL_FRUSTUM, STOP_AND_WAIT, CHC, CHCPLUSPLUS, NUM_ RENDERMODES};56 enum {CULL_FRUSTUM, STOP_AND_WAIT, CHC, CHCPLUSPLUS, NUM_TRAVERSAL_TYPES}; 52 57 53 58 RenderTraverser(); … … 118 123 void SetShowBounds(bool showBounds); 119 124 125 virtual int GetType() const = 0; 120 126 121 127 protected: … … 187 193 188 194 bool mShowBounds; 195 196 // timers 197 PerfTimer restTimer; 198 PerfTimer waitTimer; 199 PerfTimer queryTimer; 189 200 }; 190 201 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
r2795 r2800 81 81 } 82 82 83 cout << "loaded " << mTextureTable.size() << " textures" << endl;83 cout << "loaded " << (int)mTextureTable.size() << " textures" << endl; 84 84 } 85 85 … … 102 102 } 103 103 104 cout << "loaded " << mGeometryTable.size() << " shapes" << endl;104 cout << "loaded " << (int)mGeometryTable.size() << " shapes" << endl; 105 105 } 106 106 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.cpp
r2797 r2800 5 5 #include "SceneQuery.h" 6 6 #include "RenderTraverser.h" 7 #include <IL/il.h> 8 #include <assert.h> 7 9 8 10 9 void startil(); 10 void stopil(); 11 void startil() 12 { 13 ilInit(); 14 assert(ilGetError() == IL_NO_ERROR); 15 } 16 17 18 void stopil() 19 { 20 ilShutDown(); 21 assert(ilGetError() == IL_NO_ERROR); 22 } 11 23 12 24 … … 17 29 18 30 19 const static int viewport[4] = {0, 0, 512, 512}; 20 //const static int viewport[4] = {0, 0, 1024, 768}; 31 //const static int viewport[4] = {0, 0, 512, 512}; 32 const static int viewport[4] = {0, 0, 1024, 768}; 33 //const static int viewport[4] = {0, 0, 2048, 2048}; 21 34 22 35 … … 34 47 int py = (pt.y - mSceneBox.Min(1)) * (viewport[3] - 1) / mSceneBox.Size(1); 35 48 36 const float d = mDepth[px + py * viewport[1]];49 unsigned char d = mDepth[px + py * viewport[2]]; 37 50 38 if (d > 0.0f) 51 const float offs = mSceneBox.Size(2) * 1e-1f; 52 53 static float depth = (float)d; 54 55 if (d > 0) 39 56 { 40 pt.z = mSceneBox.Max().z - mSceneBox.Size().z * d; 41 cout << "new depth " << pt.z << " (" << d << ")" << endl; 57 const float x = 0.1f; 58 depth = depth * x + d * (1.0f - x); 59 pt.z = mSceneBox.Max().z - mSceneBox.Size().z * depth / 255.0f + offs; 60 //cout << "new depth " << pt.z << " (" << d << ")" << endl; 42 61 43 62 return true; 44 63 } 64 //cout << "invalid depth: " << d << endl; 45 65 46 66 return false; … … 65 85 66 86 //glPixelStorei(GL_PACK_ROW_LENGTH, viewport[2]); 87 glPixelStorei(GL_PACK_ALIGNMENT, 1); 88 glReadBuffer(GL_BACK); 67 89 68 90 // hack: should create offscreen buffer for this … … 80 102 glClear(GL_DEPTH_BUFFER_BIT); 81 103 82 mDepth = new float[viewport[2] * viewport[3]]; 104 mDepth = new unsigned char[viewport[2] * viewport[3]]; 105 //mDepth = new float[viewport[2] * viewport[3]]; 83 106 84 107 //renderer->SetCamera(orthoCam); … … 86 109 renderer->RenderScene(); 87 110 88 glReadPixels(0, 0, viewport[2], viewport[3], GL_DEPTH_COMPONENT, GL_FLOAT, mDepth); 111 glReadPixels(0, 0, viewport[2], viewport[3], GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, mDepth); 112 //glReadPixels(0, 0, viewport[2], viewport[3], GL_DEPTH_COMPONENT, GL_FLOAT, mDepth); 113 /* 114 startil(); 89 115 116 if (!ilTexImage(viewport[2], viewport[3], 1, 1, IL_LUMINANCE, IL_UNSIGNED_BYTE, mDepth)) 117 { 118 cerr << "IL error " << ilGetError() << endl; 119 stopil(); 120 return; 121 } 122 123 ILstring writename = ILstring("out.tga"); 124 125 ilSetInteger(IL_TGA_RLE, 1); 126 if (!ilSaveImage(writename)) 127 { 128 cerr << "TGA write error " << ilGetError() << endl; 129 } 130 131 stopil(); 132 */ 90 133 DEL_PTR(orthoCam); 91 134 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.h
r2796 r2800 4 4 #include "common.h" 5 5 #include "AxisAlignedBox3.h" 6 6 7 7 8 namespace CHCDemoEngine … … 22 23 bool CalcIntersection(Vector3 &pt); 23 24 24 25 25 protected: 26 26 … … 32 32 AxisAlignedBox3 mSceneBox; 33 33 34 float*mDepth;34 unsigned char *mDepth; 35 35 }; 36 36 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/StopAndWaitTraverser.cpp
r2795 r2800 33 33 OcclusionQuery *query = IssueOcclusionQuery(node); 34 34 35 waitTimer.Entry(); 35 36 bool visible = query->GetQueryResult() > mVisibilityThreshold; 37 waitTimer.Exit(); 36 38 37 39 if (visible) -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/StopAndWaitTraverser.h
r2782 r2800 16 16 StopAndWaitTraverser(); 17 17 18 //~StopAndWaitTraverser(); 18 int GetType() const { return STOP_AND_WAIT; } 19 19 20 20 21 protected: -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Texture.cpp
r2782 r2800 2 2 #include "glInterface.h" 3 3 #include "common.h" 4 5 4 6 5 #include <IL/il.h> -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2797 r2800 57 57 int maxBatchSize = 50; 58 58 59 int trianglesPerVirtualLeaf = 1000;59 int trianglesPerVirtualLeaf = INITIAL_TRIANGLES_PER_VIRTUAL_LEAVES; 60 60 61 61 SceneQuery *sceneQuery = NULL; … … 83 83 int queryCulledNodes = 0; 84 84 int stateChanges = 0; 85 int numBatches = 0; 85 86 86 87 bool showHelp = false; … … 98 99 bool useRenderQueue = true; 99 100 bool useMultiQueries = true; 101 102 bool flyMode = true; 100 103 101 104 /// the accumulated z axis rotation … … 233 236 visualization = new Visualization(bvh, camera, NULL, &state); 234 237 235 //sceneQuery = new SceneQuery(bvh->GetBox(), traverser); 238 sceneQuery = new SceneQuery(bvh->GetBox(), traverser); 239 236 240 237 241 glutMainLoop(); … … 270 274 glEnable(GL_CULL_FACE); 271 275 //glDisable(GL_CULL_FACE); 272 276 glDisable(GL_TEXTURE_2D); 273 277 274 278 GLfloat ambientColor[] = {0.5, 0.5, 0.5, 1.0}; … … 292 296 "'F3' - shows/hides bounds (boxes or tight bounds)", 293 297 "'F4' - shows/hides statistics", 294 "'F5', - shows/hides parameters", 298 "'F5', - toggles between fly / walkmode", 299 "'F6', - shows/hides parameters", 295 300 "'SPACE' - cycles through occlusion culling algorithms", 296 301 "", … … 390 395 glEnable(GL_LIGHTING); 391 396 glEnable(GL_LIGHT0); 392 glEnable(GL_LIGHT1); 397 //glEnable(GL_LIGHT1); 398 glDisable(GL_LIGHT1); 393 399 394 400 //GLfloat ambient[] = {0.5, 0.5, 0.5, 1.0}; … … 424 430 425 431 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); 426 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);427 //glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE);432 //glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); 433 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE); 428 434 //glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL_EXT, GL_SEPARATE_SPECULAR_COLOR_EXT); 429 435 glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL_EXT, GL_SINGLE_COLOR_EXT); 430 431 } 436 } 437 432 438 433 439 void SetupEyeView() … … 476 482 void Display() 477 483 { 484 Vector3 oldPos = camera->GetPosition(); 485 478 486 PerfTimer frameTimer; 479 480 487 frameTimer.Start(); 481 488 … … 493 500 KeyVerticalMotion(KeyShift()); 494 501 495 496 502 Vector3 playerPos = camera->GetPosition(); 497 //sceneQuery->CalcIntersection(playerPos); 503 504 if (!flyMode) 505 { 506 Vector3 playerPos = camera->GetPosition(); 507 508 bool validIntersect = sceneQuery->CalcIntersection(playerPos); 509 510 if (validIntersect && 511 (( playerPos.z - oldPos.z) < bvh->GetBox().Size(2) * 1e-1f)) 512 { 498 513 camera->SetPosition(playerPos); 514 } 515 } 499 516 500 517 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); … … 532 549 break; 533 550 case 32: //space 534 renderMode = (renderMode + 1) % RenderTraverser::NUM_ RENDERMODES;551 renderMode = (renderMode + 1) % RenderTraverser::NUM_TRAVERSAL_TYPES; 535 552 ResetTraverser(); 536 553 break; … … 563 580 break; 564 581 case '8': 565 {566 582 eightKeyPressed = true; 567 KeyVerticalMotion(-KeyShift());568 583 break; 569 }570 584 case '9': 571 {572 585 nineKeyPressed = true; 573 KeyVerticalMotion(+KeyShift());574 586 break; 575 }576 587 case 'o': 577 588 case 'O': … … 581 592 case 'a': 582 593 case 'A': 583 {584 594 leftKeyPressed = true; 585 camera->Pitch(KeyRotationAngle());586 }587 595 break; 588 596 case 'd': 589 597 case 'D': 590 {591 598 rightKeyPressed = true; 592 camera->Pitch(-KeyRotationAngle());593 }594 599 break; 595 600 case 'w': 596 601 case 'W': 597 {598 602 upKeyPressed = true; 599 KeyHorizontalMotion(KeyShift());600 }601 603 break; 602 604 case 'x': 603 605 case 'X': 604 {605 606 downKeyPressed = true; 606 KeyHorizontalMotion(-KeyShift());607 }608 607 break; 609 608 case 'r': … … 716 715 case GLUT_KEY_F5: 717 716 showOptions = !showOptions; 717 break; 718 case GLUT_KEY_F6: 719 flyMode = !flyMode; 718 720 break; 719 721 case GLUT_KEY_LEFT: … … 1004 1006 if (numbers.size() > 0) 1005 1007 { 1006 sprintf _s(hstr, "%d", numbers.back());1008 sprintf(hstr, "%d", numbers.back()); 1007 1009 str.append(hstr); 1008 1010 } … … 1010 1012 for (int i = (int)numbers.size() - 2; i >= 0; i--) 1011 1013 { 1012 sprintf _s(hstr, ",%03d", numbers[i]);1014 sprintf(hstr, ",%03d", numbers[i]); 1013 1015 str.append(hstr); 1014 1016 } … … 1050 1052 issuedQueries = traverser->GetStats().mNumIssuedQueries; 1051 1053 stateChanges = traverser->GetStats().mNumStateChanges; 1052 } 1053 1054 sprintf_s(msg2, "assumed visible frames: %4d, max batch size: %4d", 1054 numBatches = traverser->GetStats().mNumBatches; 1055 } 1056 1057 sprintf(msg2, "assumed visible frames: %4d, max batch size: %4d", 1055 1058 assumedVisibleFrames, maxBatchSize); 1056 1059 1057 sprintf _s(msg3, "render queue: %d, multiqueries: %d, tight bounds: %d",1060 sprintf(msg3, "render queue: %d, multiqueries: %d, tight bounds: %d", 1058 1061 useRenderQueue, useMultiQueries, useTightBounds); 1059 1062 … … 1064 1067 CalcDecimalPoint(str2, bvh->GetBvhStats().mTriangles); 1065 1068 1066 sprintf _s(msg4, "rendered nodes: %6d (of %6d), rendered triangles: %s (of %s)",1069 sprintf(msg4, "rendered nodes: %6d (of %6d), rendered triangles: %s (of %s)", 1067 1070 renderedNodes, bvh->GetNumVirtualNodes(), str.c_str(), str2.c_str()); 1068 1071 1069 sprintf _s(msg5, "traversed: %5d, frustum culled: %5d, query culled: %5d",1072 sprintf(msg5, "traversed: %5d, frustum culled: %5d, query culled: %5d", 1070 1073 traversedNodes, frustumCulledNodes, queryCulledNodes); 1071 1074 1072 sprintf _s(msg6, "issued queries: %5d, state changes: %5d", issuedQueries, stateChanges);1073 1074 sprintf _s(msg8, "triangles per virtual leaf: %5d", trianglesPerVirtualLeaf);1075 1076 sprintf _s(msg7, "fps: %6.1f", fps);1075 sprintf(msg6, "issued queries: %5d, state changes: %5d, render batches: %5d", issuedQueries, stateChanges, numBatches); 1076 1077 sprintf(msg8, "triangles per virtual leaf: %5d", trianglesPerVirtualLeaf); 1078 1079 sprintf(msg7, "fps: %6.1f", fps); 1077 1080 1078 1081 … … 1085 1088 else 1086 1089 { 1087 glColor3f(1.0f, 1.0f, 1.0f); 1090 // glColor3f(1.0f, 1.0f, 1.0f); 1091 glColor3f(1.0f, 0.0f, 0.0f); 1088 1092 Output(850, 30, msg[renderMode]); 1089 1093 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/common.h
r2795 r2800 476 476 static std::string model_path("data/city/model/"); 477 477 478 478 479 /////////// 479 480 //-- typedefs … … 490 491 static std::ofstream Debug("debug.log"); 491 492 492 } 493 494 #endif 495 496 497 498 499 500 501 502 493 494 #define INITIAL_TRIANGLES_PER_VIRTUAL_LEAVES 1000 495 496 } 497 498 #endif 499 500 501 502 503 504 505 506
Note: See TracChangeset
for help on using the changeset viewer.