Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/preferences/src/world_entities/weapons/projectile.cc @ 6658

Last change on this file since 6658 was 6142, checked in by bensch, 19 years ago

orxonox/trunk: merge the ObjectManager to the trunk
merged with command:
svn merge -r6082:HEAD objectmanager/ ../trunk/

conflicts resolution was easy this time :)
but specially merged the world to network_world

File size: 2.4 KB
Line 
1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   ### File Specific
14   main-programmer: Patrick Boenzli
15   co-programmer:
16*/
17#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
18
19#include "projectile.h"
20
21#include "world_entity.h"
22#include "weapon.h"
23#include "model.h"
24
25using namespace std;
26
27
28/**
29 *  standard constructor
30*/
31Projectile::Projectile () : WorldEntity()
32{
33  this->setClassID(CL_PROJECTILE, "Projectile");
34
35  this->lifeCycle = 0.0;
36  this->lifeSpan = 1.0f; /* sec */
37  this->target = NULL;
38  this->removeNode();
39}
40
41
42/**
43 *  standard deconstructor
44*/
45Projectile::~Projectile ()
46{
47  /*
48     do not delete the test projectModel, since it is pnode
49     and will be cleaned out by world
50  */
51  //delete this->projectileModel;
52}
53
54
55void Projectile::setEnergies(float energyMin, float energyMax)
56{
57  this->energyMin = energyMin;
58  if (energyMax <= energyMin)
59  {
60    this->bChargeable = false;
61    this->energyMax = energyMin;
62  }
63  else
64  {
65    this->bChargeable = true;
66    this->energyMax = energyMax;
67  }
68}
69
70
71/**
72 *  this sets the flight direction of the projectile
73 * @param directin in which to flight
74
75   this function will calculate a vector out of this to be used in the
76   tick function
77*/
78void Projectile::setFlightDirection(const Quaternion& flightDirection)
79{
80  Vector v(1, 0, 0);
81  this->flightDirection = flightDirection.apply(v);
82  this->flightDirection.normalize();
83}
84
85/**
86 *  sets the velocity vector to a spec speed
87 * @param velocity: vector of the velocity
88*/
89void Projectile::setVelocity(const Vector &velocity)
90{
91  //Vector offsetVel =
92  this->velocity = velocity;
93 // offsetVel.normalize();
94  //this->velocity += (offsetVel * 50.0);
95}
96
97
98
99void Projectile::setTarget(PNode* target)
100{
101  if (this->target == NULL)
102    this->target = new PNode(target, PNODE_PARENT_MODE_DEFAULT | PNODE_REPARENT_ON_PARENTS_REMOVE);
103  else
104    this->target->setParent(target);
105}
106
107
108/**
109 * signal tick, time dependent things will be handled here
110 * @param dt since last tick
111*/
112void Projectile::tick (float dt)
113{
114  Vector v = this->velocity * (dt);
115  this->shiftCoor(v);
116
117  if (this->tickLifeCycle(dt))
118    this->destroy();
119}
120
121
122/**
123 *  the function gets called, when the projectile is destroyed
124*/
125void Projectile::destroy ()
126{}
127
Note: See TracBrowser for help on using the repository browser.