Changeset 544 for trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
- Timestamp:
- 01/16/06 19:33:48 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r535 r544 9 9 #include "AxisAlignedBox3.h" 10 10 #include "Triangle3.h" 11 #include "Tetrahedron3.h" 11 12 12 13 #include <stack> … … 2549 2550 2550 2551 2552 float BspNodeGeometry::GetVolume() const 2553 { 2554 //-- compute volume using tetrahedralization of the geometry 2555 // and adding the volume of the single tetrahedrons 2556 float volume = 0; 2557 const float f = 1.0f / 6.0f; 2558 2559 PolygonContainer::const_iterator pit, pit_end = mPolys.end(); 2560 2561 for (pit = mPolys.begin(); pit != pit_end; ++ pit) 2562 { 2563 Polygon3 *poly = *pit; 2564 const Vector3 v = poly->mVertices[0]; 2565 2566 for (int i = 1; i < (int)poly->mVertices.size() - 1; ++ i) 2567 { 2568 volume += f * (DotProd(v, 2569 CrossProd(poly->mVertices[i], poly->mVertices[i + 1]))); 2570 } 2571 } 2572 2573 Debug << "volume: " << volume << endl; 2574 return volume; 2575 } 2576 2577 2578 Vector3 BspNodeGeometry::ComputeMassCenter() const 2579 { 2580 int n = 0; 2581 2582 Vector3 center(0,0,0); 2583 2584 PolygonContainer::const_iterator pit, pit_end = mPolys.end(); 2585 2586 for (pit = mPolys.begin(); pit != pit_end; ++ pit) 2587 { 2588 Polygon3 *poly = *pit; 2589 2590 VertexContainer::const_iterator vit, vit_end = poly->mVertices.end(); 2591 2592 for(vit = poly->mVertices.begin(); vit != vit_end; ++ vit) 2593 { 2594 center += *vit; 2595 ++ n; 2596 } 2597 } 2598 2599 return center / (float)n; 2600 } 2601 2602 2551 2603 void BspNodeGeometry::AddToMesh(Mesh &mesh) 2552 2604 {
Note: See TracChangeset
for help on using the changeset viewer.