Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/projectiles/projectile.cc @ 6685

Last change on this file since 6685 was 6434, checked in by bensch, 19 years ago

orxonox/trunk: moved the projectiles to Projectiles

File size: 2.3 KB
RevLine 
[3573]1
2
[4597]3/*
[3573]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
[4597]15   co-programmer:
[3573]16*/
[5357]17#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
[3573]18
19#include "projectile.h"
[3618]20
[3573]21#include "world_entity.h"
[6434]22#include "world_entities/weapons/weapon.h"
[3678]23#include "model.h"
[3573]24
25using namespace std;
26
27
[3578]28/**
[4836]29 *  standard constructor
[3578]30*/
[4932]31Projectile::Projectile () : WorldEntity()
[3573]32{
[4322]33  this->setClassID(CL_PROJECTILE, "Projectile");
[4597]34
[4890]35  this->lifeCycle = 0.0;
[5063]36  this->lifeSpan = 1.0f; /* sec */
[6078]37  this->target = NULL;
[5769]38  this->removeNode();
[3573]39}
40
41
[3578]42/**
[4836]43 *  standard deconstructor
[3578]44*/
[4597]45Projectile::~Projectile ()
[3573]46{
[4597]47  /*
48     do not delete the test projectModel, since it is pnode
49     and will be cleaned out by world
[3629]50  */
51  //delete this->projectileModel;
[3573]52}
53
[3578]54
[6431]55void Projectile::setMinEnergy(float energyMin)
[4948]56{
57  this->energyMin = energyMin;
58}
59
60
[3578]61/**
[4836]62 *  this sets the flight direction of the projectile
63 * @param directin in which to flight
[3632]64
65   this function will calculate a vector out of this to be used in the
66   tick function
67*/
[4927]68void Projectile::setFlightDirection(const Quaternion& flightDirection)
[3632]69{
70  Vector v(1, 0, 0);
[4890]71  this->flightDirection = flightDirection.apply(v);
72  this->flightDirection.normalize();
[3632]73}
74
75/**
[4836]76 *  sets the velocity vector to a spec speed
77 * @param velocity: vector of the velocity
[4464]78*/
79void Projectile::setVelocity(const Vector &velocity)
80{
[4955]81  //Vector offsetVel =
82  this->velocity = velocity;
83 // offsetVel.normalize();
84  //this->velocity += (offsetVel * 50.0);
[4464]85}
86
[5766]87
88
89void Projectile::setTarget(PNode* target)
90{
[6078]91  if (this->target == NULL)
92    this->target = new PNode(target, PNODE_PARENT_MODE_DEFAULT | PNODE_REPARENT_ON_PARENTS_REMOVE);
93  else
94    this->target->setParent(target);
[5766]95}
96
97
[4464]98/**
[4927]99 * signal tick, time dependent things will be handled here
[6056]100 * @param dt since last tick
[3578]101*/
[6056]102void Projectile::tick (float dt)
[3632]103{
[6056]104  Vector v = this->velocity * (dt);
[3686]105  this->shiftCoor(v);
[3683]106
[6056]107  if (this->tickLifeCycle(dt))
108    this->destroy();
[3632]109}
[3573]110
111
[3578]112/**
[4836]113 *  the function gets called, when the projectile is destroyed
[3578]114*/
[4597]115void Projectile::destroy ()
[3574]116{}
[3573]117
Note: See TracBrowser for help on using the repository browser.