- Timestamp:
- Dec 21, 2005, 1:49:06 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 81 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property
svn:ignore
set to
Makefile.in
Makefile
configure
*.kdevelop
Doxyfile
config.log
config.h
config.status
stamp-h1
autom4te.cache
aclocal.m4
-
Property
svn:ignore
set to
-
trunk/src
-
Property
svn:ignore
set to
.deps
orxonox
Makefile
Makefile.in
-
Property
svn:ignore
set to
-
trunk/src/Makefile.am
r6139 r6222 86 86 world_entities/space_ships/space_ship.cc \ 87 87 world_entities/space_ships/helicopter.cc \ 88 world_entities/creatures/md2_creature.cc \ 88 89 world_entities/spawning_point.cc \ 89 90 subprojects/benchmark.cc … … 133 134 world_entities/space_ships/space_ship.h \ 134 135 world_entities/space_ships/helicopter.h \ 136 world_entities/creatures/md2_creature.h \ 135 137 world_entities/spawning_point.h \ 136 138 defs/stdincl.h \ -
trunk/src/defs/class_id.h
r6162 r6222 149 149 CL_SPACE_SHIP = 0x0000020a, 150 150 CL_HELICOPTER = 0x0000020b, 151 CL_SPAWNING_POINT = 0x0000020b, 151 CL_SPAWNING_POINT = 0x0000020c, 152 CL_MD2_CREATURE = 0x0000020d, 152 153 153 154 CL_TURRET_POWER_UP = 0x00000211, -
trunk/src/lib
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
libORXlibs.a
-
Property
svn:ignore
set to
-
trunk/src/lib/collision_detection
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
libORX*
-
Property
svn:ignore
set to
-
trunk/src/lib/collision_detection/cd_engine.cc
r6151 r6222 19 19 #include "obb_tree.h" 20 20 #include "debug.h" 21 #include "list.h"22 21 23 22 #include "model.h" -
trunk/src/lib/collision_detection/obb.cc
r5120 r6222 17 17 18 18 #include "obb.h" 19 #include "list.h"20 19 #include "vector.h" 21 20 -
trunk/src/lib/event
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
libORX*
-
Property
svn:ignore
set to
-
trunk/src/lib/graphics
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
libORX*
-
Property
svn:ignore
set to
-
trunk/src/lib/graphics/graphics_engine.cc
r6162 r6222 37 37 #ifdef __WIN32__ 38 38 #include "class_list.h" 39 #include "list.h"40 39 #include "static_model.h" 41 40 #endif … … 579 578 std::list<WorldEntity*>::const_iterator entity; 580 579 for (entity = drawList.begin(); entity != drawList.end(); entity++) 581 if ((*entity)->isVisible()) 582 (*entity)->draw(); 580 if ((*entity)->isVisible()) 581 (*entity)->draw(); 583 582 } 584 583 -
trunk/src/lib/graphics/importer
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
libORX*
-
Property
svn:ignore
set to
-
trunk/src/lib/graphics/importer/md2Model.cc
r6022 r6222 21 21 #include "resource_manager.h" 22 22 23 //#include <fstream>24 25 23 26 24 using namespace std; … … 36 34 }; 37 35 38 //! again one of these strange id software parts39 static float *shadeDots = MD2Model::anormsDots[0];40 36 41 37 //! the angle under which the model is viewd, used internaly … … 46 42 sAnim MD2Model::animationList[21] = 47 43 { 48 // begin, end, fps 49 { 0, 39, 9 }, //!< STAND50 { 40, 45, 10 }, //!< RUN51 { 46, 53, 10 }, //!< ATTACK52 { 54, 57, 7 }, //!< PAIN_A53 { 58, 61, 7 }, //!< PAIN_B54 { 62, 65, 7 }, //!< PAIN_C55 { 66, 71, 7 }, //!< JUMP56 { 72, 83, 7 }, //!< FLIP57 { 84, 94, 7 }, //!< SALUTE58 { 95, 111, 10 }, //!< FALLBACK59 { 112, 122, 7 }, //!< WAVE60 { 123, 134, 6 }, //!< POINTT61 { 135, 153, 10 }, //!< CROUCH_STAND62 { 154, 159, 7 }, //!< CROUCH_WALK63 { 160, 168, 10 }, //!< CROUCH_ATTACK64 { 196, 172, 7 }, //!< CROUCH_PAIN65 { 173, 177, 5 }, //!< CROUCH_DEATH66 { 178, 183, 7 }, //!< DEATH_FALLBACK67 { 184, 189, 7 }, //!< DEATH_FALLFORWARD68 { 190, 197, 7 }, //!< DEATH_FALLBACKSLOW69 { 198, 198, 5 }, //!< BOOM44 // begin, end, fps, interruptable 45 { 0, 39, 9, 1 }, //!< STAND 46 { 40, 45, 10, 1 }, //!< RUN 47 { 46, 53, 10, 0 }, //!< ATTACK 48 { 54, 57, 7, 1 }, //!< PAIN_A 49 { 58, 61, 7, 1 }, //!< PAIN_B 50 { 62, 65, 7, 1 }, //!< PAIN_C 51 { 66, 71, 7, 0 }, //!< JUMP 52 { 72, 83, 7, 1 }, //!< FLIP 53 { 84, 94, 7, 1 }, //!< SALUTE 54 { 95, 111, 10, 1 }, //!< FALLBACK 55 { 112, 122, 7, 1 }, //!< WAVE 56 { 123, 134, 6, 1 }, //!< POINTT 57 { 135, 153, 10, 1 }, //!< CROUCH_STAND 58 { 154, 159, 7, 1 }, //!< CROUCH_WALK 59 { 160, 168, 10, 1 }, //!< CROUCH_ATTACK 60 { 196, 172, 7, 1 }, //!< CROUCH_PAIN 61 { 173, 177, 5, 0 }, //!< CROUCH_DEATH 62 { 178, 183, 7, 0 }, //!< DEATH_FALLBACK 63 { 184, 189, 7, 0 }, //!< DEATH_FALLFORWARD 64 { 190, 197, 7, 0 }, //!< DEATH_FALLBACKSLOW 65 { 198, 198, 5, 1 }, //!< BOOM 70 66 }; 71 67 … … 87 83 88 84 this->scaleFactor = this->data->scaleFactor; 85 86 shadeDots = MD2Model::anormsDots[0]; 87 /* set the animation stat mannualy */ 88 this->animationState.type = STAND; 89 this->animationState.numPlays = 1; 89 90 this->setAnim(STAND); 91 92 this->debug(); 90 93 } 91 94 … … 103 106 /** 104 107 * initializes an array of vert with the current frame scaled vertices 105 * @param verticesList: the list of vertices to interpolate between108 * @param this->verticesList: the list of vertices to interpolate between 106 109 107 110 we won't use the pVertices array directly, since its much easier and we need 108 111 saving of data anyway 109 112 */ 110 void MD2Model::interpolate( sVec3D* verticesList)113 void MD2Model::interpolate(/*sVec3D* this->verticesList*/) 111 114 { 112 115 sVec3D* currVec; … … 118 121 for( int i = 0; i < this->data->numVertices; ++i) 119 122 { 120 verticesList[i][0] = currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0]);121 verticesList[i][1] = currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1]);122 verticesList[i][2] = currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2]);123 this->verticesList[i][0] = currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0]); 124 this->verticesList[i][1] = currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1]); 125 this->verticesList[i][2] = currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2]); 123 126 } 124 127 } … … 135 138 if( (type < 0) || (type > MAX_ANIMATIONS) ) 136 139 type = STAND; 140 141 if( MD2Model::animationList[this->animationState.type].bStoppable == 0) 142 { 143 if( this->animationState.numPlays == 0 ) 144 return; 145 } 137 146 138 147 this->animationState.startFrame = animationList[type].firstFrame; … … 141 150 this->animationState.fps = animationList[type].fps; 142 151 this->animationState.type = type; 152 this->animationState.numPlays = 0; 143 153 144 154 this->animationState.interpolationState = 0.0f; … … 155 165 void MD2Model::tick(float time) 156 166 { 157 this->animationState.localTime += time; 167 this->animate(time); 168 this->processLighting(); 169 this->interpolate(/*this->verticesList*/); 158 170 } 159 171 … … 164 176 * FIXME 165 177 */ 166 void MD2Model::draw() 167 { 168 if( likely(this->animationState.localTime > 0.0)) 169 this->animate(); 170 178 void MD2Model::draw() const 179 { 171 180 glPushMatrix(); 172 173 181 this->renderFrame(); 174 182 // renderFrameTriangles(); 175 183 glPopMatrix(); 176 184 } … … 180 188 \brief this is an internal function to render this special frame selected by animate() 181 189 */ 182 void MD2Model::renderFrame() 183 { 184 static sVec3D verticesList[MD2_MAX_VERTICES]; /* performance: created only once in a lifetime */ 190 void MD2Model::renderFrame() const 191 { 185 192 int* pCommands = this->data->pGLCommands; 186 193 … … 191 198 glCullFace(GL_BACK); 192 199 193 this->processLighting();194 this->interpolate(verticesList);195 200 this->data->material->select(); 196 201 … … 208 213 } 209 214 210 211 215 for(; i > 0; i--, pCommands += 3) /* down counting for loop, next 3 gl commands */ 212 216 { 213 217 glTexCoord2f( ((float *)pCommands)[0], ((float *)pCommands)[1] ); 214 218 glNormal3fv(anorms[this->data->pLightNormals[pCommands[2]]]); 215 glVertex3fv( verticesList[pCommands[2]]);219 glVertex3fv(this->verticesList[pCommands[2]]); 216 220 } 217 221 glEnd(); … … 223 227 224 228 229 void MD2Model::renderFrameTriangles() const 230 { 231 //static sVec3D this->verticesList[MD2_MAX_VERTICES]; /* performance: created only once in a lifetime */ 232 int* pCommands = this->data->pGLCommands; 233 /* some face culling stuff */ 234 // glPushAttrib(GL_POLYGON_BIT); 235 // glFrontFace(GL_CW); 236 // glEnable(GL_CULL_FACE); 237 // glCullFace(GL_BACK); 238 // 239 // this->processLighting(); 240 // this->interpolate(/*this->verticesList*/); 241 this->data->material->select(); 242 243 /* draw the triangles */ 244 glBegin(GL_TRIANGLES); 245 246 for( int i = 0, k = 0; i < this->data->numTriangles; ++i, k += 3) 247 { 248 float* v = this->data->pVertices[this->data->pTriangles[i].indexToVertices[0]]; 249 250 printf("triangle: %i\n", i); 251 printf(" v0: (%f, %f, %f)\n", v[0], v[1], v[2]); 252 v = this->data->pVertices[this->data->pTriangles[i].indexToVertices[1]]; 253 printf(" v1: (%f, %f, %f)\n", v[0], v[1], v[2]); 254 v = this->data->pVertices[this->data->pTriangles[i].indexToVertices[2]]; 255 printf(" v2: (%f, %f, %f)\n", v[0], v[1], v[2]); 256 257 258 glNormal3f(anorms[i][0], anorms[i][1], anorms[i][2]); 259 glVertex3fv(this->data->pVertices[this->data->pTriangles[i].indexToVertices[0]]); 260 261 glNormal3f(anorms[i][0], anorms[i][1], anorms[i][2]); 262 glVertex3fv(this->data->pVertices[this->data->pTriangles[i].indexToVertices[1]]); 263 264 glNormal3f(anorms[i][0], anorms[i][1], anorms[i][2]); 265 glVertex3fv(this->data->pVertices[this->data->pTriangles[i].indexToVertices[2]]); 266 } 267 268 glEnd(); 269 } 270 271 225 272 /** 226 273 \brief animates the current model … … 228 275 depending on the time passed (tick function), the player will select another model 229 276 */ 230 void MD2Model::animate() 231 { 277 void MD2Model::animate(float time) 278 { 279 this->animationState.localTime += time; 280 232 281 if( this->animationState.localTime - this->animationState.lastTime > (1.0f / this->animationState.fps)) 233 282 { … … 236 285 237 286 if( this->animationState.nextFrame > this->animationState.endFrame) 287 { 238 288 this->animationState.nextFrame = this->animationState.startFrame; 289 this->animationState.numPlays++; 290 } 239 291 this->animationState.lastTime = this->animationState.localTime; 240 292 } … … 297 349 this->numTexCoor = 0; 298 350 299 this->scaleFactor = 0.2f; 351 // this->scaleFactor = 1.0f; 352 this->scaleFactor = 0.1f; 300 353 301 354 this->fileName = NULL; … … 399 452 { 400 453 /* SPEEDUP: *(pVerts + i + 0) = (*(frame->pVertices + i + 0)... */ 401 pVertex[j][0] = ((frame->pVertices[j].v[0] * frame->scale[0] ) + frame->translate[0] )* this->scaleFactor; 402 pVertex[j][1] = ((frame->pVertices[j].v[2] * frame->scale[2]) + frame->translate[2]) * this->scaleFactor; 403 pVertex[j][2] = (-1.0 * (frame->pVertices[j].v[1] * frame->scale[1] + frame->translate[1])) * this->scaleFactor; 454 pVertex[j][0] = ((frame->pVertices[j].v[0] * frame->scale[0] ) + frame->translate[0] )* this->scaleFactor; 455 pVertex[j][1] = ((frame->pVertices[j].v[2] * frame->scale[2]) + frame->translate[2]) * this->scaleFactor; 456 pVertex[j][2] = (-1.0 * (frame->pVertices[j].v[1] * frame->scale[1] + frame->translate[1])) * this->scaleFactor; 457 458 //printf("vertex %i/%i: (%f, %f, %f)\n", j, this->numVertices, pVertex[j][0], pVertex[j][1], pVertex[j][2]); 404 459 405 460 pNormals[j] = frame->pVertices[j].lightNormalIndex; 406 461 } 407 462 } 463 PRINTF(4)("Finished loading the md2 file\n"); 408 464 409 465 delete [] buffer; -
trunk/src/lib/graphics/importer/md2Model.h
r6022 r6222 65 65 }; 66 66 67 68 //! compressed vertex data: char insetead of float, the value will be expanded by the scale value. only for loading 69 typedef struct 70 { 71 unsigned char v[3]; //!< the vector of the vertex 72 unsigned char lightNormalIndex; //!< the index of the light normal 73 } sVertex; 74 75 76 //! compressed texture offset data: coords scaled by the texture size. Only for loading 77 typedef struct 78 { 79 short s; //!< the s,t coordinates of a texture 80 short t; //!< the s,t coordinates of a texture 81 } sTexCoor; 82 83 84 //! holds tha informations about a md2 frame 85 typedef struct 86 { 87 sVec3D scale; //!< scales values of the model 88 sVec3D translate; //!< translates the model 89 char name[16]; //!< frame name: something like "run32" 90 sVertex pVertices[1]; //!< first vertex of thes frame 91 } sFrame; 92 93 94 //! holds the information about a triangle 95 typedef struct 96 { 97 unsigned short indexToVertices[3]; //!< index to the verteces of the triangle 98 unsigned short indexToTexCoor[3]; //!< index to the texture coordinates 99 } sTriangle; 100 101 102 103 //! the command list of the md2 model, very md2 specific 104 typedef struct 105 { 106 float s; //!< texture coordinate 1 107 float t; //!< texture coordinate 2 108 int vertexIndex; //!< index of the vertex in the vertex list 109 } glCommandVertex; 110 111 112 //! a md2 animation definition 113 typedef struct 114 { 115 int firstFrame; //!< first frame of the animation 116 int lastFrame; //!< last frame of the animation 117 int fps; //!< speed: number of frames per second 118 int bStoppable; //!< 1 if the animation is stoppable 0 else 119 } sAnim; 120 121 122 //! animation state definition 123 typedef struct 124 { 125 int startFrame; //!< the start frame of an animation 126 int endFrame; //!< last frame of the animation 127 int fps; //!< fps of the animaion (speed) 128 129 float localTime; //!< the local time 130 float lastTime; //!< last time stamp 131 float interpolationState; //!< the state of the animation [0..1] 132 133 int type; //!< animation type 134 135 int currentFrame; //!< the current frame 136 int nextFrame; //!< the next frame in the list 137 int numPlays; //!< the number of times, this has been played in series 138 } sAnimState; 67 139 68 140 … … 143 215 virtual ~MD2Model(); 144 216 145 void draw(); 217 virtual void draw() const; 218 void renderFrameTriangles() const; 219 146 220 147 221 void setAnim(int type); 148 /** 149 * scales the current model 150 * @param scaleFactor: the factor [0..1] to use for scaling 151 */ 222 /** returns the current animation @returns animation type */ 223 inline int MD2Model::getAnim() { return this->animationState.type; } 224 /** scales the current model @param scaleFactor: the factor [0..1] to use for scaling */ 152 225 void scaleModel(float scaleFactor) { this->scaleFactor = scaleFactor;} 153 226 154 v oid tick(float dtS);227 virtual void tick(float dtS); 155 228 void debug(); 156 229 157 230 158 231 private: 159 void animate( );232 void animate(float time); 160 233 void processLighting(); 161 void interpolate( sVec3D* verticesList);162 void renderFrame() ;234 void interpolate(/*sVec3D* verticesList*/); 235 void renderFrame() const ; 163 236 164 237 … … 168 241 static float anormsDots[SHADEDOT_QUANT][256]; //!< the anormals dot products 169 242 static sAnim animationList[21]; //!< the anomation list 243 //! again one of these strange id software parts 244 float* shadeDots; 170 245 171 246 MD2Data* data; //!< the md2 data pointer … … 174 249 float scaleFactor; //!< the scale factor (individual) 175 250 sAnimState animationState; //!< animation state of the model 251 sVec3D verticesList[MD2_MAX_VERTICES]; //!< place to temp sav the vert 176 252 }; 177 253 -
trunk/src/lib/graphics/importer/model.h
r6033 r6222 29 29 30 30 31 32 //! compressed vertex data: char insetead of float, the value will be expanded by the scale value. only for loading33 typedef struct34 {35 char v[3]; //!< the vector of the vertex36 unsigned char lightNormalIndex; //!< the index of the light normal37 } sVertex;38 39 40 //! compressed texture offset data: coords scaled by the texture size. Only for loading41 typedef struct42 {43 short s; //!< the s,t coordinates of a texture44 short t; //!< the s,t coordinates of a texture45 } sTexCoor;46 47 48 //! holds tha informations about a md2 frame49 typedef struct50 {51 sVec3D scale; //!< scales values of the model52 sVec3D translate; //!< translates the model53 char name[16]; //!< frame name: something like "run32"54 sVertex pVertices[1]; //!< first vertex of thes frame55 } sFrame;56 57 58 //! holds the information about a triangle59 typedef struct60 {61 unsigned short indexToVertices[3]; //!< index to the verteces of the triangle62 unsigned short indexToTexCoor[3]; //!< index to the texture coordinates63 } sTriangle;64 65 66 31 //! holds the information about a triangle 67 32 typedef struct … … 72 37 } sTriangleExt; 73 38 74 75 //! the command list of the md2 model, very md2 specific76 typedef struct77 {78 float s; //!< texture coordinate 179 float t; //!< texture coordinate 280 int vertexIndex; //!< index of the vertex in the vertex list81 } glCommandVertex;82 83 84 //! a md2 animation definition85 typedef struct86 {87 int firstFrame; //!< first frame of the animation88 int lastFrame; //!< last frame of the animation89 int fps; //!< speed: number of frames per second90 } sAnim;91 92 93 //! animation state definition94 typedef struct95 {96 int startFrame; //!< the start frame of an animation97 int endFrame; //!< last frame of the animation98 int fps; //!< fps of the animaion (speed)99 100 float localTime; //!< the local time101 float lastTime; //!< last time stamp102 float interpolationState; //!< the state of the animation [0..1]103 104 int type; //!< animation type105 106 int currentFrame; //!< the current frame107 int nextFrame; //!< the next frame in the list108 } sAnimState;109 39 110 40 //! Model Information definitions … … 122 52 123 53 } modelInfo; 124 125 54 126 55 -
trunk/src/lib/graphics/render2D/render_2d.cc
r5417 r6222 20 20 #include "graphics_engine.h" 21 21 #include "class_list.h" 22 #include "list.h"23 22 #include "element_2d.h" 24 23 -
trunk/src/lib/graphics/spatial_separation
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
libORX*
-
Property
svn:ignore
set to
-
trunk/src/lib/graphics/text_engine/text_engine.cc
r5885 r6222 37 37 38 38 #include "debug.h" 39 #include "list.h"40 39 41 40 /////////////////// -
trunk/src/lib/gui
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
libORX*
-
Property
svn:ignore
set to
-
trunk/src/lib/gui/gl_gui
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
libORX*
-
Property
svn:ignore
set to
-
trunk/src/lib/gui/gtk_gui
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
libORX*
-
Property
svn:ignore
set to
-
trunk/src/lib/network
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
libORX*
-
Property
svn:ignore
set to
-
trunk/src/lib/parser
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
libORX*
-
Property
svn:ignore
set to
-
trunk/src/lib/parser/ini_parser
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
lib*
-
Property
svn:ignore
set to
-
trunk/src/lib/parser/tinyxml
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
libtinyxml*
-
Property
svn:ignore
set to
-
trunk/src/lib/particles
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
libORX*
-
Property
svn:ignore
set to
-
trunk/src/lib/particles/particle_system.cc
r5994 r6222 130 130 LoadParam(root, "type", this, ParticleSystem, setType) 131 131 .describe("sets the type of the Particles, (dot, spark, sprite or model)"); 132 133 LoadParam(root, "texture", this, ParticleSystem, setMaterialTexture); 132 134 133 135 LOAD_PARAM_START_CYCLE(root, element); -
trunk/src/lib/physics
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
libORX*
-
Property
svn:ignore
set to
-
trunk/src/lib/shell
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
libORX*
-
Property
svn:ignore
set to
-
trunk/src/lib/shell/shell.cc
r5787 r6222 23 23 24 24 #include "text.h" 25 #include "list.h"26 25 #include "graphics_engine.h" 27 26 #include "material.h" -
trunk/src/lib/shell/shell_buffer.cc
r5783 r6222 18 18 #include "shell_buffer.h" 19 19 #include "debug.h" 20 #include "list.h"21 20 #include "shell.h" 22 21 -
trunk/src/lib/shell/shell_command.cc
r5885 r6222 19 19 #include "shell_command_class.h" 20 20 21 #include " list.h"21 #include "compiler.h" 22 22 #include "debug.h" 23 23 #include "class_list.h" -
trunk/src/lib/shell/shell_input.cc
r5787 r6222 26 26 27 27 #include "debug.h" 28 #include "list.h"29 28 #include "compiler.h" 30 29 #include "stdlibincl.h" -
trunk/src/lib/sound
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
libORX*
-
Property
svn:ignore
set to
-
trunk/src/lib/sound/sound_engine.cc
r6142 r6222 24 24 25 25 #include "p_node.h" 26 #include "list.h"27 26 #include "resource_manager.h" 28 27 #include "debug.h" -
trunk/src/lib/util/executor/executor.cc
r5659 r6222 18 18 #include "executor.h" 19 19 20 #include "list.h"21 20 #include "debug.h" 22 21 #include "class_list.h" -
trunk/src/story_entities/debug_world.cc
r6150 r6222 48 48 49 49 #include "glmenu_imagescreen.h" 50 #include "list.h"51 50 #include "game_loader.h" 52 51 -
trunk/src/story_entities/network_world.cc
r6142 r6222 48 48 49 49 #include "glmenu_imagescreen.h" 50 #include "list.h"51 50 #include "game_loader.h" 52 51 -
trunk/src/story_entities/world.cc
r6155 r6222 46 46 47 47 #include "glmenu_imagescreen.h" 48 #include "list.h"49 48 #include "game_loader.h" 50 49 … … 348 347 // tn->addChild(this->localCamera); 349 348 localCamera->setClipRegion(1, 10000.0); 350 localCamera->lookAt(playable);349 // localCamera->lookAt(playable); 351 350 // this->localPlayer->setParentMode(PNODE_ALL); 352 351 if (sky != NULL) … … 356 355 } 357 356 357 this->localCamera->getTarget()->getParent()->debugNode(0); 358 358 SoundEngine::getInstance()->setListener(this->localCamera); 359 359 -
trunk/src/subprojects
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
-
Property
svn:ignore
set to
-
trunk/src/subprojects/collision_detection
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
collision
-
Property
svn:ignore
set to
-
trunk/src/subprojects/importer
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
importer
multitex
-
Property
svn:ignore
set to
-
trunk/src/subprojects/importer/Makefile.am
r5865 r6222 24 24 $(MAINSRCDIR)/lib/math/vector.cc \ 25 25 $(MAINSRCDIR)/util/loading/resource_manager.cc \ 26 $(MAINSRCDIR)/lib/ util/ini_parser.cc \26 $(MAINSRCDIR)/lib/parser/ini_parser/ini_parser.cc \ 27 27 $(MAINSRCDIR)/lib/coord/p_node.cc \ 28 $(MAINSRCDIR)/lib/coord/null_parent.cc \29 28 $(MAINSRCDIR)/util/loading/load_param.cc \ 30 29 $(MAINSRCDIR)/util/loading/load_param_description.cc \ … … 52 51 $(MAINSRCDIR)/lib/math/vector.cc \ 53 52 $(MAINSRCDIR)/util/loading/resource_manager.cc \ 54 $(MAINSRCDIR)/lib/ util/ini_parser.cc \53 $(MAINSRCDIR)/lib/parser/ini_parser/ini_parser.cc \ 55 54 $(MAINSRCDIR)/lib/coord/p_node.cc \ 56 $(MAINSRCDIR)/lib/coord/null_parent.cc \57 55 $(MAINSRCDIR)/util/loading/load_param.cc \ 58 56 $(MAINSRCDIR)/util/loading/load_param_description.cc \ -
trunk/src/subprojects/importer/importer.cc
r4741 r6222 21 21 22 22 #include "objModel.h" 23 #include "md2Model.h" 23 24 #include "primitive_model.h" 24 25 #include <stdlib.h> … … 40 41 41 42 if (argc>=3) 42 obj = new OBJModel (argv[1], atof(argv[2])); 43 { 44 if( strstr(argv[1], ".obj") != NULL) 45 obj = new OBJModel (argv[1], atof(argv[2])); 46 else if( strstr(argv[1], ".md2") != NULL) 47 { 48 obj = new MD2Model(argv[1], argv[2]); 49 ((MD2Model*)obj)->tick(0.1f); 50 } 51 } 43 52 else if (argc>=2) 44 obj = new OBJModel(argv[1]); 53 { 54 if( strstr(argv[1], ".obj") != NULL) 55 obj = new OBJModel(argv[1]); 56 else if( strstr(argv[1], ".md2") != NULL) { 57 obj = new MD2Model(argv[1], "fake_texture.bad"); 58 obj = new MD2Model(argv[1], argv[2]); 59 ((MD2Model*)obj)->tick(0.1f); 60 } 61 } 45 62 else 46 63 obj = new PrimitiveModel(PRIM_CYLINDER); -
trunk/src/subprojects/network
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
network
-
Property
svn:ignore
set to
-
trunk/src/subprojects/particles
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
particles
-
Property
svn:ignore
set to
-
trunk/src/subprojects/testmain
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
testmain
-
Property
svn:ignore
set to
-
trunk/src/util
-
Property
svn:ignore
set to
Makefile
Makefile.in
.deps
libORX*
-
Property
svn:ignore
set to
-
trunk/src/util/animation/animation.h
r5777 r6222 7 7 #define _ANIMATION_H 8 8 9 #include "list.h"10 9 #include "base_object.h" 11 #include "confincl.h" // must be here to determin the DEBUG-level12 10 #include "debug.h" 13 11 12 #include "list.h" 14 13 // FORWARD DECLARATION 15 14 -
trunk/src/util/loading/resource_manager.cc
r5994 r6222 19 19 20 20 #include "debug.h" 21 22 #include <algorithm> 21 23 22 24 // different resource Types … … 40 42 #endif /* NO_SHADERS */ 41 43 42 #include "list.h"43 #include "sdlincl.h"44 45 44 // File Handling Includes 46 45 #include <sys/types.h> … … 61 60 strcpy(this->dataDir, "./"); 62 61 this->tryDataDir("./data"); 63 this->imageDirs = new tList<char>;64 this->resourceList = new tList<Resource>;65 62 } 66 63 … … 76 73 this->unloadAllByPriority(RP_GAME); 77 74 78 if (this->resourceList->getSize() > 0) 79 PRINTF(1)("Not removed all Resources, since there are still %d resources registered\n", this->resourceList->getSize()); 80 81 delete this->resourceList; 75 if (!this->resourceList.empty()) 76 PRINTF(1)("Not removed all Resources, since there are still %d resources registered\n", this->resourceList.size()); 77 82 78 // deleting the Directorie Lists 83 tIterator<char>* tmpIt = imageDirs->getIterator(); 84 char* tmpDir = tmpIt->firstElement(); 85 while(tmpDir) 86 { 87 delete[] tmpDir; 88 tmpDir = tmpIt->nextElement(); 89 } 90 delete tmpIt; 91 delete this->imageDirs; 79 while (!this->imageDirs.empty()) 80 { 81 delete[] this->imageDirs.front(); 82 this->imageDirs.pop_front(); 83 } 92 84 93 85 delete[] this->dataDir; … … 211 203 { 212 204 // check if the Directory has been added before 213 tIterator<char>* tmpImageDirs = imageDirs->getIterator(); 214 char* tmpDir = tmpImageDirs->firstElement(); 215 while(tmpDir) 216 { 217 if (!strcmp(tmpDir, newDir)) 218 { 219 PRINTF(3)("Path %s already loaded\n", newDir); 220 delete[] newDir; 221 delete tmpImageDirs; 222 return true; 223 } 224 tmpDir = tmpImageDirs->nextElement(); 225 } 226 delete tmpImageDirs; 227 205 std::list<char*>::const_iterator imageDir; 206 for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++) 207 { 208 if (!strcmp(*imageDir, newDir)) 209 { 210 PRINTF(3)("Path %s already loaded\n", newDir); 211 delete[] newDir; 212 return true; 213 } 214 } 228 215 // adding the directory to the List 229 this->imageDirs ->add(newDir);216 this->imageDirs.push_back(newDir); 230 217 return true; 231 218 } … … 389 376 else 390 377 tmpResource->secFileName = NULL; 391 tmpResource->pointer = new MD2Data(fullName, tmpResource->secFileName); 378 tmpResource->pointer = new MD2Data(fullName, tmpResource->secFileName); 379 // tmpResource->pointer = new MD2Model(fullName, tmpResource->secFileName); 380 392 381 } 393 382 break; … … 425 414 else 426 415 { 427 char* tmpDir; 428 tIterator<char>* iterator = imageDirs->getIterator(); 429 tmpDir = iterator->firstElement(); 430 while(tmpDir) 416 std::list<char*>::iterator imageDir; 417 for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++) 431 418 { 432 char* imgName = new char[strlen( tmpDir)+strlen(fileName)+1];433 sprintf(imgName, "%s%s", tmpDir, fileName);419 char* imgName = new char[strlen(*imageDir)+strlen(fileName)+1]; 420 sprintf(imgName, "%s%s", *imageDir, fileName); 434 421 if(isFile(imgName)) 435 422 { … … 440 427 } 441 428 delete[] imgName; 442 tmpDir = iterator->nextElement();443 429 } 444 delete iterator;445 430 } 446 431 if(!tmpResource) … … 477 462 } 478 463 if (tmpResource->pointer != NULL) 479 this->resourceList ->add(tmpResource);464 this->resourceList.push_back(tmpResource); 480 465 delete[] fullName; 481 466 } … … 572 557 PRINTF(4)("Resource %s safely removed.\n", resource->name); 573 558 delete[] resource->name; 574 this->resourceList->remove(resource); 559 std::list<Resource*>::iterator resourceIT = std::find(this->resourceList.begin(), this->resourceList.end(), resource); 560 this->resourceList.erase(resourceIT); 575 561 delete resource; 576 562 } … … 590 576 bool ResourceManager::unloadAllByPriority(ResourcePriority prio) 591 577 { 592 tIterator<Resource>* iterator = resourceList->getIterator(); 593 Resource* enumRes = iterator->lastElement(); 594 while (enumRes) 595 { 596 if (enumRes->prio <= prio) 597 if (enumRes->count == 0) 598 unload(enumRes, prio); 599 else 600 PRINTF(2)("unable to unload %s because there are still %d references to it\n", 601 enumRes->name, enumRes->count); 602 //enumRes = resourceList->nextElement(); 603 enumRes = iterator->prevElement(); 604 } 605 delete iterator; 578 std::list<Resource*>::iterator resource, pre; 579 pre = --this->resourceList.end(); 580 unsigned int removeCount; 581 for (unsigned int round = 0; round < 3; round++) 582 { 583 removeCount = 0; 584 while (pre != resourceList.end()) 585 { 586 resource = pre; 587 pre--; 588 if ((*resource)->prio <= prio) 589 { 590 if ((*resource)->count == 0) 591 unload((*resource), prio); 592 else 593 { 594 PRINTF(2)("unable to unload %s because there are still %d references to it\n", 595 (*resource)->name, (*resource)->count); 596 removeCount++; 597 } 598 } 599 } 600 if (removeCount == 0) break; 601 } 606 602 } 607 603 … … 619 615 void* param1, void* param2, void* param3) const 620 616 { 621 // Resource* enumRes = resourceList->enumerate(); 622 tIterator<Resource>* iterator = resourceList->getIterator(); 623 Resource* enumRes = iterator->firstElement(); 624 while (enumRes) 625 { 626 if (enumRes->type == type && !strcmp(fileName, enumRes->name)) 617 std::list<Resource*>::const_iterator resource; 618 for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++) 619 { 620 if ((*resource)->type == type && !strcmp(fileName, (*resource)->name)) 627 621 { 628 622 bool match = false; … … 635 629 if (!param1) 636 630 { 637 if ( enumRes->modelSize == 1.0)631 if ((*resource)->modelSize == 1.0) 638 632 match = true; 639 633 } 640 else if ( enumRes->modelSize == *(float*)param1)634 else if ((*resource)->modelSize == *(float*)param1) 641 635 match = true; 642 636 break; … … 644 638 if (!param1) 645 639 { 646 if ( enumRes->secFileName == NULL)640 if ((*resource)->secFileName == NULL) 647 641 match = true; 648 642 } 649 else if (!strcmp( enumRes->secFileName, (const char*)param1))643 else if (!strcmp((*resource)->secFileName, (const char*)param1)) 650 644 match = true; 651 645 break; … … 655 649 if (param1 == NULL) 656 650 { 657 if ( enumRes->ttfSize == FONT_DEFAULT_RENDER_SIZE)651 if ((*resource)->ttfSize == FONT_DEFAULT_RENDER_SIZE) 658 652 match = true; 659 653 } 660 else if ( enumRes->ttfSize == *(unsigned int*)param1)654 else if ((*resource)->ttfSize == *(unsigned int*)param1) 661 655 match = true; 662 656 break; … … 666 660 if (!param1) 667 661 { 668 if ( enumRes->secFileName == NULL)662 if ((*resource)->secFileName == NULL) 669 663 match = true; 670 664 } 671 else if (!strcmp( enumRes->secFileName, (const char*)param1))665 else if (!strcmp((*resource)->secFileName, (const char*)param1)) 672 666 match = true; 673 667 #endif /* NO_SHADERS */ … … 678 672 if (match) 679 673 { 680 delete iterator; 681 return enumRes; 674 return (*resource); 682 675 } 683 676 } 684 enumRes = iterator->nextElement(); 685 } 686 delete iterator; 677 } 687 678 return NULL; 688 679 } … … 696 687 { 697 688 // Resource* enumRes = resourceList->enumerate(); 698 tIterator<Resource>* iterator = resourceList->getIterator(); 699 Resource* enumRes = iterator->firstElement(); 700 while (enumRes) 701 { 702 if (pointer == enumRes->pointer) 703 { 704 delete iterator; 705 return enumRes; 706 } 707 enumRes = iterator->nextElement(); 708 } 709 delete iterator; 689 std::list<Resource*>::const_iterator resource; 690 for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++) 691 if (pointer == (*resource)->pointer) 692 return (*resource); 710 693 return NULL; 711 694 } … … 920 903 PRINT(0)(" Data-Directory is: %s\n", this->dataDir); 921 904 PRINT(0)(" List of Image-Directories: "); 922 tIterator<char>* tmpIt = imageDirs->getIterator(); 923 char* tmpDir = tmpIt->firstElement(); 924 while(tmpDir) 925 { 926 PRINT(0)("%s ",tmpDir); 927 tmpDir = tmpIt->nextElement(); 928 } 929 delete tmpIt; 905 std::list<char*>::const_iterator imageDir; 906 for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++) 907 PRINT(0)("%s ", (*imageDir)); 930 908 PRINT(0)("\n"); 931 909 932 910 PRINT(0)("List of all stored Resources:\n"); 933 tIterator<Resource>* iterator = resourceList->getIterator();934 Resource* enumRes = iterator->firstElement();935 while (enumRes) 911 std::list<Resource*>::const_iterator resource; 912 for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++) 913 936 914 { 937 915 PRINT(0)("-----------------------------------------\n"); 938 PRINT(0)("Name: %s; References: %d; Type: %s ", enumRes->name, enumRes->count, ResourceManager::ResourceTypeToChar(enumRes->type));916 PRINT(0)("Name: %s; References: %d; Type: %s ", (*resource)->name, (*resource)->count, ResourceManager::ResourceTypeToChar((*resource)->type)); 939 917 940 918 PRINT(0)("gets deleted at "); 941 switch( enumRes->prio)919 switch((*resource)->prio) 942 920 { 943 921 default: … … 955 933 break; 956 934 } 957 enumRes = iterator->nextElement(); 958 } 959 delete iterator; 935 } 960 936 961 937 -
trunk/src/util/loading/resource_manager.h
r5994 r6222 21 21 #include "base_object.h" 22 22 23 #include "stdlibincl.h"24 23 25 // FORWARD DECLARATION 26 template<class T> class tList; 24 #include <list> 27 25 28 26 //! An eumerator for different fileTypes the resourceManager supports … … 144 142 145 143 char* dataDir; //!< The Data Directory, where all relevant Data is stored. 146 tList<Resource>*resourceList; //!< The List of Resources, that has already been loaded.147 tList<char>*imageDirs; //!< A list of directories in which images are stored.144 std::list<Resource*> resourceList; //!< The List of Resources, that has already been loaded. 145 std::list<char*> imageDirs; //!< A list of directories in which images are stored. 148 146 149 147 }; -
trunk/src/util/state.cc
r6142 r6222 26 26 27 27 28 constPNode* State::camera = NULL;29 constPNode* State::cameraTarget = NULL;28 PNode* State::camera = NULL; 29 PNode* State::cameraTarget = NULL; 30 30 31 31 ObjectManager* State::objectManager = NULL; … … 34 34 * sets camera and target of the current Camera 35 35 */ 36 void State::setCamera( const PNode* camera, constPNode* cameraTarget)36 void State::setCamera(PNode* camera, PNode* cameraTarget) 37 37 { 38 38 State::camera = camera; -
trunk/src/util/state.h
r6142 r6222 25 25 ////////////// 26 26 /** @param camera the PNode to the Camera, @param cameraTarget the PNode to the Camera's target */ 27 static void setCamera( const PNode* camera, constPNode* cameraTarget);27 static void setCamera(PNode* camera, PNode* cameraTarget); 28 28 /** @returns a Pointer to the PNode of the Camera */ 29 static inline constPNode* getCamera() { return State::camera; };29 static inline PNode* getCamera() { return State::camera; }; 30 30 /** @returns a Pointer to the CameraTarget */ 31 static inline constPNode* getCameraTarget() { return State::cameraTarget; };31 static inline PNode* getCameraTarget() { return State::cameraTarget; }; 32 32 33 33 ////////////////////// … … 46 46 State(); 47 47 48 static const PNode*camera; //!< A reference to the camera49 static const PNode*cameraTarget; //!< A reference to the cameraTarget48 static PNode* camera; //!< A reference to the camera 49 static PNode* cameraTarget; //!< A reference to the cameraTarget 50 50 static PNode* nullParent; //!< A reference to the Null-PNode. 51 51 static ObjectManager* objectManager; //!< A referenct to the current ObjectManager -
trunk/src/world_entities/Makefile.am
r6139 r6222 8 8 camera.cc \ 9 9 playable.cc \ 10 10 player.cc \ 11 11 npc.cc \ 12 12 npc2.cc \ … … 18 18 character_attributes.cc \ 19 19 test_entity.cc \ 20 space_ships/space_ship.cc \ 20 space_ships/space_ship.cc \ 21 creatures/md2_creature.cc \ 21 22 weapons/weapon_manager.cc \ 22 23 weapons/weapon.cc \ … … 27 28 weapons/rocket.cc \ 28 29 weapons/laser.cc \ 29 30 weapons/ground_turret.cc \ 30 31 weapons/crosshair.cc \ 31 32 weapons/ground_turret.cc \ 32 33 power_ups/power_up.cc \ 33 34 power_ups/turret_power_up.cc \ … … 38 39 camera.h \ 39 40 playable.h \ 40 41 player.h \ 41 42 npc.h \ 42 43 npc2.h \ … … 49 50 test_entity.h \ 50 51 space_ships/space_ship.h \ 52 creatures/md2_creature.cc \ 51 53 weapons/weapon_manager.h \ 52 54 weapons/weapon.h \ -
trunk/src/world_entities/camera.cc
r6034 r6222 119 119 case VIEW_NORMAL: 120 120 this->toFovy = 60.0; 121 this->setParentSoft("TrackNode");122 this->target->setParentSoft("TrackNode"); 121 /* this->setParentSoft("TrackNode"); 122 this->target->setParentSoft("TrackNode"); */ 123 123 this->setRelCoorSoft(-10, 5, 0); 124 124 this->target->setRelCoorSoft(0,0,0); … … 129 129 // this->target->setRelCoorSoft(Vector(10,0,0)); 130 130 131 if (!strcmp(this->target->getParent()->getName(), "Player"))132 this->target->setParentSoft("TrackNode");133 else134 this->target->setParentSoft("Player");135 this->getParent()->debugNode(0);131 // if (!strcmp(this->target->getParent()->getName(), "Player")) 132 // this->target->setParentSoft("TrackNode"); 133 // else 134 // this->target->setParentSoft("Player"); 135 // this->getParent()->debugNode(0); 136 136 137 137 // this->setParent("main-Turret"); … … 142 142 case VIEW_FRONT: 143 143 this->toFovy = 120.0; 144 this->setParentSoft("Player");145 this->target->setParentSoft("Player"); 144 /* this->setParentSoft("Player"); 145 this->target->setParentSoft("Player");*/ 146 146 this->setRelCoorSoft(4, 0, 0, 5); 147 147 this->target->setRelCoorSoft(Vector(10,0,0), 5); … … 150 150 case VIEW_LEFT: 151 151 this->toFovy = 90; 152 this->setParentSoft("TrackNode");153 this->target->setParentSoft("TrackNode"); 152 /* this->setParentSoft("TrackNode"); 153 this->target->setParentSoft("TrackNode");*/ 154 154 this->setRelCoorSoft(0, 1, -10, .5); 155 155 this->target->setRelCoorSoft(0,0,0); … … 157 157 case VIEW_RIGHT: 158 158 this->toFovy = 90; 159 this->setParentSoft("TrackNode");160 this->target->setParentSoft("TrackNode"); 159 /* this->setParentSoft("TrackNode"); 160 this->target->setParentSoft("TrackNode");*/ 161 161 this->setRelCoorSoft(Vector(0, 1, 10)); 162 162 this->target->setRelCoorSoft(0,0,0); … … 164 164 case VIEW_TOP: 165 165 this->toFovy= 120; 166 this->setParentSoft("TrackNode");167 this->target->setParentSoft("TrackNode"); 166 /* this->setParentSoft("TrackNode"); 167 this->target->setParentSoft("TrackNode");*/ 168 168 this->setRelCoorSoft(Vector(30, 50, 0)); 169 169 this->target->setRelCoorSoft(35,0,0); -
trunk/src/world_entities/npcs/npc.cc
r6142 r6222 22 22 23 23 #include "state.h" 24 #include "list.h"25 24 #include "stdlibincl.h" 26 25 #include "power_ups/turret_power_up.h" -
trunk/src/world_entities/npcs/npc_test.cc
r6054 r6222 23 23 #include "shader.h" 24 24 #include "state.h" 25 #include "list.h"26 25 #include "stdlibincl.h" 27 26 #include "debug.h" -
trunk/src/world_entities/npcs/npc_test1.cc
r6054 r6222 22 22 23 23 #include "state.h" 24 #include "list.h"25 #include "stdlibincl.h"26 24 #include "power_ups/turret_power_up.h" 27 25 #include "power_ups/laser_power_up.h" -
trunk/src/world_entities/playable.h
r6162 r6222 25 25 virtual ~Playable(); 26 26 27 virtual void enter() {}; 28 virtual void leave() {}; 27 29 28 30 virtual void addWeapon(Weapon* weapon ) {}//= 0; … … 34 36 35 37 virtual void process(const Event &event) = 0; 36 38 37 39 38 40 -
trunk/src/world_entities/player.cc
r5915 r6222 19 19 #include "event_handler.h" 20 20 21 22 #include "class_list.h" 23 #include "state.h" 24 21 25 using namespace std; 22 26 … … 28 32 { 29 33 this->init(); 34 35 EventHandler::getInstance()->subscribe(this, ES_GAME, SDLK_l); 30 36 } 31 37 … … 79 85 void Player::process(const Event &event) 80 86 { 87 if (event.type == SDLK_l && event.bPressed) 88 { 89 /// FIXME this should be in the ObjectManager 90 const std::list<BaseObject*>* objectList = ClassList::getList(CL_PLAYABLE); 91 if (objectList != NULL) 92 { 93 list<BaseObject*>::const_iterator node; 94 for (node = objectList->begin(); node != objectList->end(); node++) 95 if (this->controllable != (*node) && (dynamic_cast<PNode*>(*node)->getAbsCoor() - this->controllable->getAbsCoor()).len() < 10.0) 96 { 97 this->controllable->leave(); 98 this->disconnectControllable(); 99 this->setControllable(dynamic_cast<Playable*>(*node)); 100 this->controllable->enter(); 101 State::getCamera()->setParentSoft(this->controllable); 102 State::getCameraTarget()->setParentSoft(this->controllable); 103 104 break; 105 } 106 } 107 } 108 81 109 if (likely(this->controllable != NULL)) 82 110 this->controllable->process(event); -
trunk/src/world_entities/power_ups/laser_power_up.cc
r6142 r6222 19 19 #include "factory.h" 20 20 #include "state.h" 21 #include "list.h"22 21 23 22 #include "primitive_model.h" -
trunk/src/world_entities/power_ups/param_power_up.cc
r6113 r6222 19 19 #include "factory.h" 20 20 #include "state.h" 21 #include "list.h"22 21 23 22 #include "primitive_model.h" -
trunk/src/world_entities/power_ups/turret_power_up.cc
r6142 r6222 19 19 #include "factory.h" 20 20 #include "state.h" 21 #include "list.h"22 21 23 22 #include "primitive_model.h" -
trunk/src/world_entities/power_ups/weapon_power_up.cc
r6113 r6222 19 19 #include "factory.h" 20 20 #include "state.h" 21 #include "list.h"22 21 23 22 #include "primitive_model.h" -
trunk/src/world_entities/satellite.cc
r5994 r6222 21 21 22 22 #include "objModel.h" 23 #include "list.h"24 23 #include "vector.h" 25 24 -
trunk/src/world_entities/space_ships/helicopter.cc
r6162 r6222 95 95 96 96 this->getWeaponManager()->changeWeaponConfig(1); 97 dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false); 97 98 } 98 99 … … 184 185 185 186 187 188 189 void Helicopter::enter() 190 { 191 dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( true); 192 193 194 } 195 196 void Helicopter::leave() 197 { 198 dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false); 199 200 201 } 202 203 186 204 /** 187 205 * adds a weapon to the weapon list of the spaceship … … 324 342 if(this->getAbsDirZ().y > 0.02) this->shiftDir(Quaternion(time/5, Vector(1,0,0))); 325 343 } 326 344 327 345 if( this->bRight /* > this->getRelCoor().z*2*/) 328 346 { -
trunk/src/world_entities/space_ships/helicopter.h
r6162 r6222 24 24 void loadParams(const TiXmlElement* root); 25 25 26 virtual void enter(); 27 virtual void leave(); 28 26 29 void addWeapon(Weapon* weapon ); 27 30 void removeWeapon(Weapon* weapon); … … 39 42 40 43 private: 41 42 44 void calculateVelocity(float time); 43 45 void weaponAction(); … … 65 67 float travelSpeed; //!< the current speed of the player (to make soft movement) 66 68 float acceleration; //!< the acceleration of the player. 67 69 68 70 float airViscosity; 69 71 -
trunk/src/world_entities/space_ships/space_ship.cc
r6162 r6222 112 112 PRINTF(4)("SPACESHIP INIT\n"); 113 113 114 EventHandler::getInstance()->grabEvents(true);114 // EventHandler::getInstance()->grabEvents(true); 115 115 116 116 bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false; … … 177 177 this->getWeaponManager()->getFixedTarget()->setRelCoor(100000,0,0); 178 178 179 dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false); 179 180 } 180 181 … … 188 189 } 189 190 191 192 void SpaceShip::enter() 193 { 194 dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( true); 195 196 197 } 198 199 void SpaceShip::leave() 200 { 201 dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false); 202 203 204 } 190 205 191 206 /** … … 267 282 velocity += ((this->getAbsDirX())*travelSpeed-velocity)*airViscosity; 268 283 velocity = (velocity.getNormalized())*travelSpeed; 269 284 270 285 //orient the spaceship in direction of the mouse 271 286 rotQuat = Quaternion::quatSlerp( this->getAbsDir(),mouseDir,fabsf(time)*3); 272 if (this->getAbsDir().distance(rotQuat) > 0.001) 287 if (this->getAbsDir().distance(rotQuat) > 0.001) 273 288 this->setAbsDir( rotQuat); 274 289 //this->setAbsDirSoft(mouseDir,5); 275 290 276 291 // this is the air friction (necessary for a smooth control) 277 292 if(velocity.len() != 0) velocity -= velocity*0.01; … … 308 323 /* calculate the direction in which the craft is heading */ 309 324 325 Plane plane(Vector(0,1,0), Vector(0,0,0)); 326 310 327 if( this->bUp ) 311 328 { 312 329 //this->shiftCoor(this->getAbsDirX()); 313 330 accel += (this->getAbsDirX())*2; 314 331 315 332 /* Heli-Steuerung 316 333 accel += (this->getAbsDirX()*2; -
trunk/src/world_entities/space_ships/space_ship.h
r6162 r6222 26 26 void init(); 27 27 void loadParams(const TiXmlElement* root); 28 29 virtual void enter(); 30 virtual void leave(); 28 31 29 32 void addWeapon(Weapon* weapon ); -
trunk/src/world_entities/test_entity.cc
r6142 r6222 18 18 19 19 20 #include "executor/executor.h" 21 #include "factory.h" 22 #include "load_param.h" 23 20 24 #include "test_entity.h" 21 25 #include "stdincl.h" … … 24 28 #include "obb_tree.h" 25 29 #include "state.h" 26 #include "list.h"27 30 28 31 using namespace std; 29 32 30 33 34 CREATE_FACTORY(TestEntity, CL_TEST_ENTITY); 35 31 36 32 37 TestEntity::TestEntity () 33 38 { 34 this-> setClassID(CL_TEST_ENTITY, "TestEntity");35 // TO SOME LIST!! 39 this->init(); 40 } 36 41 37 this->md2Model = new MD2Model("models/droidika.md2", "models/droideka.pcx");38 // this->md2Model = new MD2Model("models/tris.md2", "models/tris.pcx");39 // this->md2Model = new MD2Model("models/goblin.md2", "maps/goblin.bmp");40 42 41 /// FIXME42 // this->obbTree = new OBBTree(4, (sVec3D*)this->md2Model->data->pVertices, this->md2Model->data->numVertices);43 43 44 this->md2Model->setAnim(RUN); 45 this->md2Model->debug(); 44 TestEntity::TestEntity(const TiXmlElement* root) 45 { 46 this->init(); 47 if (root != NULL) 48 this->loadParams(root); 49 50 this->init(); 46 51 } 47 52 48 53 49 54 TestEntity::~TestEntity () 55 {} 56 57 58 59 void TestEntity::init() 50 60 { 51 delete this->md2Model; 61 this->setClassID(CL_TEST_ENTITY, "TestEntity"); 62 this->toList(OM_COMMON); 63 } 64 65 /** 66 * loads the Settings of a MD2Creature from an XML-element. 67 * @param root the XML-element to load the MD2Creature's properties from 68 */ 69 void TestEntity::loadParams(const TiXmlElement* root) 70 { 71 static_cast<WorldEntity*>(this)->loadParams(root); 72 73 LoadParam(root, "md2animation", this, TestEntity, setAnim) 74 .describe("sets the animation of the md2 model") 75 .defaultValues(1, 1); 76 52 77 } 53 78 … … 55 80 void TestEntity::setAnim(int animationIndex) 56 81 { 57 this->md2Model->setAnim(animationIndex); 82 if( likely(this->getModel(0) != NULL)) 83 ((MD2Model*)this->getModel(0))->setAnim(animationIndex); 58 84 } 59 85 … … 61 87 void TestEntity::tick (float time) 62 88 { 63 this->md2Model->tick(time); 89 if( likely(this->getModel(0) != NULL)) 90 ((MD2Model*)this->getModel(0))->tick(time); 91 64 92 } 65 93 66 94 67 95 void TestEntity::collidesWith(WorldEntity* entity, const Vector& location) 68 { 69 if (entity->isA(CL_PROJECTILE)) 70 { 71 PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getName(), entity->getName(), location.x, location.y, location.z); 72 this->setVisibiliy(false); 73 this->toList(OM_DEAD); 74 } 75 } 76 77 void TestEntity::destroy () {} 78 96 {} 79 97 80 98 … … 82 100 void TestEntity::draw () const 83 101 { 84 glMatrixMode(GL_MODELVIEW); 85 glPushMatrix(); 86 float matrix[4][4]; 87 88 89 glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); 90 this->getAbsDir().matrix (matrix); 91 glMultMatrixf((float*)matrix); 92 this->md2Model->draw(); 93 94 95 glPopMatrix(); 102 this->drawLODsafe(); 96 103 } 97 104 -
trunk/src/world_entities/test_entity.h
r5500 r6222 10 10 struct t3DModel; 11 11 class Material; 12 class TiXmlElement; 12 13 13 14 class TestEntity : public WorldEntity, PhysicsInterface … … 17 18 public: 18 19 TestEntity (); 20 TestEntity(const TiXmlElement* root); 19 21 virtual ~TestEntity (); 22 23 void init(); 24 void loadParams(const TiXmlElement* root); 20 25 21 26 void setAnim(int animationIndex); 22 27 23 28 virtual void tick (float time); 24 virtual void destroy ();25 29 virtual void collidesWith(WorldEntity* entity, const Vector& location); 26 30 virtual void draw () const; -
trunk/src/world_entities/weapons/aim.cc
r6142 r6222 21 21 #include "graphics_engine.h" 22 22 #include "state.h" 23 #include "list.h"24 23 #include "material.h" 25 24 #include "t_animation.h" … … 104 103 void Aim::searchTarget(float range) 105 104 { 106 //FIXME// 107 /* tIterator<WorldEntity>* iterator = State::getWorldEntityList()->getIterator(); 108 WorldEntity* entity = iterator->firstElement(); 109 while (likely(entity != NULL)) 105 std::list<WorldEntity*>::iterator entity; 106 107 for (entity = State::getObjectManager()->getObjectList(OM_GROUP_00).begin(); 108 entity != State::getObjectManager()->getObjectList(OM_GROUP_00).end(); 109 entity ++) 110 110 { 111 if ( entity->isA(CL_NPC) && this->source->getAbsCoor().x < entity->getAbsCoor().x && (this->source->getAbsCoor() - entity->getAbsCoor()).len() < range)111 if (this->source->getAbsCoor().x < (*entity)->getAbsCoor().x && (this->source->getAbsCoor() - (*entity)->getAbsCoor()).len() < range) 112 112 { 113 if (this->getParent() != entity)113 if (this->getParent() != (*entity)) 114 114 { 115 115 this->anim->replay(); 116 this->setParentSoft(entity, 5); 116 this->setParentSoft(*entity, 5); 117 return; 117 118 } 118 delete iterator;119 return;120 119 } 121 entity = iterator->nextElement();122 120 } 123 124 delete iterator;*/125 121 } 126 122 -
trunk/src/world_entities/weapons/bomb.cc
r6142 r6222 21 21 22 22 #include "fast_factory.h" 23 #include "list.h" 23 24 24 25 25 #include "object_manager.h" -
trunk/src/world_entities/weapons/guided_missile.cc
r6162 r6222 20 20 #include "fast_factory.h" 21 21 22 #include "model.h"23 22 #include "state.h" 24 #include "list.h"25 23 #include "class_list.h" 26 24 -
trunk/src/world_entities/weapons/laser.cc
r6162 r6222 21 21 22 22 #include "state.h" 23 #include "list.h"24 23 #include "class_list.h" 25 24 #include "model.h" -
trunk/src/world_entities/weapons/rocket.cc
r6142 r6222 20 20 #include "fast_factory.h" 21 21 22 #include "model.h"23 22 #include "state.h" 24 #include "list.h"25 23 #include "class_list.h" 26 24 -
trunk/src/world_entities/weapons/test_bullet.cc
r6142 r6222 20 20 #include "fast_factory.h" 21 21 22 #include "model.h"23 22 #include "state.h" 24 #include "list.h"25 23 #include "class_list.h" 26 24 -
trunk/src/world_entities/weapons/test_gun.cc
r6162 r6222 29 29 #include "factory.h" 30 30 31 #include "vector.h"32 #include "list.h"33 31 #include "animation3d.h" 34 32 -
trunk/src/world_entities/weapons/turret.cc
r6074 r6222 23 23 24 24 #include "state.h" 25 #include "list.h"26 25 #include "animation3d.h" 27 26 -
trunk/src/world_entities/world_entity.cc
r6142 r6222 21 21 22 22 #include "model.h" 23 #include "md2Model.h" 23 24 #include "resource_manager.h" 24 25 #include "load_param.h" 25 #include "list.h"26 26 #include "vector.h" 27 27 #include "obb_tree.h" … … 84 84 // Do the PNode loading stuff 85 85 static_cast<PNode*>(this)->loadParams(root); 86 87 LoadParam(root, "md2texture", this, WorldEntity, loadMD2Texture) 88 .describe("the fileName of the texture, that should be loaded onto this world-entity. (must be relative to the data-dir)") 89 .defaultValues(1, NULL); 86 90 87 91 // Model Loading … … 89 93 .describe("the fileName of the model, that should be loaded onto this world-entity. (must be relative to the data-dir)") 90 94 .defaultValues(3, NULL, 1.0f, 0); 91 92 } 95 } 96 93 97 94 98 /** … … 103 107 if (fileName != NULL) 104 108 { 105 109 // search for the special character # in the LoadParam 106 110 if (strchr(fileName, '#') != NULL) 111 { 112 PRINTF(4)("Found # in %s... searching for LOD's\n", fileName); 113 char* lodFile = new char[strlen(fileName)+1]; 114 strcpy(lodFile, fileName); 115 char* depth = strchr(lodFile, '#'); 116 for (unsigned int i = 0; i < 5; i++) 107 117 { 108 PRINTF(4)("Found # in %s... searching for LOD's\n", fileName); 109 char* lodFile = new char[strlen(fileName)+1]; 110 strcpy(lodFile, fileName); 111 char* depth = strchr(lodFile, '#'); 112 for (unsigned int i = 0; i < 5; i++) 113 { 114 *depth = 48+(int)i; 115 printf("-------%s\n", lodFile); 116 if (ResourceManager::isInDataDir(lodFile)) 117 this->loadModel(lodFile, scaling, i); 118 } 119 return; 118 *depth = 48+(int)i; 119 printf("-------%s\n", lodFile); 120 if (ResourceManager::isInDataDir(lodFile)) 121 this->loadModel(lodFile, scaling, i); 120 122 } 121 122 PRINTF(4)("fetching %s\n", fileName); 123 if (scaling == 1.0) 124 this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN), modelNumber); 125 else 126 this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, &scaling), modelNumber); 127 if (modelNumber == 0) 128 this->buildObbTree(4); 123 return; 124 } 125 126 if(strstr(fileName, ".obj")) 127 { 128 PRINTF(4)("fetching OBJ file: %s\n", fileName); 129 if (scaling == 1.0) 130 this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN), modelNumber); 131 else 132 this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, &scaling), modelNumber); 133 134 if( modelNumber == 0) 135 this->buildObbTree(4); 136 } 137 else if(strstr(fileName, ".md2")) 138 { 139 PRINTF(4)("fetching MD2 file: %s\n", fileName); 140 Model* m = new MD2Model(fileName, this->md2TextureFileName); 141 //this->setModel((Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN), 0); 142 this->setModel(m, 0); 143 } 129 144 } 130 145 else … … 145 160 { 146 161 Resource* resource = ResourceManager::getInstance()->locateResourceByPointer(this->models[modelNumber]); 147 if (resource != NULL) 148 ResourceManager::getInstance()->unload(resource, RP_LEVEL); 149 else 150 delete this->models[modelNumber]; 151 } 162 // if (resource != NULL) 163 ResourceManager::getInstance()->unload(resource, RP_LEVEL); 164 } 165 else 166 delete this->models[modelNumber]; 167 152 168 this->models[modelNumber] = model; 169 153 170 154 171 // if (this->model != NULL) … … 272 289 } 273 290 291 292 /** 293 * this functions draws the model automaticaly in multiple LOD 294 */ 274 295 void WorldEntity::drawLODsafe() const 275 296 { 276 if (! this->models.empty())297 if (!unlikely(this->models.empty())) 277 298 { 278 299 glMatrixMode(GL_MODELVIEW); … … 291 312 if (cameraDistance > 30 && this->models.size() >= 3 && this->models[2] != NULL) 292 313 { 293 314 this->models[2]->draw(); 294 315 } 295 316 else if (cameraDistance > 10 && this->models.size() >= 2 && this->models[1] != NULL) -
trunk/src/world_entities/world_entity.h
r6142 r6222 37 37 Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; }; 38 38 39 inline void loadMD2Texture(const char* fileName) { this->md2TextureFileName = fileName; } 40 39 41 bool buildObbTree(unsigned int depth); 40 42 /** @returns a reference to the obb tree of this worldentity */ … … 72 74 /** @returns a Reference to the Iterator */ 73 75 std::list<WorldEntity*>::iterator& getEntityIterator() { return this->objectListIterator; } 76 77 74 78 protected: 75 79 // CharacterAttributes* charAttr; //!< the character attributes of a world_entity … … 77 81 private: 78 82 std::vector<Model*> models; //!< The model that should be loaded for this entity. 83 const char* md2TextureFileName; //!< the file name of the md2 model texture, only if this 79 84 BVTree* obbTree; //!< this is the obb tree reference needed for collision detection 80 85
Note: See TracChangeset
for help on using the changeset viewer.