Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3752 in orxonox.OLD for orxonox/trunk/src


Ignore:
Timestamp:
Apr 7, 2005, 10:13:42 PM (20 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….

Location:
orxonox/trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/defs/debug.h

    r3750 r3752  
    5959#define DEBUG_MODULE_ORXONOX            0
    6060#define DEBUG_MODULE_WORLD              0
    61 #define DEBUG_MODULE_PNODE              3
     61#define DEBUG_MODULE_PNODE              1
    6262#define DEBUG_MODULE_WORLD_ENTITY       0
    6363#define DEBUG_MODULE_COMMAND_NODE       0
     
    6565#define DEBUG_MODULE_LOAD               0
    6666
    67 #define DEBUG_MODULE_IMPORTER           2
     67#define DEBUG_MODULE_IMPORTER           1
    6868#define DEBUG_MODULE_TRACK_MANAGER      0
    6969#define DEBUG_MODULE_GARBAGE_COLLECTOR  0
    7070#define DEBUG_MODULE_LIGHT              0
    71 #define DEBUG_MODULE_PLAYER             3
     71#define DEBUG_MODULE_PLAYER             1
    7272#define DEBUG_MODULE_MATH               0
    7373
  • orxonox/trunk/src/simple_animation.cc

    r3744 r3752  
    7373  delete iterator;
    7474  delete this->frames;
     75  singletonRef = NULL;
    7576}
    7677
     
    118119void SimpleAnimation::selectObject(WorldEntity* entity)
    119120{
    120   printf("SimpleAnimation::selectObject() - selecing active object\n");
    121121  Animation* anim = getAnimationFromWorldEntity(entity);
    122122  if( anim == NULL)
    123123    {
    124       printf("SimpleAnimation::selectObject() - object not found, creating one\n");
    125124      anim = new Animation;
    126125      anim->object = entity;
     
    128127      anim->tmpVect = new Vector();
    129128      anim->frames = new tList<KeyFrame>();
     129      anim->animMode = LOOP;
    130130      bRunning = false;
    131131      deltaT = 0.0;
    132132      this->animators->add(anim);
    133133    }
    134   else
    135     printf("SimpleAnimation::selectObject() - animation already existent, using it\n");
    136134  this->workingAnimator = anim;
    137   printf("SimpleAnimation::selectObject() - selection completed\n");
    138135}
    139136
     
    203200}
    204201
     202
     203void SimpleAnimation::setAnimationMode(animationMode mode)
     204{
     205  if( !this->bDescriptive || this->workingAnimator == NULL)
     206    {
     207      PRINTF(1)("SimpleAnimation: executing animation code outside a AnimationBegin()/AnimationEnd() - ignoring\n");
     208      return;
     209    }
     210  this->workingAnimator->animMode = mode;
     211}
    205212
    206213/**
     
    323330              anim->lastFrame = anim->currentFrame;
    324331              anim->currentFrame = anim->frames->nextElement(anim->currentFrame);
     332              if( anim->currentFrame == anim->frames->firstElement() && anim->animMode == SINGLE)
     333                {
     334                  anim->bRunning = false;
     335                  return;
     336                }
    325337              anim->movMode = anim->currentFrame->mode;
    326338              if( anim->movMode == NEG_EXP)
     
    335347            {
    336348            case LINEAR:
    337              
    338349              *anim->tmpVect = *anim->currentFrame->position - *anim->lastFrame->position;
    339350              *anim->tmpVect = *anim->tmpVect * anim->localTime / anim->currentFrame->time;
  • orxonox/trunk/src/simple_animation.h

    r3750 r3752  
    6767 public:
    6868  static SimpleAnimation* getInstance();
     69  virtual ~SimpleAnimation();
    6970
    7071  void animatorBegin();
     
    7475  void addKeyFrame(Vector* point, Quaternion* direction, float time, movementMode mode);
    7576  void addKeyFrame(KeyFrame* frame);
     77  void setAnimationMode(animationMode mode);
    7678  void reset();
    7779
     
    8789 private:
    8890  SimpleAnimation();
    89   virtual ~SimpleAnimation();
    9091
    9192  static SimpleAnimation* singletonRef;
  • orxonox/trunk/src/story_entities/world.cc

    r3750 r3752  
    158158  delete this->trackManager;
    159159
     160  delete this->simpleAnimation;
    160161  //delete garbagecollecor
    161162  //delete animator
     
    448449            this->spawn(baseNode);
    449450
    450             WorldEntity* secondNode = new Satellite(Vector(0,0,1), 1.0);
     451            WorldEntity* secondNode = new Satellite(Vector(0,0,1), 2.0);
    451452            baseNode->addChild(secondNode);
    452             secondNode->setRelCoor(new Vector(0.0, 3.0, 0.0));
     453            secondNode->setRelCoor(new Vector(0.0, 0.0, 3.0));
    453454            this->spawn(secondNode);
    454455
    455456
    456             WorldEntity* thirdNode = new Satellite(Vector(0,0,1), 2.0);
     457            WorldEntity* thirdNode = new Satellite(Vector(0,0,1), 1.0);
    457458            secondNode->addChild(thirdNode);
    458459            thirdNode->setRelCoor(new Vector(2.0, 0.0, 0.0));
     
    460461
    461462
     463           
     464           
    462465
    463466            WorldEntity* b = new Environment();
     
    499502
    500503
     504
    501505            this->simpleAnimation->animatorBegin();
    502506            this->simpleAnimation->selectObject(b);
     507            this->simpleAnimation->setAnimationMode(SINGLE);
    503508            this->simpleAnimation->addKeyFrame(f1);
    504509            this->simpleAnimation->addKeyFrame(f2);
  • orxonox/trunk/src/world_entities/player.cc

    r3750 r3752  
    5353  acceleration = 10.0;
    5454  //weapons:
    55   Weapon* wp = new TestGun(this, new Vector(-1.1, 0.0, 2.6), new Quaternion());
     55  Weapon* wp = new TestGun(this, new Vector(-2.6, 0.1, 3.0), new Quaternion());
    5656  this->weapons->add(wp);
    5757  this->activeWeapon = wp; 
  • 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
  • orxonox/trunk/src/world_entities/test_gun.h

    r3631 r3752  
    2929class Vector;
    3030class Quaternion;
     31class SimpleAnimation;
    3132
    3233
     
    5051  virtual void draw(void);
    5152
     53 private:
     54  SimpleAnimation* animator;
     55  WorldEntity* dummy;
     56
    5257};
    5358
  • orxonox/trunk/src/world_entities/weapon.cc

    r3685 r3752  
    3737  : WorldEntity()
    3838{
    39   parent->addChild(this, PNODE_ROTATE_AND_MOVE);
     39  parent->addChild(this, PNODE_ALL);
    4040  this->setRelCoor(coordinate);
    4141  this->setRelDir(direction);
Note: See TracChangeset for help on using the changeset viewer.