- Timestamp:
- 05/27/08 21:24:34 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh
r2718 r2720 42 42 -gvs_initial_samples=16 \ 43 43 -gvs_max_viewcells=5000 \ 44 -gvs_min_contribution= 500 \44 -gvs_min_contribution=2000 \ 45 45 -gvs_per_viewcell=true \ 46 46 -preprocessor_detect_empty_viewspace+ \ -
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp
r2691 r2720 8 8 #include "Triangle3.h" 9 9 #include "VssRay.h" 10 10 #include "IntersectableWrapper.h" 11 11 12 12 … … 2135 2135 face6->mVertices.push_back(Vector3(mMax.x, mMax.y, mMax.z)); 2136 2136 face6->mVertices.push_back(Vector3(mMin.x, mMax.y, mMax.z)); 2137 2137 } 2138 /* 2139 xxxxxx 2140 x xx 2141 x x x 2142 xxxxxx x 2143 x x x 2144 x xx 2145 xxxxxx 2146 */ 2147 2148 void AxisAlignedBox3::Triangulate(ObjectContainer &triangles) const 2149 { 2150 /*PolygonContainer polys; 2151 TriangleContainer tris; 2152 2153 ExtractPolys(polys); 2154 2155 for (size_t i = 0; i < polys.size(); ++ i) 2156 { 2157 Triangle tri; 2158 polys[i].Trianulage(tris); 2159 }*/ 2160 2161 TriangleIntersectable *triObj; 2162 Triangle3 tri; 2163 2164 tri.mVertices[0] = Vector3(mMin.x, mMin.y, mMax.z); 2165 tri.mVertices[1] = Vector3(mMin.x, mMax.y, mMax.z); 2166 tri.mVertices[2] = Vector3(mMin.x, mMax.y ,mMin.z); 2167 2168 triObj = new TriangleIntersectable(tri); 2169 triangles.push_back(triObj); 2170 2171 tri.mVertices[0] = Vector3(mMin.x, mMax.y ,mMin.z); 2172 tri.mVertices[1] = Vector3(mMin.x, mMin.y, mMin.z); 2173 tri.mVertices[2] = Vector3(mMin.x, mMin.y, mMax.z); 2174 2175 triObj = new TriangleIntersectable(tri); 2176 triangles.push_back(triObj); 2177 2178 tri.mVertices[0] = Vector3(mMax.x, mMin.y, mMin.z); 2179 tri.mVertices[1] = Vector3(mMax.x, mMax.y, mMin.z); 2180 tri.mVertices[2] = Vector3(mMax.x, mMax.y, mMax.z); 2181 2182 triObj = new TriangleIntersectable(tri); 2183 triangles.push_back(triObj); 2184 2185 tri.mVertices[0] = Vector3(mMax.x, mMax.y, mMax.z); 2186 tri.mVertices[1] = Vector3(mMax.x, mMin.y, mMax.z); 2187 tri.mVertices[2] = Vector3(mMax.x, mMin.y, mMin.z); 2188 2189 triObj = new TriangleIntersectable(tri); 2190 triangles.push_back(triObj); 2191 2192 tri.mVertices[0] = Vector3(mMax.x, mMin.y ,mMin.z); 2193 tri.mVertices[1] = Vector3(mMax.x, mMin.y, mMax.z); 2194 tri.mVertices[2] = Vector3(mMin.x, mMin.y, mMax.z); 2195 2196 triObj = new TriangleIntersectable(tri); 2197 triangles.push_back(triObj); 2198 2199 tri.mVertices[0] = Vector3(mMin.x, mMin.y, mMax.z); 2200 tri.mVertices[1] = Vector3(mMin.x, mMin.y, mMin.z); 2201 tri.mVertices[2] = Vector3(mMax.x, mMin.y ,mMin.z); 2202 2203 2204 triObj = new TriangleIntersectable(tri); 2205 triangles.push_back(triObj); 2206 2207 tri.mVertices[0] = Vector3(mMin.x, mMax.y, mMin.z); 2208 tri.mVertices[1] = Vector3(mMin.x, mMax.y, mMax.z); 2209 tri.mVertices[2] = Vector3(mMax.x, mMax.y, mMax.z); 2210 2211 triObj = new TriangleIntersectable(tri); 2212 triangles.push_back(triObj); 2213 2214 tri.mVertices[0] = Vector3(mMax.x, mMax.y, mMax.z); 2215 tri.mVertices[1] = Vector3(mMax.x, mMax.y, mMin.z); 2216 tri.mVertices[2] = Vector3(mMin.x, mMax.y, mMin.z); 2217 2218 triObj = new TriangleIntersectable(tri); 2219 triangles.push_back(triObj); 2220 2221 tri.mVertices[0] = Vector3(mMin.x, mMax.y, mMin.z); 2222 tri.mVertices[1] = Vector3(mMax.x, mMax.y, mMin.z); 2223 tri.mVertices[2] = Vector3(mMax.x, mMin.y, mMin.z); 2224 2225 2226 triObj = new TriangleIntersectable(tri); 2227 triangles.push_back(triObj); 2228 2229 tri.mVertices[0] = Vector3(mMax.x, mMin.y, mMin.z); 2230 tri.mVertices[1] = Vector3(mMin.x, mMin.y, mMin.z); 2231 tri.mVertices[2] = Vector3(mMin.x, mMax.y, mMin.z); 2232 2233 triObj = new TriangleIntersectable(tri); 2234 triangles.push_back(triObj); 2235 2236 tri.mVertices[0] = Vector3(mMin.x, mMin.y, mMax.z); 2237 tri.mVertices[1] = Vector3(mMax.x, mMin.y, mMax.z); 2238 tri.mVertices[2] = Vector3(mMax.x, mMax.y, mMax.z); 2239 2240 2241 triObj = new TriangleIntersectable(tri); 2242 triangles.push_back(triObj); 2243 2244 tri.mVertices[0] = Vector3(mMax.x, mMax.y, mMax.z); 2245 tri.mVertices[1] = Vector3(mMin.x, mMax.y, mMax.z); 2246 tri.mVertices[2] = Vector3(mMin.x, mMin.y, mMax.z); 2247 2248 triObj = new TriangleIntersectable(tri); 2249 triangles.push_back(triObj); 2138 2250 } 2139 2251 -
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h
r2691 r2720 165 165 void 166 166 GetSqrDistances(const Vector3 &point, 167 float &minDistance, 168 float &maxDistance 169 ) const; 167 float &minDistance, 168 float &maxDistance) const; 170 169 171 170 // returns true, when the sphere specified by the origin and radius … … 377 376 */ 378 377 void ExtractPolys(PolygonContainer &polys) const; 379 378 /** Triangulate the box. 379 */ 380 void Triangulate(ObjectContainer &triangles) const; 380 381 /** Returns true if the mesh intersects the bounding box. 381 382 */ -
GTP/trunk/Lib/Vis/Preprocessing/src/GtpVisibility05.vcproj
r2709 r2720 529 529 > 530 530 <File 531 RelativePath=".\AxisAlignedBox3.cpp" 532 > 533 </File> 534 <File 531 535 RelativePath=".\AxisAlignedBox3.h" 532 536 > … … 952 956 > 953 957 <File 954 RelativePath=".\AxisAlignedBox3.cpp"955 >956 </File>957 <File958 958 RelativePath=".\Beam.cpp" 959 959 > -
GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.h
r2176 r2720 105 105 */ 106 106 void Triangulate(vector<Triangle3> &triangles) const; 107 108 /** 109 Triangle strip indices are created from this polgon. 107 /** Triangle strip indices are created from this polgon. 110 108 */ 111 109 void Triangulate(VertexIndexContainer &indices) const; -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r2716 r2720 1608 1608 1609 1609 1610 SceneGraphLeaf *Preprocessor::GenerateBoxGeometry(const AxisAlignedBox3 &box) 1611 { 1612 float offs = box.Min().y; 1613 AxisAlignedBox3 newBox = box; 1614 newBox.Translate(Vector3(0.0f, -offs, 0.0f)); 1615 1616 const bool dynamic = true; 1617 SceneGraphLeaf *leaf = new SceneGraphLeaf(dynamic); 1618 newBox.Triangulate(leaf->mGeometry); 1619 1620 leaf->UpdateBox(); 1621 1622 return leaf; 1623 } 1624 1625 1610 1626 SceneGraphLeaf *Preprocessor::LoadDynamicGeometry(const string &filename) 1611 1627 { … … 1678 1694 return NULL; 1679 1695 } 1696 1697 1698 float Preprocessor::_HackComputeRenderCost(ViewCell *vc) 1699 { 1700 ObjectPvs basePvs; 1701 1702 basePvs = vc->CopyPvs(); 1703 ObjectPvsIterator pit = basePvs.GetIterator(); 1704 1705 float renderCost = 0; 1706 1707 // first mark all objects from this pvs 1708 while (pit.HasMoreEntries()) 1709 { 1710 Intersectable *obj = pit.Next(); 1711 1712 if (obj->Type() == Intersectable::KD_INTERSECTABLE) 1713 { 1714 KdIntersectable *kdObj = static_cast<KdIntersectable *>(pit.Next()); 1715 1716 /*if (mShowDistanceWeightedPvs) 1717 { 1718 const AxisAlignedBox3 box = kdObj->GetBox(); 1719 1720 const float dist = SqrDistance(vc->GetBox().Center(), box.Center()); 1721 renderCost += 1.0f / dist; 1722 } 1723 else if (mShowDistanceWeightedTriangles) 1724 { 1725 const AxisAlignedBox3 box = kdObj->GetBox(); 1726 1727 const float dist = SqrDistance(vc->GetBox().Center(), box.Center()); 1728 renderCost += kdObj->ComputeNumTriangles() / dist; 1729 } 1730 else //if (mShowWeightedTriangles) 1731 { 1732 */ 1733 renderCost += kdObj->ComputeNumTriangles(); 1734 //} 1735 } 1736 } 1737 1738 return renderCost; 1739 } 1740 1741 1680 1742 1681 1743 … … 1696 1758 // now search for pvss which contained any mailed node 1697 1759 for (vit = mViewCellsManager->GetViewCells().begin(); vit != vit_end; ++ vit) { 1698 ObjectPvs &pvs = (*vit)->GetPvs(); 1699 if (Overlap(box, (*vit)->GetBox())) { 1700 pvs.Clear(); 1701 removedEntries += pvs.GetSize(); 1702 } else { 1703 // cout<<(*vit)->GetBox()<<" "<<box<<endl; 1704 shadowVolume.Init((*vit)->GetBox(), box); 1705 if (shadowVolume.CntPlanes() > maxPlanes) 1706 maxPlanes = shadowVolume.CntPlanes(); 1707 1708 int j = 0; 1709 for (int i=0; i < pvs.mEntries.size(); i++) { 1710 allEntries++; 1711 Intersectable *o = pvs.mEntries[i].mObject; 1712 if (o == inter) { 1713 removedSelfEntries++; 1714 } else { 1715 if (!shadowVolume.TestIsInsideShaft(o->GetBox())) { 1716 if (j != i) 1717 pvs.mEntries[j] = pvs.mEntries[i]; 1718 j++; 1719 } else { 1720 removedEntries++; 1760 ObjectPvs &pvs = (*vit)->GetPvs(); 1761 if (Overlap(box, (*vit)->GetBox())) { 1762 pvs.Clear(); 1763 removedEntries += pvs.GetSize(); 1764 } else { 1765 // cout<<(*vit)->GetBox()<<" "<<box<<endl; 1766 shadowVolume.Init((*vit)->GetBox(), box); 1767 if (shadowVolume.CntPlanes() > maxPlanes) 1768 maxPlanes = shadowVolume.CntPlanes(); 1769 1770 int j = 0; 1771 for (int i=0; i < pvs.mEntries.size(); i++) { 1772 allEntries++; 1773 Intersectable *o = pvs.mEntries[i].mObject; 1774 if (o == inter) { 1775 removedSelfEntries++; 1776 } else { 1777 if (!shadowVolume.TestIsInsideShaft(o->GetBox())) { 1778 if (j != i) 1779 pvs.mEntries[j] = pvs.mEntries[i]; 1780 j++; 1781 } else { 1782 removedEntries++; 1783 } 1784 } 1721 1785 } 1722 } 1786 // now the pvs has to be resorted 1787 pvs.mLastSorted = 0; 1788 if (j==0) 1789 pvs.mEntries.clear(); 1790 else { 1791 pvs.mEntries.resize(j); 1792 if (j>1) 1793 pvs.SimpleSort(); 1794 } 1723 1795 } 1724 // now the pvs has to be resorted 1725 pvs.mLastSorted = 0; 1726 if (j==0) 1727 pvs.mEntries.clear(); 1728 else { 1729 pvs.mEntries.resize(j); 1730 if (j>1) 1731 pvs.SimpleSort(); 1732 } 1733 } 1796 1797 ViewCell *vc = *vit; 1798 1799 // recompute render cost 1800 float renderCost = _HackComputeRenderCost(vc); 1801 vc->GetPvs().mStats.mWeightedTriangles = renderCost; 1734 1802 } 1735 1803 … … 1754 1822 if (mUpdateDynamicObjects) 1755 1823 { 1756 1757 1824 // delete ALL dynamic stuff and rebuild using the new trafos 1758 1825 preprocessor->mRayCaster->DeleteDynamicObjects(); 1759 1826 1760 #define MULTIPLE_OBJECTS 11827 #define MULTIPLE_OBJECTS 0 1761 1828 1762 1829 #if MULTIPLE_OBJECTS 1763 1830 static ObjectContainer objects; 1764 1765 1831 CLEAR_CONTAINER(objects); 1766 1832 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r2715 r2720 208 208 virtual void ObjectRemoved(SceneGraphLeaf *object); 209 209 210 210 SceneGraphLeaf *GenerateBoxGeometry(const AxisAlignedBox3 &box); 211 212 float _HackComputeRenderCost(ViewCell *vc); 211 213 212 214 ///////////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/ObjectPlacer.cpp
r2710 r2720 63 63 AxisAlignedBox3 box = leaf->GetBox(); 64 64 65 Vector3 p = box.Center() - pt; ;65 Vector3 p = box.Center() - pt; 66 66 67 67 // set pivot to ground of object -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2719 r2720 589 589 590 590 //cout << "dynamic objects in pvs " << mDynamicPvsObjects.size() << endl;; 591 591 #if 0 592 592 for (dit = mDynamicPvsObjects.begin(); dit != dit_end; ++ dit) 593 593 { 594 594 _RenderDynamicObject(*dit); 595 595 } 596 597 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);596 #endif 597 //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 598 598 599 599 // show placed dynamic objects as wireframe … … 789 789 790 790 int pixelCount = query->GetQueryResult(); 791 pErrorPixels = ( (float)pixelCount)/ (GetWidth() * GetHeight());791 pErrorPixels = (float)pixelCount / (GetWidth() * GetHeight()); 792 792 793 793 if (0) cout << "error pixels=" << pixelCount << endl; … … 1347 1347 void QtGlRendererWidget::LoadObjects() 1348 1348 { 1349 AxisAlignedBox3 sceneBox = mViewCellsManager->GetViewSpaceBox(); 1350 1351 float x = 1.0f; 1352 float y = 20.0f; 1353 float z = 80.0f; 1354 1355 AxisAlignedBox3 box(Vector3(0.5f * x, 0, -0.5f * z), Vector3(-0.5f * x, y, 0.5f * z)); 1356 1357 // box.Scale(Vector3(0.02f, 0.1f, 0.1f)); 1358 1359 box.Translate(-box.Min()); 1360 1361 SceneGraphLeaf *leaf = GetPreprocessor()->GenerateBoxGeometry(box); 1362 mPlacer->AddObject(leaf); 1363 1349 1364 LoadObject("../data/teapot.bn"); 1350 1365 LoadObject("../data/bunny.bn"); … … 1625 1640 } 1626 1641 1627 #if 01628 float QtGlRendererWidget::ComputeRenderCost(ViewCell *vc)1629 {1630 ObjectPvs basePvs;1631 1632 basePvs = vc->CopyPvs();1633 ObjectPvsIterator pit = basePvs.GetIterator();1634 1635 float renderCost = 0;1636 1637 //cout << "cost vis: " << mShowDistanceWeightedPvs << " " << " " << mShowDistanceWeightedTriangles << " " << mShowWeightedTriangles << endl;1638 1639 // first mark all objects from this pvs1640 while (pit.HasMoreEntries())1641 {1642 KdIntersectable *kdObj = static_cast<KdIntersectable *>(pit.Next());1643 1644 if (mShowDistanceWeightedPvs)1645 {1646 const AxisAlignedBox3 box = kdObj->GetBox();1647 1648 const float dist = SqrDistance(vc->GetBox().Center(), box.Center());1649 renderCost += 1.0f / dist;1650 }1651 else if (mShowDistanceWeightedTriangles)1652 {1653 const AxisAlignedBox3 box = kdObj->GetBox();1654 1655 const float dist = SqrDistance(vc->GetBox().Center(), box.Center());1656 renderCost += kdObj->ComputeNumTriangles() / dist;1657 }1658 else //if (mShowWeightedTriangles)1659 {1660 renderCost += kdObj->ComputeNumTriangles();1661 }1662 //if (pit.Next()->Mail();1663 }1664 1665 return renderCost;1666 }1667 #else1668 1642 1669 1643 float QtGlRendererWidget::ComputeRenderCost(ViewCell *vc) … … 1688 1662 #endif 1689 1663 } 1690 #endif1691 1692 1664 1693 1665 … … 1946 1918 if (0 && (i < 20)) 1947 1919 { 1948 cout << "pvs1: " << vc->GetPvs().GetSize() << " pvs2: " << compareInfo[i].mPvsSize << " importance: " << importance << endl; 1920 cout << "pvs1: " << vc->GetPvs().GetSize() << " pvs2: " 1921 << compareInfo[i].mPvsSize << " importance: " << importance << endl; 1949 1922 } 1950 1923 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2710 r2720 368 368 const bool isTermination) const 369 369 { 370 //if (!ray.mTerminationObject) return NULL; 371 370 372 // dynamic objects are scene graph leaves 371 373 const int index = ray.mTerminationObject->GetId(); 374 372 375 if (index >= mPreprocessor->mObjects.size()) 373 376 { 377 // Do nothing 378 return NULL; 374 379 for (size_t i = 0; i < mPreprocessor->mDynamicObjects.size(); ++ i) 375 380 {
Note: See TracChangeset
for help on using the changeset viewer.