Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5750 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Nov 24, 2005, 12:13:22 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the WorldEntities into the Trunk.
Merged with command:
svn merge branches/world_entities/ trunk/ -r5516:HEAD

conflics from world_entities changed in favor of branches/world_entity
all other conflict in favor of the trunk

Location:
trunk/src
Files:
4 deleted
39 edited
17 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r5691 r5750  
    4848                  world_entities/camera.cc \
    4949                  world_entities/player.cc \
    50                   world_entities/npc.cc \
    51                   world_entities/npc2.cc \
     50                  world_entities/npcs/npc.cc \
     51                  world_entities/npcs/npc_test1.cc \
     52                  world_entities/npcs/npc_test.cc \
    5253                  world_entities/environment.cc \
    5354                  world_entities/skysphere.cc \
     
    6263                  world_entities/weapons/test_gun.cc \
    6364                  world_entities/weapons/turret.cc \
     65                  world_entities/weapons/ground_turret.cc \
     66                  world_entities/weapons/aiming_turret.cc \
     67                  world_entities/weapons/cannon.cc \
    6468                  world_entities/weapons/test_bullet.cc \
    6569                  world_entities/weapons/rocket.cc \
    6670                  world_entities/weapons/laser.cc \
    6771                  world_entities/weapons/aim.cc \
     72                  world_entities/weapons/bomb.cc \
    6873                  world_entities/weapons/crosshair.cc \
    6974                  world_entities/power_ups/power_up.cc \
     
    8287                 world_entities/camera.h \
    8388                 world_entities/player.h \
    84                  world_entities/npc.h \
    85                  world_entities/npc2.h \
     89                 world_entities/npcs/npc.h \
     90                 world_entities/npcs/npc_test.h \
     91                 world_entities/npcs/npc_test1.h \
    8692                 world_entities/environment.h \
    8793                 world_entities/skysphere.h \
     
    95101                 world_entities/weapons/projectile.h \
    96102                 world_entities/weapons/test_gun.h \
     103                 world_entities/weapons/cannon.h \
    97104                 world_entities/weapons/turret.h \
     105                 world_entities/weapons/aiming_turret.h \
    98106                 world_entities/weapons/test_bullet.h \
    99107                 world_entities/weapons/rocket.h \
    100108                 world_entities/weapons/laser.h \
    101109                 world_entities/weapons/aim.h \
     110                 world_entities/weapons/bomb.h \
    102111                 world_entities/weapons/crosshair.h \
    103112                 world_entities/power_ups/power_up.h \
  • trunk/src/defs/class_id.h

    r5634 r5750  
    135135  CL_TEST_GUN                   =    0x00000230,
    136136  CL_TURRET                     =    0x00000231,
    137 
     137  CL_AIMING_TURRET              =    0x00000232,
     138  CL_CANNON                     =    0x00000233,
    138139
    139140  CL_TEST_BULLET                =    0x00000240,
    140141  CL_ROCKET                     =    0x00000241,
    141142  CL_LASER                      =    0x00000242,
    142 
     143  CL_BOMB                       =    0x00000243,
     144  CL_GROUND_TURRET              =    0x00000244,
    143145
    144146  // gamePlay (range from 0x00000500 0x000005ff)
  • trunk/src/lib/collision_detection/Makefile.am

    r5687 r5750  
    66libORXcd_a_SOURCES = cd_engine.cc \
    77                     collision.cc \
    8                      obb.cc \
     8                     obb.cc \
    99                     obb_tree.cc \
    10                      obb_tree_node.cc \
     10                     obb_tree_node.cc \
    1111                     bv_tree.cc \
    12                      bv_tree_node.cc \
    13                      bounding_volume.cc \
    14                      bounding_sphere.cc
     12                     bv_tree_node.cc \
     13                     bounding_volume.cc \
     14                     bounding_sphere.cc
    1515
    1616
    1717noinst_HEADERS =     cd_engine.h \
    18                      collision_defs.h \
     18                     collision_defs.h \
    1919                     collision.h \
    20                      obb.h \
     20                     obb.h \
    2121                     obb_tree.h \
    22                      obb_tree_node.h \
     22                     obb_tree_node.h \
    2323                     bv_tree.h \
    24                      bv_tree_node.h \
    25                      bounding_volume.h \
    26                      bounding_sphere.h
     24                     bv_tree_node.h \
     25                     bounding_volume.h \
     26                     bounding_sphere.h
    2727
  • trunk/src/lib/coord/p_node.h

    r5414 r5750  
    7070  inline const Vector& getAbsCoor () const { return this->absCoordinate; };
    7171  void shiftCoor (const Vector& shift);
     72  void shiftCoor (float x, float y, float z) { this->shiftCoor(Vector(x, y, z)); };
    7273
    7374  void setRelDir (const Quaternion& relDir);
     
    127128  static const char* parentingModeToChar(int parentingMode);
    128129  static PARENT_MODE charToParentingMode(const char* parentingMode);
     130
     131
    129132 private:
    130133  void init(PNode* parent);
  • trunk/src/lib/graphics/light.cc

    r5671 r5750  
    2929using namespace std;
    3030
    31 CREATE_FACTORY(Light);
     31CREATE_FACTORY(Light, CL_LIGHT);
    3232
    3333//! Definition of the Lights and their Names
  • trunk/src/lib/gui/gl_gui/glmenu/glmenu_imagescreen.cc

    r5671 r5750  
    2525#include "load_param.h"
    2626
    27 CREATE_FACTORY(GLMenuImageScreen);
     27CREATE_FACTORY(GLMenuImageScreen, CL_GLMENU_IMAGE_SCREEN);
    2828
    2929using namespace std;
  • trunk/src/lib/particles/particle_emitter.cc

    r5671 r5750  
    2929
    3030
    31 CREATE_FACTORY(ParticleEmitter);
     31CREATE_FACTORY(ParticleEmitter, CL_PARTICLE_EMITTER);
    3232
    3333/**
  • trunk/src/lib/particles/particle_system.cc

    r5671 r5750  
    3232#include "tinyxml.h"
    3333
    34 CREATE_FACTORY(ParticleSystem);
     34CREATE_FACTORY(ParticleSystem, CL_PARTICLE_SYSTEM);
    3535SHELL_COMMAND(texture, ParticleSystem, setMaterialTexture)
    3636    ->defaultValues(1, "maps/evil-flower.png");
  • trunk/src/lib/physics/fields/gravity.cc

    r5357 r5750  
    2323using namespace std;
    2424
    25 CREATE_FACTORY(Gravity);
     25CREATE_FACTORY(Gravity, CL_FIELD_GRAVITY);
    2626
    2727Gravity::Gravity(const TiXmlElement* root)
  • trunk/src/lib/physics/physics_connection.cc

    r5671 r5750  
    2929using namespace std;
    3030
    31 CREATE_FACTORY(PhysicsConnection);
     31CREATE_FACTORY(PhysicsConnection, CL_PHYSICS_CONNECTION);
    3232
    3333/**
  • trunk/src/story_entities/world.cc

    r5671 r5750  
    7070
    7171#include "cd_engine.h"
    72 #include "npc.h"
    73 #include "npc2.h"
     72#include "npcs/npc_test1.h"
    7473#include "shader.h"
    7574
     
    8180
    8281//! This creates a Factory to fabricate a World
    83 CREATE_FACTORY(World);
     82CREATE_FACTORY(World, CL_WORLD);
    8483
    8584World::World(const TiXmlElement* root)
     
    469468  for(int i = 0; i < 100; i++)
    470469  {
    471     WorldEntity* tmp = new NPC();
     470    WorldEntity* tmp = new NPCTest1();
    472471    char npcChar[10];
    473472    sprintf (npcChar, "NPC_%d", i);
  • trunk/src/subprojects/benchmark.cc

    r5427 r5750  
    3636#include <stdlib.h>
    3737#include <asm/msr.h>
    38 #include <linux/timex.h>
     38//#include <linux/timex.h>
    3939
    4040
  • trunk/src/subprojects/collision_detection/Makefile.am

    r5687 r5750  
    66
    77collision_LDADD = $(MAINSRCDIR)/util/libORXutils.a \
     8                  $(MAINSRCDIR)/lib/physics/libORXphysics.a \
    89                  $(MAINSRCDIR)/lib/collision_detection/libORXcd.a \
    910                  $(MAINSRCDIR)/lib/libORXlibs.a \
  • trunk/src/subprojects/collision_detection/collision_test_entity.cc

    r5687 r5750  
    2626
    2727using namespace std;
    28 CREATE_FACTORY(CollisionTestEntity);
     28CREATE_FACTORY(CollisionTestEntity, CL_ENVIRONMENT);
    2929
    3030/**
  • trunk/src/subprojects/importer/Makefile.am

    r5546 r5750  
    3131                  $(MAINSRCDIR)/lib/util/substring.cc \
    3232                  $(MAINSRCDIR)/lib/util/color.cc \
     33                  $(MAINSRCDIR)/lib/util/multi_type.cc \
    3334                  $(MAINSRCDIR)/util/loading/factory.cc
  • trunk/src/util/Makefile.am

    r5546 r5750  
    55
    66libORXutils_a_SOURCES = fast_factory.cc \
     7                        object_manager.cc \
    78                        loading/factory.cc \
    89                        garbage_collector.cc \
     
    1819                        track/pilot_node.cc \
    1920                        track/track_manager.cc \
    20                         track/track_node.cc
     21                        track/track_node.cc 
    2122
    2223noinst_HEADERS =        fast_factory.h \
     24                        object_manager.h \
    2325                        garbage_collector.h \
    2426                        state.h \
  • trunk/src/util/fast_factory.cc

    r5041 r5750  
    1313*/
    1414
    15 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_OBJECT_MANAGER
     15#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOAD
    1616
    1717#include "fast_factory.h"
  • trunk/src/util/loading/factory.cc

    r5298 r5750  
    3434   set everything to zero and define factoryName
    3535*/
    36 Factory::Factory (const char* factoryName)
     36Factory::Factory (const char* factoryName, ClassID classID)
    3737{
    3838  this->setClassID(CL_FACTORY, "Factory");
     
    4040
    4141  this->next = NULL;
     42  this->classID = classID;
    4243
    4344  Factory::registerFactory(this);
  • trunk/src/util/loading/factory.h

    r5357 r5750  
    3333 * this should be used at the beginning of all the Classes that should be loadable (in the cc-file)
    3434*/
    35 #define CREATE_FACTORY(CLASS_NAME) \
    36     tFactory<CLASS_NAME>* global_##CLASS_NAME##_Factory = new tFactory<CLASS_NAME>(#CLASS_NAME)
     35#define CREATE_FACTORY(CLASS_NAME, CLASS_ID) \
     36    tFactory<CLASS_NAME>* global_##CLASS_NAME##_Factory = new tFactory<CLASS_NAME>(#CLASS_NAME, CLASS_ID)
    3737
    3838//! The Factory is a loadable object handler
     
    4040
    4141 public:
    42   Factory (const char* factoryName = NULL);
     42  Factory (const char* factoryName = NULL, ClassID classID = CL_NULL);
    4343  virtual ~Factory ();
    4444
    4545  void fabricate(const char* className, const char* entityName);
     46  virtual BaseObject* fabricate(ClassID classID) = NULL;
    4647  virtual BaseObject* fabricate(const TiXmlElement* root) = NULL;
    4748  virtual BaseObject* fabricateDirect() = NULL;
     
    5758    Factory* getNext() const { return this->next; };
    5859
     60
     61  protected:
     62    ClassID           classID;              //!< The CLass-Identifyer of the Factory.
     63
    5964  private:
    6065    Factory*          next;                 //!< pointer to the next factory.
     
    6469/**
    6570 *  a factory that is able to load any kind of Object
    66    (this is a Functor)
    67 */
     71 * (this is a Functor)
     72 */
    6873template<class T> class tFactory : public Factory
    6974{
    70  public:
    71   tFactory(const char* factoryName);
    72   virtual ~tFactory();
     75  public:
     76    tFactory(const char* factoryName, ClassID classID);
     77    virtual ~tFactory();
    7378
    7479  private:
    75   virtual BaseObject* fabricate(const TiXmlElement* root);
    76   virtual BaseObject* fabricateDirect();
     80    virtual BaseObject* fabricate(ClassID classID);
     81    virtual BaseObject* fabricate(const TiXmlElement* root);
     82    virtual BaseObject* fabricateDirect();
    7783};
    7884
     
    8288*/
    8389template<class T>
    84 tFactory<T>::tFactory(const char* factoryName) : Factory(factoryName)
     90    tFactory<T>::tFactory(const char* factoryName, ClassID classID) : Factory(factoryName, classID)
    8591{
    8692  PRINTF(4)("Class: %s loadable\n", this->getName());
    8793}
    8894
    89 
     95/**
     96 * destructs the type-Factory
     97 */
    9098template<class T>
    91 tFactory<T>::~tFactory()
     99    tFactory<T>::~tFactory()
    92100{}
    93101
     102/**
     103 * fabricates an Object of type T, with the constructor T::T(const TiXmlElemnt*)
     104 * @param root the TiXmlElement T should load parameters from.
     105 * @return the newly fabricated T, NULL otherwise.
     106 */
    94107template<class T>
    95 BaseObject* tFactory<T>::fabricate(const TiXmlElement* root)
     108    BaseObject* tFactory<T>::fabricate(const TiXmlElement* root)
    96109{
    97110  if (root == NULL)
     
    106119}
    107120
     121
     122/**
     123 * fabricates an Object of type T, with the constructor T::T(const TiXmlElemnt*)
     124 * @param classID the ClassID of T that should be created.
     125 * @return the newly fabricated T if fabricated NULL otherwise.
     126 */
     127template<class T>
     128    BaseObject* tFactory<T>::fabricate(ClassID classID)
     129{
     130  if(classID == this->classID)
     131    return this->fabricateDirect();
     132  else if( getNext() != NULL)
     133    return getNext()->fabricate( classID);
     134  else
     135    return NULL;
     136}
     137
     138/**
     139 * directly fabricate an Entity of this factory.
     140 */
    108141template<class T>
    109142    BaseObject* tFactory<T>::fabricateDirect()
  • trunk/src/world_entities/Makefile.am

    r5463 r5750  
    2525                  weapons/rocket.cc \
    2626                  weapons/laser.cc \
     27                  weapons/ground_turret.cc \
    2728                  weapons/crosshair.cc \
     29                  weapons/ground_turret.cc \
    2830                  power_ups/power_up.cc \
    2931                  power_ups/turret_power_up.cc \
  • trunk/src/world_entities/environment.cc

    r5500 r5750  
    2828
    2929using namespace std;
    30 CREATE_FACTORY(Environment);
     30CREATE_FACTORY(Environment, CL_ENVIRONMENT);
    3131
    3232/**
  • trunk/src/world_entities/player.cc

    r5636 r5750  
    2828#include "weapons/test_gun.h"
    2929#include "weapons/turret.h"
     30#include "weapons/cannon.h"
    3031
    3132#include "list.h"
     
    3738using namespace std;
    3839
    39 CREATE_FACTORY(Player);
     40CREATE_FACTORY(Player, CL_PLAYER);
    4041
    4142/**
     
    4647{
    4748  this->init();
    48 
    49   //weapons:
    50   Weapon* wpRight = new TestGun(this->weaponMan, 0);
    51   Weapon* wpLeft = new TestGun(this->weaponMan, 1);
    52 
    53   this->weaponMan->addWeapon(wpRight);
    54 //  this->weaponMan->addWeapon(wpLeft, WM_CONFIG1, WM_SLOT1);
    55 //  this->weaponMan->addWeapon(wpRight, WM_CONFIG2);
    56 //  this->weaponMan->addWeapon(wpLeft, WM_CONFIG2);
    5749}
    5850
     
    8880
    8981  //weapons:
    90   Weapon* wpRight = new TestGun(this->weaponMan, 0);
     82  Weapon* wpRight = new TestGun(0);
    9183  wpRight->setName("testGun Right");
    92   Weapon* wpLeft = new TestGun(this->weaponMan, 1);
     84  Weapon* wpLeft = new TestGun(1);
    9385  wpLeft->setName("testGun Left");
     86  Weapon* cannon = dynamic_cast<Weapon*>(Factory::getFirst()->fabricate(CL_CANNON));
     87
     88  cannon->setName("BFG");
    9489
    9590  this->weaponMan->addWeapon(wpLeft, 1, 0);
    9691  this->weaponMan->addWeapon(wpRight,1 ,1);
     92  this->weaponMan->addWeapon(cannon, 0, 6);
     93
    9794  //this->weaponMan->addWeapon(turret, 3, 0);
    9895
     
    134131
    135132  this->weaponMan = new WeaponManager(this);
    136   this->weaponMan->setSlotCount(10);
     133  this->weaponMan->setSlotCount(7);
    137134
    138135  this->weaponMan->setSlotPosition(0, Vector(-2.6, .1, -3.0));
     
    153150  this->weaponMan->setSlotPosition(5, Vector(-1.5, -.5, -.5));
    154151  this->weaponMan->setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    155 
    156   this->weaponMan->setSlotPosition(6, Vector(-2.0, 0.1, -2.0));
    157   this->weaponMan->setSlotPosition(7, Vector(-2.0, 0.1, 2.0));
    158 
    159   this->weaponMan->setSlotPosition(8, Vector(-2.5, -0.3, -2.0));
    160   this->weaponMan->setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0)));
    161 
    162   this->weaponMan->setSlotPosition(9, Vector(-2.5, -0.3, 2.0));
    163   this->weaponMan->setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));
     152//
     153   this->weaponMan->setSlotPosition(6, Vector(-1, 0.0, 0));
     154   this->weaponMan->setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     155   //
     156//   this->weaponMan->setSlotPosition(8, Vector(-2.5, -0.3, -2.0));
     157//   this->weaponMan->setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0)));
     158//
     159//   this->weaponMan->setSlotPosition(9, Vector(-2.5, -0.3, 2.0));
     160//   this->weaponMan->setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));:
     161
    164162}
    165163
     
    337335}
    338336
     337#include "weapons/aiming_turret.h"
    339338// FIXME THIS MIGHT BE CONSIDERED EITHER A FEATURE, OR A BUG
    340339void Player::ADDWEAPON()
    341340{
    342   Weapon* turret1 = new Turret(this->weaponMan);
    343   turret1->setName("Turret");
    344   turret1->setStateDuration(WS_SHOOTING, (float)rand()/RAND_MAX*.5+.1);
    345 
    346   this->weaponMan->addWeapon(turret1, 2);
    347 
    348   this->weaponMan->changeWeaponConfig(2);
    349 }
     341  Weapon* turret = NULL;
     342
     343  if ((float)rand()/RAND_MAX < .1)
     344  {
     345    //if (this->weaponMan->hasFreeSlot(2, WTYPE_TURRET))
     346    {
     347      turret = new Turret();
     348      this->weaponMan->addWeapon(turret, 2);
     349      this->weaponMan->changeWeaponConfig(2);
     350    }
     351  }
     352  else
     353  {
     354    //if (this->weaponMan->hasFreeSlot(3))
     355    {
     356      turret = new AimingTurret();
     357      this->weaponMan->addWeapon(turret, 3);
     358
     359      this->weaponMan->changeWeaponConfig(3);
     360    }
     361  }
     362
     363  if(turret != NULL)
     364  {
     365    turret->setName("Turret");
     366    turret->setStateDuration(WS_SHOOTING, (float)rand()/RAND_MAX*.5+.1);
     367  }
     368}
  • trunk/src/world_entities/power_ups/laser_power_up.cc

    r5500 r5750  
    2525using namespace std;
    2626
    27 CREATE_FACTORY(LaserPowerUp);
     27CREATE_FACTORY(LaserPowerUp, CL_LASER_POWER_UP);
    2828
    2929LaserPowerUp::LaserPowerUp ()
  • trunk/src/world_entities/power_ups/turret_power_up.cc

    r5500 r5750  
    2525using namespace std;
    2626
    27 CREATE_FACTORY(TurretPowerUp);
     27CREATE_FACTORY(TurretPowerUp, CL_TURRET_POWER_UP);
    2828
    2929TurretPowerUp::TurretPowerUp ()
  • trunk/src/world_entities/skybox.cc

    r5671 r5750  
    2525using namespace std;
    2626
    27 CREATE_FACTORY(SkyBox);
     27CREATE_FACTORY(SkyBox, CL_SKYBOX);
    2828
    2929/**
  • trunk/src/world_entities/terrain.cc

    r5671 r5750  
    2929using namespace std;
    3030
    31 CREATE_FACTORY(Terrain);
     31CREATE_FACTORY(Terrain, CL_TERRAIN);
    3232
    3333/**
  • trunk/src/world_entities/weapons/aim.cc

    r5671 r5750  
    2020#include "load_param.h"
    2121#include "graphics_engine.h"
    22 #include "glincl.h"
    2322#include "state.h"
     23#include "list.h"
    2424#include "material.h"
     25#include "t_animation.h"
     26#include "text.h"
     27
     28#include "world_entity.h"
    2529
    2630using namespace std;
     
    3034 * standart constructor
    3135 */
    32 Aim::Aim (const TiXmlElement* root)
     36Aim::Aim (PNode* source, const TiXmlElement* root)
    3337{
    3438  this->init();
     39
     40  this->source = source;
    3541
    3642  if (root)
     
    4753  if (this->material)
    4854    delete this->material;
     55
     56  if (this->text != NULL)
     57    delete this->text;
    4958}
    5059
     
    5867
    5968  this->setLayer(E2D_LAYER_TOP);
    60   this->setRotationSpeed(5);
     69  this->setRotationSpeed(30.0* (float)rand()/RAND_MAX + 10.0);
    6170  this->setSize(GraphicsEngine::getInstance()->getResolutionX()/10.0);
    6271
    63 //  this->setBindNode(this);
     72  this->setBindNode(this);
    6473  this->material = new Material;
    65 }
    66 
     74  this->source = NULL;
     75
     76  this->anim = new tAnimation<Aim>(this, &Aim::setSize);
     77  this->anim->setInfinity(ANIM_INF_CONSTANT);
     78  this->anim->addKeyFrame(500, .3, ANIM_LINEAR);
     79  this->anim->addKeyFrame(100, .2, ANIM_LINEAR);
     80  this->anim->addKeyFrame(50, .01, ANIM_LINEAR);
     81
     82  this->text = new Text();
     83  this->text->setParent2D(this);
     84  this->text->setRelCoor2D(10, -50);
     85  this->text->setParentMode2D(E2D_PARENT_MOVEMENT);
     86  this->text->setText("Testing");
     87}
    6788
    6889void Aim::loadParams(const TiXmlElement* root)
     
    80101}
    81102
     103void Aim::searchTarget(float range)
     104{
     105  tIterator<WorldEntity>* iterator = State::getWorldEntityList()->getIterator();
     106  WorldEntity* entity = iterator->firstElement();
     107  while (likely(entity != NULL))
     108  {
     109    if (entity->isA(CL_NPC) && this->source->getAbsCoor().x < entity->getAbsCoor().x && (this->source->getAbsCoor() - entity->getAbsCoor()).len() < range)
     110    {
     111      if (this->getParent() != entity)
     112      {
     113        this->anim->replay();
     114        this->setParentSoft(entity, 5);
     115      }
     116      delete iterator;
     117      return;
     118    }
     119    entity = iterator->nextElement();
     120  }
     121
     122  delete iterator;
     123}
     124
     125
    82126
    83127/**
     
    108152  this->shiftDir2D(dt * rotationSpeed);
    109153
    110 
    111   float z = 0.0f;
    112   glReadPixels ((int)this->getAbsCoor2D().x,
    113                  GraphicsEngine::getInstance()->getResolutionY()-(int)this->getAbsCoor2D().y-1,
    114                  1,
    115                  1,
    116                  GL_DEPTH_COMPONENT,
    117                  GL_FLOAT,
    118                  &z);
    119 
    120 
    121   GLdouble objX=.0, objY=.0, objZ=.0;
    122   gluUnProject(this->getAbsCoor2D().x,
    123                GraphicsEngine::getInstance()->getResolutionY()-this->getAbsCoor2D().y-1,
    124                .99,  // z
    125                GraphicsEngine::modMat,
    126                GraphicsEngine::projMat,
    127                GraphicsEngine::viewPort,
    128                &objX,
    129                &objY,
    130                &objZ );
    131 
    132   this->setAbsCoor(objX, objY, objZ);
     154  char outputText[100];
     155  sprintf(outputText, "%s - distance: %f\n", this->getParent()->getName(), (this->source->getAbsCoor() - this->getAbsCoor()).len());
     156  this->text->setText(outputText);
     157
     158
     159  if (this->source->getAbsCoor().x > this->getAbsCoor().x )
     160    this->searchTarget(1000);
     161//   float z = 0.0f;
     162//   glReadPixels ((int)this->getAbsCoor2D().x,
     163//                  GraphicsEngine::getInstance()->getResolutionY()-(int)this->getAbsCoor2D().y-1,
     164//                  1,
     165//                  1,
     166//                  GL_DEPTH_COMPONENT,
     167//                  GL_FLOAT,
     168//                  &z);
     169//
     170//
     171//   GLdouble objX=.0, objY=.0, objZ=.0;
     172//   gluUnProject(this->getAbsCoor2D().x,
     173//                GraphicsEngine::getInstance()->getResolutionY()-this->getAbsCoor2D().y-1,
     174//                .99,  // z
     175//                GraphicsEngine::modMat,
     176//                GraphicsEngine::projMat,
     177//                GraphicsEngine::viewPort,
     178//                &objX,
     179//                &objY,
     180//                &objZ );
     181//
     182//   this->setAbsCoor(objX, objY, objZ);
    133183}
    134184
     
    138188void Aim::draw() const
    139189{
     190
    140191  glPushMatrix();
    141192  glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);
  • trunk/src/world_entities/weapons/aim.h

    r5557 r5750  
    1212// FORWARD DECLARATION
    1313class Model;
     14class Text;
    1415class Material;
    1516class TiXmlElement;
     17template<class T> class tAnimation;
    1618
    1719//! An Aim for zooming in on Targets.
     20/**
     21 * An Aim is a PNode, that is connected, to the Target, it has aquired
     22 * The target becomes, if selected its Parent.
     23 *
     24 * Also the Aim is a Element2D, as it draws a cross onto the Target.
     25 */
    1826class Aim : public PNode, public Element2D {
    1927
    2028 public:
    21   Aim(const TiXmlElement* root = NULL);
     29  Aim(PNode* source, const TiXmlElement* root = NULL);
    2230  virtual ~Aim();
    2331
     
    2533  void loadParams(const TiXmlElement* root);
    2634
     35  inline void setSource(PNode* source) { this->source = source; };
     36
    2737  inline void selectTarget(PNode* target) { this->setParent(target); };
    2838  inline PNode* getTarget(PNode* target) { return this->getParent(); };
    2939
     40  void searchTarget(float range);
    3041
    3142  void setSize(float size);
     
    4051   Material*        material;             //!< a material for the Aim.
    4152   float            rotationSpeed;        //!< Speed of the Rotation.
     53   tAnimation<Aim>* anim;
     54
     55   PNode*           source;               //!< Where this Shot has come from.
     56
     57   Text*            text;                 //!< A Text to display onto this Node. (distance to Target)
    4258};
    4359
  • trunk/src/world_entities/weapons/crosshair.cc

    r5671 r5750  
    7676  GraphicsEngine::showMouse(false);
    7777  GraphicsEngine::stealWMEvents(true);
     78  SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2);
    7879}
    7980
  • trunk/src/world_entities/weapons/laser.cc

    r5687 r5750  
    8484    Laser::explosionParticles->setName("LaserExplosionParticles");
    8585    Laser::explosionParticles->setLifeSpan(.5, .3);
    86     Laser::explosionParticles->setRadius(0.0, 3.0);
     86    Laser::explosionParticles->setRadius(0.0, 10.0);
    8787    Laser::explosionParticles->setRadius(.5, 6.0);
    8888    Laser::explosionParticles->setRadius(1.0, 3.0);
  • trunk/src/world_entities/weapons/laser.h

    r5500 r5750  
    4242
    4343    WorldEntity* hitEntity; // FIXME TEMPORARY
    44 
    4544};
    4645
  • trunk/src/world_entities/weapons/test_gun.cc

    r5500 r5750  
    4141using namespace std;
    4242
    43 CREATE_FACTORY(TestGun);
     43CREATE_FACTORY(TestGun, CL_TEST_GUN);
    4444
    4545/**
     
    4848   creates a new weapon
    4949*/
    50 TestGun::TestGun (WeaponManager* weaponManager, int leftRight)
    51   : Weapon(weaponManager)
     50TestGun::TestGun ( int leftRight)
     51  : Weapon()
    5252{
    5353  this->init();
  • trunk/src/world_entities/weapons/test_gun.h

    r5500 r5750  
    3838  {
    3939  public:
    40     TestGun (WeaponManager* weaponManager, int leftRight);
     40    TestGun (int leftRight);
    4141    TestGun (const TiXmlElement* root);
    4242    virtual ~TestGun ();
  • trunk/src/world_entities/weapons/turret.cc

    r5512 r5750  
    3030#include "factory.h"
    3131
    32 CREATE_FACTORY(Turret);
     32CREATE_FACTORY(Turret, CL_TURRET);
    3333
    3434using namespace std;
    3535
    36 
    3736/**
    3837 *  standard constructor
    39 
    40    creates a new weapon
    41 */
    42 Turret::Turret (WeaponManager* weaponManager)
    43   : Weapon(weaponManager)
     38 *
     39 * creates a new Turret
     40 */
     41Turret::Turret ()
     42  : Weapon()
    4443{
    4544  this->init();
     
    5352}
    5453
    55 
     54/**
     55 * creates a new Turret from a TiXmlElement
     56 */
    5657Turret::Turret(const TiXmlElement* root)
    5758{
     
    117118{
    118119  Quaternion quat;
    119   Vector direction = this->getWeaponManager()->getFixedTarget()->getAbsCoor() - this->getAbsCoor();
     120  Vector direction = this->getAbsCoor();/*this->getWeaponManager()->getFixedTarget()->getAbsCoor() - this->getAbsCoor();*/
    120121
    121122  direction.normalize();
     
    135136    return;
    136137
    137   PNode* target = this->getWeaponManager()->getFixedTarget();
    138 
    139   if (target != NULL)
    140   {
    141138    pj->setVelocity(this->getVelocity()+(this->getAbsDir().apply(Vector(1,0,0))*100.0 + VECTOR_RAND(13)
    142139            /*target->getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity());
    143   }
    144   else
    145     pj->setVelocity(target->getVelocity());
    146140
    147141  pj->setParent(NullParent::getInstance());
     
    159153void Turret::draw () const
    160154{
    161   this->getWeaponManager()->getFixedTarget()->debugDraw(10);
    162 
    163155  /* draw gun body */
    164156  glMatrixMode(GL_MODELVIEW);
  • trunk/src/world_entities/weapons/turret.h

    r5511 r5750  
    1212  {
    1313  public:
    14     Turret (WeaponManager* weaponManager);
     14    Turret ();
    1515    Turret(const TiXmlElement* root);
    1616    virtual ~Turret ();
  • trunk/src/world_entities/weapons/weapon.cc

    r5671 r5750  
    4141 * creates a new weapon
    4242*/
    43 Weapon::Weapon (WeaponManager* weaponManager)
     43Weapon::Weapon ()
    4444{
    4545  this->init();
    46   this->setWeaponManager(weaponManager);
    4746}
    4847
     
    9796  this->energyMax = 10.0;                          //< How much energy can be carried
    9897  this->capability = WTYPE_ALL;                    //< The Weapon has all capabilities @see W_Capability.
    99 
    100   this->setWeaponManager(NULL);                    //< By default the Weapon is free, and unhandled by a WeaponManager (this is good for small enemies).
    10198}
    10299
  • trunk/src/world_entities/weapons/weapon.h

    r5500 r5750  
    8181  public:
    8282    // INITIALISATION //
    83     Weapon (WeaponManager* weaponManager = NULL);
     83    Weapon ();
    8484    virtual ~Weapon ();
    8585
     
    9393    ///////////////////
    9494
    95     /** @param weaponManager sets the WeaponManager for this Weapon (NULL if free)) */
    96     inline void setWeaponManager(WeaponManager* weaponManager) { this->weaponManager = weaponManager; };
    97     /** @returns the WeaponManager of this Weapon (or NULL if it is free) */
    98     inline WeaponManager* getWeaponManager() const { return this->weaponManager; };
    99 
    10095    /** @returns true if the Weapon is Active  (this is used to check if the weapon must be drawn)*/
    101     inline bool isActive() const { return (this->currentState == WS_INACTIVE)?false:true; };
     96    inline bool isActive() const { return (this->currentState == WS_INACTIVE)? false : true; };
    10297    /** @returns true if the weapon must be drawn */
    103     inline bool isVisible() const { return (this->currentState != WS_INACTIVE || !this->hideInactive)?true:false; };
     98    inline bool isVisible() const { return (this->currentState != WS_INACTIVE || !this->hideInactive) ? true : false; };
    10499    /** @returns true if the Weapon is chargeable */
    105100    inline bool isChargeable() const { return this->chargeable; };
     
    120115
    121116
     117    // EMISSION
    122118    void setEmissionPoint(const Vector& point);
    123119    /** @see void setEmissionPoint(const Vector& point); */
     
    126122    inline const Vector& getEmissionPoint() const { return this->emissionPoint.getAbsCoor(); };
    127123
     124    // STATE CHANGES //
    128125    /** @param state the State to time @param duration the duration of the State */
    129126    inline void setStateDuration(const char* state, float duration) { setStateDuration(charToState(state), duration); };
     
    131128    inline void setStateDuration(WeaponState state, float duration) { /*(state < WS_STATE_COUNT)?*/this->times[state] = duration; };
    132129    /** @param state The state to query @returns the Time the queried State takes to complete */
    133     inline float getStateDuration(WeaponState state) const { return (state < WS_STATE_COUNT)?this->times[state]:0.0; };
     130    inline float getStateDuration(WeaponState state) const { return (state < WS_STATE_COUNT)? this->times[state] : 0.0; };
    134131    /** @returns true if the time of the currentState is elapsed, false otherwise */
    135     inline bool stateTimeElapsed() const { return (this->stateDuration > this->times[currentState])?true:false; };
     132    inline bool stateTimeElapsed() const { return (this->stateDuration > this->times[currentState])? true : false; };
    136133    /** @returns the current State of the Weapon */
    137134    inline WeaponState getCurrentState() const { return this->currentState; };
     
    149146    // FLOW
    150147    void tickW(float dt); //!< this is a function that must be called by the weaponManager, or any other weaponHandler, all other functions are handled from within
     148
    151149    virtual void tick(float dt) {};
    152150    virtual void draw() const;
     
    194192    // it is all about energy
    195193    float                energy;                           //!< The energy stored in the weapons secondary buffers (reserve)
    196     float                energyLoaded;                     //!< The energy stored in the weapons primary buffers (firewithout reload)
     194    float                energyLoaded;                     //!< The energy stored in the weapons primary buffers (fire without reload)
    197195    float                energyMax;                        //!< The maximal energy that can be stored in the secondary buffers (reserveMax)
    198196    float                energyLoadedMax;                  //!< The maximal energy that can be stored in the primary buffers
     
    220218    ClassID              projectile;                      //!< the projectile used for this weapon (since they should be generated via macro and the FastFactory, only the ClassID must be known.)
    221219    FastFactory*         projectileFactory;               //!< A factory, that produces and handles the projectiles.
    222 
    223     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.
    224220  };
    225221
  • trunk/src/world_entities/weapons/weapon_manager.cc

    r5671 r5750  
    2323#include "crosshair.h"
    2424
     25#include "class_list.h"
    2526#include "load_param.h"
    2627#include "factory.h"
    27 #include "vector.h"
    2828#include "list.h"
    2929#include "t_animation.h"
    3030#include "null_parent.h"
     31
    3132
    3233using namespace std;
     
    109110  this->crossHairSizeAnim->addKeyFrame(100, .05, ANIM_LINEAR);
    110111  this->crossHairSizeAnim->addKeyFrame(50, .01, ANIM_LINEAR);
     112
     113  this->targetIterator = NULL;
    111114}
    112115
     
    334337    }
    335338  }
     339}
     340
     341
     342/**
     343 * Selects an Entity from the NPC-list, and returns the Target
     344 */
     345PNode* WeaponManager::getSomeTarget()
     346{
     347   if (this->targetIterator == NULL)
     348   {
     349     tList<BaseObject>* npcList = ClassList::getList(CL_NPC);
     350     if (npcList != NULL)
     351     {
     352       this->targetIterator = npcList->getIterator();
     353       this->targetIterator->firstElement();
     354     }
     355     else
     356       return NULL;
     357   }
     358
     359   PNode* retNode = dynamic_cast<PNode*>(targetIterator->nextElement());
     360   if (retNode == NULL && this->targetIterator->getList()->getSize() > 0)
     361     retNode =  dynamic_cast<PNode*>(targetIterator->firstElement());
     362
     363   return retNode;
     364}
     365
     366
     367/**
     368 * Selects an Entity from the Entity-List, that is near of the carrier PNode.
     369 * @param carrier: The PNode from which the distance should be measured
     370 * @param distance: The Maximum Distance to Return.
     371 */
     372PNode* WeaponManager::getDistanceTarget(const PNode* carrier, float distance)
     373{
     374  tList<BaseObject>* npcList = ClassList::getList(CL_NPC);
     375  if (npcList != NULL)
     376  {
     377    tIterator<BaseObject>* npcIT = npcList->getIterator();
     378    PNode* tmpNPC = dynamic_cast<PNode*>(npcIT->firstElement());
     379    while (tmpNPC != NULL)
     380    {
     381      if ((carrier->getAbsCoor() - tmpNPC->getAbsCoor()).len() < distance)
     382      {
     383        delete npcIT;
     384        return tmpNPC;
     385      }
     386      tmpNPC = dynamic_cast<PNode*>(npcIT->nextElement());
     387    }
     388    delete npcIT;
     389  }
     390  return this->getFixedTarget();
     391
    336392}
    337393
  • trunk/src/world_entities/weapons/weapon_manager.h

    r5453 r5750  
    1717// FORWARD DECLARATION
    1818template <class T> class tAnimation;
     19template <class T> class tIterator;
    1920
    2021
     
    7071    void removeWeapon(Weapon* weapon, int configID = -1);
    7172
    72 
     73    // FIXME ::
     74//    bool hasFreeSlot(int configID, long capability = WTYPE_ALL) { return ( getNextFreeSlot(configID, capability ) != -1)? true : false; };
    7375
    7476    void nextWeaponConfig();
     
    7779
    7880    /** @returns a fixed target namely the Crosshair's 3D position */
    79     inline PNode* getFixedTarget() { return this->crosshair; };
     81    inline PNode* getFixedTarget() const { return this->crosshair; };
     82    PNode* getSomeTarget();
     83    PNode* getDistanceTarget(const PNode* carrier, float distance);
     84
    8085    void fire();
     86    //! @TODO: implement this function (maybe also in Weapon itself)
     87    void releaseFire();
    8188
    8289    void tick(float dt);
     
    8592    void debug() const;
    8693
    87   private:
     94 // private:
    8895    int getNextFreeSlot(int configID, long capability = WTYPE_ALL);
    8996
     
    102109    Crosshair*              crosshair;                                //!< an aim.
    103110    tAnimation<Crosshair>*  crossHairSizeAnim;                        //!< An animation for the crosshair (scaling)
     111
     112    tIterator<BaseObject>*  targetIterator;                           //!< An iterator for traversion lists of enemies.
    104113};
Note: See TracChangeset for help on using the changeset viewer.