- Timestamp:
- Dec 19, 2005, 4:52:01 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/defs/class_id.h
r6139 r6162 92 92 CL_TEXTURE = 0x00c01000, 93 93 CL_MODEL = 0x00c02000, 94 CL_STATIC_MODEL = 0x00c04000, 95 CL_VERTEX_ARRAY_MODEL = 0x00c08000, 94 96 95 97 … … 202 204 CL_MATERIAL = 0x00000804, 203 205 CL_TEXTURE_SEQUENCE = 0x00c04805, 204 CL_VERTEX_ARRAY_MODEL = 0x00000806, 205 CL_OBJMODEL = 0x00000807, 206 CL_OBJ_MODEL = 0x00000807, 206 207 CL_PROMITIVE_MODEL = 0x00000808, 207 208 CL_MD2Model = 0x00000809, -
trunk/src/lib/graphics/graphics_engine.cc
r6142 r6162 38 38 #include "class_list.h" 39 39 #include "list.h" 40 #include " model.h"40 #include "static_model.h" 41 41 #endif 42 42 using namespace std; … … 285 285 } 286 286 PRINTF(4)("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); 287 288 } 287 } 288 289 289 290 290 /** … … 322 322 } 323 323 // REBUILDING MODELS 324 const std::list<BaseObject*>* modelList = ClassList::getList(CL_ MODEL);324 const std::list<BaseObject*>* modelList = ClassList::getList(CL_STATIC_MODEL); 325 325 if (texList != NULL) 326 326 { 327 327 std::list<BaseObject*>::const_iterator reModel; 328 328 for (reModel = modelList->begin(); reModel != modelList->end(); reModel++) 329 dynamic_cast< Model*>(*reModel)->rebuild();329 dynamic_cast<StaticModel*>(*reModel)->rebuild(); 330 330 } 331 331 #endif /* __WIN32__ */ -
trunk/src/lib/graphics/importer/model.cc
r6073 r6162 28 28 Model::Model() 29 29 { 30 // this->setClassID(CL_PROTO_ID, "ProtoClass");30 this->setClassID(CL_MODEL, "Model"); 31 31 this->pModelInfo.numVertices = 0; 32 32 this->pModelInfo.numTriangles = 0; … … 55 55 const GLfloat* pVertices = NULL; 56 56 const GLfloat* pNorm = NULL; 57 57 58 58 glBegin(GL_TRIANGLES); 59 59 for( int i = 0; i < this->pModelInfo.numTriangles; ++i) … … 64 64 glNormal3f(pNorm[0], pNorm[1], pNorm[2]); 65 65 glVertex3f(pVertices[0], pVertices[1], pVertices[2]); 66 66 67 67 pNorm = &this->pModelInfo.pNormals[this->pModelInfo.pTriangles[i].indexToNormals[1]]; 68 68 pVertices = &this->pModelInfo.pVertices[this->pModelInfo.pTriangles[i].indexToVertices[1]]; 69 69 glNormal3f(pNorm[0], pNorm[1], pNorm[2]); 70 70 glVertex3f(pVertices[0], pVertices[1], pVertices[2]); 71 71 72 72 pNorm = &this->pModelInfo.pNormals[this->pModelInfo.pTriangles[i].indexToNormals[2]]; 73 73 pVertices = &this->pModelInfo.pVertices[this->pModelInfo.pTriangles[i].indexToVertices[2]]; 74 74 glNormal3f(pNorm[0], pNorm[1], pNorm[2]); 75 75 glVertex3f(pVertices[0], pVertices[1], pVertices[2]); 76 76 77 77 } 78 78 glEnd(); -
trunk/src/lib/graphics/importer/objModel.cc
r6022 r6162 34 34 OBJModel::OBJModel(const char* fileName, float scaling) : StaticModel(fileName) 35 35 { 36 this->setClassID(CL_OBJ_MODEL, "OBJModel"); 37 36 38 this->objPath = "./"; 37 39 -
trunk/src/lib/graphics/importer/static_model.cc
r6072 r6162 144 144 StaticModel::StaticModel(const char* modelName) 145 145 { 146 this->setClassID(CL_ MODEL, "Model");146 this->setClassID(CL_STATIC_MODEL, "StaticModel"); 147 147 PRINTF(4)("new 3D-Model is being created\n"); 148 148 this->setName(modelName); … … 550 550 this->currentGroup->currentFace->vertexCount++; 551 551 } 552 552 553 553 this->currentGroup->faceCount += this->currentGroup->currentFace->vertexCount -2; 554 554 this->faceCount += this->currentGroup->currentFace->vertexCount -2; -
trunk/src/world_entities/playable.h
r5915 r6162 34 34 35 35 virtual void process(const Event &event) = 0; 36 36 37 37 38 -
trunk/src/world_entities/space_ships/helicopter.cc
r6005 r6162 99 99 100 100 /** 101 * initializes a Spaceship101 * initializes a Helicopter 102 102 */ 103 103 void Helicopter::init() … … 240 240 void Helicopter::tick (float time) 241 241 { 242 cycle += time;243 242 // spaceship controlled movement 244 243 this->calculateVelocity(time); … … 246 245 Vector move = (velocity)*time; 247 246 248 //orient the spaceship model in the direction of movement.249 250 247 // this is the air friction (necessary for a smooth control) 251 if(velocity.len() != 0) velocity -= velocity*0.01; 252 248 if(velocity.len() != 0) velocity -= velocity*0.1; 249 250 251 //hoover effect 252 cycle += time; 253 253 this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02); 254 255 //readjust 256 // if (this->getAbsDirZ().y > 0.1) this->shiftDir(Quaternion(time*0.3, Vector(1,0,0))); 257 //else if (this->getAbsDirZ().y < -0.1) this->shiftDir(Quaternion(-time*0.3, Vector(1,0,0))); 254 258 255 259 //SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2); … … 269 273 { 270 274 Vector accel(0.0, 0.0, 0.0); 271 //Vector rot(0.0, 0.0, 0.0);272 //float rotVal = 0.0;275 Vector rot(0.0, 0.0, 0.0); 276 float rotVal = 0.0; 273 277 /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */ 274 278 /* calculate the direction in which the craft is heading */ … … 277 281 { 278 282 //this->shiftCoor(this->getAbsDirX()); 279 accel += (this->getAbsDirX())*2; 283 284 accel += Vector(this->getAbsDirX().x,0,this->getAbsDirX().z).getNormalized()*2; 285 if((this->getAbsDirX()).y > -.2) 286 { 287 rot += Vector (0,0,1); 288 rotVal -= time/5; 289 } 290 } 291 else 292 { 293 if(this->getAbsDirX().y < -.02) this->shiftDir(Quaternion(time/5, Vector(0,0,1))); 280 294 } 281 295 … … 283 297 { 284 298 //this->shiftCoor((this->getAbsDirX())*-1); 285 accel -= (this->getAbsDirX())*2; 299 accel -= Vector(this->getAbsDirX().x,0,this->getAbsDirX().z).getNormalized()*2; 300 if((this->getAbsDirX()).y < .2) 301 { 302 rot += Vector (0,0,1); 303 rotVal += time/5; 304 } 305 } 306 else 307 { 308 if(this->getAbsDirZ().y > 0.02) this->shiftDir(Quaternion(-time/5, Vector(0,0,1))); 286 309 } 287 310 288 311 if( this->bLeft /* > -this->getRelCoor().z*2*/) 289 312 { 290 this->shiftDir(Quaternion(time, Vector(0,1,0))); 291 // accel -= rightDirection; 313 //this->shiftDir(Quaternion(time, Vector(0,1,0))); 314 accel -= Vector(this->getAbsDirZ().x,0,this->getAbsDirZ().z).getNormalized()*2; 315 //velocityDir.normalize(); 316 if((this->getAbsDirZ()).y < .2) 317 { 318 rot +=Vector(1,0,0); 319 rotVal -= time/5; 320 } 321 } 322 else 323 { 324 if(this->getAbsDirZ().y > 0.02) this->shiftDir(Quaternion(time/5, Vector(1,0,0))); 325 } 326 327 if( this->bRight /* > this->getRelCoor().z*2*/) 328 { 329 //this->shiftDir(Quaternion(-time, Vector(0,1,0))); 330 331 accel += Vector(this->getAbsDirZ().x,0,this->getAbsDirZ().z).getNormalized()*2; 332 //velocityDir.normalize(); 333 if((this->getAbsDirZ()).y > -.2) 334 { 335 rot += Vector(1,0,0); 336 rotVal += time/5; 337 } 338 } 339 else 340 { 341 if(this->getAbsDirZ().y < -0.02) this->shiftDir(Quaternion(-time/5, Vector(1,0,0))); 342 } 343 344 if( this->bRollL /* > -this->getRelCoor().z*2*/) 345 { 346 this->shiftDir(Quaternion(-time, Vector(1,0,0))); 347 //accel -= rightDirection; 292 348 //velocityDir.normalize(); 293 349 //rot +=Vector(1,0,0); 294 350 //rotVal -= .4; 295 351 } 296 if( this->bR ight/* > this->getRelCoor().z*2*/)297 { 298 this->shiftDir(Quaternion( -time, Vector(0,1,0)));299 300 // 352 if( this->bRollR /* > this->getRelCoor().z*2*/) 353 { 354 this->shiftDir(Quaternion(time, Vector(1,0,0))); 355 356 //accel += rightDirection; 301 357 //velocityDir.normalize(); 302 358 //rot += Vector(1,0,0); 303 359 //rotVal += .4; 304 360 } 305 306 if( this->bRollL /* > -this->getRelCoor().z*2*/)307 {308 this->shiftDir(Quaternion(-time, Vector(1,0,0)));309 // accel -= rightDirection;310 //velocityDir.normalize();311 //rot +=Vector(1,0,0);312 //rotVal -= .4;313 }314 if( this->bRollR /* > this->getRelCoor().z*2*/)315 {316 this->shiftDir(Quaternion(time, Vector(1,0,0)));317 318 // accel += rightDirection;319 //velocityDir.normalize();320 //rot += Vector(1,0,0);321 //rotVal += .4;322 }323 361 if (this->bAscend ) 324 362 { 325 this->shiftDir(Quaternion(time, Vector(0,0,1)));326 327 // accel += upDirection;363 //this->shiftDir(Quaternion(time, Vector(0,0,1))); 364 365 accel += (this->getAbsDirY())*2; 328 366 //velocityDir.normalize(); 329 367 //rot += Vector(0,0,1); … … 332 370 if (this->bDescend ) 333 371 { 334 this->shiftDir(Quaternion(-time, Vector(0,0,1)));335 336 // accel -= upDirection;372 //this->shiftDir(Quaternion(-time, Vector(0,0,1))); 373 374 accel -= (this->getAbsDirY())*2; 337 375 //velocityDir.normalize(); 338 376 //rot += Vector(0,0,1); … … 341 379 342 380 velocity += accel; 343 //rot.normalize();344 //this->setRelDirSoft(Quaternion(rotVal, rot), 5);381 rot.normalize(); 382 this->shiftDir(Quaternion(rotVal, rot)); 345 383 } 346 384 … … 373 411 374 412 if( event.type == SDLK_a) 375 this->b RollL= event.bPressed;413 this->bLeft = event.bPressed; 376 414 else if( event.type == SDLK_d) 377 this->bR ollR= event.bPressed;415 this->bRight = event.bPressed; 378 416 else if( event.type == KeyMapper::PEV_FIRE1) 379 417 this->bFire = event.bPressed; … … 382 420 else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed) 383 421 this->getWeaponManager()->previousWeaponConfig(); 384 422 else if( event.type == SDLK_e) 423 this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0); 424 else if( event.type == SDLK_c) 425 this->bDescend = event.bPressed; //this->shiftCoor(0,-.1,0); 385 426 else if( event.type == SDLK_w) 386 427 this->bUp = event.bPressed; //this->shiftCoor(0,.1,0); … … 391 432 this->xMouse = event.xRel; 392 433 this->yMouse = event.yRel; 434 if(((this->getAbsDirX().y) <= .2 && yMouse > 0) || ((this->getAbsDirX().y) >= -.2 && yMouse < 0)) yMouse = 0; 393 435 this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1))); 394 436 } -
trunk/src/world_entities/space_ships/helicopter.h
r6005 r6162 65 65 float travelSpeed; //!< the current speed of the player (to make soft movement) 66 66 float acceleration; //!< the acceleration of the player. 67 68 float airViscosity; 67 69 68 70 }; -
trunk/src/world_entities/space_ships/space_ship.cc
r6078 r6162 119 119 mouseSensitivity = 0.001; 120 120 airViscosity = 1.0; 121 122 121 cycle = 0.0; 123 122 … … 125 124 travelSpeed = 15.0; 126 125 this->velocity = Vector(0.0,0.0,0.0); 127 this-> velocityDir = Vector(1.0,0.0,0.0);126 this->mouseDir = this->getAbsDir(); 128 127 129 128 // GLGuiButton* button = new GLGuiPushButton(); … … 175 174 // this->getWeaponManager()->setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));: 176 175 176 this->getWeaponManager()->getFixedTarget()->setParent(this); 177 this->getWeaponManager()->getFixedTarget()->setRelCoor(100000,0,0); 178 177 179 } 178 180 … … 265 267 velocity += ((this->getAbsDirX())*travelSpeed-velocity)*airViscosity; 266 268 velocity = (velocity.getNormalized())*travelSpeed; 267 269 270 //orient the spaceship in direction of the mouse 271 rotQuat = Quaternion::quatSlerp( this->getAbsDir(),mouseDir,fabsf(time)*3); 272 if (this->getAbsDir().distance(rotQuat) > 0.001) 273 this->setAbsDir( rotQuat); 274 //this->setAbsDirSoft(mouseDir,5); 275 268 276 // this is the air friction (necessary for a smooth control) 269 277 if(velocity.len() != 0) velocity -= velocity*0.01; … … 293 301 { 294 302 Vector accel(0.0, 0.0, 0.0); 295 //Vector rot(0.0, 0.0, 0.0); 303 /* 304 Vector rot(0.0, 0.0, 0.0); // wird benötigt für Helicopter 305 */ 296 306 //float rotVal = 0.0; 297 307 /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */ … … 302 312 //this->shiftCoor(this->getAbsDirX()); 303 313 accel += (this->getAbsDirX())*2; 314 315 /* Heli-Steuerung 316 accel += (this->getAbsDirX()*2; 317 if( 318 */ 304 319 } 305 320 … … 331 346 if( this->bRollL /* > -this->getRelCoor().z*2*/) 332 347 { 333 this->shiftDir(Quaternion(-time, Vector(1,0,0)));348 mouseDir *= Quaternion(-time, Vector(1,0,0)); 334 349 // accel -= rightDirection; 335 350 //velocityDir.normalize(); … … 339 354 if( this->bRollR /* > this->getRelCoor().z*2*/) 340 355 { 341 this->shiftDir(Quaternion(time, Vector(1,0,0)));356 mouseDir *= Quaternion(time, Vector(1,0,0)); 342 357 343 358 // accel += rightDirection; … … 407 422 this->xMouse = event.xRel; 408 423 this->yMouse = event.yRel; 409 this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1))); 424 mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1))); 425 if( xMouse*xMouse + yMouse*yMouse < 0.9) 426 this->setAbsDir(mouseDir); 410 427 } 411 428 } -
trunk/src/world_entities/space_ships/space_ship.h
r6034 r6162 8 8 9 9 #include "playable.h" 10 10 11 11 12 template<class T> class tList; … … 64 65 65 66 Vector velocity; //!< the velocity of the player. 66 Vector velocityDir; //!< the direction of the velocity of the spaceship 67 Quaternion mouseDir; //!< the direction where the player wants to fly 68 Quaternion rotQuat; 67 69 float travelSpeed; //!< the current speed of the player (to make soft movement) 68 70 float acceleration; //!< the acceleration of the player. -
trunk/src/world_entities/weapons/crosshair.cc
r5978 r6162 67 67 this->setSize(GraphicsEngine::getInstance()->getResolutionX()/10.0); 68 68 69 //this->setBindNode(this);69 this->setBindNode(this); 70 70 this->material = new Material; 71 71 … … 166 166 { 167 167 glPushMatrix(); 168 glTranslatef( GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2, 0);168 glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); 169 169 170 170 glRotatef(this->getAbsDir2D(), 0,0,1); -
trunk/src/world_entities/weapons/guided_missile.cc
r6142 r6162 45 45 this->energyMin = 1; 46 46 this->energyMax = 10; 47 this->lifeSpan = 5.0;48 this->agility = 5.0;49 this->maxVelocity = 100;47 this->lifeSpan = 10.0; 48 this->agility = 4; 49 this->maxVelocity = 75; 50 50 51 51 this->emitter = new ParticleEmitter(Vector(0,1,0), M_2_PI, 100, 5); … … 147 147 void GuidedMissile::tick (float time) 148 148 { 149 //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1); 149 150 150 if (this->target != NULL && this->target->getParent() != PNode::getNullParent()) 151 151 { 152 velocity += ((target->getAbsCoor() - this->getAbsCoor()).getNormalized())*agility; 153 float speed = velocity.len(); 154 if (speed > this->maxVelocity) 155 velocity *= maxVelocity/speed; 152 speed = velocity.len(); 153 diffVector = ((target->getAbsCoor() - this->getAbsCoor()).getNormalized()); 154 155 if(velocity.dot(diffVector) != 0) 156 { 157 correctionVector = (( ( diffVector * (speed * speed/( velocity.dot(diffVector ) ) )) - velocity).getNormalized()) * agility; 158 159 if(velocity.dot(diffVector) > 0) 160 velocity += correctionVector; 161 else if (velocity.dot(diffVector) < 0) 162 velocity -= correctionVector; 163 } 164 else 165 velocity += diffVector * agility; 156 166 157 167 this->setAbsDir(Quaternion(velocity, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0))); 158 168 } 169 170 velocity *= maxVelocity/velocity.len(); 159 171 Vector v = this->velocity * (time); 160 172 this->shiftCoor(v); -
trunk/src/world_entities/weapons/guided_missile.h
r6054 r6162 40 40 float agility; 41 41 float maxVelocity; 42 float speed; 43 Vector diffVector ; 44 Vector correctionVector; 42 45 43 46 WorldEntity* hitEntity; // FIXME TEMPORARY -
trunk/src/world_entities/weapons/laser.cc
r6142 r6162 45 45 this->energyMin = 1; 46 46 this->energyMax = 10; 47 this->lifeSpan = 1.0;47 this->lifeSpan = 5.0; 48 48 49 49 this->emitter = new ParticleEmitter(Vector(0,1,0), M_2_PI, 100, 5); -
trunk/src/world_entities/weapons/test_gun.cc
r6074 r6162 184 184 pj->setParent(PNode::getNullParent()); 185 185 186 pj->setVelocity(this->get Velocity() + this->getAbsDir().apply(Vector(1,0,0))*50+VECTOR_RAND(5));186 pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*250 + VECTOR_RAND(5)); 187 187 188 188 pj->setAbsCoor(this->getEmissionPoint());
Note: See TracChangeset
for help on using the changeset viewer.