-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMLP.cpp
More file actions
197 lines (136 loc) · 4.52 KB
/
MLP.cpp
File metadata and controls
197 lines (136 loc) · 4.52 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
//================================================//
#include "MLP.hpp"
//================================================//
MLP::MLP(Ogre::SceneManager* mgr) : Weapon(mgr)
{
m_pSceneMgr = mgr;
// Set filename
m_filename = "br.mesh";
m_damage = 10.0;
// Set the offset here and the Weapon init() function will translate it
m_offset = Ogre::Vector3(2.50, -2.10, -7.20);
// Set behaviour elements
m_type = TYPE_PROJECTILE;
m_projectileOffset = Ogre::Vector3(0, 0, -1.0);
// Set projectile data
m_projectileData.colour = Ogre::ColourValue(1.0, 1.0, 1.0);
m_projectileData.speed = 7.0;
m_projectileData.damage = m_damage;
m_projectileData.range = 10000.0;
// Sound
//m_pSoundAttack->init(Sound::TYPE_FIRE1);
}
//================================================//
MLP::~MLP(void)
{
m_pSceneMgr->destroyAnimation(ATTACK_ANIMATION);
}
//================================================//
void MLP::init(Ogre::SceneNode* node)
{
Weapon::init(node);
m_pSceneNode->rotate(Ogre::Vector3::UNIT_Y, Ogre::Radian((Ogre::Math::PI / 2.0)), Ogre::Node::TS_LOCAL);
m_pSceneNode->scale(1.6, 1.6, 1.6);
m_pEntity->setMaterialName("mainbody");
m_pEntity->setCastShadows(false);
m_muzzleFlashPos = Ogre::Vector3(6.0, 0.0, 0.0);
m_muzzleFlashType = MuzzleFlash::TYPE_FLASH2;
createAnimations();
}
//================================================//
void MLP::createAnimations(void)
{
m_pSceneNode->setInitialState();
Ogre::Animation* anim = m_pSceneMgr->createAnimation(ATTACK_ANIMATION, 250.0);
Ogre::NodeAnimationTrack* track = anim->createNodeTrack(0, m_pSceneNode);
anim->setInterpolationMode(Ogre::Animation::IM_LINEAR);
Ogre::TransformKeyFrame* key;
key = track->createNodeKeyFrame(0.0);
key = track->createNodeKeyFrame(125.0);
key->setTranslate(Ogre::Vector3(0.0, 0.0, 4.0));
key = track->createNodeKeyFrame(250.0);
key->setTranslate(Ogre::Vector3::ZERO);
m_pAnimState = m_pSceneMgr->createAnimationState(ATTACK_ANIMATION);
m_pAnimState->setLoop(false);
}
//================================================//
void MLP::attack(Sparks::Camera* camera)
{
if(!m_pAnimState->getEnabled()){
m_pAnimState->setEnabled(true);
Weapon::projectileAttack(camera);
}
}
//================================================//
void MLP::reload(void)
{
}
//================================================//
void MLP::update(double timeSinceLastFrame)
{
Weapon::update(timeSinceLastFrame);
}
//================================================//
//================================================//
TestGun::TestGun(Ogre::SceneManager* mgr) : Weapon(mgr)
{
m_pSceneMgr = mgr;
// set filename
m_filename = "br.mesh";
m_damage = 10.0;
// set the offset here and the Weapon constructor will translate it
m_offset = Ogre::Vector3(2.50, -2.10, -7.20);
// set behaviour elements
m_type = TYPE_RAY;
m_projectileOffset = Ogre::Vector3(0, 0, -1.0);
m_range = 6000.0;
m_debugRays = false;
// Sound
m_pSoundAttack->init(Sound::TYPE_FIRE1);
}
//================================================//
TestGun::~TestGun(void)
{
m_pSceneMgr->destroyAnimation(ATTACK_ANIMATION);
}
//================================================//
void TestGun::init(Ogre::SceneNode* node)
{
Weapon::init(node);
m_pSceneNode->rotate(Ogre::Vector3::UNIT_Y, Ogre::Radian((Ogre::Math::PI / 2.0)), Ogre::Node::TS_LOCAL);
m_pSceneNode->scale(1.6, 1.6, 1.6);
m_pEntity->setMaterialName("mainbody");
m_pEntity->setCastShadows(false);
m_muzzleFlashPos = Ogre::Vector3(6.0, 0.0, 0.0);
m_muzzleFlashType = MuzzleFlash::TYPE_FLASH2;
createAnimations();
}
//================================================//
void TestGun::createAnimations(void)
{
m_pSceneNode->setInitialState();
Ogre::Animation* anim = m_pSceneMgr->createAnimation(ATTACK_ANIMATION, 250);
Ogre::NodeAnimationTrack* track = anim->createNodeTrack(0, m_pSceneNode);
anim->setInterpolationMode(Ogre::Animation::IM_LINEAR);
Ogre::TransformKeyFrame* key;
key = track->createNodeKeyFrame(0.0);
key = track->createNodeKeyFrame(125.0);
key->setTranslate(Ogre::Vector3(0.0, 0.0, 3.0));
key = track->createNodeKeyFrame(250.0);
key->setTranslate(Ogre::Vector3::ZERO);
m_pAnimState = m_pSceneMgr->createAnimationState(ATTACK_ANIMATION);
m_pAnimState->setLoop(false);
}
//================================================//
void TestGun::attack(Sparks::Camera* camera)
{
if(!m_pAnimState->getEnabled()){
m_pAnimState->setEnabled(true);
Weapon::rayAttack(camera);
}
}
//================================================//
void TestGun::update(double timeSinceLastFrame)
{
Weapon::update(timeSinceLastFrame);
}