| VRS - The Virtual Rendering System |
| version 3.3 |
#include <vrs/sg/scenegraphanalyzer.h>

Public Types | |
| enum | ClipMode { CLIPMODE_INSIDE, CLIPMODE_PARTIALLY_INSIDE, CLIPMODE_PARTIALLY_OUTSIDE, CLIPMODE_OUTSIDE } |
| enum | ClipMask { CLIPMASK_IGNORE_X = 1, CLIPMASK_IGNORE_Y = 2, CLIPMASK_IGNORE_Z = 4 } |
| enum | ShapeType { SH_PolygonSet, SH_MappedVertexAttributeShapeGL } |
| Converts all PolygonSets to MappedVertexAttributeShapeGL or vice versa. More... | |
Static Public Member Functions | |
| static SO< Iterator< const ClassInfo * > > | findClasses (SO< SceneThing > scene, bool traverseSceneThingsOnly=false) |
| findClasses() creates an iterator of all classes of the objects in the scene graph. | |
| static Result | findObjects (const ID &className, SO< SceneThing > scene, bool traverseSceneThingsOnly=false) |
| Given a class name and a SceneGraph this methods collects all RenderObjs of the given class. | |
| static SO< Iterator< SO < RenderObj > > > | findLeafs (SO< SceneThing > scene) |
| Returns an iterator containing all leafs of the scene graph,. | |
| static SO< SceneThing > | createOptimizedScene (SO< SceneThing > scene, bool checkPreconditions=true, bool useStaticLighting=false) |
| Creates an optimized scene graph by removing redundancies. | |
| template<class T> | |
| static void | replaceSceneObjects (SO< SceneThing > scene, const VRS::ID &className, SO< CallbackR2< Iterator< SO< SharedObj > > *, SharedObj *, T > > replaceCB, T userData) |
| replaceSceneObjects() traverses the scene graph. | |
| static void | replaceSceneObjects (SO< SceneThing > scene, const VRS::ID &className, SO< CallbackR1< Iterator< SO< SharedObj > > *, SharedObj * > > replaceCB=0) |
| static void | clipScene (SO< SceneThing > target, const Bounds &bounds, ClipMode mode, ClipMask mask=ClipMask(0), bool enablePolygonSetClipping=false) |
| Removes all subgraphs and polygonset inside, intersecting, or not intersecting (dependent on 'mode') subgraphs and shapes. | |
| static SO< Iterator< SO < PolygonSet > > > | collapseScene (SO< SceneThing > scene, bool changeScene=false) |
| Collects all PolygonSets of a scene and transforms them according to the corresponding transforms in the scene graph. | |
| static void | extractTexturedShapes (std::vector< SceneGraphAnalyzer::TexturedShapes > &outTexturedShapes, SO< SceneThing > scene) |
| static void | KillLowerLODs (SO< SceneThing > target) |
| Extracting all shapes from a Scene containing LOD nodes leads to merging of different LODs. | |
| static SO< SceneThing > | flattenScene (SO< SceneThing > scene) |
| Collects all PolygonSets of a scene and transforms them according to the corresponding transforms in the scene graph. | |
| static std::pair< SO < SceneThing >, SO< SceneThing > > | extractNormalMappedPolygonSets (SO< SceneThing > scene) |
This method splits a scene into two parts: a) input scene without the parts described in b) b) all Polygonsets that occure after a NormalmapGL attribute in the scene graph Note:
| |
| static std::pair< SO < SceneThing >, SO< SceneThing > > | splitScene (VRS::SO< VRS::SceneThing > scene, double alphaThreshold=0.9) |
This method splits a scene into two parts: a) Completely opaque objects (first result) (all alpha values above "alphaThreshold") b) Semitransparent or complete objects (second result) Note:
| |
| static void | convertToPrimitiveQuadTree (SO< SceneThing > &scene, unsigned int desiredLeafVertexCount=1000) |
| This method converts all PolygonSets and MappedVertexAttributeShapes into PrimitiveQuadTrees Only shapes with more than minVertexCount are affected. | |
| static void | forceShapeType (SO< SceneThing > scene, enum ShapeType) |
| static void | forceTriangleMeshes (SO< SceneThing > scene, bool indexed) |
| Converts all PolygonSets in a scene to triangle meshes. | |
| static void | applyBatchSegmentation (SO< SceneThing > scene, unsigned int maxBatchSize=0xFFFF) |
| Vertex buffers of size 0xFFFF or less allow for using unsigned short indices, which are more efficient to store and render. | |
| static void | applyVertexCacheOptimization (SO< SceneThing > scene) |
| Sorts the triangles of each indexed triangle mesh according to vertex-cache coherency to optimize rendering performance. | |
| static void | optimizeMeshes (SO< SceneThing > scene, unsigned int maxBatchSize=0xFFFF) |
| Combines the methods above in a mesh optimization procedure. | |
| static int | countTriangles (SO< SceneThing > scene) |
| Traverse the scene with a visitor and counts the number of triangles for all occurrences of PolygonSet and MappedVertexAttributeShape and sums up their triangle count. | |
| static void | InvertOrientation (SO< SceneNode > target) |
| Traverses target with a visitor that calls invertOrientation() for all found PolygonSets and MappedVertexAttributeShapes. | |
| static bool | ValidatePolygonSets (SO< SceneNode > target, bool fixErrors=false) |
| Checks all PolygonSets in a Scene using PolygonSetTool::isValid(). | |
Classes | |
| struct | Result |
| struct | TexturedShapes |
| For simple scenes (no special nodes) containing Textures and PolygonSets, this method extracts all PolygonSets and corresponding textures. More... | |
provided by a loaded 3ds file. NOTE: If the scene graph contains some special SceneNodes which influence their contained objects (e.g. SceneAdjuster), their effect is not represented in the iterator of context objects. For this, the methods have a bool parameter traverseSceneThingsOnly. If it is set to true, all SceneNodes that are not instances of SceneThing (and therefore have unknown effect on its contained objects) are handled as atomic objects, i.e. they are not traversed.
Converts all PolygonSets to MappedVertexAttributeShapeGL or vice versa.
Note the restrictions of the conversion, stated in mappedvertexattributeshapegl.h.
| static SO<Iterator<const ClassInfo*> > VRS::SceneGraphAnalyzer::findClasses | ( | SO< SceneThing > | scene, | |
| bool | traverseSceneThingsOnly = false | |||
| ) | [static] |
findClasses() creates an iterator of all classes of the objects in the scene graph.
More exactly the result contains one ClassInfo pointer for each class present in the scene.
| static Result VRS::SceneGraphAnalyzer::findObjects | ( | const ID & | className, | |
| SO< SceneThing > | scene, | |||
| bool | traverseSceneThingsOnly = false | |||
| ) | [static] |
Given a class name and a SceneGraph this methods collects all RenderObjs of the given class.
Usually it will be used for Shapes or more specificly for PolygonSets.
| static SO<Iterator<SO<RenderObj> > > VRS::SceneGraphAnalyzer::findLeafs | ( | SO< SceneThing > | scene | ) | [static] |
Returns an iterator containing all leafs of the scene graph,.
i.e. all RenderObjs being the last object contained in a SceneNode.
| static SO<SceneThing> VRS::SceneGraphAnalyzer::createOptimizedScene | ( | SO< SceneThing > | scene, | |
| bool | checkPreconditions = true, |
|||
| bool | useStaticLighting = false | |||
| ) | [static] |
Creates an optimized scene graph by removing redundancies.
E.g. if there is a SceneThing with two subscenes both containing a pointer to the same texture and respectively a shape, it will be replaced by one subscene containing the texture reference and both shapes. If checkPreconditions is false, the preconditions described below are not checked. Therefore there is no warranty for the returned scene to contain the full information of the source scene. If checkPreconditions is true, NULL is returned for an unsuitable input scene graph.
Note:
| static void VRS::SceneGraphAnalyzer::replaceSceneObjects | ( | SO< SceneThing > | scene, | |
| const VRS::ID & | className, | |||
| SO< CallbackR2< Iterator< SO< SharedObj > > *, SharedObj *, T > > | replaceCB, | |||
| T | userData | |||
| ) | [inline, static] |
replaceSceneObjects() traverses the scene graph.
Each instance of 'className' (or a derivation) is removed and passed to the replaceCallback. All objects returned by the callback are inserted into the scene graph at the position where the previous object had been removed. If 'callback' is NULL, the objects are removed only. The pointer 'userData' is passed to the callback in each call. Note: The method works only for Objects that are contained in SceneThings (or derivations of SceneThing). For other nodes, it cannot be known how to replace objects.
| static void VRS::SceneGraphAnalyzer::replaceSceneObjects | ( | SO< SceneThing > | scene, | |
| const VRS::ID & | className, | |||
| SO< CallbackR1< Iterator< SO< SharedObj > > *, SharedObj * > > | replaceCB = 0 | |||
| ) | [static] |
| static void VRS::SceneGraphAnalyzer::clipScene | ( | SO< SceneThing > | target, | |
| const Bounds & | bounds, | |||
| ClipMode | mode, | |||
| ClipMask | mask = ClipMask(0), |
|||
| bool | enablePolygonSetClipping = false | |||
| ) | [static] |
Removes all subgraphs and polygonset inside, intersecting, or not intersecting (dependent on 'mode') subgraphs and shapes.
Note: clipScene does only subdivide SceneThings. Other kinds of scene nodes are handled like shapes, i.e. they are either removed or retained, but never split. Using 'mask' you can specify that only certain axes are considered, e.g., one can split in (x,y) by setting mask to CLIPMASK_IGNORE_Z. If enablePolygonSetClipping is true, polygonsets in the scene graph are clipped on a per triangle basis. When setting it to true, note:
Note: In the current implementation, transformations are not yet considered!
| static SO<Iterator<SO<PolygonSet> > > VRS::SceneGraphAnalyzer::collapseScene | ( | SO< SceneThing > | scene, | |
| bool | changeScene = false | |||
| ) | [static] |
Collects all PolygonSets of a scene and transforms them according to the corresponding transforms in the scene graph.
The return value contains all appropriately transformed PolygonSets of the scene. If 'changeScene' is true, all transforms within the scene are removed and the vertices of the original PolygonSets within the scene are directly changed. In this case, the return iterator contains pointer to the transformed original PolygonSets. Otherwise, (for 'changeScene' = false) the returned iterator contains transformed copies of the scene PolygonSets. Note the following restrictions:
| static void VRS::SceneGraphAnalyzer::extractTexturedShapes | ( | std::vector< SceneGraphAnalyzer::TexturedShapes > & | outTexturedShapes, | |
| SO< SceneThing > | scene | |||
| ) | [static] |
| static void VRS::SceneGraphAnalyzer::KillLowerLODs | ( | SO< SceneThing > | target | ) | [static] |
Extracting all shapes from a Scene containing LOD nodes leads to merging of different LODs.
To avoid this, this method reduces all LOD nodes to their maximum LOD.
| static SO<SceneThing> VRS::SceneGraphAnalyzer::flattenScene | ( | SO< SceneThing > | scene | ) | [static] |
Collects all PolygonSets of a scene and transforms them according to the corresponding transforms in the scene graph.
The return scene graph is a copy of the original one. No objects are modified. The returned scene contains one sub-scene per PolygonSet and each sub-scene contains all attributes influencing the corresponding PolygonSet-object. Note the following restrictions:
| static std::pair<SO<SceneThing>, SO<SceneThing> > VRS::SceneGraphAnalyzer::extractNormalMappedPolygonSets | ( | SO< SceneThing > | scene | ) | [static] |
This method splits a scene into two parts: a) input scene without the parts described in b) b) all Polygonsets that occure after a NormalmapGL attribute in the scene graph Note:
| static std::pair<SO<SceneThing>, SO<SceneThing> > VRS::SceneGraphAnalyzer::splitScene | ( | VRS::SO< VRS::SceneThing > | scene, | |
| double | alphaThreshold = 0.9 | |||
| ) | [static] |
This method splits a scene into two parts: a) Completely opaque objects (first result) (all alpha values above "alphaThreshold") b) Semitransparent or complete objects (second result) Note:
| static void VRS::SceneGraphAnalyzer::convertToPrimitiveQuadTree | ( | SO< SceneThing > & | scene, | |
| unsigned int | desiredLeafVertexCount = 1000 | |||
| ) | [static] |
This method converts all PolygonSets and MappedVertexAttributeShapes into PrimitiveQuadTrees Only shapes with more than minVertexCount are affected.
No other optimizations are performed (use respective methods before this one)
| static void VRS::SceneGraphAnalyzer::forceShapeType | ( | SO< SceneThing > | scene, | |
| enum | ShapeType | |||
| ) | [static] |
| static void VRS::SceneGraphAnalyzer::forceTriangleMeshes | ( | SO< SceneThing > | scene, | |
| bool | indexed | |||
| ) | [static] |
Converts all PolygonSets in a scene to triangle meshes.
The following shapes will be ignored (=> left unchanged):
| static void VRS::SceneGraphAnalyzer::applyBatchSegmentation | ( | SO< SceneThing > | scene, | |
| unsigned int | maxBatchSize = 0xFFFF | |||
| ) | [static] |
Vertex buffers of size 0xFFFF or less allow for using unsigned short indices, which are more efficient to store and render.
Therefore, this method splits large triangle meshes into a set of smaller ones, whereby each mesh has 0xFFFF or less vertices. This method has only effect for indexed triangle meshes.
| static void VRS::SceneGraphAnalyzer::applyVertexCacheOptimization | ( | SO< SceneThing > | scene | ) | [static] |
Sorts the triangles of each indexed triangle mesh according to vertex-cache coherency to optimize rendering performance.
| static void VRS::SceneGraphAnalyzer::optimizeMeshes | ( | SO< SceneThing > | scene, | |
| unsigned int | maxBatchSize = 0xFFFF | |||
| ) | [static] |
Combines the methods above in a mesh optimization procedure.
As a result, all shapes (PolygonSets as well as MappedVertexAttributeShapes) are converted to vertex-cache-optimized batches of the given size. These batches are finally stored as MappedVertexAttributeShapes. Note: This optimization procedure does not yet address the problem of too many small shapes.
| static int VRS::SceneGraphAnalyzer::countTriangles | ( | SO< SceneThing > | scene | ) | [static] |
Traverse the scene with a visitor and counts the number of triangles for all occurrences of PolygonSet and MappedVertexAttributeShape and sums up their triangle count.
Note: Only simple triangle meshes are supported. Other primitve types or shapes with range iterators are skipped.
Traverses target with a visitor that calls invertOrientation() for all found PolygonSets and MappedVertexAttributeShapes.
| static bool VRS::SceneGraphAnalyzer::ValidatePolygonSets | ( | SO< SceneNode > | target, | |
| bool | fixErrors = false | |||
| ) | [static] |
Checks all PolygonSets in a Scene using PolygonSetTool::isValid().
If everything is okay, it returns true. If fixErrors is set, PolygonSetTool::ValidatePolygonSet is applied to all invalid shapes, so that the shape validity is ensured. Note: