Changeset 2678 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 05/15/08 13:02:00 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 1 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Camera.cpp
r2635 r2678 21 21 22 22 #ifdef USE_HAVRAN_RAYCASTER 23 //#include "timer.h"24 23 #include "raypack.h" 25 24 #endif -
GTP/trunk/Lib/Vis/Preprocessing/src/Containers.h
r2615 r2678 76 76 /// a container for dynamic objects 77 77 78 #if USE_TRANSFORMED_MESH_INSTANCE_HACK79 typedef std::vector<TransformedMeshInstance *> DynamicObjectsContainer;80 #else81 78 typedef vector<SceneGraphLeaf *> DynamicObjectsContainer; 82 #endif 79 83 80 84 81 } -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r2677 r2678 522 522 glPopMatrix(); 523 523 524 #if 1 525 // test the box of the object 526 AxisAlignedBox3 box = leaf->GetBox(); 527 RenderBox(box); 528 #endif 524 if (1) 525 { 526 // test the box of the object 527 AxisAlignedBox3 box = leaf->GetBox(); 528 RenderBox(box); 529 } 529 530 } 530 531 … … 567 568 for (dit = p->mDynamicObjects.begin(); dit != dit_end; ++ dit) 568 569 { 569 #if USE_TRANSFORMED_MESH_INSTANCE_HACK570 RenderIntersectable(*dit);571 #else572 570 _RenderDynamicObject(*dit); 571 } 573 572 #endif 574 }575 #endif576 577 #if 1578 573 _RenderSceneTrianglesWithDrawArrays(); 579 574 580 #else581 static int glList = -1;582 if (mUseGlLists) {583 if (glList == -1) {584 glList = glGenLists(1);585 glNewList(glList, GL_COMPILE);586 _RenderSceneTriangles();587 glEndList();588 }589 590 glCallList(glList);591 } else592 _RenderSceneTriangles();593 594 #endif595 575 return true; 596 576 } -
GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.h
r2623 r2678 83 83 const bool pruneInvalidRays = true); 84 84 85 virtual void AddDynamicObjecs(const ObjectContainer &objects, const Matrix4x4 &m) {}; 86 virtual void UpdateDynamicObjects(const Matrix4x4 &m) {}; 87 virtual void DeleteDynamicObjects() {}; 85 virtual void AddDynamicObjecs(const ObjectContainer &objects, const Matrix4x4 &m) {DYN_ERROR_STRING;} 86 virtual void UpdateDynamicObjects(const Matrix4x4 &m) {DYN_ERROR_STRING;} 87 virtual void DeleteDynamicObjects() {DYN_ERROR_STRING;} 88 88 89 89 protected: -
GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.h
r2623 r2678 58 58 ); 59 59 60 virtual void AddDynamicObjecs(const ObjectContainer &objects, const Matrix4x4 &m) { };61 virtual void UpdateDynamicObjects(const Matrix4x4 &m) { };62 virtual void DeleteDynamicObjects() { };60 virtual void AddDynamicObjecs(const ObjectContainer &objects, const Matrix4x4 &m) { DYN_ERROR_STRING; }; 61 virtual void UpdateDynamicObjects(const Matrix4x4 &m) { DYN_ERROR_STRING;}; 62 virtual void DeleteDynamicObjects() {DYN_ERROR_STRING;}; 63 63 64 64 protected: -
GTP/trunk/Lib/Vis/Preprocessing/src/Matrix4x4.cpp
r1980 r2678 137 137 indxr[i] = irow; 138 138 indxc[i] = icol; 139 if (x[icol][icol] == 0.0 )139 if (x[icol][icol] == 0.0f) 140 140 return 1; /* singular matrix */ 141 141 142 pivinv = 1.0 / x[icol][icol];143 x[icol][icol] = 1.0 ;142 pivinv = 1.0f / x[icol][icol]; 143 x[icol][icol] = 1.0f ; 144 144 for ( l = 0 ; l<n ; l++) 145 145 x[l][icol] = x[l][icol] * pivinv ; … … 149 149 { 150 150 dum = x[icol][ll]; 151 x[icol][ll] = 0.0 ;151 x[icol][ll] = 0.0f; 152 152 for ( l = 0 ; l<n ; l++) 153 153 x[l][ll] = x[l][ll] - x[l][icol] * dum ; … … 208 208 for (int i = 0; i < 4; i++) 209 209 for (int j = 0; j < 4; j++) 210 M.x[i][j] = (i == j) ? 1.0 : 0.0;210 M.x[i][j] = (i == j) ? 1.0f : 0.0f; 211 211 return M; 212 212 } … … 321 321 double one_minus_cosine = 1 - cosine; 322 322 323 M.x[0][0] = axis.x * axis.x + (1.0 - axis.x * axis.x) * cosine;323 M.x[0][0] = axis.x * axis.x + (1.0f - axis.x * axis.x) * cosine; 324 324 M.x[0][1] = axis.x * axis.y * one_minus_cosine + axis.z * sine; 325 325 M.x[0][2] = axis.x * axis.z * one_minus_cosine - axis.y * sine; … … 327 327 328 328 M.x[1][0] = axis.x * axis.y * one_minus_cosine - axis.z * sine; 329 M.x[1][1] = axis.y * axis.y + (1.0 - axis.y * axis.y) * cosine;329 M.x[1][1] = axis.y * axis.y + (1.0f - axis.y * axis.y) * cosine; 330 330 M.x[1][2] = axis.y * axis.z * one_minus_cosine + axis.x * sine; 331 331 M.x[1][3] = 0; … … 333 333 M.x[2][0] = axis.x * axis.z * one_minus_cosine + axis.y * sine; 334 334 M.x[2][1] = axis.y * axis.z * one_minus_cosine - axis.x * sine; 335 M.x[2][2] = axis.z * axis.z + (1.0 - axis.z * axis.z) * cosine;335 M.x[2][2] = axis.z * axis.z + (1.0f - axis.z * axis.z) * cosine; 336 336 M.x[2][3] = 0; 337 337 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r2660 r2678 1244 1244 pruneInvalidRays); 1245 1245 1246 //#if DYNAMIC_OBJECTS_HACK1247 1246 // disabled not neccessary 1248 1247 UpdateDynamicObjects(); 1249 #if 01250 static Ray hRay;1251 VssRayContainer::iterator vit, vit_end = vssRays.end();1252 1253 for (vit = vssRays.begin(); vit != vit_end; ++ vit)1254 {1255 VssRay *vssRay = *vit;1256 1257 DynamicObjectsContainer::const_iterator tit, tit_end = mDynamicObjects.end();1258 bool foundIntersect = false;1259 1260 #if USE_TRANSFORMED_MESH_INSTANCE_HACK1261 hRay.Init(*vssRay);1262 1263 for (tit = mDynamicObjects.begin(); tit != tit_end; ++ tit)1264 {1265 TransformedMeshInstance *tmi = *tit;1266 1267 float maxT, minT;1268 1269 // test with bounding box1270 if (tmi->GetBox().GetMinMaxT(hRay, &minT, &maxT))1271 {1272 if (tmi->CastRay(hRay)) //cout << "z"; else cout<< "r";1273 {1274 //cout << "i: " << Intersectable::GetTypeName(hRay.intersections[0].mObject);1275 foundIntersect = true;1276 }1277 }1278 }1279 1280 if (foundIntersect)1281 {1282 ++ numTransformed;1283 // write new results back into vssRay1284 vssRay->Init(hRay);1285 }1286 1287 hRay.intersections.clear();1288 #else1289 1290 ////////////1291 // TODO Vlastimil1292 1293 for (tit = mDynamicObjects.begin(); tit != tit_end; ++ tit)1294 {1295 // remove vss ray termination triangle with container object1296 if (foundIntersect)1297 {1298 vssRay->mTerminationObject = (*tit)->GetIntersectable();1299 }1300 }1301 1302 1303 #endif1304 1305 1306 }1307 #endif1308 1248 } 1309 1249 … … 1746 1686 bool parsed = false; 1747 1687 1748 if (strstr(filename.c_str(), ".obj")) { 1749 cout<<"parsing obj file.."<<endl; 1750 ObjParser *p = new ObjParser; 1751 parsed = p->ParseFile(filename, 1752 leaf, 1753 false); 1754 leaf->UpdateBox(); 1755 cout<<leaf->GetBox(); 1756 1757 float s = 10.0f; 1758 leaf->ApplyTransform(ScaleMatrix(s, s, s)); 1759 leaf->ApplyTransform(TranslationMatrix(Vector3(0, 10, 0))); 1760 1761 1762 } else { 1763 cout<<"parsing binary obj file.."<<endl; 1764 1765 parsed = LoadBinaryObj(filename, leaf, NULL, 100); 1766 } 1767 1688 if (strstr(filename.c_str(), ".obj")) 1689 { 1690 cout<<"parsing obj file.."<<endl; 1691 ObjParser *p = new ObjParser; 1692 parsed = p->ParseFile(filename, 1693 leaf, 1694 false); 1695 leaf->UpdateBox(); 1696 cout<<leaf->GetBox(); 1697 1698 float s = 10.0f; 1699 leaf->ApplyTransform(ScaleMatrix(s, s, s)); 1700 leaf->ApplyTransform(TranslationMatrix(Vector3(0, 10, 0))); 1701 1702 1703 } 1704 else 1705 { 1706 cout<<"parsing binary obj file ... " << endl; 1707 1708 parsed = LoadBinaryObj(filename, leaf, NULL, 100); 1709 } 1710 1768 1711 if (parsed) 1769 1712 { 1770 1713 cout<<"success."<<endl; 1771 1714 leaf->UpdateBox(); … … 1774 1717 //leaf->RebuildKtbTree(); 1775 1718 mSceneGraph->GetRoot()->mChildren.push_back(leaf); 1776 1719 1777 1720 if (mRayCaster) 1778 1779 1780 1721 mRayCaster->AddDynamicObjecs(leaf->mGeometry, leaf->GetTransformation()); 1722 1723 1781 1724 return true; 1782 } else 1783 { 1784 cout<<"failed."<<endl; 1785 1786 } 1725 } 1726 else 1727 { 1728 cout<<"failed."<<endl; 1729 1730 } 1787 1731 1788 1732 #endif … … 1792 1736 1793 1737 1794 void 1795 Preprocessor::ObjectMoved(SceneGraphLeaf *object) 1796 { 1797 // first invalidate all PVS from which this object is visible 1798 ViewCellContainer::const_iterator vit, vit_end = mViewCellsManager->GetViewCells().end(); 1799 1800 AxisAlignedBox3 box = object->GetBox(); 1801 1802 ObjectContainer objects; 1803 1804 if (0) { 1805 // simplified computation taking only the objects intersecting the box 1806 KdNode::NewMail(); 1807 1808 // first mail all kDObjects which are intersected by the object 1809 preprocessor->mKdTree->CollectKdObjects(box, 1810 objects); 1811 1812 } else { 1813 ViewCellContainer viewCells; 1814 mViewCellsManager->ComputeBoxIntersections(box, viewCells); 1815 1816 ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end(); 1817 1818 ObjectPvs pvs; 1819 1820 for (int i=0; it != it_end; ++ it, ++ i) { 1821 //cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl; 1822 pvs.MergeInPlace((*it)->GetPvs()); 1823 } 1824 1825 ObjectPvsIterator pit = pvs.GetIterator(); 1826 while (pit.HasMoreEntries()) { 1827 PvsData pvsData; 1828 Intersectable *object = pit.Next(pvsData); 1829 objects.push_back(object); 1830 } 1831 } 1832 1833 int pvsCounter = 0; 1834 // now search for pvss which contained any mailed node 1835 for (vit = mViewCellsManager->GetViewCells().begin(); vit != vit_end; ++ vit) { 1836 ObjectPvs &pvs = (*vit)->GetPvs(); 1837 for (int i=0; i < objects.size(); i++) { 1838 vector<PvsEntry<Intersectable *,PvsData> >::iterator v; 1839 // ObjectPvsIterator it; 1840 if (pvs.Find(objects[i], v)) { 1841 // clear the pvs 1842 pvs.Clear(); 1843 pvsCounter++; 1844 break; 1845 } 1846 } 1847 } 1848 1849 cout<<"Number of affected objects "<<objects.size()<<endl; 1850 cout<<"Cleared "<<pvsCounter<<" PVSs ("<<mViewCellsManager->GetViewCells().size()/ 1851 (float)pvsCounter*100.0f<<"%) "<<endl; 1852 1738 void Preprocessor::ObjectMoved(SceneGraphLeaf *object) 1739 { 1740 // first invalidate all PVS from which this object is visible 1741 ViewCellContainer::const_iterator vit, vit_end = mViewCellsManager->GetViewCells().end(); 1742 1743 AxisAlignedBox3 box = object->GetBox(); 1744 1745 ObjectContainer objects; 1746 1747 if (0) 1748 { 1749 // simplified computation taking only the objects intersecting the box 1750 KdNode::NewMail(); 1751 1752 // first mail all kDObjects which are intersected by the object 1753 preprocessor->mKdTree->CollectKdObjects(box, objects); 1754 1755 } 1756 else 1757 { 1758 ViewCellContainer viewCells; 1759 mViewCellsManager->ComputeBoxIntersections(box, viewCells); 1760 1761 // add object to all viewcells that intersect the bounding box 1762 ObjectPvs pvs; 1763 1764 ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end(); 1765 1766 for (int i = 0; it != it_end; ++ it, ++ i) 1767 { 1768 //cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl; 1769 pvs.MergeInPlace((*it)->GetPvs()); 1770 } 1771 1772 ObjectPvsIterator pit = pvs.GetIterator(); 1773 while (pit.HasMoreEntries()) 1774 { 1775 PvsData pvsData; 1776 Intersectable *object = pit.Next(pvsData); 1777 objects.push_back(object); 1778 } 1779 } 1780 1781 int pvsCounter = 0; 1782 1783 // now search for pvss which contained any mailed node 1784 for (vit = mViewCellsManager->GetViewCells().begin(); vit != vit_end; ++ vit) 1785 { 1786 ObjectPvs &pvs = (*vit)->GetPvs(); 1787 1788 for (int i=0; i < objects.size(); i++) 1789 { 1790 vector<PvsEntry<Intersectable *,PvsData> >::iterator v; 1791 1792 if (pvs.Find(objects[i], v)) { 1793 // clear the pvs 1794 pvs.Clear(); 1795 pvsCounter++; 1796 break; 1797 } 1798 } 1799 } 1800 1801 cout<<"Number of affected objects "<<objects.size()<<endl; 1802 cout<<"Cleared "<<pvsCounter<<" PVSs ("<<mViewCellsManager->GetViewCells().size()/ 1803 (float)pvsCounter*100.0f<<"%) "<<endl; 1804 1853 1805 } 1854 1806 … … 1858 1810 if (mUpdateDynamicObjects) 1859 1811 { 1860 1812 // delete ALL dynamic stuff and rebuild using the new trafos 1861 1813 preprocessor->mRayCaster->DeleteDynamicObjects(); 1862 1814 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r2645 r2678 220 220 /// the view cells manager 221 221 ViewCellsManager *mViewCellsManager; 222 222 223 #if DYNAMIC_OBJECTS_HACK 223 224 DynamicObjectsContainer mDynamicObjects; … … 295 296 virtual void EvalViewCellHistogram(); 296 297 298 /** Notify the preprocessor that an object has moved and must be reevaluated. 299 */ 297 300 virtual void ObjectMoved(SceneGraphLeaf *object); 298 301 -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2677 r2678 497 497 for (dit = mDynamicObjects.begin(); dit != dit_end; ++ dit) 498 498 { 499 #if USE_TRANSFORMED_MESH_INSTANCE_HACK500 RenderIntersectable(*dit);501 #else502 499 _RenderDynamicObject(*dit); 503 #endif504 500 } 505 501 #endif -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
r2677 r2678 236 236 237 237 bool mUseRandomColorPerPvsObject; 238 238 239 #if DYNAMIC_OBJECTS_HACK 239 240 DynamicObjectsContainer mDynamicObjects; 240 241 #endif 242 241 243 QtGlRendererWidget(SceneGraph *sceneGraph, 242 244 ViewCellsManager *viewcells, -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2660 r2678 368 368 const bool isTermination) const 369 369 { 370 // dynamic objects are scene graph leaves 370 371 #if DYNAMIC_OBJECTS_HACK 371 372 #if USE_TRANSFORMED_MESH_INSTANCE_HACK373 if (ray.mTerminationObject->Type() == Intersectable::TRANSFORMED_MESH_INSTANCE)374 return ray.mTerminationObject;375 #else376 372 if (ray.mTerminationObject->Type() == Intersectable::SCENEGRAPHLEAF_INTERSECTABLE) 377 373 return ray.mTerminationObject; 378 374 #endif 379 375 380 #endif381 376 if (mUseKdPvs) 382 377 { -
GTP/trunk/Lib/Vis/Preprocessing/src/common.h
r2655 r2678 24 24 25 25 #define DYNAMIC_OBJECTS_HACK 1 26 #define USE_ TRANSFORMED_MESH_INSTANCE_HACK027 //#define USE_HAVRAN_RAYCASTER 0 26 #define USE_HAVRAN_RAYCASTER 0 27 28 28 29 29 namespace GtpVisibilityPreprocessor { … … 532 532 #endif 533 533 534 #define DYN_ERROR_STRING do {std::cout << "error: dynamic objects not supported" << endl;} while (0) 535 534 536 /** view cell id belonging to empty view space. 535 537 */ … … 545 547 546 548 547 548
Note: See TracChangeset
for help on using the changeset viewer.