diff options
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CDefaultSceneNodeFactory.cpp')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CDefaultSceneNodeFactory.cpp | 358 |
1 files changed, 179 insertions, 179 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CDefaultSceneNodeFactory.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CDefaultSceneNodeFactory.cpp index 942d3cd..9ba7302 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/CDefaultSceneNodeFactory.cpp +++ b/libraries/irrlicht-1.8/source/Irrlicht/CDefaultSceneNodeFactory.cpp | |||
@@ -1,179 +1,179 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt | 1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt |
2 | // This file is part of the "Irrlicht Engine". | 2 | // This file is part of the "Irrlicht Engine". |
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | 3 | // For conditions of distribution and use, see copyright notice in irrlicht.h |
4 | 4 | ||
5 | #include "CDefaultSceneNodeFactory.h" | 5 | #include "CDefaultSceneNodeFactory.h" |
6 | #include "ISceneManager.h" | 6 | #include "ISceneManager.h" |
7 | #include "ITextSceneNode.h" | 7 | #include "ITextSceneNode.h" |
8 | #include "ITerrainSceneNode.h" | 8 | #include "ITerrainSceneNode.h" |
9 | #include "IDummyTransformationSceneNode.h" | 9 | #include "IDummyTransformationSceneNode.h" |
10 | #include "ICameraSceneNode.h" | 10 | #include "ICameraSceneNode.h" |
11 | #include "IBillboardSceneNode.h" | 11 | #include "IBillboardSceneNode.h" |
12 | #include "IAnimatedMeshSceneNode.h" | 12 | #include "IAnimatedMeshSceneNode.h" |
13 | #include "IParticleSystemSceneNode.h" | 13 | #include "IParticleSystemSceneNode.h" |
14 | #include "ILightSceneNode.h" | 14 | #include "ILightSceneNode.h" |
15 | #include "IMeshSceneNode.h" | 15 | #include "IMeshSceneNode.h" |
16 | 16 | ||
17 | namespace irr | 17 | namespace irr |
18 | { | 18 | { |
19 | namespace scene | 19 | namespace scene |
20 | { | 20 | { |
21 | 21 | ||
22 | 22 | ||
23 | CDefaultSceneNodeFactory::CDefaultSceneNodeFactory(ISceneManager* mgr) | 23 | CDefaultSceneNodeFactory::CDefaultSceneNodeFactory(ISceneManager* mgr) |
24 | : Manager(mgr) | 24 | : Manager(mgr) |
25 | { | 25 | { |
26 | 26 | ||
27 | #ifdef _DEBUG | 27 | #ifdef _DEBUG |
28 | setDebugName("CDefaultSceneNodeFactory"); | 28 | setDebugName("CDefaultSceneNodeFactory"); |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | // don't grab the scene manager here to prevent cyclic references | 31 | // don't grab the scene manager here to prevent cyclic references |
32 | 32 | ||
33 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_CUBE, "cube")); | 33 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_CUBE, "cube")); |
34 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_SPHERE, "sphere")); | 34 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_SPHERE, "sphere")); |
35 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_TEXT, "text")); | 35 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_TEXT, "text")); |
36 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_WATER_SURFACE, "waterSurface")); | 36 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_WATER_SURFACE, "waterSurface")); |
37 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_TERRAIN, "terrain")); | 37 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_TERRAIN, "terrain")); |
38 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_SKY_BOX, "skyBox")); | 38 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_SKY_BOX, "skyBox")); |
39 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_SKY_DOME, "skyDome")); | 39 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_SKY_DOME, "skyDome")); |
40 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_SHADOW_VOLUME, "shadowVolume")); | 40 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_SHADOW_VOLUME, "shadowVolume")); |
41 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_OCTREE, "octree")); | 41 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_OCTREE, "octree")); |
42 | // Legacy support | 42 | // Legacy support |
43 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_OCTREE, "octTree")); | 43 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_OCTREE, "octTree")); |
44 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_MESH, "mesh")); | 44 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_MESH, "mesh")); |
45 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_LIGHT, "light")); | 45 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_LIGHT, "light")); |
46 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_EMPTY, "empty")); | 46 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_EMPTY, "empty")); |
47 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_DUMMY_TRANSFORMATION, "dummyTransformation")); | 47 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_DUMMY_TRANSFORMATION, "dummyTransformation")); |
48 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_CAMERA, "camera")); | 48 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_CAMERA, "camera")); |
49 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_BILLBOARD, "billBoard")); | 49 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_BILLBOARD, "billBoard")); |
50 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_ANIMATED_MESH, "animatedMesh")); | 50 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_ANIMATED_MESH, "animatedMesh")); |
51 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_PARTICLE_SYSTEM, "particleSystem")); | 51 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_PARTICLE_SYSTEM, "particleSystem")); |
52 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_VOLUME_LIGHT, "volumeLight")); | 52 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_VOLUME_LIGHT, "volumeLight")); |
53 | // SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_MD3_SCENE_NODE, "md3")); | 53 | // SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_MD3_SCENE_NODE, "md3")); |
54 | 54 | ||
55 | // legacy, for version <= 1.4.x irr files | 55 | // legacy, for version <= 1.4.x irr files |
56 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_CAMERA_MAYA, "cameraMaya")); | 56 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_CAMERA_MAYA, "cameraMaya")); |
57 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_CAMERA_FPS, "cameraFPS")); | 57 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_CAMERA_FPS, "cameraFPS")); |
58 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_Q3SHADER_SCENE_NODE, "quake3Shader")); | 58 | SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_Q3SHADER_SCENE_NODE, "quake3Shader")); |
59 | } | 59 | } |
60 | 60 | ||
61 | 61 | ||
62 | //! adds a scene node to the scene graph based on its type id | 62 | //! adds a scene node to the scene graph based on its type id |
63 | ISceneNode* CDefaultSceneNodeFactory::addSceneNode(ESCENE_NODE_TYPE type, ISceneNode* parent) | 63 | ISceneNode* CDefaultSceneNodeFactory::addSceneNode(ESCENE_NODE_TYPE type, ISceneNode* parent) |
64 | { | 64 | { |
65 | switch(type) | 65 | switch(type) |
66 | { | 66 | { |
67 | case ESNT_CUBE: | 67 | case ESNT_CUBE: |
68 | return Manager->addCubeSceneNode(10, parent); | 68 | return Manager->addCubeSceneNode(10, parent); |
69 | case ESNT_SPHERE: | 69 | case ESNT_SPHERE: |
70 | return Manager->addSphereSceneNode(5, 16, parent); | 70 | return Manager->addSphereSceneNode(5, 16, parent); |
71 | case ESNT_TEXT: | 71 | case ESNT_TEXT: |
72 | return Manager->addTextSceneNode(0, L"example"); | 72 | return Manager->addTextSceneNode(0, L"example"); |
73 | case ESNT_WATER_SURFACE: | 73 | case ESNT_WATER_SURFACE: |
74 | return Manager->addWaterSurfaceSceneNode(0, 2.0f, 300.0f, 10.0f, parent); | 74 | return Manager->addWaterSurfaceSceneNode(0, 2.0f, 300.0f, 10.0f, parent); |
75 | case ESNT_TERRAIN: | 75 | case ESNT_TERRAIN: |
76 | return Manager->addTerrainSceneNode("", parent, -1, | 76 | return Manager->addTerrainSceneNode("", parent, -1, |
77 | core::vector3df(0.0f,0.0f,0.0f), | 77 | core::vector3df(0.0f,0.0f,0.0f), |
78 | core::vector3df(0.0f,0.0f,0.0f), | 78 | core::vector3df(0.0f,0.0f,0.0f), |
79 | core::vector3df(1.0f,1.0f,1.0f), | 79 | core::vector3df(1.0f,1.0f,1.0f), |
80 | video::SColor(255,255,255,255), | 80 | video::SColor(255,255,255,255), |
81 | 4, ETPS_17, 0, true); | 81 | 4, ETPS_17, 0, true); |
82 | case ESNT_SKY_BOX: | 82 | case ESNT_SKY_BOX: |
83 | return Manager->addSkyBoxSceneNode(0,0,0,0,0,0, parent); | 83 | return Manager->addSkyBoxSceneNode(0,0,0,0,0,0, parent); |
84 | case ESNT_SKY_DOME: | 84 | case ESNT_SKY_DOME: |
85 | return Manager->addSkyDomeSceneNode(0, 16, 8, 0.9f, 2.0f, 1000.0f, parent); | 85 | return Manager->addSkyDomeSceneNode(0, 16, 8, 0.9f, 2.0f, 1000.0f, parent); |
86 | case ESNT_SHADOW_VOLUME: | 86 | case ESNT_SHADOW_VOLUME: |
87 | return 0; | 87 | return 0; |
88 | case ESNT_OCTREE: | 88 | case ESNT_OCTREE: |
89 | return Manager->addOctreeSceneNode((IMesh*)0, parent, -1, 128, true); | 89 | return Manager->addOctreeSceneNode((IMesh*)0, parent, -1, 128, true); |
90 | case ESNT_MESH: | 90 | case ESNT_MESH: |
91 | return Manager->addMeshSceneNode(0, parent, -1, core::vector3df(), | 91 | return Manager->addMeshSceneNode(0, parent, -1, core::vector3df(), |
92 | core::vector3df(), core::vector3df(1,1,1), true); | 92 | core::vector3df(), core::vector3df(1,1,1), true); |
93 | case ESNT_LIGHT: | 93 | case ESNT_LIGHT: |
94 | return Manager->addLightSceneNode(parent); | 94 | return Manager->addLightSceneNode(parent); |
95 | case ESNT_EMPTY: | 95 | case ESNT_EMPTY: |
96 | return Manager->addEmptySceneNode(parent); | 96 | return Manager->addEmptySceneNode(parent); |
97 | case ESNT_DUMMY_TRANSFORMATION: | 97 | case ESNT_DUMMY_TRANSFORMATION: |
98 | return Manager->addDummyTransformationSceneNode(parent); | 98 | return Manager->addDummyTransformationSceneNode(parent); |
99 | case ESNT_CAMERA: | 99 | case ESNT_CAMERA: |
100 | return Manager->addCameraSceneNode(parent); | 100 | return Manager->addCameraSceneNode(parent); |
101 | case ESNT_CAMERA_MAYA: | 101 | case ESNT_CAMERA_MAYA: |
102 | return Manager->addCameraSceneNodeMaya(parent); | 102 | return Manager->addCameraSceneNodeMaya(parent); |
103 | case ESNT_CAMERA_FPS: | 103 | case ESNT_CAMERA_FPS: |
104 | return Manager->addCameraSceneNodeFPS(parent); | 104 | return Manager->addCameraSceneNodeFPS(parent); |
105 | case ESNT_BILLBOARD: | 105 | case ESNT_BILLBOARD: |
106 | return Manager->addBillboardSceneNode(parent); | 106 | return Manager->addBillboardSceneNode(parent); |
107 | case ESNT_ANIMATED_MESH: | 107 | case ESNT_ANIMATED_MESH: |
108 | return Manager->addAnimatedMeshSceneNode(0, parent, -1, core::vector3df(), | 108 | return Manager->addAnimatedMeshSceneNode(0, parent, -1, core::vector3df(), |
109 | core::vector3df(), core::vector3df(1,1,1), true); | 109 | core::vector3df(), core::vector3df(1,1,1), true); |
110 | case ESNT_PARTICLE_SYSTEM: | 110 | case ESNT_PARTICLE_SYSTEM: |
111 | return Manager->addParticleSystemSceneNode(true, parent); | 111 | return Manager->addParticleSystemSceneNode(true, parent); |
112 | case ESNT_VOLUME_LIGHT: | 112 | case ESNT_VOLUME_LIGHT: |
113 | return (ISceneNode*)Manager->addVolumeLightSceneNode(parent); | 113 | return (ISceneNode*)Manager->addVolumeLightSceneNode(parent); |
114 | default: | 114 | default: |
115 | break; | 115 | break; |
116 | } | 116 | } |
117 | 117 | ||
118 | return 0; | 118 | return 0; |
119 | } | 119 | } |
120 | 120 | ||
121 | 121 | ||
122 | //! adds a scene node to the scene graph based on its type name | 122 | //! adds a scene node to the scene graph based on its type name |
123 | ISceneNode* CDefaultSceneNodeFactory::addSceneNode(const c8* typeName, ISceneNode* parent) | 123 | ISceneNode* CDefaultSceneNodeFactory::addSceneNode(const c8* typeName, ISceneNode* parent) |
124 | { | 124 | { |
125 | return addSceneNode( getTypeFromName(typeName), parent ); | 125 | return addSceneNode( getTypeFromName(typeName), parent ); |
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | //! returns amount of scene node types this factory is able to create | 129 | //! returns amount of scene node types this factory is able to create |
130 | u32 CDefaultSceneNodeFactory::getCreatableSceneNodeTypeCount() const | 130 | u32 CDefaultSceneNodeFactory::getCreatableSceneNodeTypeCount() const |
131 | { | 131 | { |
132 | return SupportedSceneNodeTypes.size(); | 132 | return SupportedSceneNodeTypes.size(); |
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | //! returns type of a createable scene node type | 136 | //! returns type of a createable scene node type |
137 | ESCENE_NODE_TYPE CDefaultSceneNodeFactory::getCreateableSceneNodeType(u32 idx) const | 137 | ESCENE_NODE_TYPE CDefaultSceneNodeFactory::getCreateableSceneNodeType(u32 idx) const |
138 | { | 138 | { |
139 | if (idx<SupportedSceneNodeTypes.size()) | 139 | if (idx<SupportedSceneNodeTypes.size()) |
140 | return SupportedSceneNodeTypes[idx].Type; | 140 | return SupportedSceneNodeTypes[idx].Type; |
141 | else | 141 | else |
142 | return ESNT_UNKNOWN; | 142 | return ESNT_UNKNOWN; |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | //! returns type name of a createable scene node type | 146 | //! returns type name of a createable scene node type |
147 | const c8* CDefaultSceneNodeFactory::getCreateableSceneNodeTypeName(u32 idx) const | 147 | const c8* CDefaultSceneNodeFactory::getCreateableSceneNodeTypeName(u32 idx) const |
148 | { | 148 | { |
149 | if (idx<SupportedSceneNodeTypes.size()) | 149 | if (idx<SupportedSceneNodeTypes.size()) |
150 | return SupportedSceneNodeTypes[idx].TypeName.c_str(); | 150 | return SupportedSceneNodeTypes[idx].TypeName.c_str(); |
151 | else | 151 | else |
152 | return 0; | 152 | return 0; |
153 | } | 153 | } |
154 | 154 | ||
155 | 155 | ||
156 | //! returns type name of a createable scene node type | 156 | //! returns type name of a createable scene node type |
157 | const c8* CDefaultSceneNodeFactory::getCreateableSceneNodeTypeName(ESCENE_NODE_TYPE type) const | 157 | const c8* CDefaultSceneNodeFactory::getCreateableSceneNodeTypeName(ESCENE_NODE_TYPE type) const |
158 | { | 158 | { |
159 | for (u32 i=0; i<SupportedSceneNodeTypes.size(); ++i) | 159 | for (u32 i=0; i<SupportedSceneNodeTypes.size(); ++i) |
160 | if (SupportedSceneNodeTypes[i].Type == type) | 160 | if (SupportedSceneNodeTypes[i].Type == type) |
161 | return SupportedSceneNodeTypes[i].TypeName.c_str(); | 161 | return SupportedSceneNodeTypes[i].TypeName.c_str(); |
162 | 162 | ||
163 | return 0; | 163 | return 0; |
164 | } | 164 | } |
165 | 165 | ||
166 | 166 | ||
167 | ESCENE_NODE_TYPE CDefaultSceneNodeFactory::getTypeFromName(const c8* name) const | 167 | ESCENE_NODE_TYPE CDefaultSceneNodeFactory::getTypeFromName(const c8* name) const |
168 | { | 168 | { |
169 | for (u32 i=0; i<SupportedSceneNodeTypes.size(); ++i) | 169 | for (u32 i=0; i<SupportedSceneNodeTypes.size(); ++i) |
170 | if (SupportedSceneNodeTypes[i].TypeName == name) | 170 | if (SupportedSceneNodeTypes[i].TypeName == name) |
171 | return SupportedSceneNodeTypes[i].Type; | 171 | return SupportedSceneNodeTypes[i].Type; |
172 | 172 | ||
173 | return ESNT_UNKNOWN; | 173 | return ESNT_UNKNOWN; |
174 | } | 174 | } |
175 | 175 | ||
176 | 176 | ||
177 | } // end namespace scene | 177 | } // end namespace scene |
178 | } // end namespace irr | 178 | } // end namespace irr |
179 | 179 | ||