Changeset 6169 in orxonox.OLD for branches/christmas_branche/src/world_entities
- Timestamp:
- Dec 20, 2005, 12:22:17 AM (19 years ago)
- Location:
- branches/christmas_branche/src/world_entities
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/christmas_branche/src/world_entities/space_ships/space_ship.cc
r6162 r6169 267 267 velocity += ((this->getAbsDirX())*travelSpeed-velocity)*airViscosity; 268 268 velocity = (velocity.getNormalized())*travelSpeed; 269 269 270 270 //orient the spaceship in direction of the mouse 271 271 rotQuat = Quaternion::quatSlerp( this->getAbsDir(),mouseDir,fabsf(time)*3); 272 if (this->getAbsDir().distance(rotQuat) > 0.001) 272 if (this->getAbsDir().distance(rotQuat) > 0.001) 273 273 this->setAbsDir( rotQuat); 274 274 //this->setAbsDirSoft(mouseDir,5); 275 275 276 276 // this is the air friction (necessary for a smooth control) 277 277 if(velocity.len() != 0) velocity -= velocity*0.01; … … 312 312 //this->shiftCoor(this->getAbsDirX()); 313 313 accel += (this->getAbsDirX())*2; 314 314 315 315 /* Heli-Steuerung 316 316 accel += (this->getAbsDirX()*2; -
branches/christmas_branche/src/world_entities/world_entity.cc
r6167 r6169 21 21 22 22 #include "model.h" 23 #include "md2Model.h" 23 24 #include "resource_manager.h" 24 25 #include "load_param.h" … … 56 57 this->objectListNumber = OM_INIT; 57 58 this->objectListIterator = NULL; 59 this->supportsLOD = false; 58 60 59 61 this->toList(OM_NULL); … … 117 119 this->loadModel(lodFile, scaling, i); 118 120 } 121 this->supportsLOD = true; 119 122 return; 120 123 } … … 134 137 { 135 138 PRINTF(4)("fetching MD2 file: %s\n", fileName); 136 this->setModel((Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN), 0); 139 // MD2Model* m = (MD2Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN); 140 MD2Model* m = new MD2Model(fileName, "/home/boenzlip/orxonox/data/maps/santa_claus.pcx"); 141 m->debug(); 142 //this->setModel((Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN), 0); 143 this->setModel((Model*)m, 0); 137 144 } 138 145 } … … 154 161 { 155 162 Resource* resource = ResourceManager::getInstance()->locateResourceByPointer(this->models[modelNumber]); 156 if (resource != NULL) 157 ResourceManager::getInstance()->unload(resource, RP_LEVEL); 158 else 159 delete this->models[modelNumber]; 160 } 163 // if (resource != NULL) 164 ResourceManager::getInstance()->unload(resource, RP_LEVEL); 165 } 166 else 167 delete this->models[modelNumber]; 168 161 169 this->models[modelNumber] = model; 170 162 171 163 172 // if (this->model != NULL) … … 281 290 } 282 291 292 293 /** 294 * this functions draws the model automaticaly in multiple LOD 295 */ 283 296 void WorldEntity::drawLODsafe() const 284 297 { 285 if (!this->models.empty()) 286 { 287 glMatrixMode(GL_MODELVIEW); 288 glPushMatrix(); 289 290 /* translate */ 291 glTranslatef (this->getAbsCoor ().x, 292 this->getAbsCoor ().y, 293 this->getAbsCoor ().z); 294 Vector tmpRot = this->getAbsDir().getSpacialAxis(); 295 glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 298 if (!unlikely(this->models.empty())) 299 { 300 if( likely(this->supportsLOD)) 301 { 302 glMatrixMode(GL_MODELVIEW); 303 glPushMatrix(); 304 305 /* translate */ 306 glTranslatef (this->getAbsCoor ().x, 307 this->getAbsCoor ().y, 308 this->getAbsCoor ().z); 309 Vector tmpRot = this->getAbsDir().getSpacialAxis(); 310 glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 296 311 297 312 298 313 // This Draws the LOD's 299 float cameraDistance = (State::getCamera()->getAbsCoor() - this->getAbsCoor()).len(); 300 if (cameraDistance > 30 && this->models.size() >= 3 && this->models[2] != NULL) 314 float cameraDistance = (State::getCamera()->getAbsCoor() - this->getAbsCoor()).len(); 315 if (cameraDistance > 30 && this->models.size() >= 3 && this->models[2] != NULL) 316 { 317 this->models[2]->draw(); 318 } 319 else if (cameraDistance > 10 && this->models.size() >= 2 && this->models[1] != NULL) 320 { 321 this->models[1]->draw(); 322 } 323 else if (this->models.size() >= 1 && this->models[0] != NULL) 324 { 325 this->models[0]->draw(); 326 } 327 glPopMatrix(); 328 } 329 else // no LOD 301 330 { 302 this->models[2]->draw(); 331 glMatrixMode(GL_MODELVIEW); 332 glPushMatrix(); 333 334 /* translate */ 335 glTranslatef (this->getAbsCoor ().x, 336 this->getAbsCoor ().y, 337 this->getAbsCoor ().z); 338 Vector tmpRot = this->getAbsDir().getSpacialAxis(); 339 glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 340 341 this->models[0]->draw(); 342 343 glPopMatrix(); 303 344 } 304 else if (cameraDistance > 10 && this->models.size() >= 2 && this->models[1] != NULL) 305 { 306 this->models[1]->draw(); 307 } 308 else if (this->models.size() >= 1 && this->models[0] != NULL) 309 { 310 this->models[0]->draw(); 311 } 312 glPopMatrix(); 313 } 345 } 346 314 347 } 315 348 -
branches/christmas_branche/src/world_entities/world_entity.h
r6142 r6169 77 77 private: 78 78 std::vector<Model*> models; //!< The model that should be loaded for this entity. 79 bool supportsLOD; //!< If this model format supports LOD (level of detail) this is true 79 80 BVTree* obbTree; //!< this is the obb tree reference needed for collision detection 80 81
Note: See TracChangeset
for help on using the changeset viewer.