aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CVolumeLightSceneNode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CVolumeLightSceneNode.cpp')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CVolumeLightSceneNode.cpp404
1 files changed, 202 insertions, 202 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CVolumeLightSceneNode.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CVolumeLightSceneNode.cpp
index 966e823..7f8a5a5 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CVolumeLightSceneNode.cpp
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CVolumeLightSceneNode.cpp
@@ -1,202 +1,202 @@
1// Copyright (C) 2007-2012 Dean Wadsworth 1// Copyright (C) 2007-2012 Dean Wadsworth
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 "CVolumeLightSceneNode.h" 5#include "CVolumeLightSceneNode.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 10
11namespace irr 11namespace irr
12{ 12{
13namespace scene 13namespace scene
14{ 14{
15 15
16//! constructor 16//! constructor
17CVolumeLightSceneNode::CVolumeLightSceneNode(ISceneNode* parent, ISceneManager* mgr, 17CVolumeLightSceneNode::CVolumeLightSceneNode(ISceneNode* parent, ISceneManager* mgr,
18 s32 id, const u32 subdivU, const u32 subdivV, 18 s32 id, const u32 subdivU, const u32 subdivV,
19 const video::SColor foot, 19 const video::SColor foot,
20 const video::SColor tail, 20 const video::SColor tail,
21 const core::vector3df& position, 21 const core::vector3df& position,
22 const core::vector3df& rotation, const core::vector3df& scale) 22 const core::vector3df& rotation, const core::vector3df& scale)
23 : IVolumeLightSceneNode(parent, mgr, id, position, rotation, scale), 23 : IVolumeLightSceneNode(parent, mgr, id, position, rotation, scale),
24 Mesh(0), LPDistance(8.0f), 24 Mesh(0), LPDistance(8.0f),
25 SubdivideU(subdivU), SubdivideV(subdivV), 25 SubdivideU(subdivU), SubdivideV(subdivV),
26 FootColor(foot), TailColor(tail), 26 FootColor(foot), TailColor(tail),
27 LightDimensions(core::vector3df(1.0f, 1.2f, 1.0f)) 27 LightDimensions(core::vector3df(1.0f, 1.2f, 1.0f))
28{ 28{
29 #ifdef _DEBUG 29 #ifdef _DEBUG
30 setDebugName("CVolumeLightSceneNode"); 30 setDebugName("CVolumeLightSceneNode");
31 #endif 31 #endif
32 32
33 constructLight(); 33 constructLight();
34} 34}
35 35
36 36
37CVolumeLightSceneNode::~CVolumeLightSceneNode() 37CVolumeLightSceneNode::~CVolumeLightSceneNode()
38{ 38{
39 if (Mesh) 39 if (Mesh)
40 Mesh->drop(); 40 Mesh->drop();
41} 41}
42 42
43 43
44void CVolumeLightSceneNode::constructLight() 44void CVolumeLightSceneNode::constructLight()
45{ 45{
46 if (Mesh) 46 if (Mesh)
47 Mesh->drop(); 47 Mesh->drop();
48 Mesh = SceneManager->getGeometryCreator()->createVolumeLightMesh(SubdivideU, SubdivideV, FootColor, TailColor, LPDistance, LightDimensions); 48 Mesh = SceneManager->getGeometryCreator()->createVolumeLightMesh(SubdivideU, SubdivideV, FootColor, TailColor, LPDistance, LightDimensions);
49} 49}
50 50
51 51
52//! renders the node. 52//! renders the node.
53void CVolumeLightSceneNode::render() 53void CVolumeLightSceneNode::render()
54{ 54{
55 if (!Mesh) 55 if (!Mesh)
56 return; 56 return;
57 57
58 video::IVideoDriver* driver = SceneManager->getVideoDriver(); 58 video::IVideoDriver* driver = SceneManager->getVideoDriver();
59 driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); 59 driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
60 60
61 driver->setMaterial(Mesh->getMeshBuffer(0)->getMaterial()); 61 driver->setMaterial(Mesh->getMeshBuffer(0)->getMaterial());
62 driver->drawMeshBuffer(Mesh->getMeshBuffer(0)); 62 driver->drawMeshBuffer(Mesh->getMeshBuffer(0));
63} 63}
64 64
65 65
66//! returns the axis aligned bounding box of this node 66//! returns the axis aligned bounding box of this node
67const core::aabbox3d<f32>& CVolumeLightSceneNode::getBoundingBox() const 67const core::aabbox3d<f32>& CVolumeLightSceneNode::getBoundingBox() const
68{ 68{
69 return Mesh->getBoundingBox(); 69 return Mesh->getBoundingBox();
70} 70}
71 71
72 72
73void CVolumeLightSceneNode::OnRegisterSceneNode() 73void CVolumeLightSceneNode::OnRegisterSceneNode()
74{ 74{
75 if (IsVisible) 75 if (IsVisible)
76 { 76 {
77 SceneManager->registerNodeForRendering(this, ESNRP_TRANSPARENT); 77 SceneManager->registerNodeForRendering(this, ESNRP_TRANSPARENT);
78 } 78 }
79 ISceneNode::OnRegisterSceneNode(); 79 ISceneNode::OnRegisterSceneNode();
80} 80}
81 81
82 82
83//! returns the material based on the zero based index i. To get the amount 83//! returns the material based on the zero based index i. To get the amount
84//! of materials used by this scene node, use getMaterialCount(). 84//! of materials used by this scene node, use getMaterialCount().
85//! This function is needed for inserting the node into the scene hirachy on a 85//! This function is needed for inserting the node into the scene hirachy on a
86//! optimal position for minimizing renderstate changes, but can also be used 86//! optimal position for minimizing renderstate changes, but can also be used
87//! to directly modify the material of a scene node. 87//! to directly modify the material of a scene node.
88video::SMaterial& CVolumeLightSceneNode::getMaterial(u32 i) 88video::SMaterial& CVolumeLightSceneNode::getMaterial(u32 i)
89{ 89{
90 return Mesh->getMeshBuffer(i)->getMaterial(); 90 return Mesh->getMeshBuffer(i)->getMaterial();
91} 91}
92 92
93 93
94//! returns amount of materials used by this scene node. 94//! returns amount of materials used by this scene node.
95u32 CVolumeLightSceneNode::getMaterialCount() const 95u32 CVolumeLightSceneNode::getMaterialCount() const
96{ 96{
97 return 1; 97 return 1;
98} 98}
99 99
100 100
101void CVolumeLightSceneNode::setSubDivideU (const u32 inU) 101void CVolumeLightSceneNode::setSubDivideU (const u32 inU)
102{ 102{
103 if (inU != SubdivideU) 103 if (inU != SubdivideU)
104 { 104 {
105 SubdivideU = inU; 105 SubdivideU = inU;
106 constructLight(); 106 constructLight();
107 } 107 }
108} 108}
109 109
110 110
111void CVolumeLightSceneNode::setSubDivideV (const u32 inV) 111void CVolumeLightSceneNode::setSubDivideV (const u32 inV)
112{ 112{
113 if (inV != SubdivideV) 113 if (inV != SubdivideV)
114 { 114 {
115 SubdivideV = inV; 115 SubdivideV = inV;
116 constructLight(); 116 constructLight();
117 } 117 }
118} 118}
119 119
120 120
121void CVolumeLightSceneNode::setFootColor(const video::SColor inColor) 121void CVolumeLightSceneNode::setFootColor(const video::SColor inColor)
122{ 122{
123 if (inColor != FootColor) 123 if (inColor != FootColor)
124 { 124 {
125 FootColor = inColor; 125 FootColor = inColor;
126 constructLight(); 126 constructLight();
127 } 127 }
128} 128}
129 129
130 130
131void CVolumeLightSceneNode::setTailColor(const video::SColor inColor) 131void CVolumeLightSceneNode::setTailColor(const video::SColor inColor)
132{ 132{
133 if (inColor != TailColor) 133 if (inColor != TailColor)
134 { 134 {
135 TailColor = inColor; 135 TailColor = inColor;
136 constructLight(); 136 constructLight();
137 } 137 }
138} 138}
139 139
140 140
141//! Writes attributes of the scene node. 141//! Writes attributes of the scene node.
142void CVolumeLightSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const 142void CVolumeLightSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
143{ 143{
144 ISceneNode::serializeAttributes(out, options); 144 ISceneNode::serializeAttributes(out, options);
145 145
146 out->addFloat("lpDistance", LPDistance); 146 out->addFloat("lpDistance", LPDistance);
147 out->addInt("subDivideU", SubdivideU); 147 out->addInt("subDivideU", SubdivideU);
148 out->addInt("subDivideV", SubdivideV); 148 out->addInt("subDivideV", SubdivideV);
149 149
150 out->addColor("footColor", FootColor); 150 out->addColor("footColor", FootColor);
151 out->addColor("tailColor", TailColor); 151 out->addColor("tailColor", TailColor);
152 152
153 out->addVector3d("lightDimension", LightDimensions); 153 out->addVector3d("lightDimension", LightDimensions);
154} 154}
155 155
156 156
157//! Reads attributes of the scene node. 157//! Reads attributes of the scene node.
158void CVolumeLightSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) 158void CVolumeLightSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
159{ 159{
160 LPDistance = in->getAttributeAsFloat("lpDistance"); 160 LPDistance = in->getAttributeAsFloat("lpDistance");
161 LPDistance = core::max_(LPDistance, 8.0f); 161 LPDistance = core::max_(LPDistance, 8.0f);
162 162
163 SubdivideU = in->getAttributeAsInt("subDivideU"); 163 SubdivideU = in->getAttributeAsInt("subDivideU");
164 SubdivideU = core::max_(SubdivideU, 1u); 164 SubdivideU = core::max_(SubdivideU, 1u);
165 165
166 SubdivideV = in->getAttributeAsInt("subDivideV"); 166 SubdivideV = in->getAttributeAsInt("subDivideV");
167 SubdivideV = core::max_(SubdivideV, 1u); 167 SubdivideV = core::max_(SubdivideV, 1u);
168 168
169 FootColor = in->getAttributeAsColor("footColor"); 169 FootColor = in->getAttributeAsColor("footColor");
170 TailColor = in->getAttributeAsColor("tailColor"); 170 TailColor = in->getAttributeAsColor("tailColor");
171 171
172 LightDimensions = in->getAttributeAsVector3d("lightDimension"); 172 LightDimensions = in->getAttributeAsVector3d("lightDimension");
173 173
174 constructLight(); 174 constructLight();
175 175
176 ISceneNode::deserializeAttributes(in, options); 176 ISceneNode::deserializeAttributes(in, options);
177} 177}
178 178
179 179
180//! Creates a clone of this scene node and its children. 180//! Creates a clone of this scene node and its children.
181ISceneNode* CVolumeLightSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager) 181ISceneNode* CVolumeLightSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager)
182{ 182{
183 if (!newParent) 183 if (!newParent)
184 newParent = Parent; 184 newParent = Parent;
185 if (!newManager) 185 if (!newManager)
186 newManager = SceneManager; 186 newManager = SceneManager;
187 187
188 CVolumeLightSceneNode* nb = new CVolumeLightSceneNode(newParent, 188 CVolumeLightSceneNode* nb = new CVolumeLightSceneNode(newParent,
189 newManager, ID, SubdivideU, SubdivideV, FootColor, TailColor, RelativeTranslation); 189 newManager, ID, SubdivideU, SubdivideV, FootColor, TailColor, RelativeTranslation);
190 190
191 nb->cloneMembers(this, newManager); 191 nb->cloneMembers(this, newManager);
192 nb->getMaterial(0) = Mesh->getMeshBuffer(0)->getMaterial(); 192 nb->getMaterial(0) = Mesh->getMeshBuffer(0)->getMaterial();
193 193
194 if ( newParent ) 194 if ( newParent )
195 nb->drop(); 195 nb->drop();
196 return nb; 196 return nb;
197} 197}
198 198
199 199
200} // end namespace scene 200} // end namespace scene
201} // end namespace irr 201} // end namespace irr
202 202