- Timestamp:
- 10/24/08 12:29:30 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
r3064 r3065 4 4 assumedVisibleFrames=10 5 5 maxBatchSize=50 6 trianglesPerVirtualLeaf=300 6 #trianglesPerVirtualLeaf=300 7 trianglesPerVirtualLeaf=30000 7 8 keyForwardMotion=20.0f 8 9 keyRotation=1.5f -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/AxisAlignedBox3.cpp
r3021 r3065 56 56 { 57 57 return (mMin == Vector3(-MAXFLOAT)) || 58 (mMax == Vector3(-MAXFLOAT));58 (mMax == Vector3(-MAXFLOAT)); 59 59 } 60 60 … … 216 216 AxisAlignedBox3::IsInside(const Vector3 &v) const 217 217 { 218 return ! 219 (v.x > mMax.x) ||220 (v.y < mMin.y) ||221 (v.y > mMax.y) ||222 (v.z < mMin.z) ||223 (v.z > mMax.z));218 return !((v.x < mMin.x) || 219 (v.x > mMax.x) || 220 (v.y < mMin.y) || 221 (v.y > mMax.y) || 222 (v.z < mMin.z) || 223 (v.z > mMax.z)); 224 224 } 225 225 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
r3064 r3065 27 27 #endif 28 28 29 #define INVALID_TEST ((unsigned int)-1) 30 31 using namespace std; 29 32 30 33 namespace CHCDemoEngine 31 34 { 32 33 #define INVALID_TEST ((unsigned int)-1)34 35 using namespace std;36 37 35 38 36 int BvhNode::sCurrentState = 0; … … 76 74 77 75 static Plane3 sNearPlane; 76 static float sNear; 78 77 static Frustum sFrustum; 79 78 … … 147 146 148 147 149 /********************************************************** */150 /* class Bvh implementation 151 /********************************************************** */148 /**********************************************************/ 149 /* class Bvh implementation */ 150 /**********************************************************/ 152 151 153 152 … … 183 182 184 183 if (mRoot) delete mRoot; 185 186 184 // delete vbo 187 185 glDeleteBuffersARB(1, &mVboId); … … 191 189 void Bvh::Init() 192 190 { 193 mStaticRoot = NULL;191 //mStaticRoot = NULL; 194 192 mDynamicRoot = NULL; 195 193 mRoot = NULL; … … 202 200 203 201 // nodes are tested using the subnodes from 3 levels below 204 mMaxDepthForTestingChildren = 3;202 mMaxDepthForTestingChildren = 0;//3; 205 203 //mMaxDepthForTestingChildren = 4; 206 204 … … 311 309 tStack.pop(); 312 310 313 // found depth => take this node311 // found node in specified depth => take this node 314 312 if ((d == depth) || (node->IsLeaf())) 315 313 { … … 338 336 // do the test only if necessary 339 337 if (!(node->mPlaneMask[BvhNode::sCurrentState] & (1 << i))) 338 { 340 339 return true; 341 340 } 341 342 342 343 //////// 343 344 //-- test the n-vertex … … 375 376 376 377 //////// 377 //-- apply frustum culling for the planes [mPreferredPlane - 5]378 //-- apply frustum culling for the planes with index mPreferredPlane to 6 378 379 379 380 for (int i = node->mPreferredPlane[BvhNode::sCurrentState]; i < 6; ++ i) … … 382 383 383 384 ////////// 384 //-- do the view frustum culling for the planes [0 - m_iPreferredPlane)385 //-- apply frustum culling for the planes with index 0 to mPreferredPlane 385 386 386 387 for (int i = 0; i < node->mPreferredPlane[BvhNode::sCurrentState]; ++ i) … … 413 414 // store near plane 414 415 sNearPlane = Plane3(cam->GetDirection(), cam->GetPosition()); 416 sNear = cam->GetNear(); 415 417 416 418 // rebuild dynamic part of the hierarchy … … 424 426 void Bvh::UpdateDistance(BvhNode *node) const 425 427 { 426 // use distance to center rather than the distance to the near plane because 427 // otherwise problems with big object penetrating the near plane 428 // q: should we use distance to center rather than the distance to the near plane? 429 430 // because otherwise problems with big object penetrating the near plane 428 431 // (e.g., big objects in the distance which are then always visible) 429 432 // especially annoying is this problem when using the frustum 430 433 // fitting on the visible objects for shadow mapping 431 432 // node->mDistance = node->GetBox()GetMinDistance(sNearPlane);434 // on the other hand, distance to near plane can also be used 435 // for near plane intersection 433 436 node->mDistance = sNearPlane.Distance(node->GetBox().Center()); 437 //node->mDistance = node->GetBox().GetMinDistance(sNearPlane); 434 438 } 435 439 … … 458 462 void Bvh::RenderBounds(BvhNode *node, RenderState *state, bool useTightBounds) 459 463 { 460 // if not using tight bounds, rendering boxes in immediate mode 461 // is preferable to vertex arrays (less setup time) 462 if (!useTightBounds) 463 { 464 RenderBoundingBoxImmediate(node->GetBox()); 465 } 466 else 467 { 468 // hack: use dummy wrapper in order to use function 469 static BvhNodeContainer dummy(1); 470 dummy[0] = node; 471 RenderBounds(dummy, state, useTightBounds); 472 } 464 // hack: use dummy contayiner as wrapper in order to use multibox function 465 static BvhNodeContainer dummy(1); 466 dummy[0] = node; 467 RenderBounds(dummy, state, useTightBounds); 473 468 } 474 469 … … 490 485 RenderBoundingBoxImmediate((*nit)->GetBox()); 491 486 } 492 cout<<"y"; 487 493 488 renderedBoxes = (int)nodes.size(); 494 489 } 495 490 else 496 { cout<<"x";491 { 497 492 renderedBoxes = PrepareBoundsWithDrawArrays(nodes); 498 493 RenderBoundsWithDrawArrays(renderedBoxes, state); … … 529 524 { 530 525 BvhNode *node = *nit; 531 532 526 const int numIndices = node->mNumTestNodes * sNumIndicesPerBox; 533 527 … … 569 563 // collect bvh nodes 570 564 BvhNodeContainer nodes; 571 CollectNodes(m StaticRoot, nodes);565 CollectNodes(mRoot, nodes); 572 566 573 567 cout << "creating new indices" << endl; … … 587 581 } 588 582 589 590 583 cout << "creating global indices buffer" << endl; 591 584 … … 607 600 // resize array 608 601 node->mIndicesPtr = mCurrentIndicesPtr; 609 610 602 int numIndices = 0; 611 603 612 // the bounding box of the test nodes are rendered instead of the root node604 // the bounding boxes of the test nodes are rendered instead of the node itself 613 605 // => store their indices 614 606 for (int i = 0; i < node->mNumTestNodes; ++ i, numIndices += sNumIndicesPerBox) … … 657 649 658 650 nodes.reserve(GetNumStaticNodes()); 659 CollectNodes(m StaticRoot, nodes);651 CollectNodes(mRoot, nodes); 660 652 661 653 const unsigned int bufferSize = 8 * (int)nodes.size(); … … 717 709 // collect all nodes 718 710 BvhNodeContainer nodes; 719 CollectNodes(m StaticRoot, nodes);711 CollectNodes(mRoot, nodes); 720 712 721 713 cout << "recomputing bounds, children will be tested in depth " << mMaxDepthForTestingChildren << endl; … … 930 922 // first invalidate old virtual leaves 931 923 BvhNodeContainer leaves; 932 CollectVirtualLeaves(m StaticRoot, leaves);924 CollectVirtualLeaves(mRoot, leaves); 933 925 934 926 BvhNodeContainer::const_iterator bit, bit_end = leaves.end(); … … 998 990 999 991 std::stack<BvhNode *> nodeStack; 1000 nodeStack.push(m StaticRoot);992 nodeStack.push(mRoot); 1001 993 1002 994 while (!nodeStack.empty()) … … 1039 1031 const Vector3 u = box.Max(); 1040 1032 1033 /////////// 1034 //-- render AABB as triangle strips 1035 1041 1036 glBegin(GL_TRIANGLE_STRIP); 1042 { 1043 /////////// 1044 //-- render AABB as triangle strips 1045 1046 // render first half of AABB 1047 glVertex3f(l.x, l.y, u.z); 1048 glVertex3f(u.x, l.y, u.z); 1049 glVertex3f(l.x, u.y, u.z); 1050 glVertex3f(u.x, u.y, u.z); 1051 glVertex3f(l.x, u.y, l.z); 1052 glVertex3f(u.x, u.y, l.z); 1053 glVertex3f(l.x, l.y, l.z); 1054 glVertex3f(u.x, l.y, l.z); 1055 1056 glPrimitiveRestartNV(); 1057 1058 // render second half of AABB 1059 glVertex3f(l.x, u.y, u.z); 1060 glVertex3f(l.x, u.y, l.z); 1061 glVertex3f(l.x, l.y, u.z); 1062 glVertex3f(l.x, l.y, l.z); 1063 glVertex3f(u.x, l.y, u.z); 1064 glVertex3f(u.x, l.y, l.z); 1065 glVertex3f(u.x, u.y, u.z); 1066 glVertex3f(u.x, u.y, l.z); 1067 } 1037 1038 // render first half of AABB 1039 glVertex3f(l.x, l.y, u.z); 1040 glVertex3f(u.x, l.y, u.z); 1041 glVertex3f(l.x, u.y, u.z); 1042 glVertex3f(u.x, u.y, u.z); 1043 glVertex3f(l.x, u.y, l.z); 1044 glVertex3f(u.x, u.y, l.z); 1045 glVertex3f(l.x, l.y, l.z); 1046 glVertex3f(u.x, l.y, l.z); 1047 1048 glPrimitiveRestartNV(); 1049 1050 // render second half of AABB 1051 glVertex3f(l.x, u.y, u.z); 1052 glVertex3f(l.x, u.y, l.z); 1053 glVertex3f(l.x, l.y, u.z); 1054 glVertex3f(l.x, l.y, l.z); 1055 glVertex3f(u.x, l.y, u.z); 1056 glVertex3f(u.x, l.y, l.z); 1057 glVertex3f(u.x, u.y, u.z); 1058 glVertex3f(u.x, u.y, l.z); 1059 1068 1060 glEnd(); 1069 1061 } 1070 1071 1072 1062 1073 1063 … … 1123 1113 bool useTightBounds) 1124 1114 { 1125 glDisable(GL_TEXTURE_2D);1126 glDisable(GL_LIGHTING);1127 1115 glColor3f(1, 1, 1); 1128 1116 1129 1117 // hack: for deferred shading we have to define a material 1130 1118 static Technique boxMat; 1119 boxMat.SetLightingEnabled(false); 1120 1131 1121 boxMat.SetEmmisive(RgbaColor(1.0f, 1.0f, 1.0f, 1.0f)); 1132 1122 … … 1135 1125 if (!useTightBounds) 1136 1126 { 1137 RenderBoxForViz(node->GetBox()); 1127 //RenderBoxForViz(node->GetBox()); 1128 glPolygonMode(GL_FRONT, GL_LINE); 1129 RenderBoundingBoxImmediate(node->GetBox()); 1130 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 1138 1131 } 1139 1132 else … … 1144 1137 } 1145 1138 } 1146 1147 glEnable(GL_LIGHTING);1148 glEnable(GL_TEXTURE_2D);1149 1139 } 1150 1140 … … 1297 1287 1298 1288 1299 } 1289 bool Bvh::IntersectsNearPlane(BvhNode *node) const 1290 { 1291 float distanceToNearPlane = node->GetBox().GetMinDistance(sNearPlane); 1292 // we stored the near plane distance => we can use it also here 1293 //float distanceToNearPlane = node->GetDistance(); 1294 1295 return distanceToNearPlane < sNear; 1296 } 1297 1298 1299 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h
r3064 r3065 62 62 */ 63 63 BvhNode(BvhNode *parent); 64 /** Virtual destructor doing nothing. 65 */ 66 virtual ~BvhNode(); 67 /** Reset the status of this node. 68 */ 69 virtual void ResetVisibility(); 64 70 /** Returns true if this node is a leaf. 65 71 */ 66 //virtual bool IsPseudoLeaf() = 0; 67 /** Virtual destructor doing nothing. 68 */ 69 virtual ~BvhNode(); 72 virtual bool IsLeaf() const = 0; 70 73 /** Depth of this node in the tree. 71 74 */ 72 inline int GetDepth() const {return mDepth;}75 inline int GetDepth() const; 73 76 /** Returns parent of this bvh node, NULL if it is root. 74 77 */ 75 inline BvhNode *GetParent() {return mParent;}78 inline BvhNode *GetParent(); 76 79 /** Number of leaves in the subtree induced by this node. 77 80 */ 78 inline int GetNumLeaves() const {return mNumLeaves;} 79 /** Reset the status of this node. 80 */ 81 virtual void ResetVisibility(); 82 83 virtual bool IsLeaf() const = 0; 84 85 bool IsVirtualLeaf() const { return mIsVirtualLeaf; } 86 81 inline int GetNumLeaves() const; 82 /** Returns true if this node is a "virtual" leaf, 83 i.e., the node is handled as a leaf during traversal. 84 */ 85 inline bool IsVirtualLeaf() const; 87 86 /** Returns the stored distance to the near plane. 88 87 */ 89 float GetDistance() const { return mDistance; }88 inline float GetDistance() const; 90 89 91 90 … … 131 130 /** Returns the bounding box of this node. 132 131 */ 133 inline const AxisAlignedBox3 &GetBox() { return mBox; }132 inline const AxisAlignedBox3 &GetBox() const; 134 133 /** Return index of this node. 135 134 */ 136 inline int GetId() const { return mId; }135 inline int GetId() const; 137 136 /** See get 138 137 */ 139 inline void SetId(int id) { mId = id; }138 inline void SetId(int id); 140 139 141 140 … … 160 159 order to not break temporal coherency. 161 160 */ 162 static void SetCurrentState(int _state) { sCurrentState = _state; }161 inline static void SetCurrentState(int _state) { sCurrentState = _state; } 163 162 164 163 … … 174 173 175 174 ////////////// 176 //-- members that define the current state. There is one state for each camera175 //-- members definig the current visibility state (one state per camera) 177 176 178 177 /// the currently used state … … 197 196 /// #leaves under this node 198 197 int mNumLeaves; 199 200 201 ////////////202 //-- rendering related options203 204 205 // Indices to first and last triangle in the triangle array206 // assumes the triangle are placed in continuous chunk of memory207 // however this need not be a global array!208 209 /// the index of the first triangle210 int mFirst;211 /// the index of the last triangle212 int mLast;213 214 /// the bounding boxes of these nodes are queries instead of the current node215 int mTestNodesIdx;216 /// the number of tighter bounding volumes used for this node217 int mNumTestNodes;218 /// used for efficient element array rendering219 int mIndicesPtr;220 221 198 /// Area of this node 222 199 float mArea; … … 236 213 */ 237 214 bool mIsMaxDepthForVirtualLeaf; 215 216 217 //////////// 218 //-- rendering related options 219 220 // Indices to first and last triangle in the triangle array 221 // assumes the triangle are placed in continuous chunk of memory 222 // however this need not be a global array! 223 224 /// the index of the first triangle 225 int mFirst; 226 /// the index of the last triangle 227 int mLast; 228 229 230 //////////////// 231 //-- rendering related options 232 233 /// the bounding boxes of the test nodes are queries instead of the actual node 234 int mTestNodesIdx; 235 /// the number of these test nodes 236 int mNumTestNodes; 237 /// used for efficient element array rendering 238 int mIndicesPtr; 238 239 }; 239 240 … … 357 358 } 358 359 359 360 int BvhNode::GetDepth() const 361 { 362 return mDepth; 363 } 364 365 366 BvhNode *BvhNode::GetParent() 367 { 368 return mParent; 369 } 370 371 372 int BvhNode::GetNumLeaves() const 373 { 374 return mNumLeaves; 375 } 376 377 378 bool BvhNode::IsVirtualLeaf() const 379 { 380 return mIsVirtualLeaf; 381 } 382 383 384 float BvhNode::GetDistance() const 385 { 386 return mDistance; 387 } 388 389 390 const AxisAlignedBox3 &BvhNode::GetBox() const 391 { 392 return mBox; 393 } 394 395 396 int BvhNode::GetId() const 397 { 398 return mId; 399 } 400 401 402 void BvhNode::SetId(int id) 403 { 404 mId = id; 405 } 360 406 361 407 … … 383 429 virtual ~BvhInterior(); 384 430 431 385 432 protected: 386 433 … … 409 456 a lower distance has a higher value in the queue 410 457 */ 411 class mygreaterdistance458 class GtDistance 412 459 { 413 460 public: … … 418 465 }; 419 466 420 typedef std::priority_queue<BvhNode *, std::vector<BvhNode *>, mygreaterdistance> TraversalQueue;467 typedef std::priority_queue<BvhNode *, std::vector<BvhNode *>, GtDistance> TraversalQueue; 421 468 422 469 … … 464 511 /** Returns number of bvh nodes. 465 512 */ 466 inline int GetNumNodes() const { return mNumNodes; }513 inline int GetNumNodes() const; 467 514 /** Returns number of bvh leaves. 468 515 */ 469 inline int GetNumLeaves() const { return mNumNodes / 2 + 1;}516 inline int GetNumLeaves() const; 470 517 /** Returns number of 'virtual' nodes in the hierarchy, i.e. 471 518 the number of nodes actually used for traversal. 472 519 */ 473 in t GetNumVirtualNodes() const { return mNumVirtualNodes; }520 inline int GetNumVirtualNodes() const; 474 521 /** Returns number of bvh leaves. 475 522 */ 476 inline int GetNumVirtualLeaves() const { return mNumVirtualNodes / 2 + 1;}523 inline int GetNumVirtualLeaves() const; 477 524 /** Returns root node of the bvh. 478 525 */ 479 BvhNode *GetRoot() { return mRoot; } 480 526 inline BvhNode *GetRoot(); 527 /** Returns the bounding box of this bvh. 528 */ 529 inline const AxisAlignedBox3 &GetBox() const; 530 /** Returns true if the current bvh node intersects the near plane. 531 */ 532 bool IntersectsNearPlane(BvhNode *node) const; 533 534 481 535 /////////////// 482 536 //-- functions collecting nodes based on some criteria 483 537 484 /** Collect all nodes higher or equal to a given depth.538 /** Collect all child nodes in a given depth from the specified node. 485 539 */ 486 540 void CollectNodes(BvhNode *node, BvhNodeContainer &nodes, int depth); … … 489 543 */ 490 544 void CollectLeaves(BvhNode *node, BvhLeafContainer &leaves); 491 /** Collect only the virtual leaves (can be anywhere in the Žhierarchy).545 /** Collect only the virtual leaves (can be anywhere in the hierarchy). 492 546 */ 493 547 void CollectVirtualLeaves(BvhNode *node, BvhNodeContainer &leaves); … … 512 566 */ 513 567 int RenderBounds(const BvhNodeContainer &nodes, RenderState *state, bool useTightBounds); 514 /** Returns the bounding box of this bvh. 515 */ 516 inline const AxisAlignedBox3 &GetBox() { return mBox; } 568 517 569 518 570 … … 656 708 657 709 ///////////////////////////// 658 // functions that are required to build the dynamic part of the hierarchy 710 //-- functions used to construct the dynamic part of the hierarchy 711 659 712 int SortTriangles(BvhLeaf *leaf, 660 713 int axis, … … 686 739 BvhNode *mRoot; 687 740 /// the root of static part of the the hierarchy 688 BvhNode *mStaticRoot;741 //BvhNode *mStaticRoot; 689 742 /// the root of dynamic part of the the hierarchy 690 743 BvhNode *mDynamicRoot; … … 741 794 }; 742 795 796 797 798 ///////////////// 799 //-- public inline functions 800 801 802 int Bvh::GetNumNodes() const 803 { 804 return mNumNodes; 805 } 806 807 808 int Bvh::GetNumLeaves() const 809 { 810 return mNumNodes / 2 + 1; 811 } 812 813 814 int Bvh::GetNumVirtualNodes() const 815 { 816 return mNumVirtualNodes; 817 } 818 819 820 int Bvh::GetNumVirtualLeaves() const 821 { 822 return mNumVirtualNodes / 2 + 1; 823 } 824 825 826 BvhNode *Bvh::GetRoot() 827 { 828 return mRoot; 829 } 830 831 832 const AxisAlignedBox3 &Bvh::GetBox() const 833 { 834 return mBox; 835 } 836 837 743 838 } 744 839 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp
r3064 r3065 73 73 74 74 Bvh *bvh = new Bvh(entities); 75 bvh->mStaticRoot = LoadNextNode(stream, NULL); 75 76 BvhNode *root = LoadNextNode(stream, NULL); 76 77 77 78 #if 1 78 bvh->mRoot = bvh->mStaticRoot; 79 bvh->mNumNodes = 1; 79 80 bvh->mRoot = root; 81 80 82 #else 83 // copy root and set new one for dynamic objects 84 BvhInterior *newRoot = new BvhInterior(NULL); 85 86 newRoot->mBox = root->mBox; 87 newRoot->mFirst = root->mFirst; 88 newRoot->mLast = root->mLast; 81 89 82 // we are setting a new root node 83 // and adds one level of indirection to the bvh 84 // It allows us to use dynamic objects 90 // create 'dynamic' leaf which basically is a container 91 // for all dynamic objects 92 BvhLeaf *dynamicLeaf = new BvhLeaf(newRoot); 93 dynamicLeaf->mBox = root->mBox; 85 94 86 // the new bvh has two main branches 87 // a static branch (the old root), and adynamic branch 88 // we create a 'dynamic' leaf which basically is a container 89 // for all dynamic objects underneath 90 // the bounding boxes of the dynamic tree must be updated 91 // once each frame in order to be able to incorporate 92 // the movements of the objects within 95 newRoot->mFront = root; 96 root->mParent = newRoot; 93 97 94 // create new root95 BvhInterior *newRoot = new BvhInterior(NULL); 98 newRoot->mBack = dynamicLeaf; 99 96 100 bvh->mRoot = newRoot; 97 98 // the separation is a purely logical one99 // the bounding boxes of the child nodes are100 // identical to those of the root node101 102 newRoot->mBox = bvh->mStaticRoot->mBox;103 newRoot->mArea = newRoot->mBox.SurfaceArea();104 105 newRoot->mFirst = bvh->mStaticRoot->mFirst;106 newRoot->mLast = bvh->mStaticRoot->mLast;107 108 // add static root on left subtree109 newRoot->mFront = bvh->mStaticRoot;110 bvh->mStaticRoot->mParent = newRoot;111 112 // create and add dynamic root113 BvhLeaf *dynamicRoot = new BvhLeaf(newRoot);114 115 dynamicRoot->mFirst = 0;116 dynamicRoot->mLast = 0;117 dynamicRoot->mBox = bvh->mStaticRoot->mBox;118 dynamicRoot->mArea = dynamicRoot->mBox.SurfaceArea();119 120 bvh->mDynamicRoot = dynamicRoot;121 newRoot->mBack = dynamicRoot;122 123 bvh->mNumNodes = 1;124 125 101 #endif 126 102 127 tQueue.push(bvh->mStaticRoot); 103 tQueue.push(bvh->mRoot); 104 bvh->mNumNodes = 1; 128 105 129 106 while(!tQueue.empty()) -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCPlusPlusTraverser.cpp
r3038 r3065 123 123 // for near plane intersecting bounding box possible 124 124 // wrong results => skip occlusion query 125 if ( IntersectsNearPlane(node))125 if (mBvh->IntersectsNearPlane(node)) 126 126 { 127 127 // update node's visited flag -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCTraverser.cpp
r2818 r3065 71 71 // for near plane intersecting bounding box possible 72 72 // wrong results => skip occlusion query 73 if ( IntersectsNearPlane(node))73 if (mBvh->IntersectsNearPlane(node)) 74 74 { 75 75 // update node's visited flag -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.cpp
r3058 r3065 36 36 /// if depth write should be enabled 37 37 mDepthWriteEnabled = true; 38 38 /// the render queue bucket this technique is assigned to 39 39 mRenderQueueBucket = NULL; 40 40 } … … 60 60 } 61 61 62 /*63 Technique::Technique(const Technique &tech)64 {65 mAmbientColor = tech.mAmbientColor;66 mDiffuseColor = tech.mDiffuseColor;67 mSpecularColor = tech.mSpecularColor;68 mEmmisiveColor = tech.mEmmisiveColor;69 70 mVertexProgram = tech.mVertexProgram;71 mFragmentProgram = tech.mFragmentProgram;72 73 mAlphaTestEnabled = tech.mAlphaTestEnabled;74 mCullFaceEnabled = tech.mCullFaceEnabled;75 76 mTexture = tech.mTexture;77 78 mVertexProgramParameters = tech.mVertexProgramParameters;79 mFragmentProgramParameters = tech.mFragmentProgramParameters;80 81 mColorWriteEnabled = tech.mColorWriteEnabled;82 mLightingEnabled = tech.mLightingEnabled;83 mDepthWriteEnabled = tech.mDepthWriteEnabled;84 }*/85 86 87 Technique::~Technique()88 {89 }90 91 62 92 63 void Technique::Render(RenderState *state) … … 103 74 void Technique::SetFragmentProgram(ShaderProgram *p) 104 75 { 105 mFragmentProgram = p; 106 76 mFragmentProgram = p; 107 77 mFragmentProgramParameters.Reset(); 108 78 mFragmentProgramParameters.SetProgram(p); … … 113 83 { 114 84 mVertexProgram = p; 115 116 85 mVertexProgramParameters.Reset(); 117 86 mVertexProgramParameters.SetProgram(p); … … 119 88 120 89 121 /***********************************************/ 122 /* class Material implementation */ 123 /***********************************************/ 90 91 /***************************************************/ 92 /* class Material implementation */ 93 /***************************************************/ 124 94 125 95 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.h
r3054 r3065 56 56 */ 57 57 Technique(); 58 59 //Technique(const Technique &tech);60 58 /** Sets ambient and diffuse color to color 61 59 */ 62 60 Technique(const RgbaColor &color); 63 64 ~Technique();65 61 /** Renders this technique. 66 62 */ -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
r3057 r3065 86 86 87 87 88 // q matt: is this function really necessary or would it be better 89 // to just create a query material and use the setstate function? 88 static Technique GetDummyTechnique() 89 { 90 Technique tech; 91 tech.Init(); 92 93 tech.SetColorWriteEnabled(true); 94 tech.SetLightingEnabled(true); 95 tech.SetDepthWriteEnabled(false); 96 //tech.SetCullFaceEnabled(false); 97 98 return tech; 99 } 100 101 /** A special technique for occlusion queries. This material 102 has color write, depth write, and lighting turned off 103 */ 104 static Technique GetQueryTechnique() 105 { 106 Technique tech; 107 tech.Init(); 108 109 tech.SetColorWriteEnabled(false); 110 tech.SetLightingEnabled(false); 111 tech.SetDepthWriteEnabled(false); 112 //tech.SetCullFaceEnabled(false); 113 114 return tech; 115 } 116 117 90 118 bool RenderState::SetMode(Mode mode) 91 119 { … … 101 129 /// the query box material 102 130 static Technique queryTech = GetQueryTechnique(); 103 SetState(&queryTech); 131 static Technique dummyTech = GetDummyTechnique(); 132 133 //if ((float)rand() / RAND_MAX < 0.2) 134 // SetState(&dummyTech); 135 //else 136 SetState(&queryTech); 104 137 } 105 138 … … 286 319 287 320 288 Technique RenderState::GetQueryTechnique()289 {290 Technique tech;291 292 tech.Init();293 294 tech.SetColorWriteEnabled(false);295 tech.SetLightingEnabled(false);296 tech.SetDepthWriteEnabled(false);297 298 return tech;299 }300 301 302 321 void RenderState::SetUseAlphaToCoverage(bool useAlphaToCoverage) 303 322 { -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h
r3061 r3065 73 73 protected: 74 74 75 /** A special technique for occlusion queries. This material76 has color write, depth write, and lighting turned off77 */78 static Technique GetQueryTechnique();79 80 75 81 76 ////////////////// -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h
r2951 r3065 154 154 */ 155 155 void IssueOcclusionQuery(const OcclusionQuery &query); 156 /** Retunrs true if the current bvh node intersects the near plane.157 */158 inline bool IntersectsNearPlane(BvhNode *node) const;159 156 /** Enqueues a bvh node for distance traversal 160 157 */ … … 216 213 217 214 218 inline bool RenderTraverser::IntersectsNearPlane(BvhNode *node) const219 {220 return node->GetDistance() < mCamera->GetNear();221 215 } 222 216 223 217 224 218 225 }226 227 228 229 219 #endif // RENDERTRAVERSER_H -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/StopAndWaitTraverser.cpp
r2802 r3065 25 25 { 26 26 // if intersects near plane assume visible and don't issue test 27 if ( IntersectsNearPlane(node))27 if (mBvh->IntersectsNearPlane(node)) 28 28 { 29 29 TraverseNode(node); … … 33 33 OcclusionQuery *query = IssueOcclusionQuery(node); 34 34 35 const bool visible = query->GetQueryResult() > mVisibilityThreshold;35 const bool visible = (query->GetQueryResult() > mVisibilityThreshold); 36 36 37 37 if (visible) -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3064 r3065 178 178 179 179 bool useOptimization = false; 180 //bool useTightBounds = true;181 bool useTightBounds = false;180 bool useTightBounds = true; 181 //bool useTightBounds = false; 182 182 bool useRenderQueue = true; 183 183 bool useMultiQueries = true; … … 1765 1765 1766 1766 glEnable(GL_TEXTURE_2D); 1767 1768 1767 myfont.Begin(); 1769 1768 … … 1771 1770 { 1772 1771 glColor3f(0.0f, 1.0f, 0.0f); 1773 1774 1772 int i = 0; 1775 1773 1776 static char *renderMethodStr[] = {"forward", "depth pass + forward", "deferred shading", "depth pass + deferred"}; 1774 static char *renderMethodStr[] = 1775 {"forward", "depth pass + forward", "deferred shading", "depth pass + deferred"}; 1777 1776 1778 1777 sprintf(msg[i ++], "multiqueries: %d, tight bounds: %d, render queue: %d", 1779 1778 useMultiQueries, useTightBounds, useRenderQueue); 1780 1779 1781 1780 sprintf(msg[i ++], "render technique: %s, SSAO: %d", renderMethodStr[renderMethod], useAdvancedShading); … … 1831 1830 1832 1831 if (!showAlgorithmTime) 1833 1832 sprintf(msg[7], "%s: %6.1f fps", alg_str[renderMode], fps); 1834 1833 else 1835 1834 sprintf(msg[7], "%s: %6.1f ms", alg_str[renderMode], rTime); … … 1850 1849 void RenderSky() 1851 1850 { 1852 buddha->Render(&state);1851 //buddha->Render(&state); 1853 1852 1854 1853 if ((renderMethod == RENDER_DEFERRED) || (renderMethod == RENDER_DEPTH_PASS_DEFERRED))
Note: See TracChangeset
for help on using the changeset viewer.