Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/world_entities/world_entity.cc @ 3891

Last change on this file since 3891 was 3832, checked in by patrick, 19 years ago

orxonox/trunk: animation class functions implemented, list enhanced

File size: 5.6 KB
RevLine 
[2036]1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   ### File Specific:
14   main-programmer: Patrick Boenzli
[2190]15   co-programmer: Christian Meyer
[2036]16*/
17
18#include <iostream>
19
20#include "world_entity.h"
[3803]21#include "model.h"
[3608]22#include "list.h"
[3803]23#include "vector.h"
[3608]24
25//#include "stdincl.h"
[3474]26//#include "collision.h"
[2036]27
28using namespace std;
29
[2043]30/**
[2190]31   \brief standard constructor
32   
33   Every derived contructor HAS to call the previous one supplying the isFree parameter. This is necessary to distunguish
34   between free and bound entities. The difference between them is simply the fact that the movement of a free entity is
35   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.
36   To specify an entity to be free or bound set the default parameter in the declaration of the constructor.
37   Theoretically you should never have to call the constructor of an Entity directly, for it is called by the spawn() function of the World
38   class. So if you want to create a new entity at any time, call World::spawn(). It will handle everything that is necessary.
[2043]39*/
[2190]40WorldEntity::WorldEntity (bool isFree) : bFree(isFree)
41{
[3365]42  this->setClassName ("WorldEntity");
[2822]43  this->bDraw = true;
[3803]44  this->model = NULL;
[3474]45  //  collisioncluster = NULL;
[2190]46}
[2043]47
48/**
[3245]49   \brief standard destructor
[2043]50*/
[2190]51WorldEntity::~WorldEntity ()
[2036]52{
[3474]53  // if( collisioncluster != NULL) delete collisioncluster;
[3672]54  if (this->model)
55    ResourceManager::getInstance()->unload(this->model);
[3531]56}
57
58/**
[3583]59   \brief sets the character attributes of a worldentity
60   \param character attributes
61
62   these attributes don't have to be set, only use them, if you need them
[2043]63*/
[3583]64void WorldEntity::setCharacterAttributes(CharacterAttributes* charAttr)
65{}
[2036]66
[3583]67
[2043]68/**
[3583]69   \brief gets the Character attributes of this worldentity
70   \returns character attributes
[2043]71*/
[3583]72CharacterAttributes* WorldEntity::getCharacterAttributes()
73{}
74
75
[2043]76/**
[2822]77   \brief query whether the WorldEntity in question is free
78   \return true if the WorldEntity is free or false if it isn't
[2043]79*/
[2190]80bool WorldEntity::isFree ()
[2036]81{
[2190]82  return bFree;
[2036]83}
84
[2043]85/**
[2822]86   \brief set the WorldEntity's collision hull
87   \param newhull: a pointer to a completely assembled CollisionCluster
88   
89   Any previously assigned collision hull will be deleted on reassignment
[2043]90*/
[3474]91/*
[3229]92void WorldEntity::setCollision (CollisionCluster* newhull)
[2036]93{
[2822]94  if( newhull == NULL) return;
95  if( collisioncluster != NULL) delete collisioncluster;
96  collisioncluster = newhull;
[2036]97}
[3474]98*/
[2036]99
100
[3365]101/**
102    \brief process draw function
103*/
104void WorldEntity::processDraw ()
105{
[3832]106
[3365]107}
108
[3449]109/**
110   \brief sets the drawable state of this entity.
111   \param bDraw TRUE if draweable, FALSE otherwise
112*/
[3365]113void WorldEntity::setDrawable (bool bDraw)
114{
115  this->bDraw = bDraw;
116}
117
118
[2043]119/**
[2822]120   \brief this function is called, when two entities collide
121   \param other: the world entity with whom it collides
122   \param ownhitflags: flags to the CollisionCluster subsections that registered an impact
123   \param otherhitflags: flags to the CollisionCluster subsections of the other entity that registered an impact
[2043]124
[2822]125   Implement behaviour like damage application or other miscellaneous collision stuff in this function
[2043]126*/
[2190]127void WorldEntity::collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) {}
[2036]128
[3583]129
[2043]130/**
131   \brief this function is called, when the ship is hit by a waepon
132   \param weapon: the laser/rocket/shoot that hits.
133   \param loc: place where it is hit
[2036]134
[2043]135   calculate the damage depending
136*/
[3578]137void WorldEntity::hit(WorldEntity* weapon, Vector* loc) {}
[2043]138
139
140/**
[2822]141   \brief this is called immediately after the Entity has been constructed and initialized
142   
143   Put any initialisation code that requires knowledge of location (placement if the Entity is free) and owner of the entity here.
144   DO NOT place such code in the constructor, those variables are set AFTER the entity is constucted.
[2043]145*/
[3229]146void WorldEntity::postSpawn ()
[2190]147{
148}
[2043]149
[3583]150
[2043]151/**
[3583]152   \brief this method is called by the world if the WorldEntity leaves valid gamespace
[2822]153   
[3583]154   For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a
155   place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy).
[2190]156*/
[3583]157void WorldEntity::leftWorld ()
[2190]158{
159}
[2043]160
[3583]161
[2190]162/**
[3583]163   \brief this method is called every frame
164   \param time: the time in seconds that has passed since the last tick
165   
166   Handle all stuff that should update with time inside this method (movement, animation, etc.)
[2043]167*/
[3803]168void WorldEntity::tick(float time) 
[2190]169{
170}
[3583]171
172
173/**
174   \brief the entity is drawn onto the screen with this function
175   
176   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.
[3365]177*/
[3803]178void WorldEntity::draw() 
179{
180  glMatrixMode(GL_MODELVIEW);
181  glPushMatrix();
182  float matrix[4][4];
183 
184  /* translate */
185  glTranslatef (this->getAbsCoor ().x, 
186                this->getAbsCoor ().y, 
187                this->getAbsCoor ().z);
188  /* rotate */
189  this->getAbsDir ().matrix (matrix);
190  glMultMatrixf((float*)matrix);
[2043]191
[3803]192  if (this->model)
193    this->model->draw();
194  glPopMatrix();
195}
[3583]196
[3803]197
[2043]198/**
[3583]199   \brief this handles incoming command messages
200   \param cmd: a pointer to the incoming Command structure
[2822]201   
[3583]202   Put all code that handles Command messages here, this will mainly be called by the assigned CommandNode but can also be used
203   to send commands from one WorldEntity to another.
[2043]204*/
[3583]205void WorldEntity::command (Command* cmd)
[2190]206{
207}
Note: See TracBrowser for help on using the repository browser.