Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4955 in orxonox.OLD


Ignore:
Timestamp:
Jul 25, 2005, 3:48:55 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: extemely stupid aiming, but it works. Had to fix quite a few bugs in the process.

Location:
orxonox/trunk/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/coord/p_node.cc

    r4870 r4955  
    626626  {
    627627    glBegin(GL_LINE_STRIP);
    628     glVertex3f( .5,  .5, -.5);
    629     glVertex3f( .5,  .5,  .5);
    630     glVertex3f(-.5,  .5,  .5);
    631     glVertex3f(-.5, -.5,  .5);
    632     glVertex3f( .5,  .5, -.5);
    633     glVertex3f( .5, -.5, -.5);
    634     glVertex3f(-.5, -.5, -.5);
    635     glVertex3f(-.5,  .5, -.5);
     628    glVertex3f( .5*size,  .5*size, -.5*size);
     629    glVertex3f( .5*size,  .5*size,  .5*size);
     630    glVertex3f(-.5*size,  .5*size,  .5*size);
     631    glVertex3f(-.5*size, -.5*size,  .5*size);
     632    glVertex3f( .5*size,  .5*size, -.5*size);
     633    glVertex3f( .5*size, -.5*size, -.5*size);
     634    glVertex3f(-.5*size, -.5*size, -.5*size);
     635    glVertex3f(-.5*size,  .5*size, -.5*size);
    636636    glEnd();
    637637    glBegin(GL_LINE_STRIP);
    638     glVertex3f(-.5, -.5, -.5);
    639     glVertex3f(-.5, -.5,  .5);
    640     glVertex3f( .5, -.5,  .5);
    641     glVertex3f( .5, -.5, -.5);
     638    glVertex3f(-.5*size, -.5*size, -.5*size);
     639    glVertex3f(-.5*size, -.5*size,  .5*size);
     640    glVertex3f( .5*size, -.5*size,  .5*size);
     641    glVertex3f( .5*size, -.5*size, -.5*size);
    642642    glEnd();
    643643    glBegin(GL_LINES);
    644     glVertex3f( .5, -.5,  .5);
    645     glVertex3f( .5,  .5,  .5);
    646     glVertex3f(-.5, -.5,  .5);
    647     glVertex3f(-.5,  .5,  .5);
     644    glVertex3f( .5*size, -.5*size,  .5*size);
     645    glVertex3f( .5*size,  .5*size,  .5*size);
     646    glVertex3f(-.5*size, -.5*size,  .5*size);
     647    glVertex3f(-.5*size,  .5*size,  .5*size);
    648648    glEnd();
    649649  }
  • orxonox/trunk/src/lib/graphics/graphics_engine.cc

    r4864 r4955  
    316316void GraphicsEngine::enter2DMode()
    317317{
    318   GraphicsEngine::storeMatrices();
     318  //GraphicsEngine::storeMatrices();
    319319  SDL_Surface *screen = SDL_GetVideoSurface();
    320320
     
    433433void GraphicsEngine::draw() const
    434434{
     435  GraphicsEngine::storeMatrices();
    435436  Render2D::getInstance()->draw(E2D_ALL_LAYERS);
    436437  LightManager::getInstance()->draw();
  • orxonox/trunk/src/lib/graphics/render2D/render_2d.cc

    r4862 r4955  
    114114/**
    115115 * renders all the Elements of the Render2D-engine
     116 * @param layer the Layer to draw
    116117 */
    117118void Render2D::draw(unsigned int layer) const
     
    137138    drawLayer << 1;
    138139  }
    139 
    140140  GraphicsEngine::leave2DMode();
    141141
  • orxonox/trunk/src/story_entities/world.cc

    r4940 r4955  
    917917
    918918      /* update tick the rest */
    919       TrackManager::getInstance()->tick(this->dtS);
     919      //TrackManager::getInstance()->tick(this->dtS);
    920920      this->localCamera->tick(this->dtS);
    921921      // tick the engines
  • orxonox/trunk/src/world_entities/player.cc

    r4954 r4955  
    4646
    4747  //weapons:
    48   Weapon* wpRight = new TestGun(0);
    49   Weapon* wpLeft = new TestGun(1);
     48  Weapon* wpRight = new TestGun(this->weaponMan, 0);
     49  Weapon* wpLeft = new TestGun(this->weaponMan, 1);
    5050
    5151  this->weaponMan->addWeapon(wpRight);
     
    8080
    8181  //weapons:
    82   Weapon* wpRight = new TestGun(0);
     82  Weapon* wpRight = new TestGun(this->weaponMan, 0);
    8383  wpRight->setName("testGun Right");
    84   Weapon* wpLeft = new TestGun(1);
     84  Weapon* wpLeft = new TestGun(this->weaponMan, 1);
    8585  wpLeft->setName("testGun Left");
    8686
  • orxonox/trunk/src/world_entities/weapons/crosshair.cc

    r4865 r4955  
    165165  gluUnProject(position2D[0],
    166166               GraphicsEngine::getInstance()->getResolutionY()-position2D[1]-1,
    167                .99,
     167               .99,  // z
    168168               GraphicsEngine::modMat,
    169169               GraphicsEngine::projMat,
     
    183183void Crosshair::draw() const
    184184{
    185   GraphicsEngine::storeMatrices();
    186 
    187 
    188 
    189 
    190185//   glBegin(GL_TRIANGLES);
    191186//   glColor3f(1,0,0);
     
    194189//   glVertex3f(objX, objY, objZ+1);
    195190//   glEnd();
    196 
    197   this->debugDraw();
    198 
    199   GraphicsEngine::enter2DMode();
     191  glPushMatrix();
    200192  GLdouble pos[3];
    201193  gluProject(this->getAbsCoor().x,
     
    221213  glVertex2f(size, size);
    222214  glEnd();
    223 
    224   GraphicsEngine::leave2DMode();
    225 }
     215  glPopMatrix();
     216
     217}
  • orxonox/trunk/src/world_entities/weapons/projectile.cc

    r4948 r4955  
    9191void Projectile::setVelocity(const Vector &velocity)
    9292{
    93   Vector offsetVel = this->velocity = velocity;
    94   offsetVel.normalize();
    95   this->velocity += (offsetVel * 50.0);
     93  //Vector offsetVel =
     94  this->velocity = velocity;
     95 // offsetVel.normalize();
     96  //this->velocity += (offsetVel * 50.0);
    9697}
    9798
  • orxonox/trunk/src/world_entities/weapons/test_gun.cc

    r4953 r4955  
    2626#include "model.h"
    2727#include "test_bullet.h"
     28#include "weapon_manager.h"
    2829
    2930#include "state.h"
     
    4445   creates a new weapon
    4546*/
    46 TestGun::TestGun (int leftRight)
     47TestGun::TestGun (WeaponManager* weaponManager, int leftRight)
     48  : Weapon(weaponManager)
    4749{
    4850  this->setClassID(CL_TEST_GUN, "TestGun");
     
    158160  Projectile* pj =  dynamic_cast<Projectile*>(this->getProjectileFactory()->resurrect());
    159161
     162  PNode* target = this->getWeaponManager()->getFixedTarget();
     163
     164  if (target != NULL)
     165  {
     166    target->debugDraw();
     167    Vector test = ((target->getAbsCoor() - this->getAbsCoor())*5);
     168    pj->setVelocity(test/20.0);//this->getVelocity());
     169  }
     170  else
     171    pj->setVelocity(target->getVelocity());
     172
     173
    160174  pj->setAbsCoor(this->getEmissionPoint());
    161175  pj->setAbsDir(this->getAbsDir());
    162   pj->setVelocity(this->getVelocity());
    163176  State::getWorldEntityList()->add(pj);
    164177}
     
    191204void TestGun::draw ()
    192205{
     206  this->getWeaponManager()->getFixedTarget()->debugDraw(10);
     207
    193208  /* draw gun body */
    194209  glMatrixMode(GL_MODELVIEW);
  • orxonox/trunk/src/world_entities/weapons/test_gun.h

    r4953 r4955  
    2929  {
    3030  public:
    31     TestGun (int leftRight);
     31    TestGun (WeaponManager* weaponManager, int leftRight);
    3232    virtual ~TestGun ();
    3333
  • orxonox/trunk/src/world_entities/weapons/weapon.cc

    r4953 r4955  
    3939 * creates a new weapon
    4040*/
    41 Weapon::Weapon ()
     41Weapon::Weapon (WeaponManager* weaponManager)
    4242{
    4343  this->init();
     44  this->setWeaponManager(weaponManager);
    4445}
    4546
     
    8889  this->energy = .0;
    8990  this->energyMax = 10.0;
     91
     92  this->setWeaponManager(NULL);
    9093}
    9194
  • orxonox/trunk/src/world_entities/weapons/weapon.h

    r4953 r4955  
    2424// FORWARD DECLARATION
    2525class Projectile;
    26 class Weapon;
     26class WeaponManager;
    2727class Animation3D;
    2828class TiXmlElement;
     
    7272  public:
    7373    // INITIALISATION //
    74     Weapon ();
     74    Weapon (WeaponManager* weaponManager = NULL);
    7575    Weapon(const TiXmlElement* root);
    7676    virtual ~Weapon ();
     
    8585    ///////////////////
    8686
     87    /** @param weaponManager sets the WeaponManager for this Weapon (NULL if free))*/
     88    inline void setWeaponManager(WeaponManager* weaponManager) { this->weaponManager = weaponManager; };
     89    /** @returns the WeaponManager of this Weapon (or NULL if it is free) */
     90    inline WeaponManager* getWeaponManager() const { return this->weaponManager; };
    8791
    8892    /** @returns true if the Weapon is Active  (this is used to check if the weapon must be drawn)*/
     
    199203    ClassID              projectile;                      //!< the projectile used for this weapon (since they should be generated via macro and the FastFactory, only the ClassID must be known.)
    200204    FastFactory*         projectileFactory;               //!< A factory, that produces and handles the projectiles.
     205
     206    WeaponManager*       weaponManager;                   //!< The weaponManager this weapon is connected to. if NULL it is assumed, that the weapon is freely connected to an entity without a binding WeaponManager.
    201207  };
    202208
  • orxonox/trunk/src/world_entities/weapons/weapon_manager.h

    r4954 r4955  
    1414
    1515#include "p_node.h"
     16#include "crosshair.h"
    1617
    1718// FORWARD DECLARATION
    1819class PNode;
    1920class Weapon;
    20 class Crosshair;
    2121template <class T> class tAnimation;
    2222
     
    8787    void removeWeapon(Weapon* weapon, int configID = -1);
    8888
     89
     90
    8991    void nextWeaponConfig();
    9092    void previousWeaponConfig();
    9193    void changeWeaponConfig(int weaponConfig);
    9294
     95    /** @returns a fixed target namely the Crosshair's 3D position */
     96    inline PNode* getFixedTarget() { return this->crosshair; }
    9397    void fire();
    9498
Note: See TracChangeset for help on using the changeset viewer.