Changeset 10252 in orxonox.OLD for branches/playability/src/world_entities/projectiles
- Timestamp:
- Jan 17, 2007, 1:41:51 PM (18 years ago)
- Location:
- branches/playability/src/world_entities/projectiles
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/playability/src/world_entities/projectiles/projectile_weapon.cc
r10235 r10252 182 182 } 183 183 184 void ProjectileWeapon:: fire()184 void ProjectileWeapon::blow() 185 185 { 186 186 } -
branches/playability/src/world_entities/projectiles/projectile_weapon.h
r10235 r10252 82 82 inline float getAngle () { return this->angle; }; 83 83 84 inline void updateAngle ( float dt ) { this->angle += this->rotationSpeed * dt; }; 85 86 inline void setFragments( int frag ) { this->fragments = frag; }; 87 inline int getFragments () { return this->fragments; }; 88 89 // virtual void blow (); 90 84 91 protected: 85 92 // energy … … 100 107 Vector rotationAxis; //!< rotation axis 101 108 109 int fragments; //!< Number of fragements created by the blow 110 102 111 Vector velocity; //!< velocity of the projectile_weapon. 103 112 104 113 PNode* target; //!< A target for guided Weapons. 105 114 106 virtual void fire();115 virtual void blow(); 107 116 108 117 // FastFactory ff; -
branches/playability/src/world_entities/projectiles/spike_ball.cc
r10235 r10252 31 31 #include "space_ships/space_ship.h" 32 32 33 // #include "weapons/weapon.h"34 // #include "../weapons/weapon_manager.h"35 33 36 34 #include "class_id_DEPRECATED.h" … … 65 63 this->halo->setSize(2, 2); 66 64 this->halo->setTexture("hbolt_halo.png"); 65 66 this->setFragments(26); 67 68 this->size = 4; 69 // this->fastFactory = tFastFactory<Spike>::getFastFactory(CL_SPIKE, "Spike"); 70 67 71 /* 68 72 this->weaponMan = new WeaponManager(dynamic_cast<WorldEntity*>(this)); … … 118 122 this->setDamage(5); 119 123 this->setHealth(0); 120 this->rotationVector = VECTOR_RAND(1); 124 this->setRotationAxis(VECTOR_RAND(1)); 125 this->setAngle(); 126 127 this->launcher[0] = Vector(1.0, 0.0, 0.0); 128 this->launcher[1] = Vector(0.0, 1.0, 0.0); 129 this->launcher[2] = Vector(0.0, 0.0, 1.0); 130 131 this->launcher[3] = Vector(1.0, 1.0, 0.0); 132 this->launcher[4] = Vector(0.0, 1.0, 1.0); 133 this->launcher[5] = Vector(1.0, 0.0, 1.0); 134 this->launcher[6] = Vector(1.0, -1.0, 0.0); 135 this->launcher[7] = Vector(0.0, 1.0, -1.0); 136 this->launcher[8] = Vector(-1.0, 0.0, 1.0); 137 138 this->launcher[9] = Vector(-1.0, 1.0, 1.0); 139 this->launcher[10] = Vector(1.0, 1.0, 1.0); 140 this->launcher[11] = Vector(1.0, -1.0, 1.0); 141 this->launcher[12] = Vector(-1.0, -1.0, 1.0); 142 143 int tmp = this->getFragments() / 2; 144 for (int i = 0; i < tmp; i++) 145 { 146 this->launcher[i].normalize(); 147 this->launcher[tmp + i] = this->launcher[i] * (-1); 148 } 121 149 } 122 150 … … 143 171 // this->deactivate(); 144 172 } 173 174 175 void SpikeBall::blow() 176 { 177 Spike* pj = NULL; 178 179 for ( int i = 0; i < this->getFragments(); i++) 180 { 181 pj = new Spike(); 182 if (pj == NULL) 183 return; 184 185 pj->setParent(PNode::getNullParent()); 186 187 pj->setVelocity(this->launcher[i].getNormalized() * 250.0); 188 189 pj->setParent(PNode::getNullParent()); 190 pj->setAbsCoor(this->getAbsCoor() + this->launcher[i] * this->size); 191 Quaternion q; 192 pj->setAbsDir(q.lookAt(Vector(), this->launcher[i], VECTOR_RAND(1))); 145 193 /* 146 void SpikeBall::blow() 147 { 148 const float* v = this->getModel()->getVertexArray(); 149 Projectile* pj = NULL; 150 151 for (unsigned int i = 0; i < this->getModel()->getVertexCount(); i++) 152 { 153 154 // v = this->getModel()->getModelInfo 155 156 pj = this->getProjectile(); 157 if (pj == NULL) 158 return; 159 160 if (v[i].x * v[i].x + v[i].y * v[i].y + v[i].z * v[i].z > 4) 161 { 162 pj->setParent(PNode::getNullParent()); 163 pj->setAbsCoor(this->getAbsCoor() + v); 164 pj->setAbsDir(v->getNormalized() * this->speed); 165 pj->activate(); 166 } 167 } 168 }*/ 194 pj->setAbsCoor(this->getAbsCoor() + VECTOR_RAND(3)); 195 pj->setAbsDir(this->getAbsDir());*/ 196 pj->activate(); 197 } 198 } 199 200 201 void SpikeBall::updateFireDir(){ 202 203 float** m = new float* [3]; 204 for( int i = 0; i < 3 ; i++) 205 m[i] = new float; 206 207 float nx, ny, nz, ca, sa; 208 209 nx = this->getRotationAxis().x; 210 ny = this->getRotationAxis().y; 211 nz = this->getRotationAxis().z; 212 213 ca = cos (this->getAngle()); 214 sa = sin (this->getAngle()); 215 // final version below... easier to to cheat with the one above. 216 217 m[0][0] = nx * nx * (1 - ca) + ca; 218 m[0][1] = nx * ny * (1 - ca) + nz * sa; 219 m[0][2] = nx * nz * (1 - ca) - ny * sa; 220 m[1][0] = nx * nz * (1 - ca) - nz * sa; 221 m[1][1] = ny * ny * (1 - ca) + ca; 222 m[1][2] = ny * nz * (1 - ca) + nx * sa; 223 m[2][0] = nx * nz * (1 - ca) + ny * sa; 224 m[2][1] = ny * nz * (1 - ca) - nx * sa; 225 m[2][2] = nz * nz * (1 - ca) + ca; 226 227 float x, y, z; 228 for (int i = 0; i < this->getFragments(); i++){ 229 // printf("%i ", i); 230 x = m[0][0] * this->launcher[i].x + m[0][1] * this->launcher[i].y + m[0][2] * this->launcher[i].z; 231 y = m[1][0] * this->launcher[i].x + m[1][1] * this->launcher[i].y + m[1][2] * this->launcher[i].z; 232 z = m[2][0] * this->launcher[i].x + m[2][1] * this->launcher[i].y + m[2][2] * this->launcher[i].z; 233 234 this->launcher[i] = Vector (x, y, z); 235 } 236 // printf("\n"); 237 238 for( int i = 0; i < 3 ; i++) 239 delete m[i]; 240 delete m; 241 } 169 242 170 243 … … 180 253 181 254 if(this->lifeCycle > .9){ 182 printf("called by spikeball "); 183 this->weaponMan->fire(); 255 // printf("called by spikeball "); 256 // this->weaponMan->fire(); 257 // this->blow(); 184 258 } 185 259 … … 187 261 this->deactivate(); 188 262 189 angle += rotationSpeed * dt; 263 this->updateAngle( dt ); 264 // angle += rotationSpeed * dt; 190 265 } 191 266 -
branches/playability/src/world_entities/projectiles/spike_ball.h
r10235 r10252 1 1 /*! 2 * @file lbolt.h3 * @brief light blaster lbolt2 * @file spike_ball.h 3 * @brief Noxonian SpikeBall Projectile; 2 stage weapon, splits into spikes 4 4 */ 5 5 … … 8 8 9 9 #include "projectile_weapon.h" 10 #include "spike.h" 10 11 #include "effects/billboard.h" 11 12 … … 19 20 class SpriteParticles; 20 21 class ParticleEmitter; 21 class FastFactory;22 22 class FastFactory; 23 23 … … 41 41 virtual void draw () const; 42 42 43 inline Vector getRotationVector() { return this->rotationVector; } 44 inline float getAngle() { return this->angle; } 45 46 // virtual void blow(); 43 // inline Vector getRotationVector() { return this->rotationVector; } 44 // inline float getAngle() { return this->angle; } 47 45 48 46 private: … … 63 61 WorldEntity* hitEntity; // FIXME TEMPORARY 64 62 65 WeaponManager* weaponMan; 63 // WeaponManager* weaponMan; 64 65 void updateFireDir(); 66 virtual void blow(); 67 68 // int spikes; 69 Vector* launcher; 70 float size; 71 66 72 }; 67 73
Note: See TracChangeset
for help on using the changeset viewer.