- Timestamp:
- 10/26/08 20:39:31 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
r3055 r3071 228 228 </File> 229 229 <File 230 RelativePath=".\src\RenderTraverser.cpp" 231 > 232 <FileConfiguration 233 Name="Debug|Win32" 234 > 235 <Tool 236 Name="VCCLCompilerTool" 237 ObjectFile="$(IntDir)\$(InputName)1.obj" 238 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 239 /> 240 </FileConfiguration> 241 <FileConfiguration 242 Name="Release|Win32" 243 > 244 <Tool 245 Name="VCCLCompilerTool" 246 ObjectFile="$(IntDir)\$(InputName)1.obj" 247 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 248 /> 249 </FileConfiguration> 250 </File> 251 <File 230 252 RelativePath=".\src\SampleGenerator.cpp" 231 253 > … … 368 390 <File 369 391 RelativePath=".\src\FrustumCullingTraverser.cpp" 370 >371 <FileConfiguration372 Name="Debug|Win32"373 >374 <Tool375 Name="VCCLCompilerTool"376 ObjectFile="$(IntDir)\$(InputName)1.obj"377 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"378 />379 </FileConfiguration>380 <FileConfiguration381 Name="Release|Win32"382 >383 <Tool384 Name="VCCLCompilerTool"385 ObjectFile="$(IntDir)\$(InputName)1.obj"386 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"387 />388 </FileConfiguration>389 </File>390 <File391 RelativePath=".\src\RenderTraverser.cpp"392 392 > 393 393 <FileConfiguration -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
r3070 r3071 1184 1184 while (1) 1185 1185 { 1186 while (mGeometry[i]->GetWorldCenter()[axis] < position) 1187 { 1188 //cout<<" i " << i << " " << mGeometry[i]->GetWorldCenter()[axis]; 1189 ++ i; 1190 } 1191 1192 while (position < mGeometry[j]->GetWorldCenter()[axis]) 1193 { 1194 //cout<< axis << " j " << j << " " << mGeometry[j]->GetWorldCenter()[axis] << " " << position<< " "; 1195 -- j; 1196 } 1186 while (mGeometry[i]->GetWorldCenter()[axis] < position) ++ i; 1187 while (position < mGeometry[j]->GetWorldCenter()[axis]) -- j; 1197 1188 1198 1189 // sorting finished … … 1216 1207 // spatial median 1217 1208 float m = leaf->mBox.Center()[axis]; 1218 //cout << "here3 " << leaf->mBox << " " << leaf->mFirst << " " << leaf->mLast << endl;1219 1209 return SortTriangles(leaf, axis, m); 1220 1210 } … … 1229 1219 leaf->mIsVirtualLeaf = true; 1230 1220 leaf->mIsMaxDepthForVirtualLeaf = true; 1221 cout << "leaf contructed:" << leaf->mBox << " " << leaf->mFirst << " " << leaf->mLast << endl; 1231 1222 return leaf; 1232 1223 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/EntityMerger.cpp
r3070 r3071 48 48 Geometry *geom = MergeGeometry(geom1, geom2); 49 49 50 Shape *shape = new Shape(geom, mat , parent);50 Shape *shape = new Shape(geom, mat); 51 51 52 52 return shape; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrustumCullingTraverser.cpp
r2802 r3071 24 24 else 25 25 { 26 mStats.mNumFrustumCulledNodes ++;26 ++ mStats.mNumFrustumCulledNodes; 27 27 } 28 28 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp
r3061 r3071 7 7 #include "Shape.h" 8 8 #include "RenderState.h" 9 #include "Transform3.h" 10 9 11 10 12 using namespace std; … … 78 80 for (; sit != sit_end; ++ sit) 79 81 { 80 Enqueue(*sit );81 } 82 } 83 84 85 void RenderQueue::Enqueue(Shape *shape )82 Enqueue(*sit, entity->GetTransform()); 83 } 84 } 85 86 87 void RenderQueue::Enqueue(Shape *shape, Transform3 *trafo) 86 88 { 87 89 Technique *tech = shape->GetMaterial()->GetTechnique(mState->GetRenderTechnique()); … … 157 159 } 158 160 159 bucket->mShapes.push_back( shape);161 bucket->mShapes.push_back(ShapePair(shape, trafo)); 160 162 } 161 163 … … 184 186 for (size_t i = 0; i < mActiveBuckets.size(); ++ i) 185 187 { 186 Shape Container::const_iterator sit, sit_end = mActiveBuckets[i]->mShapes.end();188 ShapePairArray::const_iterator sit, sit_end = mActiveBuckets[i]->mShapes.end(); 187 189 188 190 for (sit = mActiveBuckets[i]->mShapes.begin(); sit != sit_end; ++ sit) 189 191 { 190 Shape *shape = *sit; 192 ShapePair s = *sit; 193 194 Shape *shape = s.first; 195 Transform3 *t = s.second; 196 197 t->Load(mState); 191 198 shape->Render(mState); 199 t->Unload(mState); 192 200 } 193 201 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.h
r3061 r3071 3 3 4 4 #include "common.h" 5 #include "Timer/PerfTimer.h"6 5 7 6 … … 12 11 class Camera; 13 12 13 typedef std::pair<Shape *, Transform3 *> ShapePair; 14 typedef std::vector<ShapePair> ShapePairArray; 14 15 15 16 /** Defines a bucket for scene entities that have the same properties. … … 45 46 46 47 /// the shapes that belong to a bucket 47 Shape ContainermShapes;48 ShapePairArray mShapes; 48 49 }; 49 50 … … 73 74 /** Enqueues a single shape. 74 75 */ 75 void Enqueue(Shape *shape );76 void Enqueue(Shape *shape, Transform3 *trafo); 76 77 /** Sets the current render state 77 78 */ … … 86 87 */ 87 88 void Clear(); 89 88 90 89 91 protected: -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp
r3070 r3071 158 158 EnqueueNode(mBvh->GetRoot()); 159 159 // add dynamic root 160 EnqueueNode(mBvh->GetDynamicRoot()); 160 if (mBvh->GetDynamicRoot()) 161 EnqueueNode(mBvh->GetDynamicRoot()); 161 162 162 163 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
r3070 r3071 115 115 116 116 // create shape 117 Shape *shape = new Shape(geom, mat , sceneGeom);117 Shape *shape = new Shape(geom, mat); 118 118 119 119 mShapes.push_back(shape); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp
r3070 r3071 102 102 } 103 103 104 mTransform->Load(state); 105 104 106 for (; sit != sit_end; ++ sit) 105 107 { 106 108 (*sit)->Render(state); 107 109 } 110 111 mTransform->Unload(state); 108 112 } 109 113 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h
r3070 r3071 36 36 /** Copy constructur. 37 37 */ 38 //SceneEntity(const SceneEntity & trafo);38 //SceneEntity(const SceneEntity &e); 39 39 /** Destructor. 40 40 */ … … 112 112 /// the bounding box 113 113 AxisAlignedBox3 mBox; 114 /// transform matrix114 /// describes a 3D transform 115 115 Transform3 *mTransform; 116 116 /// Stores information about the LOD levels … … 120 120 /// when this entity was last rendered 121 121 int mLastRendered; 122 122 /// the LOD level currently used for rendering 123 123 int mCurrentLODLevel; 124 /// which frame the lod info waslast updated124 /// frame number in which the LODs were last updated 125 125 int mLODLastUpdated; 126 /// the center of gravity of this sceneentity126 /// the center of gravity of this entity 127 127 Vector3 mCenter; 128 128 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntityConverter.cpp
r3070 r3071 43 43 Geometry *geom = new Geometry(vertices, normals, NULL, 36, false); 44 44 45 Shape *shape = new Shape(geom, mat , ent);45 Shape *shape = new Shape(geom, mat); 46 46 ent->AddShape(shape); 47 47 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.cpp
r3070 r3071 10 10 { 11 11 12 Shape::Shape(Geometry *geometry, Material *mat , SceneEntity *parent):12 Shape::Shape(Geometry *geometry, Material *mat): 13 13 mGeometry(geometry), 14 mMaterial(mat), 15 mParent(parent) 14 mMaterial(mat) 16 15 { 17 16 mCenter = GetBoundingBox().Center(); … … 28 27 mMaterial->Render(state); 29 28 30 mParent->GetTransform()->Load(state);31 29 mGeometry->Render(state); 32 mParent->GetTransform()->Unload(state);33 30 } 34 31 … … 53 50 54 51 55 AxisAlignedBox3 Shape::GetWorldBoundingBox() const52 Vector3 Shape::GetCenter() const 56 53 { 57 if (mParent->GetTransform()->IsIdentity()) 58 return mGeometry->GetBoundingBox(); 59 60 Matrix4x4 mat = mParent->GetTransform()->GetMatrix(); 61 62 return Transform(mGeometry->GetBoundingBox(), mat); 63 } 64 65 66 Vector3 Shape::GetWorldCenter() const 67 { 68 if (mParent->GetTransform()->IsIdentity()) 69 return mCenter; 70 71 Matrix4x4 mat = mParent->GetTransform()->GetMatrix(); 72 73 return mat * mCenter; 54 return mCenter; 74 55 } 75 56 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.h
r3070 r3071 32 32 /** Creates a scene entity. 33 33 */ 34 Shape(Geometry *geometry, Material *mat , SceneEntity *parent);34 Shape(Geometry *geometry, Material *mat); 35 35 36 36 ~Shape(); … … 43 43 /** See set 44 44 */ 45 Geometry *GetGeometry() const { return mGeometry; }45 inline Geometry *GetGeometry() const { return mGeometry; } 46 46 /** Set pointer to the material 47 47 */ … … 50 50 */ 51 51 AxisAlignedBox3 GetBoundingBox() const; 52 /** Returns bounding box transformed with the parent transform.53 */54 AxisAlignedBox3 GetWorldBoundingBox() const;55 52 /** Returns material of this shape. 56 53 */ 57 54 inline Material *GetMaterial() const { return mMaterial; } 58 /** Returns transformedcenter point of this shape.55 /** Returns center point of this shape. 59 56 */ 60 Vector3 Get WorldCenter() const;57 Vector3 GetCenter() const; 61 58 62 59 … … 67 64 Geometry *mGeometry; 68 65 Material *mMaterial; 69 SceneEntity *mParent;70 66 }; 71 67 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.cpp
r3070 r3071 32 32 { 33 33 if (mIsIdentity) return; 34 35 34 glPopMatrix(); 36 35 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3070 r3071 497 497 LoadModel("hbuddha.dem", dynamicObjects); 498 498 buddha = dynamicObjects.back(); 499 dynamicObjects.clear();500 Vector3 sceneCenter(470.398f, 240.364f, 182.5f);499 500 const Vector3 sceneCenter(470.398f, 240.364f, 182.5f); 501 501 Matrix4x4 transl = TranslationMatrix(sceneCenter); 502 502 buddha->GetTransform()->SetMatrix(transl); 503 503 504 Vector3 offs = Vector3::ZERO();505 506 504 for (int i = 0; i < 10; ++ i) 507 505 { … … 509 507 resourceManager->AddSceneEntity(ent); 510 508 511 offs.x = RandomValue(.0f, 50.0f); 512 offs.y = RandomValue(.0f, 50.0f); 509 Vector3 offs = Vector3::ZERO(); 510 511 offs.x = RandomValue(.0f, 150.0f); 512 offs.y = RandomValue(.0f, 150.0f); 513 513 514 514 transl = TranslationMatrix(sceneCenter + offs); … … 1873 1873 void RenderSky() 1874 1874 { 1875 //buddha->Render(&state);1876 1877 1875 if ((renderMethod == RENDER_DEFERRED) || (renderMethod == RENDER_DEPTH_PASS_DEFERRED)) 1878 1876 state.SetRenderTechnique(DEFERRED); … … 2008 2006 for (sit = (*resourceManager->GetShapes()).begin(); sit != sit_end; ++ sit) 2009 2007 { 2010 renderQueue->Enqueue(*sit); 2008 static Transform3 dummy(IdentityMatrix()); 2009 renderQueue->Enqueue(*sit, &dummy); 2011 2010 } 2012 2011
Note: See TracChangeset
for help on using the changeset viewer.