-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsseParticleEmitter.cpp
More file actions
122 lines (99 loc) · 2.81 KB
/
sseParticleEmitter.cpp
File metadata and controls
122 lines (99 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//========================================================
// Scaled Simulator Engine
//
// Author: Jason Huntley
//
// Description: Particle Emmitter
//
// Notes:
//
// Y+
// |
// |__ X+
// /
// Z+
//
// License:
//
// Licensed under the Apache License, Version 2.0
// (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of
// the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in
// writing, software distributed under the License is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing
// permissions and limitations under the License.
//
//=========================================================
#include "sseParticleEmitter.hpp"
#include "sseParticle.hpp"
#include "sseTexture.h"
#include "sseCamera.hpp"
#include "sseCommand.hpp"
#define MAX_PARTICLES 150
sseParticleEmitter::sseParticleEmitter(void) : sseObject()
{
stringstream sstm;
sstm << "ParticleEmitter-" << getID();
setName(sstm.str());
//m_materialDefault.setMode(MAT_UPDATE_FRONT);
//m_materialDefault.setShine(100.0);
}
sseParticleEmitter::~sseParticleEmitter(void)
{
}
void sseParticleEmitter::Load(sseTexture *pTextureLoader)
{
LoadExplosion();
}
void sseParticleEmitter::LoadExplosion()
{
for(int i = 0; i < MAX_PARTICLES; ++i)
{
sseParticle *particle=new sseParticle();
particle->SetEnabled(false);
particle->SetLife(RAND(1.0f, 2.0f));
//particle->SetLife(20.0);
particle->SetSize(1.0f);
particle->SetColor(215, 115, 40);
particle->SetXVelocity(RAND(-0.8f, 0.8));
particle->SetYVelocity(RAND(-0.8f, 0.8));
particle->SetZVelocity(RAND(-0.8f, 0.8f));
particle->SetRotationalVel(0.0, 0.0, RAND(-1.0f, 1.0f));
AddNode(particle, false, false);
}
}
void sseParticleEmitter::affineTransform()
{
sseCamera *c=m_command->GetActiveCamera();
dMatrix44 camMatrix=*c->GetViewTransformation();
dMatrix transpose=camMatrix.Transpose();
dQuaternion qRotX(vRight,m_Pitch);
dQuaternion qRotY(vUp,m_Yaw);
dQuaternion qRotZ(vLookAt,m_Roll);
m_objectMatrix=(qRotX*qRotY*qRotZ).Get4x4Matrix();
transpose[3]=m_vPos;
transpose[0][3]=0;
transpose[1][3]=0;
transpose[2][3]=0;
transpose[3][3]=1;
//TRST
m_objectMatrix*=transpose;
}
void sseParticleEmitter::HandleMouseMotionEvents(SDL_MouseMotionEvent *pMotion)
{
}
void sseParticleEmitter::HandleMouseButtonEvents(SDL_MouseButtonEvent *pButton)
{
}
void sseParticleEmitter::HandleKeyPressEvents(SDL_Scancode *pKeyEvent)
{
}
void sseParticleEmitter::HandleKeyReleaseEvents(SDL_Scancode *pKeyEvent)
{
}