00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <vrs/sg/scenething.h>
00019 #include <vrs/shape.h>
00020
00021 #ifndef VRS_OPENGL_SCENESHAPEMANAGERGL_H
00022 #define VRS_OPENGL_SCENESHAPEMANAGERGL_H
00023
00024 namespace VRS {
00025
00026 class SceneShapeGL;
00027
00028 class VRS_CORE_API SceneShapeManagerGL :
00029 public SceneNode
00030 {
00031 public:
00032 VRS_TYPEINFO(SceneShapeManagerGL, SceneNode);
00033 VRS_SERIALIZABLE(SceneShapeManagerGL);
00034
00035 struct OptimizationFlags {
00036 enum CullingMode { CM_Off, CM_BackFaces, CM_FrontFaces };
00037 VRS_SERIALIZABLE_CLASS_ENUM(CullingMode);
00038
00039 OptimizationFlags() :
00040 hasTransparency(true),
00041 useStaticLighting(true),
00042 maxTextureAtlasSize(512),
00043 allowTextureImageWrapping(true),
00044 allowTextureImageRepeating(true),
00045 scaleTextureImageToPow2(true),
00046 maxTextureImageSize(2048),
00047 cullingMode(CM_Off),
00048 increasePrecision(true),
00049 maxVerticesPerPolygonSet(65535),
00050 allowPolygonSplitAlongAxisX(true),
00051 allowPolygonSplitAlongAxisY(true),
00052 allowPolygonSplitAlongAxisZ(true),
00053 useS3TextureCompression(true),
00054 allowRayIntersection(true),
00055 keepPolygonSets(false),
00056 optimizeForVertexCache(true),
00057 keepOnlyFinestLODLevel(false),
00058 useFakeLighting(false),
00059 fakeLightingMinIntensity(0.4),
00060 fakeLightingMaxIntensity(1.4),
00061 fakeLightingDirection(1.0, 0.0, 0.0)
00062 { }
00063
00064 bool hasTransparency;
00065 bool useStaticLighting;
00066 unsigned int maxTextureAtlasSize;
00067 bool allowTextureImageWrapping;
00068 bool allowTextureImageRepeating;
00069 bool scaleTextureImageToPow2;
00070 unsigned int maxTextureImageSize;
00071 CullingMode cullingMode;
00072 bool increasePrecision;
00073 unsigned int maxVerticesPerPolygonSet;
00074 bool allowPolygonSplitAlongAxisX;
00075 bool allowPolygonSplitAlongAxisY;
00076 bool allowPolygonSplitAlongAxisZ;
00077 bool useS3TextureCompression;
00078 bool allowRayIntersection;
00079 bool keepPolygonSets;
00080 bool optimizeForVertexCache;
00081 bool keepOnlyFinestLODLevel;
00082 bool useFakeLighting;
00083 double fakeLightingMinIntensity;
00084 double fakeLightingMaxIntensity;
00085 Vector fakeLightingDirection;
00086 };
00087
00088 SceneShapeManagerGL(
00089 SO<SceneThing> parent = NULL
00090 );
00091
00092 virtual SO<SceneShapeGL> create(
00093 SO<SceneNode> scene,
00094 const OptimizationFlags& optFlags = OptimizationFlags()
00095 );
00096
00097 virtual Bounds boundingBox(
00098 Engine* engine
00099 ) const;
00100
00101 virtual void evaluate(
00102 Engine* engine
00103 );
00104
00105 static SO<SceneNode> optimize(
00106 SO<SceneNode> scene,
00107 const OptimizationFlags& optFlags = OptimizationFlags()
00108 );
00109
00110 public:
00111 class Impl;
00112 private:
00113 SO<Impl> m_impl;
00114 };
00115
00116 class VRS_CORE_API SceneShapeGL :
00117 public Shape
00118 {
00119 public:
00120 VRS_TYPEINFO(SceneShapeGL, Shape);
00121 VRS_SERIALIZABLE_ABSTRACT_CLASS(SceneShapeGL);
00122
00123 public:
00124 virtual SO<SceneNode> scene() const = 0;
00125
00126 virtual SceneShapeManagerGL::OptimizationFlags::CullingMode cullingMode() const = 0;
00127 virtual void cullingMode(SceneShapeManagerGL::OptimizationFlags::CullingMode cullingMode) = 0;
00128
00129 virtual bool hasTransparency() const = 0;
00130 virtual void hasTransparency(bool hasTransparency) = 0;
00131 };
00132
00133 }
00134
00135 #endif // VRS_OPENGL_SCENESHAPEMANAGERGL_H