- Timestamp:
- 07/16/08 11:28:52 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 11 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
r2839 r2840 547 547 </File> 548 548 <File 549 RelativePath=".\src\Transform .h"549 RelativePath=".\src\Transform3.h" 550 550 > 551 551 </File> … … 717 717 </File> 718 718 <File 719 RelativePath=".\src\Transform .cpp"719 RelativePath=".\src\Transform3.cpp" 720 720 > 721 721 </File> -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.h
r2823 r2840 1 #ifndef GEOMETRY_H2 #define GEOMETRY_H1 #ifndef __GEOMETRY_H 2 #define __GEOMETRY_H 3 3 4 4 #include "common.h" -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp
r2839 r2840 5 5 #include "Material.h" 6 6 #include "Camera.h" 7 #include "Shape.h" 7 8 8 9 … … 138 139 entity->mRenderQueueBucket = bucket; 139 140 } 141 142 bucket->mEntities.push_back(entity); 140 143 #endif 141 bucket->mEntities.push_back(entity); 144 142 145 } 143 146 … … 146 149 { 147 150 for (size_t i = 0; i < mBuckets.size(); ++ i) 148 mBuckets[i]->m Entities.clear();151 mBuckets[i]->mShapes.clear(); 149 152 150 153 mSize = 0; … … 165 168 for (size_t i = 0; i < mBuckets.size(); ++ i) 166 169 { 167 SceneEntityContainer::const_iterator sit, sit_end = mBuckets[i]->mEntities.end(); 168 for (sit = mBuckets[i]->mEntities.begin(); sit != sit_end; ++ sit) 169 { 170 SceneEntity *ent = *sit; 171 ent->Render(mState); 170 ShapeContainer::const_iterator sit, sit_end = mBuckets[i]->mShapes.end(); 171 172 for (sit = mBuckets[i]->mShapes.begin(); sit != sit_end; ++ sit) 173 { 174 Shape *shape = *sit; 175 shape->Render(mState); 172 176 } 173 177 } … … 183 187 Debug << "\n******\nbucket " << (int)i << endl; 184 188 185 S ceneEntityContainer::const_iterator sit, sit_end = mBuckets[i]->mEntities.end();186 187 for (sit = mBuckets[i]->m Entities.begin(); sit != sit_end; ++ sit)188 { 189 S ceneEntity *ent= *sit;190 #ifdef TODO191 Material *mat = ent->GetMaterial();189 ShapeContainer::const_iterator sit, sit_end = mBuckets[i]->mShapes.end(); 190 191 for (sit = mBuckets[i]->mShapes.begin(); sit != sit_end; ++ sit) 192 { 193 Shape *shape = *sit; 194 195 Material *mat = shape->GetMaterial(); 192 196 int tsize = mat->GetTexture() ? mat->GetTexture()->GetByteSize() : 0; 193 float dist = SqrMagnitude(ent->GetBoundingBox().Center() - mCamera->GetPosition()); 194 Debug << "e: " << ent << " a: " << mat->IsAlphaTestEnabled() << " s: " << tsize << " d: " << dist << " " << endl; 197 #ifdef TODO 198 float dist = SqrMagnitude(shape->GetBoundingBox().Center() - mCamera->GetPosition()); 199 #else 200 float dist = -1; 195 201 #endif 202 Debug << "e: " << shape << " a: " << mat->IsAlphaTestEnabled() << " s: " << tsize << " d: " << dist << " " << endl; 196 203 } 197 204 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
r2839 r2840 8 8 #include "Matrix4x4.h" 9 9 #include "Vector3.h" 10 #include "Transform3.h" 10 11 11 12 … … 41 42 str.read(reinterpret_cast<char *>(&hasTrafo), sizeof(bool)); 42 43 43 Matrix4x4 * trafo;44 Matrix4x4 *m; 44 45 45 46 SceneEntity *sceneGeom; … … 47 48 if (!hasTrafo) 48 49 { 49 trafo= NULL;50 m = NULL; 50 51 } 51 52 else 52 53 { 53 trafo = new Matrix4x4(); 54 str.read(reinterpret_cast<char *>(trafo->x), sizeof(Matrix4x4)); 55 mTrafos.push_back(trafo); 56 } 57 54 m = new Matrix4x4(); 55 str.read(reinterpret_cast<char *>(m->x), sizeof(Matrix4x4)); 56 } 57 58 Transform3 *trafo = new Transform3(m); 59 mTrafos.push_back(trafo); 60 58 61 // use instancing 59 62 sceneGeom = new SceneEntity(trafo); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.h
r2795 r2840 7 7 #include <fstream> 8 8 #include <map> 9 #include "common.h" 9 10 10 #include "common.h"11 11 12 12 class igzstream; … … 21 21 class Texture; 22 22 class Matrix4x4; 23 class Transform3; 24 23 25 24 26 /** Loads a scene and also handles the cleanup … … 52 54 std::vector<Geometry *> mGeometry; 53 55 std::vector<SceneEntity *> mSceneEntities; 54 std::vector< Matrix4x4*> mTrafos;56 std::vector<Transform3 *> mTrafos; 55 57 }; 56 58 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp
r2839 r2840 4 4 #include "Material.h" 5 5 #include "RenderState.h" 6 #include "Shape.h" 6 7 #include <Cg/cg.h> 7 8 #include <Cg/cgGL.h> … … 11 12 { 12 13 13 CGparameter SceneEntity::sModelMatrixParam; 14 15 SceneEntity::SceneEntity(Matrix4x4 *trafo): mTransform(trafo) 14 SceneEntity::SceneEntity(Transform3 *trafo): mTransform(trafo) 16 15 { 17 16 } … … 25 24 ShapeContainer *SceneEntity::GetCurrentLOD() 26 25 { 27 if (mLODInfos.empty())26 /* if (mLODInfos->empty()) 28 27 return &mShapes; 29 28 … … 32 31 int i = 0; 33 32 34 for (int i = 0; i < mLODInfos .size(); ++ i)33 for (int i = 0; i < mLODInfos->size(); ++ i) 35 34 { 36 if ( mLODInfos[i].mDistance > mDistance)37 return mShapes[i];35 if ((mLODInfos*)[i].mDistance > mDistance) 36 return &(mLODInfos*)[i].mShapes; 38 37 } 39 38 40 return mShapes.last(); 39 return &(mLODInfos->last().mShapes); 40 */ 41 return NULL; 41 42 } 42 43 … … 49 50 ShapeContainer *shapes; 50 51 51 sh spes = GetCurrentLOD(mDistance);52 shapes = GetCurrentLOD(); 52 53 53 54 for (int i = 0; i < shapes->size(); ++ i) 54 55 { 55 ( shapes*)[i]->Render(state);56 (*shapes)[i]->Render(state); 56 57 } 57 58 } … … 64 65 65 66 66 void SceneEntity::SetTransform ation(Matrix4x4*trafo)67 void SceneEntity::SetTransform(Transform3 *trafo) 67 68 { 68 69 mTransform = trafo; … … 86 87 #ifdef TODO 87 88 AxisAlignedBox3 box = mGeometry->GetBoundingBox(); 89 if (mTransform) Transform(box, *mTransform); 88 90 #else 89 91 AxisAlignedBox3 box; 90 92 #endif 91 if (mTransform) Transform(box, *mTransform);93 92 94 93 95 return box; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h
r2839 r2840 17 17 class Geometry; 18 18 class RenderState; 19 struct RenderQueueBucket; 19 class Transform3; 20 20 21 21 22 /** Class representing a scene entity. … … 30 31 /** Creates a scene entity. 31 32 */ 32 SceneEntity(Transform ation*trafo);33 SceneEntity(Transform3 *trafo); 33 34 34 35 ~SceneEntity(); … … 47 48 /** Set pointer to the geometry 48 49 */ 49 void SetTransform ation(Transformation*trafo);50 void SetTransform(Transform3 *trafo); 50 51 /** Returns the transformed bounding box. 51 52 */ … … 59 60 /** Returns the trafo of this scene entity. 60 61 */ 61 inline Transformation *GetTransformation() const { return mTransform; } 62 inline Transform3 *GetTransform() const { return mTransform; } 63 62 64 63 65 protected: 64 66 67 ShapeContainer *GetCurrentLOD(); 68 65 69 /// transform matrix 66 Transform ation*mTransform;67 70 Transform3 *mTransform; 71 /// Stores information about the LOD levels 68 72 LODInfoContainer mLODInfos; 69 73 /// the renderable shapes 70 74 ShapeContainer mShapes; 71 75 /// when this entity was last rendered 72 76 int mLastRendered; 73 77 }; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.cpp
r2839 r2840 1 #include "glInterface.h"2 1 #include "Shape.h" 3 2 #include "Material.h" 4 3 #include "RenderState.h" 5 4 #include "Geometry.h" 5 #include "SceneEntity.h" 6 7 #include "glInterface.h" 6 8 #include <Cg/cg.h> 7 9 #include <Cg/cgGL.h> … … 11 13 { 12 14 13 Shape::Shape(Geometry *geometry, 14 Material *mat): 15 mGeometry(geometry), mMaterial(mat), mRenderQueueBucket(NULL) 15 Shape::Shape(Geometry *geometry, Material *mat, SceneEntity *parent): 16 mGeometry(geometry), 17 mMaterial(mat), 18 mParent(parent), 19 mRenderQueueBucket(NULL) 16 20 { 17 21 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.h
r2839 r2840 50 50 Geometry *mGeometry; 51 51 Material *mMaterial; 52 52 SceneEntity *mParent; 53 53 54 /// pointer to the renderqueue bucket this entity belongs to 54 55 RenderQueueBucket *mRenderQueueBucket; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.cpp
r2839 r2840 1 #include "Transformation.h" 2 1 #include "Transform3.h" 2 #include "Matrix4x4.h" 3 #include "RenderState.h" 3 4 4 5 … … 6 7 { 7 8 8 CGparameter Transform ation::sModelMatrixParam;9 CGparameter Transform3::sModelMatrixParam; 9 10 10 Transform ation::Transformation(Matrix4x4 *trafo): mMatrix(trafo)11 Transform3::Transform3(Matrix4x4 *trafo): mMatrix(trafo) 11 12 { 12 13 } 13 14 14 15 15 Transform ation::~Transformation16 Transform3::~Transform3() 16 17 { 18 DEL_PTR(mMatrix); 17 19 } 18 20 19 21 20 void Transform ation::Load(RenderState *state)22 void Transform3::Load(RenderState *state) 21 23 { 22 24 if (!mMatrix) return; … … 24 26 if (state->GetRenderType() == RenderState::DEFERRED) 25 27 { 26 cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)m Transform->x);28 cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)mMatrix->x); 27 29 } 28 30 else 29 31 { 30 32 glPushMatrix(); 31 glMultMatrixf((float *)m Transform->x);33 glMultMatrixf((float *)mMatrix->x); 32 34 } 33 35 } 34 36 35 37 36 void Transform ation::Unload(RenderState *state)38 void Transform3::Unload(RenderState *state) 37 39 { 38 40 if (!mMatrix) return; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.h
r2839 r2840 1 #ifndef __ SCENEENTITY_H2 #define __ SCENEENTITY_H1 #ifndef __TRANSFORM3_H 2 #define __TRANSFORM3_H 3 3 4 4 #include "glInterface.h" … … 11 11 12 12 class RenderState; 13 class Matrix4x4; 13 14 14 15 15 16 /** Class representing a transformation 16 17 */ 17 class Transform ation18 class Transform3 18 19 { 19 20 public: 20 21 21 static CGparameter sModelMatrixParam;22 23 22 /** Creates a scene entity. 24 23 */ 25 Transform ation(Matrix4x4 *trafo);24 Transform3(Matrix4x4 *trafo); 26 25 27 ~Transform ation();26 ~Transform3(); 28 27 /** Loads this transformation. 29 28 */ … … 36 35 inline Matrix4x4 *GetMatrix() const { return mMatrix; } 37 36 37 static CGparameter sModelMatrixParam; 38 39 38 40 protected: 39 41 … … 45 47 } 46 48 47 #endif // __ SCENEENTITY_H49 #endif // __TRANSFORM_H -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.h
r2806 r2840 23 23 as parameters 24 24 */ 25 Visualization(Bvh *bvh, Camera *camera, Camera *vizCamera, RenderState * renderState);25 Visualization(Bvh *bvh, Camera *camera, Camera *vizCamera, RenderState *state); 26 26 27 27 ~Visualization(); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2838 r2840 30 30 #include "Environment.h" 31 31 #include "Halton.h" 32 #include "Transform3.h" 32 33 33 34 … … 499 500 cgGLLoadProgram(sCgMrtVertexProgram); 500 501 501 SceneEntity::sModelMatrixParam = cgGetNamedParameter(sCgMrtVertexProgram, "ModelMatrix");502 Transform3::sModelMatrixParam = cgGetNamedParameter(sCgMrtVertexProgram, "ModelMatrix"); 502 503 sModelViewProjMatrixParam = cgGetNamedParameter(sCgMrtVertexProgram, "ModelViewProj"); 503 504 } … … 1066 1067 1067 1068 static Matrix4x4 identity = IdentityMatrix(); 1068 cgGLSetMatrixParameterfc( SceneEntity::sModelMatrixParam, (const float *)identity.x);1069 cgGLSetMatrixParameterfc(Transform3::sModelMatrixParam, (const float *)identity.x); 1069 1070 } 1070 1071 }
Note: See TracChangeset
for help on using the changeset viewer.