Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/movie_player/src/world_entities/world_entity.cc @ 4217

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

orxonox/branches/movie_player: merged the trunk back into the movie_player
merged with command:
svn merge -r 4014:HEAD ../trunk/ movie_player/
no conflicts

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