Changeset 2847 for GTP/trunk/App/Demos/Vis/FriendlyCulling
- Timestamp:
- 07/18/08 03:07:26 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
r2840 r2847 613 613 </File> 614 614 <File 615 RelativePath=".\src\LODInfo.cpp" 616 > 617 </File> 618 <File 615 619 RelativePath=".\src\Material.cpp" 616 620 > -
GTP/trunk/App/Demos/Vis/FriendlyCulling/Readme.txt
r2806 r2847 81 81 The project is separated into one section containing supportive code (utils), the traversal algorithms (traversal), and the basic engine classes like Camera, Geometry, Material, or RenderState (rendering). 82 82 83 the tool uses some free 3rd party libraries, like DevIL for the image processing, and glfont2 for the HUD (http://students.cs.byu.edu/~bfish/glfont2.php, many thanks to Brad Fish for fast antialiased text). Also thanks to Alexander Kusternig for providing me his code for the SSAO shader. 84 83 85 If you find any problem with the code or have any comments, please feel free to ask us at any time. -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/LODInfo.h
r2844 r2847 3 3 4 4 #include "common.h" 5 #include "Vector3.h" 5 6 6 7 … … 21 22 /// shapes belonging to this LOD level 22 23 ShapeContainer mShapes; 24 25 26 /** Has to be called each frame in order to use proper LOD level. 27 */ 28 static void InitFrame(const Vector3 &viewPoint); 29 30 static int sFrameId; 31 static Vector3 sViewPoint; 23 32 }; 24 33 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp
r2845 r2847 144 144 // assume that the incoming nodes are ordered by distance 145 145 // => set min dist on first incoming node 146 const Vector3 v = shape->Get TransformedBoundingBox().Center() - mCamera->GetPosition();146 const Vector3 v = shape->GetCenter() - mCamera->GetPosition(); 147 147 148 148 const float dist = SqrMagnitude(v); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp
r2844 r2847 109 109 { 110 110 SceneEntity *ent = entities[i]; 111 ent->UpdateLODs(mCamera); 112 111 113 112 mStats.mNumRenderedTriangles += ent->CountNumTriangles(); 114 113 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp
r2844 r2847 20 20 21 21 SceneEntity::SceneEntity(Transform3 *trafo): 22 mTransform(trafo), mCurrentLODLevel(0) 22 mTransform(trafo), mCurrentLODLevel(0), mLODLastUpdated(-1) 23 23 { 24 24 mBox.Initialize(); … … 31 31 32 32 33 void SceneEntity::UpdateLODs( Camera *cam)33 void SceneEntity::UpdateLODs(const Vector3 &viewPoint) 34 34 { 35 const Vector3 pos = Get TransformedBoundingBox().Center();35 const Vector3 pos = GetCenter(); 36 36 37 const float distance = SqrDistance(pos, cam->GetPosition());37 const float distance = SqrDistance(pos, viewPoint); 38 38 39 39 mCurrentLODLevel = 0; 40 40 41 int l = (int)mLODLevels.size();41 const int l = (int)mLODLevels.size(); 42 42 43 43 for (int i = 0; i < l; ++ i) … … 60 60 ShapeContainer::iterator &end) 61 61 { 62 if (mLODLastUpdated != LODLevel::sFrameId) 63 { 64 mLODLastUpdated = LODLevel::sFrameId; 65 UpdateLODs(LODLevel::sViewPoint); 66 } 67 62 68 start = mLODLevels[mCurrentLODLevel]->mShapes.begin(); 63 69 end = mLODLevels[mCurrentLODLevel]->mShapes.end(); … … 80 86 ShapeContainer::iterator sit, sit_end; 81 87 82 /*if (mShapes.size() > 8) 83 { 84 sit = mShapes.begin() + 6; 85 sit_end = mShapes.begin() + 6; 86 } 87 else*/ 88 GetCurrentLODLevel(sit, sit_end); 88 GetCurrentLODLevel(sit, sit_end); 89 89 90 //if (mShapes.size() > 1)91 //mShapes[0]->Render(state);92 90 for (; sit != sit_end; ++ sit) 93 91 { … … 101 99 mShapes.push_back(shape); 102 100 mBox.Include(shape->GetBoundingBox()); 101 102 mCenter = mBox.Center(); 103 103 } 104 104 … … 163 163 } 164 164 165 166 Vector3 SceneEntity::GetCenter() const 167 { 168 Matrix4x4 *mat = mTransform->GetMatrix(); 169 170 if (!mat) 171 return mCenter; 172 173 return (*mat) * mCenter; 165 174 } 175 176 177 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h
r2844 r2847 74 74 //////////////// 75 75 76 /** Internally updates current lod level. 77 */ 78 void UpdateLODs(Camera *cam); 76 79 77 /** Returns shapes of specified lod level 80 78 */ … … 90 88 int GetNumLODLevels() const { return (int)mLODLevels.size(); } 91 89 90 /** Returns transformed center point of this shape. 91 */ 92 Vector3 GetCenter() const; 93 92 94 protected: 93 95 96 /** Internally updates current lod level. 97 */ 98 void UpdateLODs(const Vector3 &viewPoint); 99 100 101 102 /// the bounding box 94 103 AxisAlignedBox3 mBox; 95 104 /// transform matrix … … 103 112 104 113 int mCurrentLODLevel; 114 115 /// which frame the lod info was last updated 116 int mLODLastUpdated; 117 118 Vector3 mCenter; 105 119 }; 106 120 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.cpp
r2844 r2847 16 16 mRenderQueueBucket(NULL) 17 17 { 18 mCenter = GetBoundingBox().Center(); 18 19 } 19 20 … … 30 31 mGeometry->Render(state); 31 32 mParent->GetTransform()->Unload(state); 32 33 33 } 34 34 … … 63 63 } 64 64 65 66 Vector3 Shape::GetCenter() const 67 { 68 Matrix4x4 *mat = mParent->GetTransform()->GetMatrix(); 69 70 if (!mat) return mCenter; 71 72 return (*mat) * mCenter; 65 73 } 74 75 76 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.h
r2842 r2847 6 6 #include <Cg/cgGL.h> 7 7 #include "common.h" 8 #include "Vector3.h" 8 9 9 10 … … 16 17 class RenderState; 17 18 class AxisAlignedBox3; 19 class Vector3; 18 20 19 21 struct RenderQueueBucket; … … 53 55 54 56 inline Material *GetMaterial() const { return mMaterial; } 57 /** Returns transformed center point of this shape. 58 */ 59 Vector3 GetCenter() const; 60 55 61 56 62 protected: 63 64 Vector3 mCenter; 57 65 58 66 Geometry *mGeometry; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2846 r2847 456 456 // create noise texture for ssao 457 457 CreateNoiseTex2D(); 458 458 459 // init render traverser 459 460 ResetTraverser(); 460 461 461 462 462 visualization = new Visualization(bvh, camera, NULL, &state); 463 463 464 464 sceneQuery = new SceneQuery(bvh->GetBox(), traverser); 465 466 // frame time is restarted every frame 467 frameTimer.Start(); 465 468 466 469 … … 1099 1102 void Display() 1100 1103 { 1101 glFlush();1102 elapsedTime = frameTimer.Elapsedms();1103 1104 // take time from last frame1105 frameTimer.Start();1106 1107 1104 Vector3 oldPos = camera->GetPosition(); 1108 1105 … … 1193 1190 1194 1191 1192 LODLevel::InitFrame(camera->GetPosition()); 1193 1194 1195 1195 // bring eye modelview matrix up-to-date 1196 1196 SetupEyeView(); … … 1272 1272 if (visMode) DisplayVisualization(); 1273 1273 } 1274 1275 glFlush(); 1276 1277 const bool restart = true; 1278 elapsedTime = frameTimer.Elapsedms(restart); 1274 1279 1275 1280 DisplayStats();
Note: See TracChangeset
for help on using the changeset viewer.