aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CSphereSceneNode.cpp
diff options
context:
space:
mode:
authorDavid Walter Seikel2013-01-13 18:54:10 +1000
committerDavid Walter Seikel2013-01-13 18:54:10 +1000
commit959831f4ef5a3e797f576c3de08cd65032c997ad (patch)
treee7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/source/Irrlicht/CSphereSceneNode.cpp
parentAdd info about changes to Irrlicht. (diff)
downloadSledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CSphereSceneNode.cpp')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CSphereSceneNode.cpp396
1 files changed, 198 insertions, 198 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CSphereSceneNode.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CSphereSceneNode.cpp
index ae047bd..a8e53d4 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CSphereSceneNode.cpp
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CSphereSceneNode.cpp
@@ -1,198 +1,198 @@
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 "CSphereSceneNode.h" 5#include "CSphereSceneNode.h"
6#include "IVideoDriver.h" 6#include "IVideoDriver.h"
7#include "ISceneManager.h" 7#include "ISceneManager.h"
8#include "S3DVertex.h" 8#include "S3DVertex.h"
9#include "os.h" 9#include "os.h"
10#include "CShadowVolumeSceneNode.h" 10#include "CShadowVolumeSceneNode.h"
11 11
12namespace irr 12namespace irr
13{ 13{
14namespace scene 14namespace scene
15{ 15{
16 16
17//! constructor 17//! constructor
18CSphereSceneNode::CSphereSceneNode(f32 radius, u32 polyCountX, u32 polyCountY, ISceneNode* parent, ISceneManager* mgr, s32 id, 18CSphereSceneNode::CSphereSceneNode(f32 radius, u32 polyCountX, u32 polyCountY, ISceneNode* parent, ISceneManager* mgr, s32 id,
19 const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) 19 const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale)
20: IMeshSceneNode(parent, mgr, id, position, rotation, scale), Mesh(0), Shadow(0), 20: IMeshSceneNode(parent, mgr, id, position, rotation, scale), Mesh(0), Shadow(0),
21 Radius(radius), PolyCountX(polyCountX), PolyCountY(polyCountY) 21 Radius(radius), PolyCountX(polyCountX), PolyCountY(polyCountY)
22{ 22{
23 #ifdef _DEBUG 23 #ifdef _DEBUG
24 setDebugName("CSphereSceneNode"); 24 setDebugName("CSphereSceneNode");
25 #endif 25 #endif
26 26
27 Mesh = SceneManager->getGeometryCreator()->createSphereMesh(radius, polyCountX, polyCountY); 27 Mesh = SceneManager->getGeometryCreator()->createSphereMesh(radius, polyCountX, polyCountY);
28} 28}
29 29
30 30
31 31
32//! destructor 32//! destructor
33CSphereSceneNode::~CSphereSceneNode() 33CSphereSceneNode::~CSphereSceneNode()
34{ 34{
35 if (Shadow) 35 if (Shadow)
36 Shadow->drop(); 36 Shadow->drop();
37 if (Mesh) 37 if (Mesh)
38 Mesh->drop(); 38 Mesh->drop();
39} 39}
40 40
41 41
42//! renders the node. 42//! renders the node.
43void CSphereSceneNode::render() 43void CSphereSceneNode::render()
44{ 44{
45 video::IVideoDriver* driver = SceneManager->getVideoDriver(); 45 video::IVideoDriver* driver = SceneManager->getVideoDriver();
46 46
47 if (Mesh && driver) 47 if (Mesh && driver)
48 { 48 {
49 driver->setMaterial(Mesh->getMeshBuffer(0)->getMaterial()); 49 driver->setMaterial(Mesh->getMeshBuffer(0)->getMaterial());
50 driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); 50 driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
51 if (Shadow) 51 if (Shadow)
52 Shadow->updateShadowVolumes(); 52 Shadow->updateShadowVolumes();
53 53
54 driver->drawMeshBuffer(Mesh->getMeshBuffer(0)); 54 driver->drawMeshBuffer(Mesh->getMeshBuffer(0));
55 if ( DebugDataVisible & scene::EDS_BBOX ) 55 if ( DebugDataVisible & scene::EDS_BBOX )
56 { 56 {
57 video::SMaterial m; 57 video::SMaterial m;
58 m.Lighting = false; 58 m.Lighting = false;
59 driver->setMaterial(m); 59 driver->setMaterial(m);
60 driver->draw3DBox(Mesh->getMeshBuffer(0)->getBoundingBox(), video::SColor(255,255,255,255)); 60 driver->draw3DBox(Mesh->getMeshBuffer(0)->getBoundingBox(), video::SColor(255,255,255,255));
61 } 61 }
62 } 62 }
63} 63}
64 64
65 65
66//! Removes a child from this scene node. 66//! Removes a child from this scene node.
67//! Implemented here, to be able to remove the shadow properly, if there is one, 67//! Implemented here, to be able to remove the shadow properly, if there is one,
68//! or to remove attached childs. 68//! or to remove attached childs.
69bool CSphereSceneNode::removeChild(ISceneNode* child) 69bool CSphereSceneNode::removeChild(ISceneNode* child)
70{ 70{
71 if (child && Shadow == child) 71 if (child && Shadow == child)
72 { 72 {
73 Shadow->drop(); 73 Shadow->drop();
74 Shadow = 0; 74 Shadow = 0;
75 } 75 }
76 76
77 return ISceneNode::removeChild(child); 77 return ISceneNode::removeChild(child);
78} 78}
79 79
80 80
81//! Creates shadow volume scene node as child of this node 81//! Creates shadow volume scene node as child of this node
82//! and returns a pointer to it. 82//! and returns a pointer to it.
83IShadowVolumeSceneNode* CSphereSceneNode::addShadowVolumeSceneNode( 83IShadowVolumeSceneNode* CSphereSceneNode::addShadowVolumeSceneNode(
84 const IMesh* shadowMesh, s32 id, bool zfailmethod, f32 infinity) 84 const IMesh* shadowMesh, s32 id, bool zfailmethod, f32 infinity)
85{ 85{
86 if (!SceneManager->getVideoDriver()->queryFeature(video::EVDF_STENCIL_BUFFER)) 86 if (!SceneManager->getVideoDriver()->queryFeature(video::EVDF_STENCIL_BUFFER))
87 return 0; 87 return 0;
88 88
89 if (!shadowMesh) 89 if (!shadowMesh)
90 shadowMesh = Mesh; // if null is given, use the mesh of node 90 shadowMesh = Mesh; // if null is given, use the mesh of node
91 91
92 if (Shadow) 92 if (Shadow)
93 Shadow->drop(); 93 Shadow->drop();
94 94
95 Shadow = new CShadowVolumeSceneNode(shadowMesh, this, SceneManager, id, zfailmethod, infinity); 95 Shadow = new CShadowVolumeSceneNode(shadowMesh, this, SceneManager, id, zfailmethod, infinity);
96 return Shadow; 96 return Shadow;
97} 97}
98 98
99 99
100//! returns the axis aligned bounding box of this node 100//! returns the axis aligned bounding box of this node
101const core::aabbox3d<f32>& CSphereSceneNode::getBoundingBox() const 101const core::aabbox3d<f32>& CSphereSceneNode::getBoundingBox() const
102{ 102{
103 return Mesh ? Mesh->getBoundingBox() : Box; 103 return Mesh ? Mesh->getBoundingBox() : Box;
104} 104}
105 105
106 106
107void CSphereSceneNode::OnRegisterSceneNode() 107void CSphereSceneNode::OnRegisterSceneNode()
108{ 108{
109 if (IsVisible) 109 if (IsVisible)
110 SceneManager->registerNodeForRendering(this); 110 SceneManager->registerNodeForRendering(this);
111 111
112 ISceneNode::OnRegisterSceneNode(); 112 ISceneNode::OnRegisterSceneNode();
113} 113}
114 114
115 115
116//! returns the material based on the zero based index i. To get the amount 116//! returns the material based on the zero based index i. To get the amount
117//! of materials used by this scene node, use getMaterialCount(). 117//! of materials used by this scene node, use getMaterialCount().
118//! This function is needed for inserting the node into the scene hirachy on a 118//! This function is needed for inserting the node into the scene hirachy on a
119//! optimal position for minimizing renderstate changes, but can also be used 119//! optimal position for minimizing renderstate changes, but can also be used
120//! to directly modify the material of a scene node. 120//! to directly modify the material of a scene node.
121video::SMaterial& CSphereSceneNode::getMaterial(u32 i) 121video::SMaterial& CSphereSceneNode::getMaterial(u32 i)
122{ 122{
123 if (i>0 || !Mesh) 123 if (i>0 || !Mesh)
124 return ISceneNode::getMaterial(i); 124 return ISceneNode::getMaterial(i);
125 else 125 else
126 return Mesh->getMeshBuffer(i)->getMaterial(); 126 return Mesh->getMeshBuffer(i)->getMaterial();
127} 127}
128 128
129 129
130//! returns amount of materials used by this scene node. 130//! returns amount of materials used by this scene node.
131u32 CSphereSceneNode::getMaterialCount() const 131u32 CSphereSceneNode::getMaterialCount() const
132{ 132{
133 return 1; 133 return 1;
134} 134}
135 135
136 136
137//! Writes attributes of the scene node. 137//! Writes attributes of the scene node.
138void CSphereSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const 138void CSphereSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
139{ 139{
140 ISceneNode::serializeAttributes(out, options); 140 ISceneNode::serializeAttributes(out, options);
141 141
142 out->addFloat("Radius", Radius); 142 out->addFloat("Radius", Radius);
143 out->addInt("PolyCountX", PolyCountX); 143 out->addInt("PolyCountX", PolyCountX);
144 out->addInt("PolyCountY", PolyCountY); 144 out->addInt("PolyCountY", PolyCountY);
145} 145}
146 146
147 147
148//! Reads attributes of the scene node. 148//! Reads attributes of the scene node.
149void CSphereSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) 149void CSphereSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
150{ 150{
151 f32 oldRadius = Radius; 151 f32 oldRadius = Radius;
152 u32 oldPolyCountX = PolyCountX; 152 u32 oldPolyCountX = PolyCountX;
153 u32 oldPolyCountY = PolyCountY; 153 u32 oldPolyCountY = PolyCountY;
154 154
155 Radius = in->getAttributeAsFloat("Radius"); 155 Radius = in->getAttributeAsFloat("Radius");
156 PolyCountX = in->getAttributeAsInt("PolyCountX"); 156 PolyCountX = in->getAttributeAsInt("PolyCountX");
157 PolyCountY = in->getAttributeAsInt("PolyCountY"); 157 PolyCountY = in->getAttributeAsInt("PolyCountY");
158 // legacy values read for compatibility with older versions 158 // legacy values read for compatibility with older versions
159 u32 polyCount = in->getAttributeAsInt("PolyCount"); 159 u32 polyCount = in->getAttributeAsInt("PolyCount");
160 if (PolyCountX ==0 && PolyCountY == 0) 160 if (PolyCountX ==0 && PolyCountY == 0)
161 PolyCountX = PolyCountY = polyCount; 161 PolyCountX = PolyCountY = polyCount;
162 162
163 Radius = core::max_(Radius, 0.0001f); 163 Radius = core::max_(Radius, 0.0001f);
164 164
165 if ( !core::equals(Radius, oldRadius) || PolyCountX != oldPolyCountX || PolyCountY != oldPolyCountY) 165 if ( !core::equals(Radius, oldRadius) || PolyCountX != oldPolyCountX || PolyCountY != oldPolyCountY)
166 { 166 {
167 if (Mesh) 167 if (Mesh)
168 Mesh->drop(); 168 Mesh->drop();
169 Mesh = SceneManager->getGeometryCreator()->createSphereMesh(Radius, PolyCountX, PolyCountY); 169 Mesh = SceneManager->getGeometryCreator()->createSphereMesh(Radius, PolyCountX, PolyCountY);
170 } 170 }
171 171
172 ISceneNode::deserializeAttributes(in, options); 172 ISceneNode::deserializeAttributes(in, options);
173} 173}
174 174
175//! Creates a clone of this scene node and its children. 175//! Creates a clone of this scene node and its children.
176ISceneNode* CSphereSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager) 176ISceneNode* CSphereSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager)
177{ 177{
178 if (!newParent) 178 if (!newParent)
179 newParent = Parent; 179 newParent = Parent;
180 if (!newManager) 180 if (!newManager)
181 newManager = SceneManager; 181 newManager = SceneManager;
182 182
183 CSphereSceneNode* nb = new CSphereSceneNode(Radius, PolyCountX, PolyCountY, newParent, 183 CSphereSceneNode* nb = new CSphereSceneNode(Radius, PolyCountX, PolyCountY, newParent,
184 newManager, ID, RelativeTranslation); 184 newManager, ID, RelativeTranslation);
185 185
186 nb->cloneMembers(this, newManager); 186 nb->cloneMembers(this, newManager);
187 nb->getMaterial(0) = Mesh->getMeshBuffer(0)->getMaterial(); 187 nb->getMaterial(0) = Mesh->getMeshBuffer(0)->getMaterial();
188 nb->Shadow = Shadow; 188 nb->Shadow = Shadow;
189 nb->Shadow->grab(); 189 nb->Shadow->grab();
190 190
191 if ( newParent ) 191 if ( newParent )
192 nb->drop(); 192 nb->drop();
193 return nb; 193 return nb;
194} 194}
195 195
196} // end namespace scene 196} // end namespace scene
197} // end namespace irr 197} // end namespace irr
198 198