Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3752 in orxonox.OLD for orxonox/trunk/src/world_entities/test_gun.cc


Ignore:
Timestamp:
Apr 7, 2005, 10:13:42 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: weapon now works perfectly: it shoots and moves to it. now i will have to change the projectile model itself….

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world_entities/test_gun.cc

    r3751 r3752  
    3030#include "vector.h"
    3131#include "list.h"
     32#include "simple_animation.h"
    3233
    3334using namespace std;
     
    4243  :  Weapon (parent, coordinate, direction)
    4344{
    44   //this->model = (Model*)ResourceManager::getInstance()->load("models/weapon_packet.obj", OBJ, RP_CAMPAIGN);
     45  this->model = (Model*)ResourceManager::getInstance()->load("models/test_gun.obj", OBJ, RP_CAMPAIGN);
    4546  this->idleTime = 0.2f;
     47
     48  this->animator = SimpleAnimation::getInstance();
     49  this->dummy = new WorldEntity(); /* a world entity that is not drawed: use this for the weapon */
     50  parent->addChild(this->dummy, PNODE_ALL);
     51  //this->dummy->setRelCoor(new Vector(-2.6, 0.1, 3.0));
     52 
     53  this->animator->animatorBegin();
     54  this->animator->selectObject(this->dummy);
     55  this->animator->setAnimationMode(SINGLE);
     56  this->animator->addKeyFrame(new Vector(-2.6, 0.1, 3.0), new Quaternion(), 0.0, NEG_EXP);
     57  this->animator->addKeyFrame(new Vector(-3.0, 0.1, 3.0), new Quaternion(), 0.1, NEG_EXP);
     58  this->animator->addKeyFrame(new Vector(-2.6, 0.1, 3.0), new Quaternion(), 0.5, NEG_EXP);
     59  this->animator->animatorEnd();
     60 
    4661}
    4762
     
    100115  this->worldEntities->add(pj);
    101116  this->localTime = 0;
     117 
     118  this->animator->animatorBegin();
     119  this->animator->selectObject(this->dummy);
     120  this->animator->start();
     121  this->animator->animatorEnd();
    102122}
    103123
     
    131151{
    132152  this->localTime += time;
    133   //this->debug();
    134   //printf("TEST_GUN: this speed is: %f\n", this->getSpeed());
    135153}
    136154
     
    148166void TestGun::draw ()
    149167{
     168 
    150169  glMatrixMode(GL_MODELVIEW);
    151170  glPushMatrix();
    152171  float matrix[4][4];
    153172 
    154   /* translate */
     173 
    155174  glTranslatef (this->getAbsCoor ().x,
    156175                this->getAbsCoor ().y,
    157176                this->getAbsCoor ().z);
    158   /* rotate */
     177 
    159178  this->getAbsDir ().matrix (matrix);
    160179  glMultMatrixf((float*)matrix);
     180  this->model->draw(1);
     181  glPopMatrix();
    161182 
    162   //this->model->draw(2);
     183
     184  glMatrixMode(GL_MODELVIEW);
     185  glPushMatrix();
     186 
     187  glTranslatef (this->dummy->getAbsCoor ().x,
     188                this->dummy->getAbsCoor ().y,
     189                this->dummy->getAbsCoor ().z);
     190
     191  this->dummy->getAbsDir ().matrix (matrix);
     192  glMultMatrixf((float*)matrix);
     193  this->model->draw(0);
    163194  glPopMatrix();
     195
    164196}
    165197
Note: See TracChangeset for help on using the changeset viewer.