|
AGX Dynamics 2.42.1.1
|
Checks all primitive sets of a render geometry for triangles and sort the triangles back to front given camera model view matrix and vertex depth reduce function [d1, d2, d3] -> d. More...
#include <TransparencyUtils.h>
Classes | |
| struct | TriangleDepth |
Public Types | |
| using | DepthReduceFunc = std::function< float(TriangleVertexDepths)> |
| using | TriangleVertexDepths = const std::array< float, 3u > & |
Static Public Member Functions | |
| template<typename TriangleBuffer > | |
| static bool | impl (TriangleBuffer &triangles, const osg::Vec3Array &vertices, const osg::Matrixf &modelViewMatrix, const DepthReduceFunc &depthReduce) |
| Implementation of the sorting when triangle primitive sets can be many things. | |
| static float | maxOf (TriangleVertexDepths depths) |
| Depth reduce as max([d1, d2, d3]). | |
| static float | midOf (TriangleVertexDepths depths) |
| Depth reduce as avg([d1, d2, d3]). | |
| static float | minOf (TriangleVertexDepths depths) |
| Depth reduce as min([d1, d2, d3]). | |
| static bool | sort (osg::Geometry &geometry, const osg::Matrixf &modelViewMatrix, DepthReduceFunc depthReduce=midOf) |
Sort all triangle primitive sets of the given geometry. | |
Checks all primitive sets of a render geometry for triangles and sort the triangles back to front given camera model view matrix and vertex depth reduce function [d1, d2, d3] -> d.
Default reduce is triangle centroid.
To get/find the model view matrix, the camera has to be given. If the camera is around, the model view matrix is:
const auto modelToWorld = osg::computeLocalToWorld( visualGeometryOrTransform->getParentalNodePaths()[ 0 ] ); const auto worldToEye = camera->getViewMatrix(); const auto modelViewMatrix = modelToWorld * worldToEye; agxOSG::PrimitiveSetTriangleSorter::sort( *geometry, modelViewMatrix );
if the camera isn't around, use agxOSG::ModelViewMatrixFinder below like: geometry->setCullCallback( new agxOSG::ModelViewMatrixFinder( [geometry]( const osg::Matrixf& modelViewMatrix ) { agxOSG::PrimitiveSetTriangleSorter::sort( *geometry, modelViewMatrix ); } );
Definition at line 73 of file TransparencyUtils.h.
| using agxOSG::PrimitiveSetTriangleSorter::DepthReduceFunc = std::function<float( TriangleVertexDepths )> |
Definition at line 77 of file TransparencyUtils.h.
| using agxOSG::PrimitiveSetTriangleSorter::TriangleVertexDepths = const std::array<float, 3u>& |
Definition at line 76 of file TransparencyUtils.h.
|
inlinestatic |
Implementation of the sorting when triangle primitive sets can be many things.
E.g., osg::DrawElementsUByte osg::DrawElementsUShort osg::DrawElementsUInt
Requirements on the triangles container is that the triangles.size % 3 == 0, i.e., triangles.size / 3 == number of triangles, and typename TriangleBuffer::value_type is the index type.
| triangles | - triangles container (size = 3 * vertices.size) |
| vertices | - triangle vertices |
| modelViewMatrix | - camera view of the triangles, the model view matrix |
| depthReduce | - triangle vertex (camera) depth reduce function |
Definition at line 142 of file TransparencyUtils.h.
|
inlinestatic |
Depth reduce as max([d1, d2, d3]).
| depths | - triangle vertex depths |
depths Definition at line 204 of file TransparencyUtils.h.
|
inlinestatic |
Depth reduce as avg([d1, d2, d3]).
| depths | - triangle vertex depths |
depths Definition at line 199 of file TransparencyUtils.h.
|
inlinestatic |
Depth reduce as min([d1, d2, d3]).
| depths | - triangle vertex depths |
depths Definition at line 191 of file TransparencyUtils.h.
|
static |
Sort all triangle primitive sets of the given geometry.
If only a specific set should be sorted, use: agxOSG::PrimitiveSetTriangleSorter::impl( dynamic_cast<TypeOfTheSet&>( *geometry->getPrimitiveSet( 7 ), mvm )
| geometry | - geometry with triangles |
| modelViewMatrix | - geometry to camera view matrix |
| depthReduce | - triangle vertex depths (as seen from the camera) reduce function [d1, d2, d3] -> d, where d is sorted for, highest to lowest |