- Timestamp:
- Dec 20, 2005, 12:22:17 AM (19 years ago)
- Location:
- branches/christmas_branche/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/christmas_branche/src/lib/event/event_handler.cc
r6167 r6169 259 259 { 260 260 this->eventsGrabbed = grabEvents; 261 //if(!grabEvents)262 //SDL_WM_GrabInput(SDL_GRAB_OFF);263 //else264 //SDL_WM_GrabInput(SDL_GRAB_ON);261 if(!grabEvents) 262 SDL_WM_GrabInput(SDL_GRAB_OFF); 263 else 264 SDL_WM_GrabInput(SDL_GRAB_ON); 265 265 } 266 266 -
branches/christmas_branche/src/lib/graphics/importer/md2Model.cc
r6022 r6169 156 156 { 157 157 this->animationState.localTime += time; 158 159 if( likely(this->animationState.localTime > 0.0)) 160 this->animate(); 161 162 static sVec3D verticesList[MD2_MAX_VERTICES]; /* performance: created only once in a lifetime */ 163 this->processLighting(); 164 this->interpolate(verticesList); 158 165 } 159 166 … … 164 171 * FIXME 165 172 */ 166 void MD2Model::draw() 167 { 168 if( likely(this->animationState.localTime > 0.0)) 169 this->animate(); 170 171 glPushMatrix(); 173 void MD2Model::draw() const 174 { 175 // glPushMatrix(); 172 176 173 177 this->renderFrame(); 174 178 175 glPopMatrix();179 // glPopMatrix(); 176 180 } 177 181 … … 180 184 \brief this is an internal function to render this special frame selected by animate() 181 185 */ 182 void MD2Model::renderFrame() 186 void MD2Model::renderFrame() const 183 187 { 184 188 static sVec3D verticesList[MD2_MAX_VERTICES]; /* performance: created only once in a lifetime */ … … 191 195 glCullFace(GL_BACK); 192 196 193 this->processLighting(); 194 this->interpolate(verticesList); 197 195 198 this->data->material->select(); 196 199 … … 406 409 } 407 410 } 411 PRINTF(4)("Finished loading the md2 file\n"); 408 412 409 413 delete [] buffer; -
branches/christmas_branche/src/lib/graphics/importer/md2Model.h
r6022 r6169 143 143 virtual ~MD2Model(); 144 144 145 v oid draw();145 virtual void draw() const; 146 146 147 147 void setAnim(int type); … … 160 160 void processLighting(); 161 161 void interpolate(sVec3D* verticesList); 162 void renderFrame() ;162 void renderFrame() const; 163 163 164 164 -
branches/christmas_branche/src/util/loading/resource_manager.cc
r5994 r6169 389 389 else 390 390 tmpResource->secFileName = NULL; 391 tmpResource->pointer = new MD2Data(fullName, tmpResource->secFileName); 391 tmpResource->pointer = new MD2Data(fullName, tmpResource->secFileName); 392 // tmpResource->pointer = new MD2Model(fullName, tmpResource->secFileName); 393 392 394 } 393 395 break; -
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.