00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 #ifndef VRS_SG_SCENEGRAPHANALYZER_H
00118 #define VRS_SG_SCENEGRAPHANALYZER_H
00119
00120 #include <vrs/scenenodevisitor.h>
00121 #include <vrs/bounds.h>
00122
00123 namespace VRS {
00124
00125 template<typename T> class Iterator;
00126 template<class RETURN, class ARG1, class ARG2> class CallbackR2;
00127 template<class RETURN, class ARG1> class CallbackR1;
00128
00129 class PolygonSet;
00130 class RenderObj;
00131 class SceneThing;
00132 class TexEnvGL;
00133 class TextureGL;
00134 class Texture2DGL;
00135 class MonoAttribute;
00136
00148 class VRS_CORE_API SceneGraphAnalyzer :
00149 public SharedObj
00150 {
00151 public:
00152
00156 static SO<Iterator<const ClassInfo*> > findClasses(
00157 SO<SceneThing> scene,
00158 bool traverseSceneThingsOnly = false
00159 );
00160
00161 struct Result {
00164 SO<Iterator<SO<SharedObj> > > objects;
00165 SO<Iterator<SO<Iterator<SO<RenderObj> > > > > contextObjects;
00166 };
00167
00179 static Result findObjects(
00180 const ID& className,
00181 SO<SceneThing> scene,
00182 bool traverseSceneThingsOnly = false
00183 );
00184
00187 static SO<Iterator<SO<RenderObj> > > findLeafs(
00188 SO<SceneThing> scene
00189 );
00190
00233 static SO<SceneThing> createOptimizedScene(
00234 SO<SceneThing> scene,
00235 bool checkPreconditions = true,
00236 bool useStaticLighting = false
00237 );
00238
00239
00248 template<class T>
00249 static void replaceSceneObjects(
00250 SO<SceneThing> scene,
00251 const VRS::ID& className,
00252 SO<CallbackR2<Iterator<SO<SharedObj> >*, SharedObj*, T> > replaceCB,
00253 T userData
00254 );
00255
00256 static void replaceSceneObjects(
00257 SO<SceneThing> scene,
00258 const VRS::ID& className,
00259 SO<CallbackR1<Iterator<SO<SharedObj> >*, SharedObj*> > replaceCB = 0
00260 );
00261
00262 enum ClipMode { CLIPMODE_INSIDE, CLIPMODE_PARTIALLY_INSIDE, CLIPMODE_PARTIALLY_OUTSIDE, CLIPMODE_OUTSIDE };
00263 enum ClipMask { CLIPMASK_IGNORE_X = 1, CLIPMASK_IGNORE_Y = 2, CLIPMASK_IGNORE_Z = 4 };
00264
00277
00278 static void clipScene(
00279 SO<SceneThing> target,
00280 const Bounds& bounds,
00281 ClipMode mode,
00282 ClipMask mask = ClipMask(0),
00283 bool enablePolygonSetClipping = false
00284 );
00285
00298 static SO<Iterator<SO<PolygonSet> > > collapseScene(
00299 SO<SceneThing> scene,
00300 bool changeScene = false
00301 );
00302
00310 struct TexturedShapes {
00311 SO<TextureGL> texture;
00312 std::vector<SO<TexEnvGL> > texEnvs;
00313 std::vector<SO<MonoAttribute> > colors;
00314 std::vector<SO<PolygonSet> > shapes;
00315 };
00316 static void extractTexturedShapes(
00317 std::vector<SceneGraphAnalyzer::TexturedShapes>& outTexturedShapes,
00318 SO<SceneThing> scene
00319 );
00320
00323 static void KillLowerLODs(SO<SceneThing> target);
00324
00334 static SO<SceneThing> flattenScene(
00335 SO<SceneThing> scene
00336 );
00337
00345 static std::pair<SO<SceneThing>, SO<SceneThing> > extractNormalMappedPolygonSets(SO<SceneThing> scene);
00346
00359 static std::pair<SO<SceneThing>, SO<SceneThing> > splitScene(
00360 VRS::SO<VRS::SceneThing> scene,
00361 double alphaThreshold = 0.9
00362 );
00363
00367 static void convertToPrimitiveQuadTree(SO<SceneThing> &scene, unsigned int desiredLeafVertexCount = 1000);
00368
00371 enum ShapeType { SH_PolygonSet, SH_MappedVertexAttributeShapeGL };
00372 static void forceShapeType(SO<SceneThing> scene, enum ShapeType);
00373
00378 static void forceTriangleMeshes(SO<SceneThing> scene, bool indexed);
00379
00385 static void applyBatchSegmentation(SO<SceneThing> scene, unsigned int maxBatchSize = 0xFFFF);
00386
00389 static void applyVertexCacheOptimization(SO<SceneThing> scene);
00390
00397 static void optimizeMeshes(SO<SceneThing> scene, unsigned int maxBatchSize = 0xFFFF);
00398
00404 static int countTriangles(SO<SceneThing> scene);
00405
00408 static void InvertOrientation(SO<SceneNode> target);
00409
00418 static bool ValidatePolygonSets(SO<SceneNode> target, bool fixErrors = false);
00419 };
00420
00421 }
00422
00423 #include <vrs/sg/scenegraphanalyzer.tli>
00424
00425 #endif // VRS_SG_SCENEGRAPHANALYZER_H