Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9168 in orxonox.OLD for branches


Ignore:
Timestamp:
Jul 4, 2006, 8:27:13 PM (18 years ago)
Author:
patrick
Message:

aiming sys

Location:
branches/presentation/src/world_entities
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/presentation/src/world_entities/creatures/fps_player.cc

    r9166 r9168  
    145145  this->getWeaponManager().getFixedTarget()->setRelCoor(1000,0,0);
    146146
    147   this->aimingSystem = new AimingSystem();
     147  this->aimingSystem = new AimingSystem(this);
    148148  this->addChild(this->aimingSystem);
    149   this->aimingSystem->toList(OM_LIST(this->getOMListNumber() + 1));
     149
    150150
    151151
     
    242242      this->getWeaponManager().setSlotPosition(0, Vector(1.5, box->halfLength[1] * f - 0.7, 1.1));
    243243      this->getWeaponManager().setSlotPosition(1, Vector(5.0, box->halfLength[1] * f, 0.0));
     244
     245      this->aimingSystem->toList(/*OM_LIST(this->getOMListNumber() + 1)*/ OM_GROUP_00);
    244246    }
    245247  }
     
    266268    }
    267269  }
     270
     271  WorldEntity* target = this->aimingSystem->getNearestTarget();
     272  if( target != NULL)
     273  {
     274    PRINTF(0)("hit hit hit, got: %s\n", target->getClassName());
     275  }
     276
    268277
    269278
  • branches/presentation/src/world_entities/weapons/aiming_system.cc

    r9166 r9168  
    1010
    1111   ### File Specific:
    12    main-programmer: Benjamin Grauer
     12   main-programmer: Patrick Boenzli
    1313   co-programmer: ...
    1414*/
     
    2323
    2424#include "aabb.h"
     25#include "obb_tree.h"
    2526
    2627#include <vector>
     
    3334 * standart constructor
    3435 */
    35 AimingSystem::AimingSystem (const TiXmlElement* root)
     36AimingSystem::AimingSystem (WorldEntity* entity)
    3637{
    3738  this->init();
    38 
    39 
    40   if (root)
    41     this->loadParams(root);
    4239}
    4340
     
    5956
    6057  this->loadModel("models/guns/targeting_system_body.obj");
    61 }
    6258
    63 
    64 void AimingSystem::loadParams(const TiXmlElement* root)
    65 {
    66   PNode::loadParams(root);
    67 
    68 //   LoadParam(root, "texture", this, AimingSystem, setTexture)
    69 //       .describe("the texture-file to load onto the AimingSystem");
    70 //
    71 //   LoadParam(root, "size", this, AimingSystem, setSize)
    72 //       .describe("the size of the AimingSystem in Pixels");
    73 //
    74 //   LoadParam(root, "rotation-speed", this, AimingSystem, setRotationSpeed)
    75 //       .describe("the Speed with which the AimingSystem should rotate");
     59  // registering default reactions:
     60  this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, CL_WORLD_ENTITY);
    7661}
    7762
     
    8974    return this->selectionList.back();
    9075
    91   WorldEntity* nearestEntity     = this->selectionList.back();
     76  WorldEntity* nearestEntity     = NULL;
    9277  float        distance          = 0.0f;
    9378  float        smalestDistance   = this->range * 5.0f;
     
    10489  }
    10590
    106   return nearestEntity;
     91  if( nearestEntity != this->owner)
     92    return nearestEntity;
     93  else return NULL;
    10794}
    10895
     
    127114{
    128115
    129   this->selectionList.clear();
     116//   this->selectionList.clear();
    130117}
    131118
     
    136123void AimingSystem::draw() const
    137124{
    138 //   if( this->getModelAABB() != NULL)
    139 //     this->getModelAABB()->drawBV(0, 1);
     125  WorldEntity::draw();
     126
     127  if( this->getOBBTree () != NULL)
     128    this->getOBBTree()->drawBV(0, 1);
    140129}
  • branches/presentation/src/world_entities/weapons/aiming_system.h

    r9166 r9168  
    2222
    2323 public:
    24   AimingSystem(const TiXmlElement* root = NULL);
     24  AimingSystem(WorldEntity* owner = NULL);
    2525  virtual ~AimingSystem();
    2626
    2727  void init();
    28   virtual void loadParams(const TiXmlElement* root);
    29 
    30 
    31   inline void selectTarget(PNode* target) { this->setParent(target); };
    32   inline PNode* getTarget(PNode* target) { return this->getParent(); };
    3328
    3429  WorldEntity* getNearestTarget();
    35 
    3630
    3731  void setRange(float range){this->range = range;};
     
    4741   std::vector<WorldEntity*>   selectionList;        //!< the selections
    4842
     43   WorldEntity*                owner;                //!< the owner of the targeting system
    4944
    5045};
  • branches/presentation/src/world_entities/world_entity.cc

    r9162 r9168  
    8585
    8686  this->toList(OM_NULL);
    87  
     87
    8888  registerVar( new SynchronizeableString( &this->md2TextureFileName, &this->md2TextureFileName, "md2TextureFileName" ) );
    8989  modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) );
    9090  scaling_handle = registerVarId( new SynchronizeableFloat( &scaling, &scaling, "scaling" ) );
    9191  list_handle = registerVarId( new SynchronizeableInt( (int*)&objectListNumber, &list_write, "list" ) );
    92  
     92
    9393  health_handle = registerVarId( new SynchronizeableFloat( &this->health, &this->health_write, "health" ) );
    9494  healthMax_handle = registerVarId( new SynchronizeableFloat( &this->healthMax, &this->healthMax_write, "maxHealth" ) );
     
    742742  this->decreaseHealth(damage);
    743743
    744   PRINTF(0)("Hit me: %s now only %f/%f health\n", this->getClassName(), this->getHealth(), this->getHealthMax());
     744  PRINTF(5)("Hit me: %s now only %f/%f health\n", this->getClassName(), this->getHealth(), this->getHealthMax());
    745745
    746746  if( this->getHealth() > 0)
     
    838838    this->toList( (OM_LIST)list_write );
    839839  }
    840  
     840
    841841  if ( std::find( id.begin(), id.end(), health_handle ) != id.end() )
    842842  {
    843843    this->setHealth( health_write );
    844844  }
    845  
     845
    846846  if ( std::find( id.begin(), id.end(), healthMax_handle ) != id.end() )
    847847  {
Note: See TracChangeset for help on using the changeset viewer.