Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/levelLoader/src/world_entities/world_entity.cc @ 4240

Last change on this file since 4240 was 4240, checked in by bensch, 19 years ago

orxonox/branches/levelLoader: SkyBox loadable in the new Style

File size: 5.3 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
25using namespace std;
26
27/**
28   \brief standard constructor
29*/
30WorldEntity::WorldEntity ()
31{
32  this->setClassName ("WorldEntity");
33  this->bDraw = true;
34  this->model = NULL;
35  //  collisioncluster = NULL;
36}
37
38/**
39   \brief Loads the WordEntity-specific Part of any derived Class
40*/
41WorldEntity::WorldEntity(TiXmlElement* root)
42{
43  this->setClassName ("WorldEntity");
44  // Name Setup
45  LoadParam<WorldEntity>(root, "name", this, &WorldEntity::setName);
46  // Model Loading     
47  this->model = NULL;
48  LoadParam<WorldEntity>(root, "model", this, &WorldEntity::loadModel);
49
50  this->bDraw = true;
51}
52
53/**
54   \brief standard destructor
55*/
56WorldEntity::~WorldEntity ()
57{
58  // if( collisioncluster != NULL) delete collisioncluster;
59  if (this->model)
60    ResourceManager::getInstance()->unload(this->model);
61}
62
63/**
64   \brief loads a Model onto a WorldEntity
65   \param fileName the name of the model to load
66*/
67void WorldEntity::loadModel(const char* fileName)
68{
69  if (this->model)
70    ResourceManager::getInstance()->unload(this->model, RP_LEVEL);
71  this->model = (Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN);
72}
73
74/**
75   \brief sets the character attributes of a worldentity
76   \param character attributes
77
78   these attributes don't have to be set, only use them, if you need them
79*/
80void WorldEntity::setCharacterAttributes(CharacterAttributes* charAttr)
81{}
82
83
84/**
85   \brief gets the Character attributes of this worldentity
86   \returns character attributes
87*/
88CharacterAttributes* WorldEntity::getCharacterAttributes()
89{}
90
91
92/**
93   \brief set the WorldEntity's collision hull
94   \param newhull: a pointer to a completely assembled CollisionCluster
95   
96   Any previously assigned collision hull will be deleted on reassignment
97*/
98/*
99void WorldEntity::setCollision (CollisionCluster* newhull)
100{
101  if( newhull == NULL) return;
102  if( collisioncluster != NULL) delete collisioncluster;
103  collisioncluster = newhull;
104}
105*/
106
107
108/**
109    \brief process draw function
110*/
111void WorldEntity::processDraw ()
112{
113
114}
115
116/**
117   \brief sets the drawable state of this entity.
118   \param bDraw TRUE if draweable, FALSE otherwise
119*/
120void WorldEntity::setDrawable (bool bDraw)
121{
122  this->bDraw = bDraw;
123}
124
125
126/**
127   \brief this function is called, when two entities collide
128   \param other: the world entity with whom it collides
129   \param ownhitflags: flags to the CollisionCluster subsections that registered an impact
130   \param otherhitflags: flags to the CollisionCluster subsections of the other entity that registered an impact
131
132   Implement behaviour like damage application or other miscellaneous collision stuff in this function
133*/
134void WorldEntity::collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) {}
135
136
137/**
138   \brief this function is called, when the ship is hit by a waepon
139   \param weapon: the laser/rocket/shoot that hits.
140   \param loc: place where it is hit
141
142   calculate the damage depending
143*/
144void WorldEntity::hit(WorldEntity* weapon, Vector* loc) {}
145
146
147/**
148   \brief this is called immediately after the Entity has been constructed and initialized
149   
150   Put any initialisation code that requires knowledge of location (placement if the Entity is free) and owner of the entity here.
151   DO NOT place such code in the constructor, those variables are set AFTER the entity is constucted.
152*/
153void WorldEntity::postSpawn ()
154{
155}
156
157
158/**
159   \brief this method is called by the world if the WorldEntity leaves valid gamespace
160   
161   For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a
162   place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy).
163*/
164void WorldEntity::leftWorld ()
165{
166}
167
168
169/**
170   \brief this method is called every frame
171   \param time: the time in seconds that has passed since the last tick
172   
173   Handle all stuff that should update with time inside this method (movement, animation, etc.)
174*/
175void WorldEntity::tick(float time) 
176{
177}
178
179
180/**
181   \brief the entity is drawn onto the screen with this function
182   
183   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.
184*/
185void WorldEntity::draw() 
186{
187  glMatrixMode(GL_MODELVIEW);
188  glPushMatrix();
189  float matrix[4][4];
190 
191  /* translate */
192  glTranslatef (this->getAbsCoor ().x, 
193                this->getAbsCoor ().y, 
194                this->getAbsCoor ().z);
195  /* rotate */
196  this->getAbsDir ().matrix (matrix);
197  glMultMatrixf((float*)matrix);
198
199  if (this->model)
200    this->model->draw();
201  glPopMatrix();
202}
203
204
205/**
206   \brief this handles incoming command messages
207   \param cmd: a pointer to the incoming Command structure
208   
209   Put all code that handles Command messages here, this will mainly be called by the assigned CommandNode but can also be used
210   to send commands from one WorldEntity to another.
211*/
212void WorldEntity::command (Command* cmd)
213{
214}
Note: See TracBrowser for help on using the repository browser.