Changeset 2839 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Timestamp:
- 07/16/08 10:46:32 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 7 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
r2825 r2839 799 799 for (int i = node->mFirst; i <= node->mLast; ++ i) 800 800 { 801 #ifdef TODO 801 802 numTriangles += mGeometry[i]->GetGeometry()->GetNumTriangles(); 803 #endif 802 804 } 803 805 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp
r2826 r2839 58 58 59 59 60 bool RenderQueue::FitsInBucket(SceneEntity *ent, size_t idx) const 61 { 60 bool RenderQueue::FitsInBucket(Shape *ent, size_t idx) const 61 { 62 #ifdef TODO 62 63 Material *mat = ent->GetMaterial(); 63 64 #else 65 Material *mat = NULL; 66 #endif 64 67 // test if entity belongs to this bucket 65 68 // note: rather slows down the application for some reason!! … … 89 92 RenderQueueBucket *bucket; 90 93 ++ mSize; 91 94 #ifdef TODO 92 95 if (entity->mRenderQueueBucket) 93 96 { … … 135 138 entity->mRenderQueueBucket = bucket; 136 139 } 137 140 #endif 138 141 bucket->mEntities.push_back(entity); 139 142 } … … 185 188 { 186 189 SceneEntity *ent = *sit; 187 190 #ifdef TODO 188 191 Material *mat = ent->GetMaterial(); 189 192 int tsize = mat->GetTexture() ? mat->GetTexture()->GetByteSize() : 0; 190 193 float dist = SqrMagnitude(ent->GetBoundingBox().Center() - mCamera->GetPosition()); 191 194 Debug << "e: " << ent << " a: " << mat->IsAlphaTestEnabled() << " s: " << tsize << " d: " << dist << " " << endl; 195 #endif 192 196 } 193 197 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.h
r2805 r2839 29 29 float mMinDistance; 30 30 31 S ceneEntityContainer mEntities;31 ShapeContainer mShapes; 32 32 }; 33 33 … … 70 70 protected: 71 71 72 inline bool FitsInBucket(S ceneEntity *ent, size_t idx) const;72 inline bool FitsInBucket(Shape *shape, size_t idx) const; 73 73 74 74 /** Sorts the render queue by materials / textures. -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp
r2825 r2839 109 109 { 110 110 SceneEntity *ent = entities[i]; 111 #ifdef TODO 111 112 mStats.mNumRenderedTriangles += ent->GetGeometry()->GetNumTriangles(); 112 113 #endif 113 114 if (mUseRenderQueue) 114 115 mRenderQueue->Enqueue(ent); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
r2833 r2839 57 57 58 58 // use instancing 59 sceneGeom = new SceneEntity( geom, mat,trafo);59 sceneGeom = new SceneEntity(trafo); 60 60 61 61 return sceneGeom; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp
r2825 r2839 13 13 CGparameter SceneEntity::sModelMatrixParam; 14 14 15 SceneEntity::SceneEntity(Geometry *geometry, 16 Material *mat, 17 Matrix4x4 *trafo): 18 mGeometry(geometry), mMaterial(mat), mTransform(trafo), mRenderQueueBucket(NULL) 15 SceneEntity::SceneEntity(Matrix4x4 *trafo): mTransform(trafo) 19 16 { 20 17 } … … 26 23 27 24 25 ShapeContainer *SceneEntity::GetCurrentLOD() 26 { 27 if (mLODInfos.empty()) 28 return &mShapes; 29 30 float mDistance = 0.0f; 31 32 int i = 0; 33 34 for (int i = 0; i < mLODInfos.size(); ++ i) 35 { 36 if (mLODInfos[i].mDistance > mDistance) 37 return mShapes[i]; 38 } 39 40 return mShapes.last(); 41 } 42 43 28 44 void SceneEntity::Render(RenderState *state) 29 45 { 30 if (mMaterial) mMaterial->Render(state); 46 //if (mMaterial) mMaterial->Render(state); 47 float mDistance = 0.0f; 31 48 32 if (mTransform) 49 ShapeContainer *shapes; 50 51 shspes = GetCurrentLOD(mDistance); 52 53 for (int i = 0; i < shapes->size(); ++ i) 33 54 { 34 if (state->GetRenderType() == RenderState::DEFERRED) 35 { 36 cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)mTransform->x); 37 38 mGeometry->Render(state); 39 40 static Matrix4x4 identity = IdentityMatrix(); 41 cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)identity.x); 42 } 43 else 44 { 45 glPushMatrix(); 46 glMultMatrixf((float *)mTransform->x); 47 48 mGeometry->Render(state); 49 50 glPopMatrix(); 51 } 52 } 53 else 54 { 55 mGeometry->Render(state); 55 (shapes*)[i]->Render(state); 56 56 } 57 57 } 58 58 59 59 60 void SceneEntity:: SetGeometry(Geometry *geom)60 void SceneEntity::AddShape(Shape *shape) 61 61 { 62 m Geometry = geom;62 mShapes.push_back(shape); 63 63 } 64 64 … … 67 67 { 68 68 mTransform = trafo; 69 }70 71 72 void SceneEntity::SetMaterial(Material *mat)73 {74 mMaterial = mat;75 69 } 76 70 … … 90 84 AxisAlignedBox3 SceneEntity::GetBoundingBox() const 91 85 { 86 #ifdef TODO 92 87 AxisAlignedBox3 box = mGeometry->GetBoundingBox(); 88 #else 89 AxisAlignedBox3 box; 90 #endif 93 91 if (mTransform) Transform(box, *mTransform); 94 92 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h
r2819 r2839 8 8 #include "AxisAlignedBox3.h" 9 9 #include "Triangle3.h" 10 #include "LODInfo.h" 10 11 11 12 12 13 namespace CHCDemoEngine 13 14 { 14 15 16 15 17 16 class Material; … … 28 27 29 28 public: 30 static CGparameter sModelMatrixParam;29 31 30 /** Creates a scene entity. 32 31 */ 33 SceneEntity( Geometry *geometry, Material *mat, Matrix4x4*trafo);32 SceneEntity(Transformation *trafo); 34 33 35 34 ~SceneEntity(); … … 37 36 */ 38 37 void Render(RenderState *state); 38 /** Set pointer to the shape 39 */ 40 void AddShape(Shape *shape); 41 /** See set 42 */ 43 inline Shape *GetShape(int i) const { return mShapes[i]; } 44 /** Returns number of shapes in vector. 45 */ 46 inline int GetNumShapes() { return (int)mShapes.size(); } 39 47 /** Set pointer to the geometry 40 48 */ 41 void SetGeometry(Geometry *geom); 42 /** See set 43 */ 44 Geometry *GetGeometry() const { return mGeometry; } 45 /** Set pointer to the geometry 46 */ 47 void SetTransformation(Matrix4x4 *trafo); 48 /** Set pointer to the material 49 */ 50 void SetMaterial(Material *mat); 49 void SetTransformation(Transformation *trafo); 51 50 /** Returns the transformed bounding box. 52 51 */ … … 58 57 */ 59 58 int GetLastRendered() const; 60 61 inline Material *GetMaterial() const { return mMaterial; }62 inline Matrix4x4*GetTransformation() const { return mTransform; }59 /** Returns the trafo of this scene entity. 60 */ 61 inline Transformation *GetTransformation() const { return mTransform; } 63 62 64 63 protected: 65 64 66 65 /// transform matrix 67 Matrix4x4 *mTransform; 68 Geometry *mGeometry; 69 Material *mMaterial; 70 66 Transformation *mTransform; 67 68 LODInfoContainer mLODInfos; 69 70 ShapeContainer mShapes; 71 71 72 int mLastRendered; 72 /// pointer to the renderqueue bucket this entity belongs to73 RenderQueueBucket *mRenderQueueBucket;74 73 }; 75 74 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/common.h
r2801 r2839 494 494 #define INITIAL_TRIANGLES_PER_VIRTUAL_LEAVES 1000 495 495 496 // #define PRINT_VERBOSE_BENCHMARKS 497 } 498 499 #endif 500 501 502 503 504 505 506 507 496 class Shape; 497 typedef std::vector<Shape *> ShapeContainer; 498 499 struct LODInfo; 500 typedef std::vector<LODInfo *> LODInfoContainer; 501 502 } 503 504 #endif 505 506 507 508 509 510 511 512
Note: See TracChangeset
for help on using the changeset viewer.