Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10540 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Jan 31, 2007, 5:04:11 AM (18 years ago)
Author:
patrick
Message:

mounting point rewritten partially, for weapon slots

Location:
trunk/src/world_entities
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/mount_point.cc

    r10534 r10540  
    140140  if( this->_mount != NULL)
    141141  {
    142     PRINTF(0)("Got detail informations\n");
     142    PRINTF(0)("Got detailed informations\n");
    143143    this->_mount->loadParams( root);
    144144
  • trunk/src/world_entities/mount_point.h

    r10534 r10540  
    3131    void mount(PNode* entity);
    3232    void unmount();
    33 
     33    PNode* getMount() { return this->_mount; }
    3434
    3535  private:
  • trunk/src/world_entities/npcs/npc.cc

    r10539 r10540  
    5252#include "weapons/turret.h"
    5353#include "weapons/cannon.h"
     54
     55#include "mount_point.h"
     56#include "weapons/weapon_slot.h"
    5457
    5558#include "npc.h"
     
    169172
    170173  this->getWeaponManager().setSlotCount(7);
     174
     175
     176  // now get slots from the mount points
     177//   const std::vector<MountPoint*>::const_iterator it = this->beginMountPoints();
     178//   std::vector<MountPoint*> list = this->getMountPoints();
     179  std::map<int, MountPoint*>::iterator it = this->mountPointMap.begin();
     180//   PRINTF(0)("\n\n\n\nsize: %i\n", this->mountPointMap.size());
     181  for( ;it != this->mountPointMap.end(); it++)
     182  {
     183    PRINTF(0)("5555555555 this npc got mountss\n\n\n");
     184    WeaponSlot* ws = dynamic_cast<WeaponSlot*>((*it).second->getMount());
     185    printf("more\n");
     186    if( ws != NULL && ws->isA(WeaponSlot::staticClassID()))
     187    {
     188      //
     189      PRINTF(0)("5555555555 this npc got slots\n\n\n");
     190
     191      this->getWeaponManager().setSlotPosition(ws->getWeaponSlot(), ws->getRelCoor());
     192      this->getWeaponManager().setSlotDirection(ws->getWeaponSlot(), ws->getRelDir());
     193    }
     194  }
     195
     196
    171197
    172198  this->getWeaponManager().setSlotPosition(0, Vector(-2.6, .1, -3.0));
  • trunk/src/world_entities/world_entity.cc

    r10537 r10540  
    416416{
    417417  // add the mount point at the last position
    418   this->mountPoints.push_back(mountPoint);
     418//   this->mountPointMap[](mountPoint);
     419  assert(false);
    419420}
    420421
     
    425426void WorldEntity::addMountPoint(int slot, MountPoint* mountPoint)
    426427{
    427   if( this->mountPoints.capacity() < (unsigned int)slot)
    428   {
    429     // reserve 5 more slots than needed so this function is called as rare as possible
    430     this->mountPoints.reserve(slot + 5);
    431   }
    432   else if( this->mountPoints[slot] != NULL)
    433   {
    434     PRINTF(4)("adding a mount point to a slot, that already is occupied! ignoring - maybe some object did not get connected well (object: %s)\n", this->getClassCName());
     428  if( this->mountPointMap.find(slot) == this->mountPointMap.end())
     429  {
     430    PRINTF(2)("adding a mount point to a slot, that already is occupied! ignoring - maybe some object did not get connected well (object: %s)\n", this->getClassCName());
    435431  }
    436432
    437433  // just connect the mount point
    438   this->mountPoints[slot] = mountPoint;
     434  this->mountPointMap[slot] = mountPoint;
    439435}
    440436
     
    446442void WorldEntity::mount(int slot, WorldEntity* entity)
    447443{
    448   if( this->mountPoints[slot] == NULL)
     444  if( this->mountPointMap.find(slot) == this->mountPointMap.end())
    449445  {
    450446    PRINTF(0)("you tried to add an entity to a mount point that doesn't exist (slot %i)\n", slot);
  • trunk/src/world_entities/world_entity.h

    r10511 r10540  
    6262  void mount(int slot, WorldEntity* entity);
    6363  void unmount(int slot);
     64
     65
    6466
    6567  /** @param visibility if the Entity should be visible (been draw) */
     
    176178  ;  ///FIXME
    177179  void debugEntity() const;
    178  
     180
    179181  void pauseTrack(bool stop);
    180182
     
    194196  void updateHealthWidget();
    195197  void addTrack(const TiXmlElement* root);
    196  
     198
     199
     200
     201  protected:
     202      std::vector<MountPoint*> mountPoints;       //!< A list with mount points for this model
     203      std::map<int, MountPoint*> mountPointMap;
     204
    197205
    198206
     
    206214  std::vector<Model*>     models;             //!< The model that should be loaded for this entity.
    207215  ObjectInformationFile*  oiFile;             //!< Reference to the object information file discribing the model of this WE
    208   std::vector<MountPoint*> mountPoints;       //!< A list with mount points for this model
    209216  std::string             md2TextureFileName; //!< the file name of the md2 model texture, only if this
    210217  std::string             modelLODName;       //!< the name of the model lod file
Note: See TracChangeset for help on using the changeset viewer.