Changeset 6222 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Dec 21, 2005, 1:49:06 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 34 edited
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/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"
Note: See TracChangeset
for help on using the changeset viewer.