Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2190 in orxonox.OLD for orxonox/trunk/src/world_entity.cc


Ignore:
Timestamp:
Jul 17, 2004, 12:11:20 PM (21 years ago)
Author:
bensch
Message:

orxonox/trunk: merged and copied all files from branches/chris into trunk. it all seems to be in propper order.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world_entity.cc

    r2077 r2190  
    1313   ### File Specific:
    1414   main-programmer: Patrick Boenzli
    15    co-programmer: ...
     15   co-programmer: Christian Meyer
    1616*/
    1717
     
    1919
    2020#include "world_entity.h"
    21 
    22 #include "vector.h"
     21#include "stdincl.h"
     22#include "collision.h"
    2323
    2424using namespace std;
    2525
    26 
    2726/**
    28    \brief
    29    \param v:
    30    \return
     27   \brief standard constructor
     28   
     29   Every derived contructor HAS to call the previous one supplying the isFree parameter. This is necessary to distunguish
     30   between free and bound entities. The difference between them is simply the fact that the movement of a free entity is
     31   not bound to the track of a world. Use this to implement projectile or effect classes that do not have to travel along the track.
     32   To specify an entity to be free or bound set the default parameter in the declaration of the constructor.
     33   Theoretically you should never have to call the constructor of an Entity directly, for it is called by the spawn() function of the World
     34   class. So if you want to create a new entity at any time, call World::spawn(). It will handle everything that is necessary.
    3135*/
    32 
    33 /**
    34    \brief Constructor
    35 
    36    This Constructor initializises the all WorldEntities. Everything, that is a part of the game-world is a child of WorldEntity. This class implements empty functions for all sort of operation a WorldEntity has to or can implement.
    37 This is some sort of standard interface to all WorldEntities...
    38 */
    39 WorldEntity::WorldEntity ()
     36WorldEntity::WorldEntity (bool isFree) : bFree(isFree)
    4037{
    41   health = 100;
    42   speed = 0;
    43 }
    44 
    45 
    46 WorldEntity::~WorldEntity () {}
    47 
    48 /**
    49    \brief sets the position of this entity
    50    \param position: Vector, pointing (from 0,0,0) to the new position
    51 */
    52 void WorldEntity::setPosition(Vector* position) {}
    53 
    54 /**
    55    \brief gets the postion of this entity
    56    \return a Vector, pointing (from 0,0,0) to the new position
    57 */
    58 Vector* getPosition() {}
    59 
    60 /**
    61    \brief sets orientation of this entity
    62    \param orientation: vector specifying in which direction the entity looks
    63 */
    64 void WorldEntity::setOrientation(Vector* orientation) {}
    65 
    66 /**
    67    \brief gets orientation of this entity
    68    \return vector specifying in which direction the entity looks
    69 */
    70 Vector* WorldEntity::getOrientation() {}
    71 
    72 /**
    73    \brief sets the speed of the entity, if any
    74    \param speed: the speed in points (openGL points) per seconds
    75 */
    76 void WorldEntity::setSpeed(float speed)
    77 {
    78   this->speed = speed;
     38        collisioncluster = NULL;
     39        owner = NULL;
    7940}
    8041
    8142/**
    82    \brief gets the speed of the entity, if any
    83    \return the speed in points (openGL points) per seconds
     43        \brief standard destructor
    8444*/
    85 float WorldEntity::getSpeed()
     45WorldEntity::~WorldEntity ()
    8646{
    87   return speed;
     47        if( collisioncluster != NULL) delete collisioncluster;
    8848}
    8949
    9050/**
    91    \brief sets the health of the entity
    92    \param health: number for the life count, normaly {0..100}
     51        \brief get the Location of the WorldEntity
     52        \return a pointer to location
    9353*/
    94 void WorldEntity::setHealth(float health)
     54Location* WorldEntity::get_location ()
    9555{
    96   this->health = health;
     56        return &loc;
    9757}
    9858
    9959/**
    100    \brief gets the health of the entity
    101    \return number for the life count, normaly {0..100}
     60        \brief get the Placement of the WorldEntity
     61        \return a pointer to placement
    10262*/
    103 float WorldEntity::getHealth()
     63Placement* WorldEntity::get_placement ()
    10464{
    105   return health;
     65        return &place;
    10666}
    10767
    10868/**
    109    \brief this method is called every tick
    110    \param time: the time since the last frame was painted
    111 
    112    This function is called before every repaint of the world, to update every time dependent variable of the entity. If the entity moves, it has to calculate the new position every tick here in this function. Do not use this for animations.
     69        \brief query whether the WorldEntity in question is free
     70        \return true if the WorldEntity is free or false if it isn't
    11371*/
    114 void WorldEntity::tick(float dt)
    115 {}
     72bool WorldEntity::isFree ()
     73{
     74  return bFree;
     75}
    11676
    11777/**
    118    \brief the entity is painted to the screen with this function
     78        \brief set the WorldEntity's collision hull
     79        \param newhull: a pointer to a completely assembled CollisionCluster
     80       
     81        Any previously assigned collision hull will be deleted on reassignment
     82*/
     83void WorldEntity::set_collision (CollisionCluster* newhull)
     84{
     85        if( newhull == NULL) return;
     86        if( collisioncluster != NULL) delete collisioncluster;
     87        collisioncluster = newhull;
     88}
     89
     90/**
     91        \brief this method is called every frame
     92        \param time: the time in seconds that has passed since the last tick
     93       
     94        Handle all stuff that should update with time inside this method (movement, animation, etc.)
     95*/
     96void WorldEntity::tick(float time)
     97{
     98}
     99
     100/**
     101   \brief the entity is drawn onto the screen with this function
    119102
    120103   This is a central function of an entity: call it to let the entity painted to the screen. Just override this function with whatever you want to be drawn.
    121104*/
    122 void WorldEntity::paint()
    123 {}
     105void WorldEntity::draw()
     106{
     107}
    124108
    125 /* virtual void WorldEntity::actionEvent(Event* event); */
    126109/**
    127    \brief this function is called, when two entities collide
    128    \param we: the world entity, with whom it collides
    129    \param loc: place where the collision happens
     110        \brief this function is called, when two entities collide
     111        \param other: the world entity with whom it collides
     112        \param ownhitflags: flags to the CollisionCluster subsections that registered an impact
     113        \param otherhitflags: flags to the CollisionCluster subsections of the other entity that registered an impact
     114
     115        Implement behaviour like damage application or other miscellaneous collision stuff in this function
    130116*/
    131 void WorldEntity::collide(WorldEntity* we, Vector loc) {}
     117void WorldEntity::collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) {}
    132118
    133119/**
     
    141127
    142128/**
    143    \brief this function is called, if the entity is to be destroied
     129   \brief this function is called when the entity is to be destroied
    144130   
    145131   This can be called, if eg. something realy bad happens :)
     
    147133void WorldEntity::destroy() {}
    148134
    149 /**
    150    \brief this function is automatically called before the entity enters the world
    151 */
    152 void WorldEntity::entityPreEnter() {}
    153135
    154136/**
    155    \brief this function is automatically called after the entity enters the world
    156 
     137        \brief basic initialisation for bound Entities
    157138*/
    158 void WorldEntity::entityPostEnter() {}
     139void WorldEntity::init( Location* spawnloc, WorldEntity* spawnowner)
     140{
     141        loc = *spawnloc;
     142        owner = spawnowner;
     143}
    159144
    160145/**
    161    \brief this function is automatically called before the entity quits the world
    162 
     146        \brief basic initialisation for free Entities
    163147*/
    164 void WorldEntity::entityPreQuit() {}
     148void WorldEntity::init( Placement* spawnplc, WorldEntity* spawnowner)
     149{
     150        place = *spawnplc;
     151        owner = spawnowner;
     152}
    165153
    166154/**
    167    \brief this function is automatically called after the entity quits the world
     155        \brief this is called immediately after the Entity has been constructed and initialized
     156       
     157        Put any initialisation code that requires knowledge of location (placement if the Entity is free) and owner of the entity here.
     158        DO NOT place such code in the constructor, those variables are set AFTER the entity is constucted.
    168159*/
    169 void WorldEntity::entityPostQuit() {}
     160void WorldEntity::post_spawn ()
     161{
     162}
     163
     164/**
     165        \brief this handles incoming command messages
     166        \param cmd: a pointer to the incoming Command structure
     167       
     168        Put all code that handles Command messages here, this will mainly be called by the assigned CommandNode but can also be used
     169        to send commands from one WorldEntity to another.
     170*/
     171void WorldEntity::command (Command* cmd)
     172{
     173}
     174
     175/**
     176        \brief this is called by the local Camera to determine the point it should look at on the WorldEntity
     177        \param locbuf: a pointer to the buffer to fill with a location to look at
     178       
     179        You may put any Location you want into locbuf, the Camera will determine via the corresponding Track how
     180        to look at the location you return with this.
     181*/
     182void WorldEntity::get_lookat (Location* locbuf)
     183{
     184}
     185
     186/**
     187        \brief this method is called by the world if the WorldEntity leaves valid gamespace
     188       
     189        For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a
     190        place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy).
     191*/
     192void WorldEntity::left_world ()
     193{
     194}
Note: See TracChangeset for help on using the changeset viewer.