Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9516 in orxonox.OLD


Ignore:
Timestamp:
Jul 27, 2006, 6:45:58 PM (18 years ago)
Author:
bensch
Message:

orxonox/proxy: the rockets from the targeting turrets aquire targets as they are supposed, but they do not get fired unless the player is near of them… strangely

Location:
branches/proxy/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/util/object_manager.cc

    r9513 r9516  
    177177{
    178178  if (omList == OM_INIT || omList == OM_SIZE)
    179     return ObjectManager::objectManagerListNames[0];
     179    return ObjectManager::objectManagerListNames[OM_NULL];
    180180
    181181  printf("%d\n", omList);
  • branches/proxy/src/world_entities/projectiles/guided_missile.h

    r9235 r9516  
    1313class ParticleEmitter;
    1414class FastFactory;
    15 class Aim;
    1615
    1716class GuidedMissile : public Projectile
  • branches/proxy/src/world_entities/weapons/aim.cc

    r9406 r9516  
    5050Aim::~Aim ()
    5151{
    52   if (this->material)
    53     delete this->material;
    54 
    5552/*  if (this->text != NULL)
    5653    delete this->text;*/
     
    7067
    7168  this->setBindNode(this);
    72   this->material = new Material;
    7369  this->source = NULL;
    7470
    7571  this->range = 10000;
    7672  this->angle = M_PI_4;
    77   this->group = OM_GROUP_01;
     73  this->targetGroup = OM_GROUP_02_PROJ;
    7874  this->anim = new tAnimation<Aim>(this, &Aim::setSize);
    7975  this->anim->setInfinity(ANIM_INF_CONSTANT);
     
    10399  LoadParam(root, "rotation-speed", this, Aim, setRotationSpeed)
    104100      .describe("the Speed with which the Aim should rotate");
     101
     102  LoadParam(root, "target-group", this, Aim, setTargetGroupS);
    105103}
    106104
     
    108106{
    109107  ObjectManager::EntityList::iterator entity;
    110 
    111   for (entity = State::getObjectManager()->getObjectList(group).begin();
    112        entity != State::getObjectManager()->getObjectList(group).end();
     108  //printf("%d\n", this->targetGroup);
     109
     110  for (entity = State::getObjectManager()->getObjectList(this->targetGroup).begin();
     111       entity != State::getObjectManager()->getObjectList(this->targetGroup).end();
    113112       entity ++)
    114113  {
    115114    diffVec = ( (*entity)->getAbsCoor() - this->source->getAbsCoor() );
    116115
    117     if ( diffVec.len() < range &&  acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) )  < angle)
     116    if ( diffVec.len() < range )//&&  acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) )  < angle)
    118117    {
    119118      //if (this->getParent() != (*entity))
    120119      {
     120        printf("found target::: %d %s::%s\n", (*entity)->getOMListNumber(), (*entity)->getClassCName(), (*entity)->getCName());
    121121        this->anim->replay();
    122         this->setParentSoft(*entity, 5);
     122        this->setParent/*Soft*/(*entity/*, 5 */);
    123123        return;
    124124      }
     
    128128   //if no target found:
    129129   this->setParent(PNode::getNullParent());
    130 
    131 
    132 
    133 }
    134 
     130}
     131
     132void Aim::setTargetGroupS(const std::string& groupName)
     133{
     134  printf("::::::::::::::::::::::: TEST\n");
     135  OM_LIST id = ObjectManager::StringToOMList(groupName);
     136  if (id != OM_NULL)
     137    this->setTargetGroup(id);
     138  else
     139    PRINTF(2)("List %s not found for targetting\n", groupName.c_str());
     140
     141  printf("targetGroup: %s, %d", groupName.c_str(), id);
     142}
    135143
    136144/**
     
    149157void Aim::setTexture(const std::string& textureFile)
    150158{
    151   this->material->setDiffuseMap(textureFile);
     159  this->material.setDiffuseMap(textureFile);
    152160}
    153161
     
    170178//only look for target if the aim hasn`t locked a target yet or if the actual target is out of range
    171179   if(this->getParent() == PNode::getNullParent() ||
    172       diffVec.len() > range ||
    173      ( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle))
     180      diffVec.len() > range )// ||
     181     //( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle))
    174182    {
    175183     this->setParentSoft(PNode::getNullParent(),5);
     
    213221
    214222  glRotatef(this->getAbsDir2D(), 0,0,1);
    215   this->material->select();
     223  this->material.select();
    216224  glBegin(GL_TRIANGLE_STRIP);
    217225  glTexCoord2f(0, 0);
  • branches/proxy/src/world_entities/weapons/aim.h

    r9513 r9516  
    1111#include "object_manager.h"
    1212
     13#include "material.h"
     14
    1315// FORWARD DECLARATION
    1416class Model;
    1517class Text;
    16 class Material;
    1718class TiXmlElement;
    1819template<class T> class tAnimation;
     
    2526 * Also the Aim is a Element2D, as it draws a cross onto the Target.
    2627 */
    27 class Aim : public PNode, public Element2D {
     28class Aim : public PNode, public Element2D
     29{
    2830
    29  public:
     31public:
    3032  Aim(PNode* source, const TiXmlElement* root = NULL);
    3133  virtual ~Aim();
    3234
    33   void init();
    3435  virtual void loadParams(const TiXmlElement* root);
    3536
     
    4344  void setRange(float range) {this->range = range;};
    4445  void setAngle(float angle) {this->angle = angle;};
    45   void setGroup(OM_LIST group) {this->group = group;};
     46  void setTargetGroup(OM_LIST group) { this->targetGroup = group; };
     47  void setTargetGroupS(const std::string& grounName);
    4648
    4749  void setSize(float size);
     
    5355  virtual void draw() const;
    5456
    55  private:
    56    Material*        material;             //!< a material for the Aim.
    57    float            rotationSpeed;        //!< Speed of the Rotation.
    58    tAnimation<Aim>* anim;
     57private:
     58  void init();
    5959
    60    float            range;                //!<
    61    float            angle;                //!<
    62    Vector           diffVec;
    63    OM_LIST          group;
    6460
    65    PNode*           source;               //!< Where this Shot has come from.
     61private:
     62  Material         material;             //!< a material for the Aim.
     63  float            rotationSpeed;        //!< Speed of the Rotation.
     64  tAnimation<Aim>* anim;
    6665
    67    Text*            text;                 //!< A Text to display onto this Node. (distance to Target)
     66  float            range;                //!<
     67  float            angle;                //!<
     68  Vector           diffVec;
     69  OM_LIST          targetGroup;
     70
     71  PNode*           source;               //!< Where this Shot has come from.
     72
     73  //   Text             text;                 //!< A Text to display onto this Node. (distance to Target)
    6874};
    6975
  • branches/proxy/src/world_entities/weapons/targeting_turret.cc

    r9406 r9516  
    1717#include "targeting_turret.h"
    1818
    19 #include "weapon_manager.h"
    20 #include "aim.h"
    21 #include "world_entities/projectiles/projectile.h"
     19#include "projectiles/projectile.h"
    2220
    2321#include "model.h"
     
    2523#include "animation3d.h"
    2624
     25#include "util/loading/load_param.h"
    2726#include "util/loading/factory.h"
    2827
     
    3029
    3130
    32 
    33 
    34 /**
    35  *  standard constructor
    36 
    37    creates a new weapon
    38 */
    39 TargetingTurret::TargetingTurret ()
    40   : Weapon()
    41 {
    42   this->init();
    43 
    44 }
    45 
    46 
    4731TargetingTurret::TargetingTurret(const TiXmlElement* root)
     32  : target(this)
    4833{
    4934  this->init();
     
    9176  //this->getProjectileFactory()->prepare(100);
    9277
    93   this->target = new Aim(this);
    94   this->target->setVisibility(false);
    95   this->target->setRange(1000);
    96   this->target->setAngle(M_PI_4);
    97   this->lockedTarget = this->target;
     78  this->target.setVisibility(false);
     79  this->target.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT | PNODE_PROHIBIT_CHILD_DELETE);
     80  this->target.setRange(1000);
     81  this->target.setAngle(M_PI_4);
     82  this->lockedTarget = &this->target;
    9883
    9984  this->lockedTime = 0;
     
    11297  Weapon::loadParams(root);
    11398
     99  LoadParam(root, "target-group", &target, Aim, setTargetGroupS);
     100
    114101}
    115102
     
    122109void TargetingTurret::deactivate()
    123110{
    124   this->target->setVisibility(false);
     111  this->target.setVisibility(false);
    125112}
    126113
     
    130117    return;
    131118
     119  this->target.tick(dt);
     120
    132121  if( lockedTime >= neededLockTime )
    133122   {
    134     lockedTarget = this->target->getParent();
     123    lockedTarget = this->target.getParent();
    135124    lockedTime = 0;
    136125   }
    137126
    138   this->target->tick(dt);
    139127
    140   if(this->target->getParent() == PNode::getNullParent())
     128  if(this->target.getParent() == PNode::getNullParent())
    141129   lockedTime = 0;
    142130  else
  • branches/proxy/src/world_entities/weapons/targeting_turret.h

    r8777 r9516  
    88
    99#include "weapon.h"
    10 
    11 /* FORWARD DECLARATION */
    12 class Aim;
     10#include "aim.h"
    1311
    1412class TargetingTurret : public Weapon
    15   {
    16   public:
    17     TargetingTurret ();
    18     TargetingTurret(const TiXmlElement* root);
    19     virtual ~TargetingTurret ();
     13{
     14public:
     15  TargetingTurret(const TiXmlElement* root = NULL);
     16  virtual ~TargetingTurret ();
    2017
    21     void init();
    22     virtual void loadParams(const TiXmlElement* root);
     18  virtual void loadParams(const TiXmlElement* root);
    2319
    24     virtual void activate();
    25     virtual void deactivate();
     20  virtual void activate();
     21  virtual void deactivate();
    2622
    27     virtual void tick(float dt);
    28     virtual void fire();
     23  virtual void tick(float dt);
     24  virtual void fire();
    2925
    30     virtual void draw() const;
     26  virtual void draw() const;
    3127
    32   private:
    33     Aim*           target;
    34     PNode*         lockedTarget;
    35     float          lockedTime;
    36     float          neededLockTime;
    37   };
     28private:
     29  void init();
     30
     31private:
     32  Aim            target;
     33  PNode*         lockedTarget;
     34  float          lockedTime;
     35  float          neededLockTime;
     36};
    3837
    3938#endif /* _TARGETING_TURRET_H */
  • branches/proxy/src/world_entities/world_entity.cc

    r9513 r9516  
    2828#include "util/loading/resource_manager.h"
    2929#include "util/loading/load_param.h"
    30 #include "vector.h"
    3130#include "obb_tree.h"
    3231
Note: See TracChangeset for help on using the changeset viewer.