Changeset 3245
- Timestamp:
- 01/04/09 16:06:56 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
r3243 r3245 16 16 statsFilename=mystats.log 17 17 18 visibilitySolution=vienna_full-8x3-refu 18 #visibilitySolution=vienna_full-8x3-refu 19 visibilitySolution=vienna_full-8x3-pgv 20 #visibilitySolution=vienna_full-8x3-spgvu 19 21 20 22 ############ … … 39 41 40 42 # initial camera position 41 #camPosition=483.398f 242.364f 186.078f43 camPosition=483.398f 242.364f 186.078f 42 44 # initial camera orientation 43 #camDirection=1 0 045 camDirection=1 0 0 44 46 45 camPosition=468.025 267.591 182.47846 camDirection=0.937282 0.348573 -047 #camPosition=468.025 267.591 182.478 48 #camDirection=0.937282 0.348573 -0 47 49 48 50 #lightDirection=-0.8f 1.0f -0.7f -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
r3244 r3245 1295 1295 if (!useTightBounds) 1296 1296 { 1297 #if 1 1297 1298 RenderBoxForViz(node->GetBox()); 1298 /*glPolygonMode(GL_FRONT, GL_LINE); 1299 #else 1300 glPolygonMode(GL_FRONT, GL_LINE); 1299 1301 RenderBoundingBoxImmediate(node->GetBox()); 1300 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);*/ 1302 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 1303 #endif 1301 1304 } 1302 1305 else -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
r3214 r3245 97 97 tech.SetLightingEnabled(false); 98 98 tech.SetDepthWriteEnabled(false); 99 //tech.SetCullFaceEnabled(false);100 99 101 100 return tech; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp
r3244 r3245 112 112 { 113 113 SceneEntity *ent = entities[i]; 114 114 115 if (!ent->IsVisible()) continue; 116 115 117 mStats.mNumRenderedTriangles += ent->CountNumTriangles(); 116 118 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp
r3120 r3245 17 17 int SceneEntity::sCurrentId = 0; 18 18 bool SceneEntity::sUseLODs = true; 19 19 int SceneEntity::sVisibleId = -1; 20 20 21 21 SceneEntity::SceneEntity(Transform3 *trafo): 22 mTransform(trafo), mCurrentLODLevel(0), mLODLastUpdated(-1), mId(sCurrentId ++) 22 mTransform(trafo), 23 mCurrentLODLevel(0), 24 mLODLastUpdated(-1), 25 mId(sCurrentId ++), 26 mVisibleId(0) 23 27 { 24 28 mBox.Initialize(); … … 121 125 122 126 123 void SceneEntity::SetLastRendered (int lastRendered)127 void SceneEntity::SetLastRenderedFrame(int lastRenderedFrame) 124 128 { 125 mLastRendered = lastRendered;129 mLastRenderedFrame = lastRenderedFrame; 126 130 } 127 131 128 132 129 int SceneEntity::GetLastRendered () const133 int SceneEntity::GetLastRenderedFrame() const 130 134 { 131 return mLastRendered ;135 return mLastRenderedFrame; 132 136 } 133 137 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h
r3243 r3245 24 24 { 25 25 friend class RenderQueue; 26 friend class EntityMerger;27 26 28 27 public: … … 31 30 */ 32 31 SceneEntity(Transform3 *trafo); 33 /** Copy constructur.34 */35 //SceneEntity(const SceneEntity &e);36 32 /** Destructor. 37 33 */ … … 45 41 /** See set 46 42 */ 47 inline Shape *GetShape(int i) const { return mShapes[i]; }43 inline Shape *GetShape(int i) const; 48 44 /** Returns number of shapes in vector. 49 45 */ 50 inline int GetNumShapes() { return (int)mShapes.size(); }46 inline int GetNumShapes(); 51 47 /** Set pointer to the geometry 52 48 */ … … 54 50 /** set frame where we last rendered this node 55 51 */ 56 void SetLastRendered (int lastRendered);52 void SetLastRenderedFrame(int lastRendered); 57 53 /** returns frame where we last visited this node 58 54 */ 59 int GetLastRendered () const;55 int GetLastRenderedFrame() const; 60 56 /** Returns the trafo of this scene entity. 61 57 */ 62 inline Transform3 *GetTransform() const { return mTransform; }58 inline Transform3 *GetTransform() const; 63 59 /** Counts number of triangles in this entity using the specified lod level 64 60 with 0 being the highest or the current lod level (if the argument is -1). … … 71 67 */ 72 68 AxisAlignedBox3 GetWorldBoundingBox() const; 73 69 /** Only the scene entities are visible that match the global id. 70 */ 71 void SetVisibleId(int id); 72 /** See set 73 */ 74 int GetVisibleId(int id) const; 75 /** Returns true if this entity is visible. 76 */ 77 bool IsVisible() const; 74 78 75 79 … … 85 89 /** Adds a new lod level. 86 90 */ 87 void AddLODLevel(const LODLevel &lod) { mLODLevels.push_back(lod); }91 void AddLODLevel(const LODLevel &lod); 88 92 /** Returns numbers of lod levels. 89 93 */ 90 int GetNumLODLevels() const { return (int)mLODLevels.size(); }94 int GetNumLODLevels() const; 91 95 /** Returns center point of this shape. 92 96 */ 93 Vector3 GetCenter() const {return mCenter; }97 Vector3 GetCenter() const; 94 98 /** Returns transformed center point of this shape. 95 99 */ … … 107 111 /** If false, the highest (most detailed) LOD level is used for all entities. 108 112 */ 109 static void SetUseLODs(bool useLODs) { sUseLODs = useLODs; }113 static void SetUseLODs(bool useLODs); 110 114 /** See set 111 115 */ 112 static bool GetUseLODs() { return sUseLODs; } 116 static bool GetUseLODs(); 117 /** Sets the global visible id. Scene entities are visible only if 118 this id is -1 or their id matches this id. 119 */ 120 static void SetGlobalVisibleId(int id); 113 121 114 122 protected: … … 133 141 ShapeContainer mShapes; 134 142 /// when this entity was last rendered 135 int mLastRendered ;143 int mLastRenderedFrame; 136 144 /// the LOD level currently used for rendering 137 145 int mCurrentLODLevel; … … 145 153 static bool sUseLODs; 146 154 static int sCurrentId; 155 156 int mVisibleId; 157 static int sVisibleId; 147 158 }; 148 159 149 160 161 inline void SceneEntity::AddLODLevel(const LODLevel &lod) 162 { 163 mLODLevels.push_back(lod); 164 } 165 166 167 inline int SceneEntity::GetNumLODLevels() const 168 { 169 return (int)mLODLevels.size(); 170 } 171 172 173 inline Vector3 SceneEntity::GetCenter() const 174 { 175 return mCenter; 176 } 177 178 179 inline void SceneEntity::SetUseLODs(bool useLODs) 180 { 181 sUseLODs = useLODs; 182 } 183 184 185 inline bool SceneEntity::GetUseLODs() 186 { 187 return sUseLODs; 188 } 189 190 191 inline Shape *SceneEntity::GetShape(int i) const 192 { 193 return mShapes[i]; 194 } 195 196 197 inline int SceneEntity::GetNumShapes() 198 { 199 return (int)mShapes.size(); 200 } 201 202 203 inline Transform3 *SceneEntity::GetTransform() const 204 { 205 return mTransform; 206 } 207 208 209 inline void SceneEntity::SetVisibleId(int id) 210 { 211 mVisibleId = id; 212 } 213 214 215 inline void SceneEntity::SetGlobalVisibleId(int id) 216 { 217 sVisibleId = id; 218 } 219 220 221 inline int SceneEntity::GetVisibleId(int id) const 222 { 223 return mVisibleId; 224 } 225 226 227 inline bool SceneEntity::IsVisible() const 228 { 229 return (sVisibleId == -1) || (mVisibleId == sVisibleId); 230 } 231 232 150 233 } 151 234 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntityConverter.cpp
r3126 r3245 39 39 } 40 40 41 cout << "number of triangles in box: " << (int)triangles.size() << endl;42 43 41 Geometry *geom = new Geometry(vertices, normals, NULL, 36, false, NULL); 44 42 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderProgram.h
r3147 r3245 37 37 */ 38 38 GPUProgramParameters(ShaderProgram *p); 39 /** Sets the assoziated program(a 1:n relationship)39 /** Sets the program associated with these parameters (a 1:n relationship) 40 40 */ 41 41 void SetProgram(ShaderProgram *p) { mProgram = p; } … … 46 46 47 47 /////////// 48 //-- setparameters by index48 //-- functions for setting parameters by index 49 49 50 50 void SetValue1f(int idx, float value); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ViewCellsTree.cpp
r3244 r3245 76 76 77 77 // get the bounding box 78 // exchange x and y coordinates and recompute box 78 79 fread(&mBox, sizeof(AxisAlignedBox3), 1, fr); 79 80 … … 81 82 Vector3 v2(mBox.Max().x, -mBox.Max().z, mBox.Max().y); 82 83 83 Vector3 newMin = v1; 84 Vector3 newMax = v2; 84 mBox.Initialize(); 85 85 86 Minimize(newMin, v2); 87 Maximize(newMax, v1); 88 89 mBox.SetMin(newMin); 90 mBox.SetMax(newMax); 86 mBox.Include(v1); 87 mBox.Include(v2); 91 88 92 89 stack<ViewCellsTreeNode **> nodeStack; … … 96 93 97 94 int numViewCells = 0; 95 96 int axes[] = {0, 0, 0}; 98 97 99 98 while (!nodeStack.empty()) … … 108 107 fread(&axis, sizeof(int), 1, fr); 109 108 110 // exchange y and z axis like we have to do for the scene109 // exchange y and z axis like for whole scene 111 110 if (axis == 2) axis = 1; 112 111 else if (axis == 1) axis = 2; … … 114 113 node->mAxis = axis; 115 114 116 if (node->mAxis > 2 || node->mAxis < -1) cout << "a " << node->mAxis << " ";117 118 115 if (!node->IsLeaf()) 119 116 { 120 float pos; 121 fread(&pos, sizeof(float), 1, fr); 117 ++ axes[node->mAxis]; 122 118 123 if (axis == 1) pos = -pos; 124 node->mPosition = pos; 125 126 nodeStack.push(&node->mFront); 127 nodeStack.push(&node->mBack); 119 float mypos; 120 fread(&mypos, sizeof(float), 1, fr); 121 // changed coordinate system must be considered also here 122 if (node->mAxis == 1) 123 { 124 node->mPosition = -mypos; 125 126 nodeStack.push(&node->mBack); 127 nodeStack.push(&node->mFront); 128 //cout << mypos << " "; 129 } 130 else 131 { 132 node->mPosition = mypos; 133 134 nodeStack.push(&node->mFront); 135 nodeStack.push(&node->mBack); 136 } 128 137 } 129 138 } 130 139 131 cout << " loaded " << numViewCells << " view cells"<< endl;140 cout << "\nloaded " << numViewCells << " view cells" << " " << axes[0] << " " << axes[1] << " " << axes[2] << endl; 132 141 return true; 133 142 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/VisibilitySolutionLoader.cpp
r3244 r3245 90 90 { 91 91 std::stack<BvhNode *> tStack; 92 tStack.push(bvh->Get Root());92 tStack.push(bvh->GetStaticRoot()); 93 93 94 94 while (!tStack.empty()) … … 140 140 fread(&entries, sizeof(int), 1, fw); 141 141 142 for (int j =0; j < entries; ++ j)142 for (int j = 0; j < entries; ++ j) 143 143 { 144 144 int objectId; … … 154 154 entities = bvh->GetGeometry(node, geometrySize); 155 155 156 //if (node->IsLeaf() && (geometrySize != 1)) 157 //if (geometrySize != 1) cout << "Error!! " << geometrySize << endl; 156 158 for (int k = 0; k < geometrySize; ++ k) 157 159 { … … 175 177 176 178 mViewCells.clear(); 177 179 int axes[] = {0, 0, 0}; 180 178 181 while (!nodeStack.empty()) 179 182 { … … 198 201 nodeStack.pop(); 199 202 200 AxisAlignedBox3 newBox = box; 201 newBox.SetMin(node->mAxis, node->mPosition); 202 203 nodeStack.push( 204 pair<ViewCellsTreeNode *, AxisAlignedBox3>(node->mFront, newBox) 205 ); 206 207 newBox = box; 208 newBox.SetMax(node->mAxis, node->mPosition); 209 210 nodeStack.push( 211 pair<ViewCellsTreeNode *, AxisAlignedBox3>(node->mBack, newBox) 212 ); 203 AxisAlignedBox3 newBox1 = box; 204 AxisAlignedBox3 newBox2 = box; 205 /*if (node->mPosition < newBox.Min(node->mAxis)) 206 cout << "e: " << node->mPosition << " " << newBox.Min(node->mAxis) << endl; 207 else if (node->mPosition > newBox.Min(node->mAxis)) 208 cout << "o: " << node->mPosition << " " << newBox.Min(node->mAxis) << endl; 209 */ 210 newBox1.SetMin(node->mAxis, node->mPosition); 211 newBox2.SetMax(node->mAxis, node->mPosition); 212 213 ++ axes[node->mAxis]; 214 215 if (node->mAxis == 1) 216 { 217 nodeStack.push(pair<ViewCellsTreeNode *, AxisAlignedBox3>(node->mBack, newBox2)); 218 nodeStack.push(pair<ViewCellsTreeNode *, AxisAlignedBox3>(node->mFront, newBox1)); 219 } 220 else 221 { 222 nodeStack.push(pair<ViewCellsTreeNode *, AxisAlignedBox3>(node->mFront, newBox1)); 223 nodeStack.push(pair<ViewCellsTreeNode *, AxisAlignedBox3>(node->mBack, newBox2)); 224 } 213 225 } 214 226 } 215 227 216 cout << "#of viewcells = " << id << endl;217 } 218 219 220 } 228 cout << "#of viewcells = " << id << " " << axes[0] << " " << axes[1] << " " << axes[2] << endl; 229 } 230 231 232 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.cpp
r3063 r3245 6 6 #include "RenderState.h" 7 7 #include "ShadowMapping.h" 8 #include "ViewCellsTree.h" 9 #include "Material.h" 10 11 8 12 #include <stack> 9 13 … … 16 20 17 21 18 static voidRenderBoxForViz(const AxisAlignedBox3 &box)22 void Visualization::RenderBoxForViz(const AxisAlignedBox3 &box) 19 23 { 20 24 glBegin(GL_LINE_LOOP); … … 76 80 mVizCamera(vizCamera), 77 81 mRenderState(renderState), 78 mFrameId(0) 82 mFrameId(0), 83 mViewCell(NULL) 79 84 { 80 85 } … … 101 106 { 102 107 mFrameId = frameId; 108 } 109 110 111 void Visualization::SetViewCell(ViewCell *vc) 112 { 113 mViewCell = vc; 114 } 115 116 117 static Technique GetVizTechnique() 118 { 119 Technique tech; 120 tech.Init(); 121 122 //tech.SetLightingEnabled(false); 123 //tech.SetDepthWriteEnabled(false); 124 125 tech.SetEmmisive(RgbaColor(1.0f, 1.0f, 1.0f, 1.0f)); 126 tech.SetDiffuse(RgbaColor(1.0f, 1.0f, 1.0f, 1.0f)); 127 tech.SetAmbient(RgbaColor(1.0f, 1.0f, 1.0f, 1.0f)); 128 129 return tech; 103 130 } 104 131 … … 134 161 { 135 162 SceneEntity *ent = entities[i]; 136 ent->Render(mRenderState); 163 164 if (ent->IsVisible()) 165 ent->Render(mRenderState); 137 166 } 138 167 } 139 168 } 169 } 170 171 // render current view cell 172 static Technique vcTechnique = GetVizTechnique(); 173 174 if (mViewCell) 175 { 176 vcTechnique.Render(mRenderState); 177 Visualization::RenderBoxForViz(mViewCell->GetBox()); 140 178 } 141 179 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.h
r3063 r3245 14 14 class AxisAlignedBox3; 15 15 class GLUquadric; 16 struct ViewCell; 16 17 17 18 … … 48 49 */ 49 50 void RenderFrustum(); 51 /** Sets the current view cell. 52 */ 53 void SetViewCell(ViewCell *vc); 50 54 55 /** Renders box as wireframe. 56 */ 57 static void RenderBoxForViz(const AxisAlignedBox3 &box); 51 58 52 59 protected: … … 65 72 /// the current frame id 66 73 int mFrameId; 74 75 ViewCell *mViewCell; 67 76 }; 68 77 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3244 r3245 141 141 ViewCellsTree *viewCellsTree = NULL; 142 142 143 static int globalVisibleId = 0; 144 145 ViewCell *viewCell = NULL; 146 143 147 144 148 /// the technique used for rendering … … 655 659 SceneEntityConverter conv; 656 660 657 // toto clean up material 661 662 ////////////////// 663 //-- occlusion query for sun 664 665 // todo: clean up material 658 666 Material *mat = resourceManager->CreateMaterial(); 659 667 … … 662 670 663 671 sunBox = conv.ConvertBox(sbox, mat, trafo); 664 665 672 resourceManager->AddSceneEntity(sunBox); 666 673 … … 1253 1260 else 1254 1261 { 1262 RenderPvs(); 1263 1255 1264 // actually render the scene geometry using the specified algorithm 1256 //traverser->RenderScene(); 1257 1258 RenderPvs(); 1265 traverser->RenderScene(); 1259 1266 } 1260 1267 … … 1954 1961 { 1955 1962 visualization->SetFrameId(traverser->GetCurrentFrameId()); 1956 1963 visualization->SetViewCell(viewCell); 1964 1957 1965 Begin2D(); 1958 1966 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); … … 2518 2526 2519 2527 2528 static Technique GetVizTechnique() 2529 { 2530 Technique tech; 2531 tech.Init(); 2532 2533 //tech.SetLightingEnabled(false); 2534 //tech.SetDepthWriteEnabled(false); 2535 2536 tech.SetEmmisive(RgbaColor(1.0f, 1.0f, 1.0f, 1.0f)); 2537 tech.SetDiffuse(RgbaColor(1.0f, 1.0f, 1.0f, 1.0f)); 2538 tech.SetAmbient(RgbaColor(1.0f, 1.0f, 1.0f, 1.0f)); 2539 2540 return tech; 2541 } 2542 2543 2520 2544 void RenderPvs() 2521 2545 { 2522 ViewCell *vc = viewCellsTree->GetViewCell(camera->GetPosition()); 2523 2524 for (int i = 0; i < vc->mPvs.Size(); ++ i) 2525 { 2526 SceneEntity *ent = vc->mPvs.GetEntry(i); 2527 ent->Render(&renderState); 2528 } 2529 } 2546 viewCell = viewCellsTree->GetViewCell(camera->GetPosition()); 2547 2548 int numTriangles = 0; 2549 2550 for (int i = 0; i < viewCell->mPvs.Size(); ++ i) 2551 { 2552 SceneEntity *ent = viewCell->mPvs.GetEntry(i); 2553 //ent->Render(&renderState); 2554 ent->SetVisibleId(globalVisibleId); 2555 2556 numTriangles += ent->CountNumTriangles(); 2557 } 2558 2559 SceneEntity::SetGlobalVisibleId(globalVisibleId ++); 2560 2561 // render current view cell 2562 static Technique vcTechnique = GetVizTechnique(); 2563 2564 vcTechnique.Render(&renderState); 2565 Visualization::RenderBoxForViz(viewCell->GetBox()); 2566 2567 visualization->SetViewCell(viewCell); 2568 2569 //cout << "pvs: " << vc->mPvs.Size() << " triangles: " << numTriangles << endl; 2570 }
Note: See TracChangeset
for help on using the changeset viewer.