- Timestamp:
- 06/15/08 23:35:07 (17 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/CHC_revisited
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/CHC_revisited/AxisAlignedBox3.cpp
r2755 r2762 720 720 } 721 721 722 #if TOIMPLEMENT723 int AxisAlignedBox3::Side(const Plane3 &plane) const724 {725 Vector3 v;726 int i, m=3, M=-3, s;727 728 for (i=0;i<8;i++) {729 GetVertex(i, v);730 if((s = plane.Side(v)) < m)731 m=s;732 if(s > M)733 M=s;734 if (m && m==-M)735 return 0;736 }737 738 return (m == M) ? m : m + M;739 }740 741 742 Plane3 AxisAlignedBox3::GetPlane(const int face) const743 {744 switch (face)745 {746 747 case 0:748 return Plane3(Vector3(-1, 0, 0), mMin);749 case 1:750 return Plane3(Vector3(1, 0, 0), mMax);751 case 2:752 return Plane3(Vector3(0, -1, 0), mMin);753 case 3:754 return Plane3(Vector3(0, 1, 0), mMax);755 case 4:756 return Plane3(Vector3(0, 0, -1), mMin);757 case 5:758 return Plane3(Vector3(0, 0, 1), mMax);759 }760 761 // should not come here762 return Plane3();763 }764 #endif765 766 722 767 723 void AxisAlignedBox3::Scale(const float scale) … … 1032 988 } 1033 989 1034 990 //int AxisAlignedBox3::GetIndexFarthestVertex(const Vector3 &vecPlaneNormal) 1035 991 int AxisAlignedBox3::GetIndexNearestVertex(const Vector3 &vecPlaneNormal) 1036 992 { 1037 int index;1038 1039 if (vecPlaneNormal.x > 0.0f)1040 index = (vecPlaneNormal.y > 0.0f) ? 0 : 3;1041 else1042 index = (vecPlaneNormal.y > 0.0f) ? 1 : 2;1043 1044 return (vecPlaneNormal.z > 0.0f) ? index : 7 - index; 1045 } 1046 1047 993 int x, y, z; 994 995 x = (vecPlaneNormal.x > 0.0f) ? 0 : 1; 996 y = (vecPlaneNormal.y > 0.0f) ? 0 : 1; 997 z = (vecPlaneNormal.z > 0.0f) ? 0 : 1; 998 999 return 4 * x + 2 * y + z; 1000 } 1001 1002 1003 //int AxisAlignedBox3::GetIndexNearestVertex(const Vector3 &vecPlaneNormal) 1048 1004 int AxisAlignedBox3::GetIndexFarthestVertex(const Vector3 &vecPlaneNormal) 1049 1005 { 1050 int index; 1006 int x, y, z; 1007 1008 x = (vecPlaneNormal.x <= 0.0f) ? 0 : 1; 1009 y = (vecPlaneNormal.y <= 0.0f) ? 0 : 1; 1010 z = (vecPlaneNormal.z <= 0.0f) ? 0 : 1; 1011 1012 return 4 * x + 2 * y + z; 1013 1014 /*int index; 1051 1015 1052 1016 if (vecPlaneNormal.x <= 0.0f) … … 1055 1019 index = (vecPlaneNormal.y <= 0.0f) ? 1 : 2; 1056 1020 1057 return (vecPlaneNormal.z <= 0.0f) ? index : 7 - index; 1021 return (vecPlaneNormal.z <= 0.0f) ? index : 7 - index;*/ 1058 1022 } 1059 1023 -
GTP/trunk/App/Demos/Vis/CHC_revisited/BinaryLoader.cpp
r2760 r2762 173 173 istr.read(reinterpret_cast<char *>(&shapeCount), sizeof(int)); 174 174 175 geometry.resize(shapeCount); 176 175 177 int progress = 0; 176 178 177 179 for (int i = 0; i < shapeCount; ++ i) 178 180 { 181 int id; 182 istr.read(reinterpret_cast<char *>(&id), sizeof(int)); 183 179 184 SceneEntity *ent = LoadSceneEntity(istr); 180 geometry.push_back(ent); 185 ent->id = id; 186 187 geometry[id] = ent; 181 188 182 189 int p = (i + 1) * 100 / shapeCount; … … 184 191 if (p >= progress) 185 192 { 186 cout << "% loaded: " << p << endl;193 //cout << "% loaded: " << p << endl; 187 194 progress += 10; 188 195 } -
GTP/trunk/App/Demos/Vis/CHC_revisited/Bvh.cpp
r2761 r2762 292 292 293 293 294 bool Bvh::TestPlane(BvhNode *node, int i, bool &bIntersect) 295 { 296 // do the test only if necessary 297 if (1)//node->mPlaneMask & (1 << i)) 298 {//cout<<"plane "<< i << endl; 299 bool outs = true; 300 //-- test the n-vertex 301 for (int j = 0; j < 8; ++ j) 302 { 303 if (sFrustum.mClipPlanes[i].Distance(node->mBox.GetVertex(j)) <= 0) outs = false; 304 } 305 if (outs) return 0; 306 //if ((node->mBox.GetDistance(sClipPlaneAABBVertexIndices[i * 2 + 0], sFrustum.mClipPlanes[i]) > 0.0f)) 307 //&& (node->mBox.GetDistance(sClipPlaneAABBVertexIndices[i * 2 + 1], sFrustum.mClipPlanes[i]) > 0.0f)) 308 { 309 // outside 310 // node->mPreferredPlane = i; 311 //cout<<"f " << node->mBox.GetDistance(sClipPlaneAABBVertexIndices[i * 2 + 0], sFrustum.mClipPlanes[i]) << " " << sFrustum.mClipPlanes[i] << endl; 312 // return false; 313 }//else cout<<"ok " << node->mBox.GetDistance(sClipPlaneAABBVertexIndices[i * 2 + 0], sFrustum.mClipPlanes[i]) << " " << sFrustum.mClipPlanes[i] << endl; 314 315 //-- test the p-vertex 316 if (node->mBox.GetDistance(sClipPlaneAABBVertexIndices[i * 2 + 1], sFrustum.mClipPlanes[i]) <= 0.0f) 317 { 318 // completely inside: children don't need to check against this plane no more 319 node->mPlaneMask^= 1 << i; 320 } 321 else 322 { 323 bIntersect = true; 324 } 325 } 326 327 return true; 328 } 329 330 294 331 int Bvh::IsWithinViewFrustum(BvhNode *node) 295 332 { … … 300 337 301 338 339 for (int i = 0; i < 6; ++ i) 340 { 341 if (!TestPlane(node, i, bIntersect)) return 0; 342 } 343 302 344 //////// 303 //-- do the viewfrustum culling for the planes [mPreferredPlane - 5]304 345 //-- apply frustum culling for the planes [mPreferredPlane - 5] 346 /* 305 347 for (int i = node->mPreferredPlane; i < 6; ++ i) 306 348 { 307 //-- do the test only if necessary 308 if (node->mPlaneMask & (1 << i)) 309 { 310 //-- test the n-vertex 311 if (node->mBox.GetDistance(sClipPlaneAABBVertexIndices[i * 2 + 0], sFrustum.mClipPlanes[i]) > 0.0f) 312 { 313 //-- outside 314 node->mPreferredPlane = i; 315 return 0; 316 } 317 318 //-- test the p-vertex 319 if (node->mBox.GetDistance(sClipPlaneAABBVertexIndices[i * 2 + 1], sFrustum.mClipPlanes[i]) <= 0.0f) 320 { 321 //-- completely inside: children don't need to check against this plane no more 322 node->mPlaneMask^= 1 << i; 323 } 324 else 325 { 326 bIntersect = true; 327 } 328 } 349 if (!TestPlane(node, i, bIntersect)) return 0; 329 350 } 330 351 … … 334 355 for (int i = 0; i < node->mPreferredPlane; ++ i) 335 356 { 336 // do the test only if necessary 337 if (node->mPlaneMask & (1 << i)) 338 { 339 //-- test the n-vertex 340 if (node->mBox.GetDistance(sClipPlaneAABBVertexIndices[i * 2 + 0], sFrustum.mClipPlanes[i]) > 0.0f) 341 { 342 // outside 343 node->mPreferredPlane = i; 344 return 0; 345 } 346 347 //-- test the p-vertex 348 if (node->mBox.GetDistance(sClipPlaneAABBVertexIndices[i * 2 + 1], sFrustum.mClipPlanes[i]) <= 0.0f) 349 { 350 // completely inside: children don't need to check against this plane no more 351 node->mPlaneMask^= 1 << i; 352 } 353 else 354 { 355 bIntersect = true; 356 } 357 } 358 } 359 357 if (!TestPlane(node, i, bIntersect)) return 0; 358 } 359 */ 360 360 return bIntersect ? -1 : 1; 361 361 } … … 373 373 sFrustum.CalcNPVertexIndices(sClipPlaneAABBVertexIndices); 374 374 375 // calc near plane 376 sNearPlane = Plane3(mCamera->GetDirection(), 377 -mCamera->GetDirection() * mCamera->GetPosition()); 375 for (int i = 0; i<12; ++ i) 376 //cout<<" x " << sClipPlaneAABBVertexIndices[i]; 377 // cout<<"\n********\n"; 378 // near plane 379 sNearPlane = Plane3(mCamera->GetDirection(), mCamera->GetPosition()); 380 381 // Debug << "near: " << sNearPlane << " d " << mCamera->GetDirection() << " " << mCamera->GetPosition() << std::endl; 382 // for (int i = 0; i < 6; ++ i) Debug << "plane: " << sFrustum.mClipPlanes[i] << std::endl; 378 383 } 379 384 … … 865 870 866 871 872 void Bvh::Dummy() 873 { 874 for (int i = 0; i < mGeometrySize; ++ i) 875 Debug << mGeometry[i]->id << " " << mGeometry[i]->GetGeometry()->GetBoundingBox() << endl; 876 877 AxisAlignedBox3 boxl; boxl.Initialize(); 878 AxisAlignedBox3 boxr; boxr.Initialize(); 879 880 881 for (int i = 0; i <= 107; ++ i) 882 boxl.Include(mGeometry[i]->GetBoundingBox()); 883 884 for (int i = 108; i <= 193; ++ i) 885 boxr.Include(mGeometry[i]->GetBoundingBox()); 886 887 Debug << "dummy " << boxl << " " << boxr << endl; 888 889 queue<BvhNode *> tStack; 890 tStack.push(mRoot); 891 892 while (!tStack.empty()) 893 { 894 BvhNode *node = tStack.front();//top(); 895 tStack.pop(); 896 897 AxisAlignedBox3 box; 898 box.Initialize(); 899 900 int i = 0; 901 for (int i = node->mFirst; i <= node->mLast; ++ i) 902 { 903 if ((mGeometry[i]->id < node->mFirst) || (mGeometry[i]->id > node->mLast)) 904 cout << "big error!! " << mGeometry[i]->id << endl; 905 else cout << "ok"<<mGeometry[i]->id; 906 box.Include(mGeometry[i]->GetBoundingBox()); 907 } 908 909 Debug<< box << " " << node->GetBox() << " f " << node->mFirst << " l " << node->mLast << " id " << node->GetId() << " l " << node->IsLeaf() << endl; 910 911 //node->mBox = box; 912 if (!node->IsLeaf()) 913 { 914 BvhInterior *interior = static_cast<BvhInterior *>(node); 915 916 tStack.push(interior->mFront); 917 tStack.push(interior->mBack); 918 } 919 } 920 } 921 922 867 923 void Bvh::SetVirtualLeaves(int numTriangles) 868 924 { -
GTP/trunk/App/Demos/Vis/CHC_revisited/Bvh.h
r2761 r2762 440 440 441 441 public: 442 442 void Dummy(); 443 443 /** Destructor. 444 444 */ … … 597 597 */ 598 598 void UpdateNumLeaves(BvhNode *node) const; 599 /** Frustum tests the ith plane. 600 */ 601 inline bool TestPlane(BvhNode *node, int i, bool &bIntersect); 602 599 603 600 604 //////////////////////// -
GTP/trunk/App/Demos/Vis/CHC_revisited/BvhLoader.cpp
r2761 r2762 46 46 stream.read(reinterpret_cast<char *>(&(node->mFirst)), sizeof(int)); 47 47 stream.read(reinterpret_cast<char *>(&(node->mLast)), sizeof(int)); 48 48 49 stream.read(reinterpret_cast<char *>(&bMin), sizeof(Vector3)); 49 50 stream.read(reinterpret_cast<char *>(&bMax), sizeof(Vector3)); 51 52 //if ((bMin.x >= bMax.x)||(bMin.y >= bMax.y)||(bMin.z >= bMax.z)) 53 // cout << "error: " << bMin << " " << bMax << endl; 50 54 51 55 node->mBox = AxisAlignedBox3(bMin, bMax); … … 54 58 55 59 //cout << "box: " << node->mBox << " area: " << node->mArea << endl; 60 cout << node->mBox << " f " << node->mFirst << " l " << node->mLast << endl; 56 61 57 62 return node; … … 107 112 bvh->PostProcess(); 108 113 // set virtual leaves for 500 triangles 109 bvh->SetVirtualLeaves( 500);114 bvh->SetVirtualLeaves(0); 110 115 111 116 bvh->UpdateNumLeaves(bvh->mRoot); … … 113 118 bvh->ComputeIds(); 114 119 // specify bounds for occlusion tests 115 bvh->RecomputeBounds();120 //bvh->RecomputeBounds(); 116 121 // compute and print stats 117 122 bvh->ComputeBvhStats(); 118 123 bvh->PrintBvhStats(); 119 124 bvh->Dummy(); 120 125 return bvh; 121 126 } -
GTP/trunk/App/Demos/Vis/CHC_revisited/Camera.cpp
r2760 r2762 65 65 void Camera::LookAtBox(const AxisAlignedBox3 &box) 66 66 { 67 mDirection = box.Min() - box.Max();68 mPosition = box.Max() - mDirection;67 mDirection = Vector3(0, 0, box.Min().z - box.Max().z); 68 mPosition = Vector3(0);//box.Max() - mDirection; 69 69 70 70 Precompute(); … … 92 92 GetProjectionMatrix(matProjectionView); 93 93 94 matProjectionView *= matViewing;95 96 float fInvLength;94 matProjectionView = matViewing * matProjectionView; 95 //matProjectionView = matProjectionView * matViewing; 96 97 97 float planes[6][4]; 98 98 99 99 100 ////////// … … 118 119 // the clipping planes look outward the frustum, 119 120 // so distances > 0 mean that a point is outside 120 fInvLength = -1.0f / sqrt(planes[i][0] * planes[i][0] + 121 planes[i][1] * planes[i][1] + 122 planes[i][2] * planes[i][2]); 121 float fInvLength = -1.0f / 122 sqrt(planes[i][0] * planes[i][0] + 123 planes[i][1] * planes[i][1] + 124 planes[i][2] * planes[i][2]); 123 125 124 126 planes[i][0] *= fInvLength; … … 127 129 planes[i][3] *= fInvLength; 128 130 129 Vector3 normal(planes[i][0], planes[i][1], planes[i][2]);130 frustum.mClipPlanes[i] = Plane3(normal, planes[i][3]);131 frustum.mClipPlanes[i].mNormal = Vector3(planes[i][0], planes[i][1], planes[i][2]); 132 frustum.mClipPlanes[i].mD = planes[i][3]; 131 133 } 132 134 } … … 156 158 157 159 158 } 159 160 161 void Camera::ComputePoints(Vector3 &ftl, Vector3 &ftr, Vector3 &fbl, Vector3 &fbr, 162 Vector3 &ntl, Vector3 &ntr, Vector3 &nbl, Vector3 &nbr) 163 { 164 float z_near = 0.1f; 165 float z_far = 300; 166 167 const float h_near = 2.0f * tan(mFovy / 2) * z_near; 168 const float w_near = h_near * GetAspect(); 169 const float h_far = 2.0f * tan(mFovy / 2) * z_far; 170 const float w_far = h_far * GetAspect(); 171 172 const Vector3 view = mDirection; 173 const Vector3 fc = mPosition + view * z_far; 174 175 const Vector3 up = mUp; 176 177 const Vector3 right = mRight; 178 179 Vector3 t1, t2; 180 181 t1 = h_far * 0.5f * up; 182 t2 = w_far * 0.5f * right; 183 184 ftl = fc + t1 - t2; 185 ftr = fc + t1 + t2; 186 fbl = fc - t1 - t2; 187 fbr = fc - t1 + t2; 188 189 const Vector3 nc = mPosition + mDirection * z_near; 190 191 t1 = h_near * 0.5f * up; 192 t2 = w_near * 0.5f * right; 193 194 ntl = nc + t1 - t2; 195 ntr = nc + t1 + t2; 196 nbl = nc - t1 - t2; 197 nbr = nc - t1 + t2; 198 } 199 200 201 } 202 -
GTP/trunk/App/Demos/Vis/CHC_revisited/Camera.h
r2756 r2762 55 55 void CalcFrustum(Frustum &frustum); 56 56 57 void ComputePoints(Vector3 &ftl, Vector3 &ftr, Vector3 &fbl, Vector3 &fbr, 58 Vector3 &ntl, Vector3 &ntr, Vector3 &nbl, Vector3 &nbr); 59 57 60 58 61 protected: -
GTP/trunk/App/Demos/Vis/CHC_revisited/FrustumCullingTraverser.cpp
r2761 r2762 1 1 #include "FrustumCullingTraverser.h" 2 2 #include "SceneEntity.h" 3 4 using namespace std; 3 5 4 6 … … 16 18 mDistanceQueue.push(mBvh->GetRoot()); 17 19 20 18 21 int traversed = 0; 19 22 while (!mDistanceQueue.empty()) … … 27 30 28 31 //bool intersects; 29 30 if (mBvh->IsWithinViewFrustum(node) )32 int intersect; 33 if (mBvh->IsWithinViewFrustum(node)!=0) 31 34 { 32 35 // update node's visited flag => needed for rendering … … 36 39 ++ traversed; 37 40 TraverseNode(node); 41 RenderBox(node->GetBox()); 38 42 } 39 43 else 40 { 44 {RenderBox(node->GetBox()); 45 if (node->IsLeaf()) 46 { 47 48 //cout <<"b: " << node->GetBox() << endl; 49 } 41 50 //mNumFrustumCulledNodes ++; 42 51 } 52 //cout << "intersect: " << intersect << " bx " << node->GetBox() << endl; 43 53 } 54 55 //RenderFrustum(); 44 56 45 std::cout << "traversed: " << traversed << std::endl;57 //std::cout << "traversed: " << traversed << std::endl; 46 58 } 47 59 -
GTP/trunk/App/Demos/Vis/CHC_revisited/Plane3.cpp
r2755 r2762 14 14 15 15 16 Plane3::Plane3(Vector3 &normal, float dist):16 /*Plane3::Plane3(const Vector3 &normal, float dist): 17 17 mNormal(normal), mD(dist) 18 18 { 19 } 19 }*/ 20 20 21 21 -
GTP/trunk/App/Demos/Vis/CHC_revisited/Plane3.h
r2755 r2762 16 16 Plane3() {} 17 17 18 Plane3(Vector3 &normal, float dist);18 //Plane3(const Vector3 &normal, float dist); 19 19 20 20 Plane3(const Vector3 &a, const Vector3 &b, const Vector3 &c); -
GTP/trunk/App/Demos/Vis/CHC_revisited/RenderTraverser.cpp
r2761 r2762 2 2 #include "glInterface.h" 3 3 #include "Timers.h" 4 #include "Camera.h" 4 5 5 6 … … 66 67 void RenderTraverser::TraverseNode(BvhNode *node) 67 68 { 68 if (node->IsVirtualLeaf()||node->IsLeaf()) 69 { 69 70 if (node->IsVirtualLeaf()) 71 { 72 //RenderBox(node->GetBox()); 73 70 74 //mNumRenderedGeometry += 71 75 mBvh->Render(node, mRenderState); … … 74 78 { 75 79 // for non leafs this renders only the bounding volume (if the flag is set) 76 //node->Render();77 80 BvhInterior *interior = static_cast<BvhInterior *>(node); 78 81 … … 394 397 } 395 398 396 } 399 400 void RenderTraverser::RenderBox(const AxisAlignedBox3 &box) 401 { 402 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 403 glDisable(GL_CULL_FACE); 404 glColor3f(1.0f, 0.0f, 0.0f); 405 406 glBegin(GL_QUADS); 407 glVertex3f(box.Min().x, box.Max().y, box.Min().z); 408 glVertex3f(box.Max().x, box.Max().y, box.Min().z); 409 glVertex3f(box.Max().x, box.Min().y, box.Min().z); 410 glVertex3f(box.Min().x, box.Min().y, box.Min().z); 411 glEnd(); 412 413 glBegin(GL_QUADS); 414 glVertex3f(box.Min().x, box.Min().y, box.Max().z); 415 glVertex3f(box.Max().x, box.Min().y, box.Max().z); 416 glVertex3f(box.Max().x, box.Max().y, box.Max().z); 417 glVertex3f(box.Min().x, box.Max().y, box.Max().z); 418 glEnd(); 419 420 glBegin(GL_QUADS); 421 glVertex3f(box.Max().x, box.Min().y, box.Min().z); 422 glVertex3f(box.Max().x, box.Min().y, box.Max().z); 423 glVertex3f(box.Max().x, box.Max().y, box.Max().z); 424 glVertex3f(box.Max().x, box.Max().y, box.Min().z); 425 glEnd(); 426 427 glBegin(GL_QUADS); 428 glVertex3f(box.Min().x, box.Min().y, box.Min().z); 429 glVertex3f(box.Min().x, box.Min().y, box.Max().z); 430 glVertex3f(box.Min().x, box.Max().y, box.Max().z); 431 glVertex3f(box.Min().x, box.Max().y, box.Min().z); 432 glEnd(); 433 434 glBegin(GL_QUADS); 435 glVertex3f(box.Min().x, box.Min().y, box.Min().z); 436 glVertex3f(box.Max().x, box.Min().y, box.Min().z); 437 glVertex3f(box.Max().x, box.Min().y, box.Max().z); 438 glVertex3f(box.Min().x, box.Min().y, box.Max().z); 439 glEnd(); 440 441 glBegin(GL_QUADS); 442 glVertex3f(box.Min().x, box.Max().y, box.Min().z); 443 glVertex3f(box.Max().x, box.Max().y, box.Min().z); 444 glVertex3f(box.Max().x, box.Max().y, box.Max().z); 445 glVertex3f(box.Min().x, box.Max().y, box.Max().z); 446 glEnd(); 447 448 glEnable(GL_CULL_FACE); 449 450 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 451 } 452 453 454 void RenderTraverser::RenderFrustum() 455 { 456 Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr; 457 mCamera->ComputePoints(ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr); 458 459 glLineWidth(2); 460 461 glBegin(GL_LINE_LOOP); 462 glVertex3d(fbl.x, fbl.y, fbl.z); 463 glVertex3d(fbr.x, fbr.y, fbr.z); 464 glVertex3d(ftr.x, ftr.y, ftr.z); 465 glVertex3d(ftl.x, ftl.y, ftl.z); 466 glEnd(); 467 468 glBegin(GL_LINE_LOOP); 469 glVertex3d(nbl.x, nbl.y, nbl.z); 470 glVertex3d(nbr.x, nbr.y, nbr.z); 471 glVertex3d(ntr.x, ntr.y, ntr.z); 472 glVertex3d(ntl.x, ntl.y, ntl.z); 473 glEnd(); 474 475 glBegin(GL_LINE_LOOP); 476 glVertex3d(fbl.x, fbl.y, fbl.z); 477 glVertex3d(ftl.x, ftl.y, ftl.z); 478 glVertex3d(ntl.x, ntl.y, ntl.z); 479 glVertex3d(nbl.x, nbl.y, nbl.z); 480 glEnd(); 481 482 glBegin(GL_LINE_LOOP); 483 glVertex3d(fbr.x, fbr.y, fbr.z); 484 glVertex3d(ftr.x, ftr.y, ftr.z); 485 glVertex3d(ntr.x, ntr.y, ntr.z); 486 glVertex3d(nbr.x, nbr.y, nbr.z); 487 glEnd(); 488 489 glBegin(GL_LINE_LOOP); 490 glVertex3d(fbr.x, fbr.y, fbr.z); 491 glVertex3d(fbl.x, fbl.y, fbl.z); 492 glVertex3d(nbl.x, nbl.y, nbl.z); 493 glVertex3d(nbr.x, nbr.y, nbr.z); 494 glEnd(); 495 496 glBegin(GL_LINE_LOOP); 497 glVertex3d(ftr.x, ftr.y, ftr.z); 498 glVertex3d(ftl.x, ftl.y, ftl.z); 499 glVertex3d(ntl.x, ntl.y, ntl.z); 500 glVertex3d(ntr.x, ntr.y, ntr.z); 501 glEnd(); 502 } 503 504 505 } -
GTP/trunk/App/Demos/Vis/CHC_revisited/RenderTraverser.h
r2760 r2762 68 68 /** Sets the camera. 69 69 */ 70 void SetCamera(Camera *cam era);70 void SetCamera(Camera *cam) {mCamera = cam;} 71 71 /** sets view projection matrix 72 72 */ … … 87 87 */ 88 88 void SetRenderState(RenderState *state); 89 90 void RenderFrustum(); 89 91 90 92 … … 117 119 118 120 void EnqueueNode(BvhNode *node); 121 122 void RenderBox(const AxisAlignedBox3 &box); 123 119 124 120 125 -
GTP/trunk/App/Demos/Vis/CHC_revisited/Vector3.h
r2756 r2762 47 47 {} 48 48 49 Vector3(float v): x(v), y(v), z(v) 50 {} 49 Vector3(float v): x(v), y(v), z(v){} 51 50 /** Copy constructor. 52 51 */ -
GTP/trunk/App/Demos/Vis/CHC_revisited/chcdemo.cpp
r2760 r2762 128 128 //const string filename("house_test.dem"); 129 129 //const string filename("city_demo.dem"); 130 const string filename("city.dem"); 130 //const string filename("city.dem"); 131 const string filename("roofs.dem"); 131 132 132 133 if (loader.Load(filename, sceneEntities)) … … 136 137 137 138 BvhLoader bvhLoader; 138 bvh = bvhLoader.Load("city.bvh", sceneEntities); 139 bvh = bvhLoader.Load("roofs.bvh", sceneEntities); 140 141 142 //bvh = bvhLoader.Load("city.bvh", sceneEntities); 143 //bvh = bvhLoader.Load("house_test.bvh", sceneEntities); 139 144 140 145 sceneBox = bvh->GetBox(); … … 171 176 172 177 glDepthFunc(GL_LESS); 178 glEnable(GL_DEPTH_TEST); 173 179 174 180 SetupLighting(); … … 185 191 //glDisable(GL_CULL_FACE); 186 192 193 187 194 GLfloat ambientColor[] = {0.5, 0.5, 0.5, 1.0}; 188 195 GLfloat diffuseColor[] = {1.0, 0.0, 0.0, 1.0}; … … 322 329 323 330 glMatrixMode(GL_MODELVIEW); 324 glLoadIdentity();325 326 331 camera->SetupCameraView(); 327 332 … … 389 394 390 395 t1 = GetTime(); 396 397 traverser->SetCamera(camera); 398 399 //traverser->RenderFrustum(); 391 400 392 401 glEnableClientState(GL_VERTEX_ARRAY); … … 446 455 447 456 448 449 457 begin2D(); 450 458 … … 473 481 } 474 482 } 475 476 483 end2D(); 477 484
Note: See TracChangeset
for help on using the changeset viewer.