Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: minor cleanup/windowsTest

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