aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.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/CParticleAnimatedMeshSceneNodeEmitter.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 '')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.cpp400
1 files changed, 200 insertions, 200 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.cpp
index 1f295e7..71adf49 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.cpp
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CParticleAnimatedMeshSceneNodeEmitter.cpp
@@ -1,200 +1,200 @@
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 "CParticleAnimatedMeshSceneNodeEmitter.h" 5#include "CParticleAnimatedMeshSceneNodeEmitter.h"
6#include "IAnimatedMeshSceneNode.h" 6#include "IAnimatedMeshSceneNode.h"
7#include "IMesh.h" 7#include "IMesh.h"
8#include "os.h" 8#include "os.h"
9 9
10namespace irr 10namespace irr
11{ 11{
12namespace scene 12namespace scene
13{ 13{
14 14
15//! constructor 15//! constructor
16CParticleAnimatedMeshSceneNodeEmitter::CParticleAnimatedMeshSceneNodeEmitter( 16CParticleAnimatedMeshSceneNodeEmitter::CParticleAnimatedMeshSceneNodeEmitter(
17 IAnimatedMeshSceneNode* node, bool useNormalDirection, 17 IAnimatedMeshSceneNode* node, bool useNormalDirection,
18 const core::vector3df& direction, f32 normalDirectionModifier, 18 const core::vector3df& direction, f32 normalDirectionModifier,
19 s32 mbNumber, bool everyMeshVertex, 19 s32 mbNumber, bool everyMeshVertex,
20 u32 minParticlesPerSecond, u32 maxParticlesPerSecond, 20 u32 minParticlesPerSecond, u32 maxParticlesPerSecond,
21 const video::SColor& minStartColor, const video::SColor& maxStartColor, 21 const video::SColor& minStartColor, const video::SColor& maxStartColor,
22 u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees, 22 u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees,
23 const core::dimension2df& minStartSize, const core::dimension2df& maxStartSize ) 23 const core::dimension2df& minStartSize, const core::dimension2df& maxStartSize )
24 : Node(0), AnimatedMesh(0), BaseMesh(0), TotalVertices(0), MBCount(0), MBNumber(mbNumber), 24 : Node(0), AnimatedMesh(0), BaseMesh(0), TotalVertices(0), MBCount(0), MBNumber(mbNumber),
25 Direction(direction), NormalDirectionModifier(normalDirectionModifier), 25 Direction(direction), NormalDirectionModifier(normalDirectionModifier),
26 MinParticlesPerSecond(minParticlesPerSecond), MaxParticlesPerSecond(maxParticlesPerSecond), 26 MinParticlesPerSecond(minParticlesPerSecond), MaxParticlesPerSecond(maxParticlesPerSecond),
27 MinStartColor(minStartColor), MaxStartColor(maxStartColor), 27 MinStartColor(minStartColor), MaxStartColor(maxStartColor),
28 MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax), 28 MinLifeTime(lifeTimeMin), MaxLifeTime(lifeTimeMax),
29 MaxStartSize(maxStartSize), MinStartSize(minStartSize), 29 MaxStartSize(maxStartSize), MinStartSize(minStartSize),
30 Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees), 30 Time(0), Emitted(0), MaxAngleDegrees(maxAngleDegrees),
31 EveryMeshVertex(everyMeshVertex), UseNormalDirection(useNormalDirection) 31 EveryMeshVertex(everyMeshVertex), UseNormalDirection(useNormalDirection)
32{ 32{
33 #ifdef _DEBUG 33 #ifdef _DEBUG
34 setDebugName("CParticleAnimatedMeshSceneNodeEmitter"); 34 setDebugName("CParticleAnimatedMeshSceneNodeEmitter");
35 #endif 35 #endif
36 setAnimatedMeshSceneNode(node); 36 setAnimatedMeshSceneNode(node);
37} 37}
38 38
39 39
40//! Prepares an array with new particles to emitt into the system 40//! Prepares an array with new particles to emitt into the system
41//! and returns how much new particles there are. 41//! and returns how much new particles there are.
42s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray) 42s32 CParticleAnimatedMeshSceneNodeEmitter::emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray)
43{ 43{
44 Time += timeSinceLastCall; 44 Time += timeSinceLastCall;
45 45
46 const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond); 46 const u32 pps = (MaxParticlesPerSecond - MinParticlesPerSecond);
47 const f32 perSecond = pps ? ((f32)MinParticlesPerSecond + os::Randomizer::frand() * pps) : MinParticlesPerSecond; 47 const f32 perSecond = pps ? ((f32)MinParticlesPerSecond + os::Randomizer::frand() * pps) : MinParticlesPerSecond;
48 const f32 everyWhatMillisecond = 1000.0f / perSecond; 48 const f32 everyWhatMillisecond = 1000.0f / perSecond;
49 49
50 if(Time > everyWhatMillisecond) 50 if(Time > everyWhatMillisecond)
51 { 51 {
52 Particles.set_used(0); 52 Particles.set_used(0);
53 u32 amount = (u32)((Time / everyWhatMillisecond) + 0.5f); 53 u32 amount = (u32)((Time / everyWhatMillisecond) + 0.5f);
54 Time = 0; 54 Time = 0;
55 SParticle p; 55 SParticle p;
56 56
57 if(amount > MaxParticlesPerSecond * 2) 57 if(amount > MaxParticlesPerSecond * 2)
58 amount = MaxParticlesPerSecond * 2; 58 amount = MaxParticlesPerSecond * 2;
59 59
60 // Get Mesh for this frame 60 // Get Mesh for this frame
61 IMesh* frameMesh = AnimatedMesh->getMesh( core::floor32(Node->getFrameNr()), 61 IMesh* frameMesh = AnimatedMesh->getMesh( core::floor32(Node->getFrameNr()),
62 255, Node->getStartFrame(), Node->getEndFrame() ); 62 255, Node->getStartFrame(), Node->getEndFrame() );
63 for(u32 i=0; i<amount; ++i) 63 for(u32 i=0; i<amount; ++i)
64 { 64 {
65 if( EveryMeshVertex ) 65 if( EveryMeshVertex )
66 { 66 {
67 for( u32 j=0; j<frameMesh->getMeshBufferCount(); ++j ) 67 for( u32 j=0; j<frameMesh->getMeshBufferCount(); ++j )
68 { 68 {
69 for( u32 k=0; k<frameMesh->getMeshBuffer(j)->getVertexCount(); ++k ) 69 for( u32 k=0; k<frameMesh->getMeshBuffer(j)->getVertexCount(); ++k )
70 { 70 {
71 p.pos = frameMesh->getMeshBuffer(j)->getPosition(k); 71 p.pos = frameMesh->getMeshBuffer(j)->getPosition(k);
72 if( UseNormalDirection ) 72 if( UseNormalDirection )
73 p.vector = frameMesh->getMeshBuffer(j)->getNormal(k) / 73 p.vector = frameMesh->getMeshBuffer(j)->getNormal(k) /
74 NormalDirectionModifier; 74 NormalDirectionModifier;
75 else 75 else
76 p.vector = Direction; 76 p.vector = Direction;
77 77
78 p.startTime = now; 78 p.startTime = now;
79 79
80 if( MaxAngleDegrees ) 80 if( MaxAngleDegrees )
81 { 81 {
82 core::vector3df tgt = p.vector; 82 core::vector3df tgt = p.vector;
83 tgt.rotateXYBy(os::Randomizer::frand() * MaxAngleDegrees); 83 tgt.rotateXYBy(os::Randomizer::frand() * MaxAngleDegrees);
84 tgt.rotateYZBy(os::Randomizer::frand() * MaxAngleDegrees); 84 tgt.rotateYZBy(os::Randomizer::frand() * MaxAngleDegrees);
85 tgt.rotateXZBy(os::Randomizer::frand() * MaxAngleDegrees); 85 tgt.rotateXZBy(os::Randomizer::frand() * MaxAngleDegrees);
86 p.vector = tgt; 86 p.vector = tgt;
87 } 87 }
88 88
89 p.endTime = now + MinLifeTime; 89 p.endTime = now + MinLifeTime;
90 if (MaxLifeTime != MinLifeTime) 90 if (MaxLifeTime != MinLifeTime)
91 p.endTime += os::Randomizer::rand() % (MaxLifeTime - MinLifeTime); 91 p.endTime += os::Randomizer::rand() % (MaxLifeTime - MinLifeTime);
92 92
93 if (MinStartColor==MaxStartColor) 93 if (MinStartColor==MaxStartColor)
94 p.color=MinStartColor; 94 p.color=MinStartColor;
95 else 95 else
96 p.color = MinStartColor.getInterpolated(MaxStartColor, os::Randomizer::frand()); 96 p.color = MinStartColor.getInterpolated(MaxStartColor, os::Randomizer::frand());
97 97
98 p.startColor = p.color; 98 p.startColor = p.color;
99 p.startVector = p.vector; 99 p.startVector = p.vector;
100 100
101 if (MinStartSize==MaxStartSize) 101 if (MinStartSize==MaxStartSize)
102 p.startSize = MinStartSize; 102 p.startSize = MinStartSize;
103 else 103 else
104 p.startSize = MinStartSize.getInterpolated(MaxStartSize, os::Randomizer::frand()); 104 p.startSize = MinStartSize.getInterpolated(MaxStartSize, os::Randomizer::frand());
105 p.size = p.startSize; 105 p.size = p.startSize;
106 106
107 Particles.push_back(p); 107 Particles.push_back(p);
108 } 108 }
109 } 109 }
110 } 110 }
111 else 111 else
112 { 112 {
113 s32 randomMB = 0; 113 s32 randomMB = 0;
114 if( MBNumber < 0 ) 114 if( MBNumber < 0 )
115 randomMB = os::Randomizer::rand() % MBCount; 115 randomMB = os::Randomizer::rand() % MBCount;
116 else 116 else
117 randomMB = MBNumber; 117 randomMB = MBNumber;
118 118
119 u32 vertexNumber = frameMesh->getMeshBuffer(randomMB)->getVertexCount(); 119 u32 vertexNumber = frameMesh->getMeshBuffer(randomMB)->getVertexCount();
120 if (!vertexNumber) 120 if (!vertexNumber)
121 continue; 121 continue;
122 vertexNumber = os::Randomizer::rand() % vertexNumber; 122 vertexNumber = os::Randomizer::rand() % vertexNumber;
123 123
124 p.pos = frameMesh->getMeshBuffer(randomMB)->getPosition(vertexNumber); 124 p.pos = frameMesh->getMeshBuffer(randomMB)->getPosition(vertexNumber);
125 if( UseNormalDirection ) 125 if( UseNormalDirection )
126 p.vector = frameMesh->getMeshBuffer(randomMB)->getNormal(vertexNumber) / 126 p.vector = frameMesh->getMeshBuffer(randomMB)->getNormal(vertexNumber) /
127 NormalDirectionModifier; 127 NormalDirectionModifier;
128 else 128 else
129 p.vector = Direction; 129 p.vector = Direction;
130 130
131 p.startTime = now; 131 p.startTime = now;
132 132
133 if( MaxAngleDegrees ) 133 if( MaxAngleDegrees )
134 { 134 {
135 core::vector3df tgt = Direction; 135 core::vector3df tgt = Direction;
136 tgt.rotateXYBy(os::Randomizer::frand() * MaxAngleDegrees); 136 tgt.rotateXYBy(os::Randomizer::frand() * MaxAngleDegrees);
137 tgt.rotateYZBy(os::Randomizer::frand() * MaxAngleDegrees); 137 tgt.rotateYZBy(os::Randomizer::frand() * MaxAngleDegrees);
138 tgt.rotateXZBy(os::Randomizer::frand() * MaxAngleDegrees); 138 tgt.rotateXZBy(os::Randomizer::frand() * MaxAngleDegrees);
139 p.vector = tgt; 139 p.vector = tgt;
140 } 140 }
141 141
142 p.endTime = now + MinLifeTime; 142 p.endTime = now + MinLifeTime;
143 if (MaxLifeTime != MinLifeTime) 143 if (MaxLifeTime != MinLifeTime)
144 p.endTime += os::Randomizer::rand() % (MaxLifeTime - MinLifeTime); 144 p.endTime += os::Randomizer::rand() % (MaxLifeTime - MinLifeTime);
145 145
146 if (MinStartColor==MaxStartColor) 146 if (MinStartColor==MaxStartColor)
147 p.color=MinStartColor; 147 p.color=MinStartColor;
148 else 148 else
149 p.color = MinStartColor.getInterpolated(MaxStartColor, os::Randomizer::frand()); 149 p.color = MinStartColor.getInterpolated(MaxStartColor, os::Randomizer::frand());
150 150
151 p.startColor = p.color; 151 p.startColor = p.color;
152 p.startVector = p.vector; 152 p.startVector = p.vector;
153 153
154 if (MinStartSize==MaxStartSize) 154 if (MinStartSize==MaxStartSize)
155 p.startSize = MinStartSize; 155 p.startSize = MinStartSize;
156 else 156 else
157 p.startSize = MinStartSize.getInterpolated(MaxStartSize, os::Randomizer::frand()); 157 p.startSize = MinStartSize.getInterpolated(MaxStartSize, os::Randomizer::frand());
158 p.size = p.startSize; 158 p.size = p.startSize;
159 159
160 Particles.push_back(p); 160 Particles.push_back(p);
161 } 161 }
162 } 162 }
163 163
164 outArray = Particles.pointer(); 164 outArray = Particles.pointer();
165 165
166 return Particles.size(); 166 return Particles.size();
167 } 167 }
168 168
169 return 0; 169 return 0;
170} 170}
171 171
172 172
173//! Set Mesh to emit particles from 173//! Set Mesh to emit particles from
174void CParticleAnimatedMeshSceneNodeEmitter::setAnimatedMeshSceneNode( IAnimatedMeshSceneNode* node ) 174void CParticleAnimatedMeshSceneNodeEmitter::setAnimatedMeshSceneNode( IAnimatedMeshSceneNode* node )
175{ 175{
176 Node = node; 176 Node = node;
177 AnimatedMesh = 0; 177 AnimatedMesh = 0;
178 BaseMesh = 0; 178 BaseMesh = 0;
179 TotalVertices = 0; 179 TotalVertices = 0;
180 VertexPerMeshBufferList.clear(); 180 VertexPerMeshBufferList.clear();
181 if ( !node ) 181 if ( !node )
182 { 182 {
183 return; 183 return;
184 } 184 }
185 185
186 AnimatedMesh = node->getMesh(); 186 AnimatedMesh = node->getMesh();
187 BaseMesh = AnimatedMesh->getMesh(0); 187 BaseMesh = AnimatedMesh->getMesh(0);
188 188
189 MBCount = BaseMesh->getMeshBufferCount(); 189 MBCount = BaseMesh->getMeshBufferCount();
190 VertexPerMeshBufferList.reallocate(MBCount); 190 VertexPerMeshBufferList.reallocate(MBCount);
191 for( u32 i = 0; i < MBCount; ++i ) 191 for( u32 i = 0; i < MBCount; ++i )
192 { 192 {
193 VertexPerMeshBufferList.push_back( BaseMesh->getMeshBuffer(i)->getVertexCount() ); 193 VertexPerMeshBufferList.push_back( BaseMesh->getMeshBuffer(i)->getVertexCount() );
194 TotalVertices += BaseMesh->getMeshBuffer(i)->getVertexCount(); 194 TotalVertices += BaseMesh->getMeshBuffer(i)->getVertexCount();
195 } 195 }
196} 196}
197 197
198} // end namespace scene 198} // end namespace scene
199} // end namespace irr 199} // end namespace irr
200 200