Changeset 2615
- Timestamp:
- 01/19/08 05:28:24 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 6 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/demo1.env
r2614 r2615 170 170 171 171 KdTree { 172 pvsArea 8e- 4172 pvsArea 8e-5 173 173 sahUseFaces false 174 174 Termination { -
GTP/trunk/Lib/Vis/Preprocessing/src/Containers.h
r2609 r2615 5 5 #include <queue> 6 6 #include <map> 7 #include "common.h" 7 8 8 9 using std::vector; … … 14 15 class HierarchyNode; 15 16 class SceneGraphNode; 17 class SceneGraphLeaf; 16 18 class Intersectable; 17 19 class Polygon3; … … 73 75 74 76 /// a container for dynamic objects 77 78 #if USE_TRANSFORMED_MESH_INSTANCE_HACK 75 79 typedef std::vector<TransformedMeshInstance *> DynamicObjectsContainer; 76 80 #else 81 typedef vector<SceneGraphLeaf *> DynamicObjectsContainer; 82 #endif 77 83 78 84 } -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r2614 r2615 471 471 472 472 473 void GlRenderer::_RenderDynamicObject(SceneGraphLeaf *leaf) 474 { 475 // apply world transform before rendering 476 Matrix4x4 m; 477 leaf->GetTransform(m); 478 479 glPushMatrix(); 480 glMultMatrixf((float *)m.x); 481 482 glBegin(GL_TRIANGLES); 483 484 ObjectContainer::const_iterator oi = leaf->mGeometry.begin(); 485 for (; oi != leaf->mGeometry.end(); oi++) 486 { 487 TriangleIntersectable *object = (TriangleIntersectable *)*oi; 488 Triangle3 *t = &(object->GetItem()); 489 490 Vector3 normal = t->GetNormal(); 491 glNormal3f(normal.x, normal.y, normal.z); 492 493 glVertex3f(t->mVertices[0].x, t->mVertices[0].y, t->mVertices[0].z); 494 glVertex3f(t->mVertices[1].x, t->mVertices[1].y, t->mVertices[1].z); 495 glVertex3f(t->mVertices[2].x, t->mVertices[2].y, t->mVertices[2].z); 496 497 } 498 499 glEnd(); 500 501 glPopMatrix(); 502 } 503 504 505 473 506 void GlRenderer::_RenderSceneTriangles() 474 507 { … … 499 532 { 500 533 Intersectable::NewMail(); 501 534 #if DYNAMIC_OBJECTS_HACK 502 535 Preprocessor *p = mViewCellsManager->GetPreprocessor(); 503 536 // handle dynamic objects … … 506 539 for (dit = p->mDynamicObjects.begin(); dit != dit_end; ++ dit) 507 540 { 508 RenderIntersectable(*dit); 509 } 510 541 #if USE_TRANSFORMED_MESH_INSTANCE_HACK 542 RenderIntersectable(*dit); 543 #else 544 _RenderDynamicObject(*dit); 545 #endif 546 } 547 #endif 511 548 #if 1 512 549 _RenderSceneTrianglesWithDrawArrays(); -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
r2600 r2615 161 161 RenderViewPoint(); 162 162 163 void _RenderDynamicObject(SceneGraphLeaf *leaf); 164 163 165 virtual void 164 166 SetupProjection(const int w, const int h, const float angle = 70.0f); -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r2601 r2615 48 48 Environment::GetSingleton()->GetBoolValue("Preprocessor.evaluatePixelError", mEvaluatePixelError); 49 49 50 Environment::GetSingleton()->GetBoolValue("ViewCells.useKdPvs", mUseKdPvs); 51 52 50 53 char gvsStatsLog[100]; 51 54 Environment::GetSingleton()->GetStringValue("GvsPreprocessor.stats", gvsStatsLog); … … 183 186 obj->mCounter = 1; 184 187 mTrianglePvs.push_back(obj); 185 186 /*mViewCellsManager->ComputeSampleContribution(ray, 187 true, 188 mCurrentViewCell, 189 true);*/ 188 189 if (mUseKdPvs) 190 { 191 KdNode *node = mKdTree->GetPvsNode(ray.mTermination); 192 193 if (!node->Mailed()) 194 { 195 node->Mail(); 196 mKdPvs.push_back(mKdTree->GetOrCreateKdIntersectable(node)); 197 } 198 } 190 199 191 200 result = true; … … 863 872 for (lit = leaves.begin(); lit != leaves.end(); ++ lit) 864 873 { 865 KdLeaf *leaf = *lit; 874 KdLeaf *leaf = *lit; 875 876 if (mUseKdPvs) 877 mKdPvs.push_back(mKdTree->GetOrCreateKdIntersectable(leaf)); 878 866 879 ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 867 880 … … 892 905 (*oit)->mCounter = 0; 893 906 } 894 int dummy = 0; 907 908 895 909 while (NextViewCell())// && (dummy < 3)) 896 910 { … … 898 912 //if (mProcessedViewCells < 53) continue; 899 913 914 if (mUseKdPvs) 915 { 916 KdNode::NewMail(); 917 mKdPvs.clear(); 918 } 919 900 920 long startTime = GetTime(); 901 921 cout << "\n***********************\n" … … 910 930 mGvsStats.mTotalTrianglePvs += mGvsStats.mTrianglePvs; 911 931 912 ObjectContainer objectPvs; 913 914 // exchange triangle pvs with objects 915 //UpdatePvs(mCurrentViewCell); 916 GetObjectPvs(objectPvs); 917 918 // add pvs 919 ObjectContainer::const_iterator it, it_end = objectPvs.end(); 920 921 for (it = objectPvs.begin(); it != it_end; ++ it) 922 { 923 mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f); 924 } 925 926 cout << "triangle pvs of " << (int)mTrianglePvs.size() 927 << " was converted to object pvs of " << (int)objectPvs.size() << endl; 928 932 if (!mUseKdPvs) 933 { 934 ObjectContainer objectPvs; 935 936 // optain object pvs 937 GetObjectPvs(objectPvs); 938 939 // add pvs 940 ObjectContainer::const_iterator it, it_end = objectPvs.end(); 941 942 for (it = objectPvs.begin(); it != it_end; ++ it) 943 { 944 mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f); 945 } 946 947 cout << "triangle pvs of " << (int)mTrianglePvs.size() 948 << " was converted to object pvs of " << (int)objectPvs.size() << endl; 949 950 mGvsStats.mPerViewCellPvs = (int)objectPvs.size(); 951 } 952 else 953 { 954 // add pvs 955 ObjectContainer::const_iterator it, it_end = mKdPvs.end(); 956 957 for (it = mKdPvs.begin(); it != it_end; ++ it) 958 { 959 mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f); 960 } 961 962 mGvsStats.mPerViewCellPvs = mKdPvs.size(); 963 } 929 964 930 965 //////// … … 932 967 933 968 mGvsStats.mViewCells = mProcessedViewCells;//mPass; 934 //mGvsStats.mPerViewCellPvs = mCurrentViewCell->GetPvs().GetSize(); 935 mGvsStats.mPerViewCellPvs = (int)objectPvs.size(); 969 936 970 937 971 mGvsStats.mTotalPvs += mGvsStats.mPerViewCellPvs; … … 950 984 951 985 mTrianglePvs.clear(); 952 986 #if 0 953 987 if (GVS_DEBUG) 954 988 { … … 957 991 CLEAR_CONTAINER(mVssRays); 958 992 } 959 960 // is this really necessary?961 //ClearRayQueue();962 993 cout << "finished" << endl; 994 963 995 if (mEvaluatePixelError || mExportVisibility) 964 996 { 965 997 StorePvs(objectPvs); 966 998 } 999 #endif 967 1000 } 968 1001 } … … 1039 1072 1040 1073 BvhLeaf::NewMail(); 1074 //KdNode::NewMail(); 1041 1075 1042 1076 ObjectContainer::const_iterator oit, oit_end = mTrianglePvs.end(); … … 1053 1087 if (!bv || bv->Mailed()) 1054 1088 continue; 1055 1089 1056 1090 bv->Mail(); 1057 1058 1091 objectPvs.push_back(bv); 1059 1092 } -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
r2176 r2615 67 67 float mTotalTime; 68 68 69 ObjectContainer mKdPvs; 70 69 71 float RaysPerSec() const { if (!mTotalTime) return 0; return (float)mTotalSamples / mTotalTime * 1e-6f; } 70 72 … … 223 225 ////////////////////// 224 226 225 //int mSamplesPerPass; 226 //int mTotalSamples; 227 bool mUseKdPvs; 227 228 int mInitialSamples; 228 229 … … 236 237 237 238 239 ObjectContainer mKdPvs; 238 240 239 241 /////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h
r2575 r2615 39 39 40 40 enum {MESH_INSTANCE, 41 TRANSFORMED_MESH_INSTANCE, 42 SPHERE, 43 VIEW_CELL, 44 OGRE_MESH_INSTANCE, 45 KD_INTERSECTABLE, 46 BVH_INTERSECTABLE, 47 TRIANGLE_INTERSECTABLE, 48 DUMMY_INTERSECTABLE, 49 ENGINE_INTERSECTABLE, 50 CONTAINER_INTERSECTABLE 41 TRANSFORMED_MESH_INSTANCE, 42 SPHERE, 43 VIEW_CELL, 44 OGRE_MESH_INSTANCE, 45 KD_INTERSECTABLE, 46 BVH_INTERSECTABLE, 47 TRIANGLE_INTERSECTABLE, 48 DUMMY_INTERSECTABLE, 49 ENGINE_INTERSECTABLE, 50 CONTAINER_INTERSECTABLE, 51 SCENEGRAPHLEAF_INTERSECTABLE 51 52 }; 52 53 -
GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.cpp
r2604 r2615 225 225 } 226 226 227 } 227 228 SceneGraphLeafIntersectable::SceneGraphLeafIntersectable(SceneGraphLeaf *item, const AxisAlignedBox3 &box): 229 IntersectableWrapper<SceneGraphLeaf *>(item), mBox(box) 230 { 231 } 232 233 } -
GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h
r2604 r2615 267 267 }; 268 268 269 270 class SceneGraphLeafIntersectable: public IntersectableWrapper<SceneGraphLeaf *> 271 { 272 public: 273 SceneGraphLeafIntersectable(SceneGraphLeaf *item, const AxisAlignedBox3 &box); 274 275 int ComputeNumTriangles() { return 0;} 276 277 int Type() const 278 { 279 return Intersectable::SCENEGRAPHLEAF_INTERSECTABLE; 280 } 281 282 AxisAlignedBox3 GetBox() const 283 { 284 return mBox; 285 } 286 287 /// the bounding box of this intersectable 288 AxisAlignedBox3 mBox; 289 290 protected: 291 292 // int mNumTriangles; 293 }; 294 295 269 296 } 270 297 -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r2606 r2615 1372 1372 bool KdTree::ImportBinTree(const string &filename, ObjectContainer &objects) 1373 1373 { 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1374 // export binary version of mesh 1375 queue<TraversalData> tStack; 1376 IN_STREAM stream(filename.c_str(), IN_BIN_MODE); 1377 1378 if (!stream.is_open()) return false; 1379 1380 // sort objects by their id 1381 // if (!is_sorted(objects.begin(), objects.end(), ilt)) 1382 sort(objects.begin(), objects.end(), ilt); 1383 1384 mBox.Initialize(); 1385 ObjectContainer::const_iterator oit, oit_end = objects.end(); 1386 1387 /////////////////////////// 1388 //-- compute bounding box of object space 1389 1390 for (oit = objects.begin(); oit != oit_end; ++ oit) 1391 { 1392 const AxisAlignedBox3 box = (*oit)->GetBox(); 1393 mBox.Include(box); 1394 } 1395 1396 // hack: we make a new root 1397 DEL_PTR(mRoot); 1398 1399 mRoot = ImportNextNode(stream, NULL, objects); 1400 1401 tStack.push(TraversalData(mRoot, mBox, 0)); 1402 mStat.Reset(); 1403 mStat.nodes = 1; 1404 1405 while(!tStack.empty()) 1406 { 1407 TraversalData tData = tStack.front(); 1408 tStack.pop(); 1409 1410 KdNode *node = tData.mNode; 1411 1412 if (!node->IsLeaf()) 1413 { 1414 mStat.nodes += 2; 1415 1416 //Debug << "i" ; 1417 KdInterior *interior = static_cast<KdInterior *>(node); 1418 interior->mBox = tData.mBox; 1419 1420 KdNode *front = ImportNextNode(stream, interior, objects); 1421 KdNode *back = ImportNextNode(stream, interior, objects); 1422 1423 interior->SetupChildLinks(back, front); 1424 1425 ++ mStat.splits[interior->mAxis]; 1426 1427 // compute new bounding box 1428 AxisAlignedBox3 frontBox, backBox; 1429 1430 tData.mBox.Split(interior->mAxis, 1431 interior->mPosition, 1432 frontBox, 1433 backBox); 1434 1435 tStack.push(TraversalData(front, frontBox, tData.mDepth + 1)); 1436 tStack.push(TraversalData(back, backBox, tData.mDepth + 1)); 1437 } 1438 else 1439 { 1440 EvaluateLeafStats(tData); 1441 //cout << "l"; 1442 } 1443 } 1444 1445 float area = GetBox().SurfaceArea()*mKdPvsArea; 1446 1447 SetPvsTerminationNodes(area); 1448 1449 Debug << mStat << endl; 1450 1451 return true; 1452 1452 } 1453 1453 … … 1456 1456 KdTree::GetOrCreateKdIntersectable(KdNode *node) 1457 1457 { 1458 1459 1458 if (node == NULL) 1459 return NULL; 1460 1460 1461 1461 if (node->mIntersectable == NULL) … … 1465 1465 KdIntersectable *kdObj = new KdIntersectable(node, GetBox(node)); 1466 1466 node->mIntersectable = kdObj; 1467 1467 1468 1468 mKdIntersectables.push_back(kdObj); 1469 1469 kdObj->SetId(id); 1470 1470 #ifdef USE_BIT_PVS 1471 1472 1471 // hack: for kd pvs the kd intersecables are the pvs objects 1472 ObjectPvsIterator::sObjects.push_back(kdObj); 1473 1473 #endif 1474 1475 1476 1474 } 1475 1476 return node->mIntersectable; 1477 1477 } 1478 1478 … … 1519 1519 } 1520 1520 1521 1522 /*KdNode * 1523 KdTree::GetPvsNode(const Triangle3 &tri) const 1524 { 1525 KdNode *node = mRoot; 1526 1527 while (node->mPvsTermination == 0 ) 1528 { 1529 KdInterior *inter = (KdInterior *)node; 1530 if (point[inter->mAxis] < inter->mPosition) 1531 node = inter->mBack; 1532 else 1533 node = inter->mFront; 1534 } 1535 1536 return node; 1537 }*/ 1538 1539 1540 1521 1541 KdNode * 1522 1542 KdTree::GetPvsNode(const Vector3 &point) const … … 1561 1581 1562 1582 while (!tStack.empty()) 1563 1564 1565 1566 1567 1568 {1569 leaves.push_back(static_cast<KdLeaf *>(node));1570 }1571 1572 {1573 KdInterior *interior = static_cast<KdInterior *>(node);1574 1575 if (box.Max(interior->mAxis) >= interior->mPosition)1576 1577 1578 1579 1580 if (box.Min(interior->mAxis) < interior->mPosition)1581 1582 1583 1584 }1585 1586 } 1587 1588 1589 1590 } 1583 { 1584 KdNode *node = tStack.top(); 1585 tStack.pop(); 1586 1587 if (node->IsLeaf()) 1588 { 1589 leaves.push_back(static_cast<KdLeaf *>(node)); 1590 } 1591 else // interior 1592 { 1593 KdInterior *interior = static_cast<KdInterior *>(node); 1594 1595 if (box.Max(interior->mAxis) >= interior->mPosition) 1596 { 1597 tStack.push(interior->mFront); 1598 } 1599 1600 if (box.Min(interior->mAxis) < interior->mPosition) 1601 { 1602 tStack.push(interior->mBack); 1603 } 1604 } 1605 } 1606 } 1607 1608 1609 1610 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r2614 r2615 1209 1209 1210 1210 #if DYNAMIC_OBJECTS_HACK 1211 1212 1211 static Ray hRay; 1213 1212 VssRayContainer::iterator vit, vit_end = vssRays.end(); … … 1216 1215 { 1217 1216 VssRay *vssRay = *vit; 1217 1218 DynamicObjectsContainer::const_iterator tit, tit_end = mDynamicObjects.end(); 1219 bool foundIntersect = false; 1220 1221 #if USE_TRANSFORMED_MESH_INSTANCE_HACK 1218 1222 hRay.Init(*vssRay); 1219 1220 DynamicObjectsContainer::const_iterator tit, tit_end = mDynamicObjects.end();1221 1222 bool foundIntersect = false;1223 1223 1224 1224 for (tit = mDynamicObjects.begin(); tit != tit_end; ++ tit) … … 1227 1227 1228 1228 float maxT, minT; 1229 1230 // test with bounding box 1229 // test with bounding box 1231 1230 if (tmi->GetBox().GetMinMaxT(hRay, &minT, &maxT)) 1232 1231 { … … 1239 1238 } 1240 1239 1241 //if (foundIntersect) cout << "x: " << Intersectable::GetTypeName(hRay.intersections[0].mObject);1242 1243 1240 if (foundIntersect) 1244 1241 { … … 1249 1246 1250 1247 hRay.intersections.clear(); 1248 #else 1249 1250 //////////// 1251 // TODO Vlastimil 1252 1253 for (tit = mDynamicObjects.begin(); tit != tit_end; ++ tit) 1254 { 1255 // remove vss ray termination triangle with container object 1256 if (foundIntersect) 1257 { 1258 vssRay->mTerminationObject = (*tit)->GetIntersectable(); 1259 } 1260 } 1261 1262 1263 #endif 1264 1265 1251 1266 } 1252 1267 #endif … … 1640 1655 inStream.read(reinterpret_cast<char *>(&mesh->mVertices[i + 2]), sizeof(Vector3)); 1641 1656 1642 /*mesh->mVertices[i].x += 20; 1643 mesh->mVertices[i + 1].x += 20; 1644 mesh->mVertices[i + 2].x += 20; 1645 1646 mesh->mVertices[i].z -= 10; 1647 mesh->mVertices[i + 1].z -= 10; 1648 mesh->mVertices[i + 2].z -= 10; 1649 */ 1657 // hack: objects initially very small 1650 1658 mesh->mVertices[i] *= 100; 1651 1659 mesh->mVertices[i + 1] *= 100; … … 1671 1679 { 1672 1680 const bool dynamic = true; 1681 #if DYNAMIC_OBJECTS_HACK 1682 #if USE_TRANSFORMED_MESH_INSTANCE_HACK 1673 1683 1674 1684 Mesh *mesh = LoadBinaryObjIntoMesh(filename); … … 1682 1692 1683 1693 mSceneGraph->GetRoot()->mChildren.push_back(leaf); 1684 //mDynamicObjects.push_back(leaf); 1694 1685 1695 mDynamicObjects.push_back(tmi); 1686 1687 1696 return true; 1688 1697 } 1689 1690 1698 #else 1699 1700 SceneGraphLeaf *leaf = new SceneGraphLeaf(dynamic); 1701 1702 if (LoadBinaryObj(filename, leaf, NULL)) 1703 { 1704 mDynamicObjects.push_back(leaf); 1705 mSceneGraph->GetRoot()->mChildren.push_back(leaf); 1706 return true 1707 } 1708 1709 #endif 1710 #endif 1691 1711 return false; 1692 1712 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r2609 r2615 219 219 /// the view cells manager 220 220 ViewCellsManager *mViewCellsManager; 221 222 //SceneGraphNodeContainer mDynamicObjects; 221 #if DYNAMIC_OBJECTS_HACK 223 222 DynamicObjectsContainer mDynamicObjects; 224 223 #endif 225 224 /// greedy optimized hierarchy for both objects and view cells 226 225 VspOspTree *mVspOspTree; -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2614 r2615 88 88 KdTree *tree): 89 89 QGLPixelBuffer(QSize(w, h)), 90 //QGLWidget(NULL, w, h),91 90 GlRendererBuffer(sceneGraph, viewcells, tree) 92 91 { … … 380 379 glNormalPointer(GL_FLOAT, 0, (char *)arrayPtr + offset * sizeof(Vector3)); 381 380 glDrawElements(GL_TRIANGLES, mIndexBufferSize, GL_UNSIGNED_INT, mIndices); 382 381 #if DYNAMIC_OBJECTS_HACK 383 382 // handle dynamic objects 384 383 DynamicObjectsContainer::const_iterator dit, dit_end = mDynamicObjects.end(); 385 384 385 386 386 for (dit = mDynamicObjects.begin(); dit != dit_end; ++ dit) 387 387 { 388 #if USE_TRANSFORMED_MESH_INSTANCE_HACK 388 389 //cerr << "here45\n****"<<endl; 389 390 RenderIntersectable(*dit); 390 } 391 #else 392 RenderDynamicObject(*dit); 393 #endif 394 } 395 #endif 391 396 } 392 397 … … 400 405 401 406 mPvsSize = mPvsCache.mPvs.GetSize(); 402 407 #if DYNAMIC_OBJECTS_HACK 403 408 mDynamicObjects.clear(); 404 409 #endif 405 410 ObjectPvsIterator it = mPvsCache.mPvs.GetIterator(); 406 411 … … 416 421 } 417 422 break; 423 #if DYNAMIC_OBJECTS_HACK 424 #if USE_TRANSFORMED_MESH_INSTANCE_HACK 425 418 426 case Intersectable::TRANSFORMED_MESH_INSTANCE: 419 427 mDynamicObjects.push_back(static_cast<TransformedMeshInstance *>(obj)); 420 428 break; 429 430 #else 431 case Intersectable::SCENEGRAPHLEAF_INTERSECTABLE: 432 mDynamicObjects.push_back(static_cast<SceneGraphLeafIntersectable *>(obj)->GetItem()); 433 break; 434 #endif 435 #endif 421 436 default: 422 437 cerr << "PreparePvs: type " << Intersectable::GetTypeName(obj) << " not handled yet" << endl; … … 513 528 //mPvsCache.mPvs = pvs; 514 529 //mMutex.unlock(); 530 cout << "pvs size: " << mPvsCache.mPvs.GetSize() << endl; 515 531 } 516 532 else … … 667 683 mViewPoint.x += (x-mousePoint.x)*MOVE_SENSITIVITY / 2.0; 668 684 } 685 #if DYNAMIC_OBJECTS_HACK 669 686 else if (e->modifiers() & Qt::AltModifier) 670 687 { … … 673 690 Matrix4x4 tm; 674 691 TransformedMeshInstance *tmi; 692 #if USE_TRANSFORMED_MESH_INSTANCE_HACK 675 693 676 694 switch (mTrafoType) … … 703 721 704 722 tmi->ApplyWorldTransform(tm); 723 #endif 705 724 updateGL(); 706 725 } 707 726 } 727 #endif 708 728 else 709 729 { … … 1001 1021 connect(mControlWidget, SIGNAL(SetScale(bool)), this, SLOT(SetScale(bool))); 1002 1022 1003 // setting the size here 1004 resize(800, 600); 1023 setWindowTitle("PVS Visualization"); 1024 1025 // setting the main window size here 1026 //resize(800, 600); 1027 //resize(640, 480); 1028 //resize(512, 384); 1029 //resize(512, 320); 1030 resize(640, 400); 1031 1005 1032 mControlWidget->show(); 1006 1033 } … … 1309 1336 while (pit.HasMoreEntries()) 1310 1337 { 1338 KdIntersectable *kdObj = static_cast<KdIntersectable *>(pit.Next()); 1339 1311 1340 if (mShowDistanceWeightedPvs) 1312 1341 { 1313 KdIntersectable *kdObj = static_cast<KdIntersectable *>(pit.Next());1314 1342 const AxisAlignedBox3 box = kdObj->GetBox(); 1315 1343 … … 1319 1347 else if (mShowDistanceWeightedTriangles) 1320 1348 { 1321 KdIntersectable *kdObj = static_cast<KdIntersectable *>(pit.Next());1322 1349 const AxisAlignedBox3 box = kdObj->GetBox(); 1323 1350 … … 1327 1354 else //if (mShowWeightedTriangles) 1328 1355 { 1329 KdIntersectable *kdObj = static_cast<KdIntersectable *>(pit.Next());1330 1356 renderCost += kdObj->ComputeNumTriangles(); 1331 1357 } … … 1436 1462 1437 1463 ComputeMaxValues(viewcells, maxPvs, maxPiercingRays, maxRelativeRays, maxRcCost); 1438 1464 // matt: temp hack 1465 //maxRcCost = 200.0f; 1466 //cout << "maxRcCost: " << maxRcCost << endl; 1439 1467 int i; 1440 1468 … … 1488 1516 else // using specialised colors 1489 1517 { 1490 1491 1492 1518 if (!mShowComparison) 1493 1519 AssignImportanceByRelativeValue(viewcells, maxPvs, maxPiercingRays, maxRelativeRays, maxRcCost); … … 1557 1583 importance = rcCost / maxRcCost; 1558 1584 } 1559 1585 if (importance > 1.0f) importance = 1.0f; 1560 1586 // c = RgbColor(importance, 1.0f - importance, 0.0f); 1561 1587 c = RainbowColorMapping(importance); … … 1658 1684 connect(rb5, SIGNAL(toggled(bool)), SIGNAL(SetShowWeightedCost(bool))); 1659 1685 1660 QGroupBox *groupBox = new QGroupBox(" Visualization options");1686 QGroupBox *groupBox = new QGroupBox("PVS Visualization"); 1661 1687 1662 1688 QVBoxLayout *vbox2 = new QVBoxLayout; … … 1771 1797 1772 1798 1773 QGroupBox *groupBox = new QGroupBox("Ray visualization options");1799 QGroupBox *groupBox = new QGroupBox("Ray visualization"); 1774 1800 QVBoxLayout *vbox2 = new QVBoxLayout; 1775 1801 … … 1816 1842 QVBoxLayout *vl = new QVBoxLayout; 1817 1843 setLayout(vl); 1818 1819 QWidget *vbox = new QGroupBox("ViewCells", this); 1820 layout()->addWidget(vbox); 1821 1822 vl = new QVBoxLayout; 1823 vbox->setLayout(vl); 1844 1845 //QWidget *vbox; 1846 1847 //vbox = new QGroupBox("Render Controls", this); 1848 //layout()->addWidget(vbox); 1849 //vl = new QVBoxLayout; 1850 //vbox->setLayout(vl); 1824 1851 1825 1852 QLabel *label; … … 1830 1857 1831 1858 label = new QLabel("Granularity"); 1832 vbox->layout()->addWidget(label); 1859 //vbox->layout()->addWidget(label); 1860 vl->addWidget(label); 1833 1861 1834 1862 slider = new QSlider(Qt::Horizontal, vbox); … … 1844 1872 1845 1873 label = new QLabel("Transfer function"); 1846 v box->layout()->addWidget(label);1874 vl->addWidget(label); 1847 1875 1848 1876 slider = new QSlider(Qt::Horizontal, vbox); … … 1859 1887 1860 1888 button = new QPushButton("Update all PVSs", vbox); 1861 v box->layout()->addWidget(button);1889 vl->addWidget(button); 1862 1890 connect(button, SIGNAL(clicked()), SLOT(UpdateAllPvs())); 1863 1891 … … 1865 1893 1866 1894 label = new QLabel("Filter size"); 1867 v box->layout()->addWidget(label);1895 vl->addWidget(label); 1868 1896 1869 1897 slider = new QSlider(Qt::Horizontal, vbox); 1870 v box->layout()->addWidget(slider);1898 vl->addWidget(slider); 1871 1899 slider->show(); 1872 1900 slider->setRange(1, 100); … … 1879 1907 1880 1908 1881 ////////////////////////////////////////// 1882 1883 label = new QLabel("Spatial Filter size"); 1884 vbox->layout()->addWidget(label); 1885 1886 slider = new QSlider(Qt::Horizontal, vbox); 1887 vbox->layout()->addWidget(slider); 1888 slider->show(); 1889 slider->setRange(1, 100); 1890 slider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 1891 slider->setValue(10); 1892 1893 connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetSpatialFilterSize(int))); 1894 1895 1909 1896 1910 /////////////////////////////////// 1897 1911 1898 1912 1899 QWidget *hbox = new QWidget( vbox);1913 QWidget *hbox = new QWidget();//vbox); 1900 1914 vl->addWidget(hbox); 1901 1915 QHBoxLayout *hlayout = new QHBoxLayout; … … 1906 1920 cb->setChecked(false); 1907 1921 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowViewCells(bool))); 1908 1922 1923 cb = new QCheckBox("Render errors", hbox); 1924 hlayout->layout()->addWidget(cb); 1925 cb->setChecked(false); 1926 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetRenderErrors(bool))); 1927 1928 #if REMOVE_TEMPORARY 1909 1929 cb = new QCheckBox("Render cost curve", hbox); 1910 1930 hlayout->addWidget(cb); 1911 1931 cb->setChecked(false); 1912 1932 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowRenderCost(bool))); 1913 1933 #endif 1914 1934 cb = new QCheckBox("Show rays", hbox); 1915 1935 hlayout->addWidget(cb); 1916 1936 cb->setChecked(false); 1917 1937 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowRays(bool))); 1918 1938 #if REMOVE_TEMPORARY 1919 1939 cb = new QCheckBox("Show Comparison", hbox); 1920 1940 hlayout->addWidget(cb); 1921 1941 cb->setChecked(false); 1922 1942 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowComparison(bool))); 1923 1943 #endif 1924 1944 1925 1945 ////////////////// … … 1934 1954 QGroupBox *groupBox = CreateVisualizationPanel(hbox); 1935 1955 vh->addWidget(groupBox, 0, 0); 1936 1956 #if REMOVE_TEMPORARY 1937 1957 QGroupBox *groupBox2 = CreateRenderCostPanel(hbox); 1938 1958 vh->addWidget(groupBox2, 0, 0); 1939 1959 #endif 1940 1960 QGroupBox *groupBox3 = CreateRayVisualizationPanel(hbox); 1941 1961 vh->addWidget(groupBox3, 0, 0); … … 1948 1968 1949 1969 /*cb = new QRadiobox("Top View", vbox); 1950 v box->layout()->addWidget(cb);1970 vl->addWidget(cb); 1951 1971 cb->setChecked(false); 1952 1972 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetTopView(bool))); 1953 1973 */ 1954 1974 1955 vbox->resize(800,150); 1975 //vbox->resize(800,150); 1976 QWidget *vbox; 1956 1977 1957 1978 vbox = new QGroupBox("Rendering", this); … … 2022 2043 2023 2044 /////////////////////////////////////////// 2024 2045 #if REMOVE_TEMPORARY 2025 2046 cb = new QCheckBox("Transparency", vbox); 2026 2047 vbox->layout()->addWidget(cb); … … 2038 2059 slider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 2039 2060 slider->setValue(0); 2040 2061 #endif 2041 2062 connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetTransparency(int))); 2042 2063 … … 2048 2069 cb->setChecked(false); 2049 2070 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetCutScene(bool))); 2050 #endif 2071 2051 2072 cb = new QCheckBox("Render boxes", vbox); 2052 2073 vbox->layout()->addWidget(cb); … … 2058 2079 cb->setChecked(false); 2059 2080 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetRenderVisibilityEstimates(bool))); 2060 2061 2062 cb = new QCheckBox("Render errors", vbox); 2063 vbox->layout()->addWidget(cb); 2064 cb->setChecked(false); 2065 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetRenderErrors(bool))); 2081 #endif 2066 2082 2067 2083 bool tmp; … … 2081 2097 cb->setChecked(tmp); 2082 2098 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetUseSpatialFilter(bool))); 2083 2099 #if REMOVE_TEMPORARY 2084 2100 cb = new QCheckBox("Render filter", vbox); 2085 2101 vbox->layout()->addWidget(cb); … … 2113 2129 vbox->layout()->addWidget(button); 2114 2130 connect(button, SIGNAL(clicked()), SIGNAL(LoadObject())); 2115 2131 #endif 2116 2132 /*cb = new QCheckBox("Stats", vbox); 2117 2133 vbox->layout()->addWidget(cb); … … 2142 2158 //connect(button, SIGNAL(clicked(void)), SLOT(StoreStatistics(void))); 2143 2159 //mHidingCost = 0.1f; 2160 ////////////////////////////////////////// 2161 2162 label = new QLabel("Spatial Filter size"); 2163 vbox->layout()->addWidget(label); 2164 2165 slider = new QSlider(Qt::Horizontal, vbox); 2166 vbox->layout()->addWidget(slider); 2167 slider->show(); 2168 slider->setRange(1, 100); 2169 slider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 2170 slider->setValue(10); 2171 2172 connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetSpatialFilterSize(int))); 2173 2144 2174 2145 2175 setWindowTitle("Preprocessor Control Widget"); -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
r2614 r2615 232 232 233 233 bool mUseRandomColorPerPvsObject; 234 234 #if DYNAMIC_OBJECTS_HACK 235 235 DynamicObjectsContainer mDynamicObjects; 236 236 #endif 237 237 QtGlRendererWidget(SceneGraph *sceneGraph, 238 238 ViewCellsManager *viewcells, -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp
r2614 r2615 31 31 mModelMatrix = IdentityMatrix(); 32 32 33 //setWindowTitle("PVS visualization"); 34 setWindowTitle("Global View Cell Visualization"); 35 33 36 trackball(manipulatorLastQuat, 0.0f, 0.0f, 0.0f, 0.0f); 34 37 //connect(renderer, SIGNAL(PvsUpdated()), this, SLOT(updateGL())); … … 46 49 QSize QtGlViewer::sizeHint() const 47 50 { 48 return QSize(640, 480); 51 // set viewer size here 52 return QSize(512, 320); 53 54 //return QSize(512, 384); 55 //return QSize(640, 480); 49 56 } 50 57 … … 228 235 { 229 236 switch (e->key()) { 237 case Qt::Key_V: 238 mRenderer->mRenderViewCells = !mRenderer->mRenderViewCells; 239 updateGL(); 240 break; 241 230 242 case Qt::Key_W: 231 243 mWireframe = !mWireframe; 232 244 updateGL(); 245 break; 246 233 247 default: 234 248 e->ignore(); -
GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.cpp
r2610 r2615 5 5 #include "X3dExporter.h" 6 6 #include "Intersectable.h" 7 #include "IntersectableWrapper.h" 7 8 8 9 … … 223 224 { 224 225 (*ni)->UpdateBox(); 225 box.Include((*ni)-> mBox);226 box.Include((*ni)->GetBox()); 226 227 } 227 228 … … 277 278 278 279 279 void SceneGraphLeaf::Transform(const Matrix4x4 &trafo) 280 { 281 mTrafo *= trafo; 282 } 283 284 } 280 SceneGraphLeaf::SceneGraphLeaf(): mIsDynamic(false) 281 { 282 mTrafo = IdentityMatrix(); 283 #if DYNAMIC_OBJECTS_HACK 284 mIntersectable = new SceneGraphLeafIntersectable(this, mBox); 285 #endif 286 } 287 288 289 SceneGraphLeaf::SceneGraphLeaf(bool isDynamic): mIsDynamic(isDynamic) 290 { 291 mTrafo = IdentityMatrix(); 292 } 293 294 295 void SceneGraphLeaf::ApplyTransform(const Matrix4x4 &trafo) 296 { 297 mTrafo = trafo * mTrafo; 298 } 299 300 301 void SceneGraphLeaf::LoadTransform(const Matrix4x4 &m) 302 { 303 mTrafo = m; 304 } 305 306 307 void SceneGraphLeaf::GetTransform(Matrix4x4 &m) const 308 { 309 m = mTrafo; 310 } 311 312 313 AxisAlignedBox3 SceneGraphLeaf::GetBox() const 314 { 315 return Transform(mBox, mTrafo); 316 } 317 318 } -
GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.h
r2610 r2615 9 9 namespace GtpVisibilityPreprocessor { 10 10 11 class SceneGraphLeafIntersectable; 11 12 12 13 /** Basic scene graph node, we are interested only in bounding boxes and topology … … 22 23 virtual void UpdateBox() = 0; 23 24 24 //protected: 25 virtual AxisAlignedBox3 GetBox() const { return mBox; } 26 27 protected: 25 28 26 29 AxisAlignedBox3 mBox; … … 51 54 public: 52 55 53 SceneGraphLeaf( bool isDynamic = false):54 mIsDynamic(isDynamic){}56 SceneGraphLeaf(); 57 SceneGraphLeaf(bool isDynamic); 55 58 ~SceneGraphLeaf(); 59 60 void LoadTransform(const Matrix4x4 &m); 56 61 57 virtual void Transform(const Matrix4x4 &trafo); 62 void GetTransform(Matrix4x4 &m) const; 63 64 virtual AxisAlignedBox3 GetBox() const; 65 66 virtual void ApplyTransform(const Matrix4x4 &trafo); 58 67 virtual bool IsDynamic() const { return mIsDynamic;} 59 68 virtual bool IsLeaf() const { return true; } 60 69 virtual void UpdateBox(); 61 70 #if DYNAMIC_OBJECT_HACK 71 SceneGraphLeafIntersectable *GetIntersectable() { return mIntersectable;} 72 #endif 73 /// used as actual pvs entry 62 74 ObjectContainer mGeometry; 63 75 64 76 protected: 65 77 #if DYNAMIC_OBJECT_HACK 78 SceneGraphLeafIntersectable *mIntersectable; 79 #endif 66 80 bool mIsDynamic; 67 81 Matrix4x4 mTrafo; … … 88 102 void GetStatistics(int &intersectables, int &faces) const; 89 103 90 AxisAlignedBox3 GetBox() const { return mRoot-> mBox; }104 AxisAlignedBox3 GetBox() const { return mRoot->GetBox(); } 91 105 /** Exports binary version of the scene. 92 106 */ -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2614 r2615 369 369 { 370 370 #if DYNAMIC_OBJECTS_HACK 371 372 #if USE_TRANSFORMED_MESH_INSTANCE_HACK 371 373 if (ray.mTerminationObject->Type() == Intersectable::TRANSFORMED_MESH_INSTANCE) 372 374 return ray.mTerminationObject; 375 #else 376 if (ray.mTerminationObject->Type() == Intersectable::SCENEGRAPHLEAF_INTERSECTABLE) 377 return ray.mTerminationObject; 378 #endif 379 373 380 #endif 374 381 if (mUseKdPvs) … … 3359 3366 // $$ warning collect objects takes only unmailed ones! 3360 3367 if (mUseKdPvs) { 3361 //GetPreprocessor()->mKdTree->CollectKdObjects(box, objects);3362 GetPreprocessor()->mKdTree->CollectSmallKdObjects(box, objects, 0.1f);3368 GetPreprocessor()->mKdTree->CollectKdObjects(box, objects); 3369 //GetPreprocessor()->mKdTree->CollectSmallKdObjects(box, objects, 0.1f); 3363 3370 3364 3371 } else … … 3370 3377 { 3371 3378 Intersectable *o = *noi; 3379 3372 3380 // $$ JB warning: pdfs are not correct at this point! 3373 3381 pvs.AddSampleDirty(o, Limits::Small); -
GTP/trunk/Lib/Vis/Preprocessing/src/common.h
r2609 r2615 23 23 #include <vector> 24 24 25 #define DYNAMIC_OBJECTS_HACK 1 25 #define DYNAMIC_OBJECTS_HACK 0 26 #define USE_TRANSFORMED_MESH_INSTANCE_HACK 1 26 27 #define USE_HAVRAN_RAYCASTER 27 28 -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r2611 r2615 348 348 rendererWidget->Show(); 349 349 350 //rendererWidget->SetWindowTitle("Global Visualization"); 351 350 352 if (1) // not working with vbo 351 353 {
Note: See TracChangeset
for help on using the changeset viewer.