Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: animation class functions implemented, list enhanced

File size: 5.6 KB
Line 
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
15   co-programmer: Christian Meyer
16*/
17
18#include <iostream>
19
20#include "world_entity.h"
21#include "model.h"
22#include "list.h"
23#include "vector.h"
24
25//#include "stdincl.h"
26//#include "collision.h"
27
28using namespace std;
29
30/**
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.
39*/
40WorldEntity::WorldEntity (bool isFree) : bFree(isFree)
41{
42  this->setClassName ("WorldEntity");
43  this->bDraw = true;
44  this->model = NULL;
45  //  collisioncluster = NULL;
46}
47
48/**
49   \brief standard destructor
50*/
51WorldEntity::~WorldEntity ()
52{
53  // if( collisioncluster != NULL) delete collisioncluster;
54  if (this->model)
55    ResourceManager::getInstance()->unload(this->model);
56}
57
58/**
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
63*/
64void WorldEntity::setCharacterAttributes(CharacterAttributes* charAttr)
65{}
66
67
68/**
69   \brief gets the Character attributes of this worldentity
70   \returns character attributes
71*/
72CharacterAttributes* WorldEntity::getCharacterAttributes()
73{}
74
75
76/**
77   \brief query whether the WorldEntity in question is free
78   \return true if the WorldEntity is free or false if it isn't
79*/
80bool WorldEntity::isFree ()
81{
82  return bFree;
83}
84
85/**
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
90*/
91/*
92void WorldEntity::setCollision (CollisionCluster* newhull)
93{
94  if( newhull == NULL) return;
95  if( collisioncluster != NULL) delete collisioncluster;
96  collisioncluster = newhull;
97}
98*/
99
100
101/**
102    \brief process draw function
103*/
104void WorldEntity::processDraw ()
105{
106
107}
108
109/**
110   \brief sets the drawable state of this entity.
111   \param bDraw TRUE if draweable, FALSE otherwise
112*/
113void WorldEntity::setDrawable (bool bDraw)
114{
115  this->bDraw = bDraw;
116}
117
118
119/**
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
124
125   Implement behaviour like damage application or other miscellaneous collision stuff in this function
126*/
127void WorldEntity::collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) {}
128
129
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
134
135   calculate the damage depending
136*/
137void WorldEntity::hit(WorldEntity* weapon, Vector* loc) {}
138
139
140/**
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.
145*/
146void WorldEntity::postSpawn ()
147{
148}
149
150
151/**
152   \brief this method is called by the world if the WorldEntity leaves valid gamespace
153   
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).
156*/
157void WorldEntity::leftWorld ()
158{
159}
160
161
162/**
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.)
167*/
168void WorldEntity::tick(float time) 
169{
170}
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.
177*/
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);
191
192  if (this->model)
193    this->model->draw();
194  glPopMatrix();
195}
196
197
198/**
199   \brief this handles incoming command messages
200   \param cmd: a pointer to the incoming Command structure
201   
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.
204*/
205void WorldEntity::command (Command* cmd)
206{
207}
Note: See TracBrowser for help on using the repository browser.