Changeset 2848
- Timestamp:
- 07/21/08 03:12:51 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
r2842 r2848 144 144 mGeometry = new SceneEntity*[mGeometrySize]; 145 145 146 mBox.Initialize();147 148 146 SceneEntityContainer::const_iterator it, it_end = entities.end(); 149 147 … … 152 150 { 153 151 mGeometry[i] = (*it); 154 //mBox.Include((*it)->GetBoundingBox()); 155 } 156 157 cout << "scene box: " << mBox << endl; 152 } 158 153 } 159 154 … … 799 794 for (int i = node->mFirst; i <= node->mLast; ++ i) 800 795 { 801 numTriangles += mGeometry[i]->CountNumTriangles( );796 numTriangles += mGeometry[i]->CountNumTriangles(0); 802 797 } 803 798 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/LODInfo.cpp
r2847 r2848 1 1 #include "LODInfo.h" 2 2 #include "Vector3.h" 3 #include "Shape.h" 4 #include "Geometry.h" 5 3 6 4 7 … … 17 20 18 21 22 void LODLevel::AddShape(Shape *shape) 23 { 24 mShapes.push_back(shape); 25 mNumTriangles += shape->GetGeometry()->GetNumTriangles(); 19 26 } 27 28 29 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/LODInfo.h
r2847 r2848 13 13 struct LODLevel 14 14 { 15 //friend class SceneEntity; 16 15 17 public: 16 18 17 19 LODLevel(float squaredDist): mSquaredDistance(squaredDist) {} 18 20 21 inline float GetSquaredDistance() { return mSquaredDistance; } 22 23 inline int GetNumShapes() { return (int)mShapes.size(); } 24 25 inline int GetNumTriangles() { return mNumTriangles; } 26 27 inline Shape *GetShape(size_t i) { return mShapes[i]; } 28 29 inline ShapeContainer &GetShapes() { return mShapes; } 30 31 void AddShape(Shape *shape); 32 33 34 //////////////// 35 36 /** Has to be called each frame in order to use proper LOD level. 37 */ 38 static void InitFrame(const Vector3 &viewPoint); 39 40 41 static int sFrameId; 42 static Vector3 sViewPoint; 43 44 45 46 protected: 47 48 ///////////////////// 49 50 float mNumTriangles; 19 51 20 52 /// distance of this LOD level … … 22 54 /// shapes belonging to this LOD level 23 55 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;32 56 }; 33 57 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp
r2847 r2848 188 188 } 189 189 } 190 191 190 //Print(); 192 191 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.h
r2844 r2848 86 86 void Print(); 87 87 88 88 89 /////////// 89 90 90 91 RenderState *mState; 92 91 93 Camera *mCamera; 92 94 //SceneEntityContainer mEntities; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp
r2847 r2848 270 270 271 271 if (mRenderQueue->GetSize() > 0) 272 { 272 273 ++ mStats.mNumBatches; 273 274 mRenderQueue->Apply();275 } 276 277 278 } 274 mRenderQueue->Apply(); 275 } 276 } 277 278 279 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
r2846 r2848 91 91 92 92 sceneGeom->AddShape(shape); 93 lodLevel-> mShapes.push_back(shape);93 lodLevel->AddShape(shape); 94 94 } 95 95 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp
r2847 r2848 45 45 LODLevel *lod = mLODLevels[i]; 46 46 47 if (lod-> mSquaredDistance> distance)47 if (lod->GetSquaredDistance() > distance) 48 48 break; 49 49 50 50 mCurrentLODLevel = i; 51 51 } 52 } 52 53 53 /*if (mLODLevels.size() > 1) 54 55 int SceneEntity::GetCurrentLODLevel() 56 { 57 if (mLODLastUpdated != LODLevel::sFrameId) 54 58 { 55 Debug << "dist: " << distance << " numshapes: " << mLODLevels[mCurrentLODLevel]->mShapes.size() << " lod: " << mCurrentLODLevel << " of " << mLODLevels.size() << endl; 56 }*/ 59 mLODLastUpdated = LODLevel::sFrameId; 60 UpdateLODs(LODLevel::sViewPoint); 61 } 62 63 return mCurrentLODLevel; 57 64 } 65 58 66 59 67 void SceneEntity::GetCurrentLODLevel(ShapeContainer::iterator &start, … … 66 74 } 67 75 68 start = mLODLevels[mCurrentLODLevel]-> mShapes.begin();69 end = mLODLevels[mCurrentLODLevel]->mShapes.end();76 start = mLODLevels[mCurrentLODLevel]->GetShapes().begin(); 77 end = mLODLevels[mCurrentLODLevel]->GetShapes().end(); 70 78 } 71 79 … … 77 85 LODLevel *lod = mLODLevels[level]; 78 86 79 start = lod-> mShapes.begin();80 end = lod-> mShapes.end();87 start = lod->GetShapes().begin(); 88 end = lod->GetShapes().end(); 81 89 } 82 90 … … 130 138 if (lodLevel == -1) 131 139 { 132 GetCurrentLODLevel(sit, sit_end); 133 } 134 else 135 { 136 GetLODLevel(lodLevel, sit, sit_end); 140 lodLevel = GetCurrentLODLevel(); 137 141 } 138 142 139 140 for (; sit != sit_end; ++ sit) 141 { 142 numTriangles += (*sit)->GetGeometry()->GetNumTriangles(); 143 } 144 145 return numTriangles; 143 return mLODLevels[lodLevel]->GetNumTriangles(); 146 144 } 147 145 … … 168 166 Matrix4x4 *mat = mTransform->GetMatrix(); 169 167 170 if (!mat) 171 return mCenter; 168 if (!mat) return mCenter; 172 169 173 170 return (*mat) * mCenter; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h
r2847 r2848 62 62 with 0 being the highest or the current lod level (if the argument is -1). 63 63 */ 64 int CountNumTriangles(int lodLevel = 0);64 int CountNumTriangles(int lodLevel = -1); 65 65 /** Returns the bounding box. 66 66 */ … … 87 87 */ 88 88 int GetNumLODLevels() const { return (int)mLODLevels.size(); } 89 90 89 /** Returns transformed center point of this shape. 91 90 */ 92 91 Vector3 GetCenter() const; 92 93 93 94 94 95 protected: … … 97 98 */ 98 99 void UpdateLODs(const Vector3 &viewPoint); 99 100 /** Returns updated index of current lod level. 101 */ 102 int GetCurrentLODLevel(); 100 103 101 104 … … 112 115 113 116 int mCurrentLODLevel; 114 115 117 /// which frame the lod info was last updated 116 118 int mLODLastUpdated; 117 119 /// the center of gravity of this scene entity 118 120 Vector3 mCenter; 119 121 }; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.cpp
r2838 r2848 7 7 #include <IL/il.h> 8 8 #include <assert.h> 9 #include "RenderTexture.h"9 //#include "RenderTexture.h" 10 10 11 11 12 12 using namespace std; 13 13 14 static int texWidth = 2048;15 static int texHeight = 2048;14 const static int texWidth = 2048; 15 const static int texHeight = 2048; 16 16 17 17 … … 107 107 { 108 108 // temporal smoothing of depth values 109 const float x = 0.5f;109 const float x = .5f; 110 110 depth = d * x + depth * (1.0f - x); 111 111 … … 131 131 132 132 orthoCam->SetNear(0.0f); 133 orthoCam->Yaw( -M_PI * 0.5f);133 orthoCam->Yaw(M_PI * 0.5f); 134 134 135 135 Vector3 pos = Vector3(mSceneBox.Center().x, mSceneBox.Center().y, mSceneBox.Max().z); … … 165 165 glPushMatrix(); 166 166 167 glOrtho( -xlen, xlen, -ylen,ylen, 0.0f, mSceneBox.Size().z);167 glOrtho(+xlen, -xlen, ylen, -ylen, 0.0f, mSceneBox.Size().z); 168 168 169 169 glMatrixMode(GL_MODELVIEW); … … 185 185 186 186 GrabDepthBuffer(mDepth, depthTexture); 187 //ExportDepthBuffer(mDepth);188 //PrintGLerror("grab");187 ExportDepthBuffer(mDepth); 188 PrintGLerror("grab"); 189 189 190 190 DEL_PTR(depthTexture); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.h
r2843 r2848 21 21 22 22 ~SceneQuery() { DEL_ARRAY_PTR(mDepth); } 23 24 23 /** Calculates intersection of vertical ray at position pt.x, pt.y and 25 24 stores the intersection point if valid. returns true if the intersection -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.h
r2847 r2848 53 53 */ 54 54 AxisAlignedBox3 GetTransformedBoundingBox() const; 55 55 /** Returns material of this shape. 56 */ 56 57 inline Material *GetMaterial() const { return mMaterial; } 57 58 /** Returns transformed center point of this shape. … … 67 68 Material *mMaterial; 68 69 SceneEntity *mParent; 69 70 70 /// pointer to the renderqueue bucket this entity belongs to 71 71 RenderQueueBucket *mRenderQueueBucket; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2847 r2848 2022 2022 bool validIntersect = sceneQuery->CalcIntersection(playerPos); 2023 2023 2024 if (validIntersect &&2025 ((playerPos.z - oldPos.z) < bvh->GetBox().Size(2) * 1e-1f))2024 if (validIntersect ) 2025 // && ((playerPos.z - oldPos.z) < bvh->GetBox().Size(2) * 1e-1f)) 2026 2026 { 2027 2027 camera->SetPosition(playerPos);
Note: See TracChangeset
for help on using the changeset viewer.