Changeset 10355 in orxonox.OLD for branches/ODE/src/world_entities
- Timestamp:
- Jan 24, 2007, 8:48:26 PM (18 years ago)
- Location:
- branches/ODE
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/ODE/src/world_entities/space_ships/hover.cc
r10114 r10355 33 33 34 34 #include "debug.h" 35 #include "bsp_entity.h" 36 #include "terrain.h" 37 #include "state.h" 38 #include "camera.h" 35 39 36 40 … … 214 218 215 219 registerVar( new SynchronizeableFloat( &rotation, &rotation, "rotation", PERMISSION_OWNER ) ); 220 221 //this->subscribeReaction(CoRe::CREngine::CR_PHYSICS_FULL_WALK, BspEntity::staticClassID()); 222 this->subscribeReaction(CoRe::CREngine::CR_PHYSICS_FULL_WALK, WorldEntity::staticClassID()); 216 223 } 217 224 … … 353 360 354 361 void Hover::draw() const 355 { 362 { 356 363 Vector tmpRot; 357 364 WorldEntity::draw(); … … 401 408 glRotatef(this->rotorCycle, 0,1,0); 402 409 this->getModel(5)->draw(); 410 403 411 glPopMatrix (); 412 413 glPushMatrix(); 414 glTranslatef (this->getAbsCoor ().x, 415 this->getAbsCoor ().y-2.0, 416 this->getAbsCoor ().z); 417 418 /* glBegin(GL_QUADS); 419 glColor4f(0.9,0.9,0.2,0.33); 420 glNormal3f( 0.0f, 1.0f, 0.0f); // Normal Pointing Up 421 glTexCoord2f(0.0f, 1.0f); glVertex3f(-10.0f, - 2.0f, -1.00f); // Point 1 (Top) 422 glTexCoord2f(0.0f, 0.0f); glVertex3f(-10.0f, -2.0f, 10.0f); // Point 2 (Top) 423 glTexCoord2f(1.0f, 0.0f); glVertex3f( 10.0f, -2.0f, 10.0f); // Point 3 (Top) 424 glTexCoord2f(1.0f, 1.0f); glVertex3f( 10.0f, -2.0f, -10.0f); // Point 4 (Top) 425 glEnd(); */ 426 427 //this->getModel(0)->draw(); 428 // glMatrixMode(GL_MODELVIEW); 429 430 // Vector tmpRot = this->getAbsDir().getSpacialAxis(); 431 // glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 432 433 Vector a = Vector(0.0,0.0,-10.0); 434 435 436 // drawDebugCube( &a); 437 // Experiment 438 439 440 441 glPushAttrib( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | GL_POLYGON_BIT | GL_STENCIL_BUFFER_BIT ); 442 glDepthMask(GL_FALSE); 443 //glClear( GL_STENCIL_BUFFER_BIT); 444 glDisable(GL_TEXTURE_2D); 445 glActiveTextureARB(GL_TEXTURE0_ARB); 446 glDisable(GL_TEXTURE_2D); 447 // drawDebugCube( &a); 448 449 450 //glEnable(GL_CULL_FACE); 451 glEnable(GL_STENCIL_TEST); 452 //glEnable(GL_POLYGON_OFFSET_FILL); 453 //glPolygonOffset(0.0f, 100.0f); 454 //drawDebugCube( &a); 455 456 457 458 glDisable( GL_LIGHTING ); // Turn Off Lighting 459 glDepthMask( GL_FALSE ); // Turn Off Writing To The Depth-Buffer 460 //glDepthFunc( GL_LEQUAL ); 461 glEnable( GL_STENCIL_TEST ); // Turn On Stencil Buffer Testing 462 //glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); // Don't Draw Into The Colour Buffer 463 //glStencilFunc( GL_ALWAYS, 1, 0xFFFFFFFFL ); 464 465 466 glColorMask(0, 0, 0, 0); 467 glStencilFunc(GL_ALWAYS, 1, 0xffffffff); 468 469 // First Pass. Increase Stencil Value In The Shadow 470 471 glFrontFace( GL_CCW ); 472 glStencilOp( GL_KEEP, GL_KEEP, GL_INCR ); 473 //doShadowPass( object, lightPosition ); 474 //drawDebugCube(&(State::getCamera()->getAbsCoor() + State::getCamera()->getAbsDirV()*3.0f) ); 475 drawDebugCube( &a); 476 this->getModel(0)->draw(); 477 //WorldEntity::draw(); 478 479 // Second Pass. Decrease Stencil Value In The Shadow 480 glFrontFace( GL_CW ); 481 glStencilOp( GL_KEEP, GL_KEEP, GL_DECR ); 482 //doShadowPass( object, lightPosition ); 483 //drawDebugCube(&(State::getCamera()->getAbsCoor() ) ); 484 drawDebugCube( &a); 485 this->getModel(0)->draw(); 486 //WorldEntity::draw(); 487 488 glFrontFace( GL_CCW ); 489 490 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 491 glDepthMask(GL_TRUE); 492 493 494 glColor4f( 0.0f, 0.9f, 0.0f, 0.4f ); 495 glDisable(GL_POLYGON_OFFSET_FILL); 496 glDisable(GL_DEPTH_TEST); 497 glDisable(GL_CULL_FACE); 498 //glEnable( GL_BLEND ); 499 //glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); 500 //glStencilFunc( GL_NOTEQUAL, 0, 0xffffffff ); 501 //glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP ); 502 ////glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); 503 504 glPushMatrix(); 505 glLoadIdentity(); 506 glBegin( GL_TRIANGLE_STRIP ); 507 glVertex3f( -1.1f, 1.1f, -5.5f ); 508 glVertex3f( -1.1f, -1.1f, -5.5f ); 509 glVertex3f( 1.1f, 1.1f, -5.5f ); 510 glVertex3f( 1.1f, -1.1f, -5.5f ); 511 glEnd(); 512 glPopMatrix (); 513 514 /* 515 glPushMatrix(); 516 glLoadIdentity(); 517 glMatrixMode(GL_PROJECTION); 518 glPushMatrix(); 519 glLoadIdentity(); 520 glOrtho(0, 1, 1, 0, 0, 1); 521 522 523 glColor4f(0.0f, 0.0f, 0.0f, 0.4f); 524 glBegin(GL_QUADS); 525 glVertex2i(0, 0); 526 glVertex2i(0, 1); 527 glVertex2i(1, 1); 528 glVertex2i(1, 0); 529 glEnd(); 530 531 glEnable(GL_DEPTH_TEST); 532 533 glPopMatrix(); 534 glMatrixMode(GL_MODELVIEW); 535 */ 536 537 glPopAttrib(); 538 glPopMatrix (); 404 539 } 405 540 … … 441 576 } 442 577 } 578 579 void drawDebugCube(const Vector* cam) 580 { 581 glBegin(GL_QUADS); 582 // Front Face 583 glNormal3f( 0.0f, 0.0f, 1.0f); // Normal Pointing Towards Viewer 584 glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -10.0f, 1.0f); // Point 1 (Front) 585 glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -10.0f, 1.0f); // Point 2 (Front) 586 glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 10.0f, 1.0f); // Point 3 (Front) 587 glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 10.0f, 1.0f); // Point 4 (Front) 588 // Back Face 589 glNormal3f( 0.0f, 0.0f,-1.0f); // Normal Pointing Away From Viewer 590 glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -10.0f, -1.0f); // Point 1 (Back) 591 glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 10.0f, -1.0f); // Point 2 (Back) 592 glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 10.0f, -1.0f); // Point 3 (Back) 593 glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -10.0f, -1.0f); // Point 4 (Back) 594 // Top Face 595 glNormal3f( 0.0f, 1.0f, 0.0f); // Normal Pointing Up 596 glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 10.0f, -1.0f); // Point 1 (Top) 597 glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 10.0f, 1.0f); // Point 2 (Top) 598 glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 10.0f, 1.0f); // Point 3 (Top) 599 glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 10.0f, -1.0f); // Point 4 (Top) 600 // Bottom Face 601 glNormal3f( 0.0f,-1.0f, 0.0f); // Normal Pointing Down 602 glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -10.0f, -1.0f); // Point 1 (Bottom) 603 glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -10.0f, -1.0f); // Point 2 (Bottom) 604 glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -10.0f, 1.0f); // Point 3 (Bottom) 605 glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -10.0f, 1.0f); // Point 4 (Bottom) 606 // Right face 607 glNormal3f( 1.0f, 0.0f, 0.0f); // Normal Pointing Right 608 glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -10.0f, -1.0f); // Point 1 (Right) 609 glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 10.0f, -1.0f); // Point 2 (Right) 610 glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 10.0f, 1.0f); // Point 3 (Right) 611 glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -10.0f, 1.0f); // Point 4 (Right) 612 // Left Face 613 glNormal3f(-1.0f, 0.0f, 0.0f); // Normal Pointing Left 614 glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -10.0f, -1.0f); // Point 1 (Left) 615 glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -10.0f, 1.0f); // Point 2 (Left) 616 glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 10.0f, 1.0f); // Point 3 (Left) 617 glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 10.0f, -1.0f); // Point 4 (Left) 618 glEnd(); // Done Drawing Quads 619 620 621 glBegin(GL_QUADS); 622 623 return; 624 // Bottom Face. Red, 75% opaque, magnified texture 625 626 //glNormal3f( 0.0f, -1.0f, 0.0f); // Needed for lighting 627 // glColor4f(0.9,0.2,0.2,.75); // Basic polygon color 628 629 //glTexCoord2f(0.800f, 0.800f); 630 glVertex3f(cam->x-5.0f, cam->y-100.0f,cam->z -5.0f); 631 // glTexCoord2f(0.200f, 0.800f); 632 glVertex3f(cam->x+5.0f, cam->y-100.0f,cam->z -5.0f); 633 //glTexCoord2f(0.200f, 0.200f); 634 glVertex3f(cam->x+ 5.0f,cam->y -100.0f,cam->z + 5.0f); 635 //glTexCoord2f(0.800f, 0.200f); 636 glVertex3f(cam->x-5.0f, cam->y-100.0f, cam->z + 5.0f); //OK 637 638 639 // Top face; offset. White, 50% opaque. 640 641 // glNormal3f( 0.0f, 5.0f, 0.0f); glColor4f(0.5,0.5,0.5,.5); 642 643 //glTexCoord2f(0.005f, 5.995f); 644 glVertex3f(cam->x-5.0f, cam->y+ 100.0f, cam->z -5.0f); 645 //glTexCoord2f(0.005f, 0.005f); 646 glVertex3f(cam->x-5.0f, cam->y+ 100.0f, cam->z +5.0f); 647 //glTexCoord2f(5.995f, 0.005f); 648 glVertex3f(cam->x+ 5.0f, cam->y+100.0f, cam->z +5.0f); 649 //glTexCoord2f(5.995f, 5.995f); 650 glVertex3f(cam->x+ 5.0f, cam->y+ 100.0f, cam->z -5.0f); //OKQUAD_STRI 651 652 653 // Far face. Green, 50% opaque, non-uniform texture cooridinates. 654 655 //glNormal3f( 0.0f, 0.0f,-5.0f); glColor4f(0.2,0.9,0.2,.5); 656 657 // glTexCoord2f(0.995f, 0.005f); 658 glVertex3f(cam->x-5.0f, cam->y-100.0f, cam->z -5.0f); 659 // glTexCoord2f(2.995f, 2.995f); 660 glVertex3f(cam->x-5.0f, cam->y+ 100.0f, cam->z -5.0f); 661 // glTexCoord2f(0.005f, 0.995f); 662 glVertex3f(cam->x+ 5.0f,cam->y+ 100.0f, cam->z -5.0f); 663 //glTexCoord2f(0.005f, 0.005f); 664 glVertex3f( cam->x+5.0f,cam->y -100.0f, cam->z -5.0f); 665 666 667 // Right face. Blue; 25% opaque 668 669 // glNormal3f( 5.0f, 0.0f, 0.0f); glColor4f(0.2,0.2,0.9,.25); 670 671 // glTexCoord2f(0.995f, 0.005f); 672 glVertex3f(cam->x+ 5.0f, cam->y -100.0f, cam->z -5.0f); 673 // glTexCoord2f(0.995f, 0.995f); 674 glVertex3f(cam->x+ 5.0f, cam->y+ 100.0f, cam->z -5.0f); 675 // glTexCoord2f(0.005f, 0.995f); 676 glVertex3f(cam->x+ 5.0f, cam->y+ 100.0f, cam->z + 5.0f); 677 // glTexCoord2f(0.005f, 0.005f); 678 glVertex3f(cam->x+ 5.0f, cam->y-100.0f, cam->z +5.0f); 679 680 681 // Front face; offset. Multi-colored, 50% opaque. 682 683 // glNormal3f( 0.0f, 0.0f, 5.0f); 684 685 // glColor4f( 0.9f, 0.2f, 0.2f, 0.5f); 686 // glTexCoord2f( 0.005f, 0.005f); 687 glVertex3f(cam->x-5.0f, cam->y-100.0f, cam->z +5.0f); 688 // glColor4f( 0.2f, 0.9f, 0.2f, 0.5f); 689 // glTexCoord2f( 0.995f, 0.005f); 690 glVertex3f(cam->x+ 5.0f, cam->y-100.0f, cam->z +5.0f); 691 // glColor4f( 0.2f, 0.2f, 0.9f, 0.5f); 692 // glTexCoord2f( 0.995f, 0.995f); 693 glVertex3f( cam->x+5.0f, cam->y+100.0f, cam->z +5.0f); 694 // glColor4f( 0.5f, 0.5f, 0.5f, 0.5f); 695 // glTexCoord2f( 0.005f, 0.995f); g 696 glVertex3f(cam->x-5.0f, cam->y+ 100.0f, cam->z +5.0f); 697 698 699 // Left Face; offset. Yellow, varying levels of opaque. 700 701 // glNormal3f(-5.0f, 0.0f, 0.0f); 702 703 // glColor4f(0.9,0.9,0.2,0.0); 704 // glTexCoord2f(0.005f, 0.005f); 705 glVertex3f(cam->x-5.0f, cam->y-100.0f, cam->z -5.0f); 706 //glColor4f(0.9,0.9,0.2,0.66); 707 // glTexCoord2f(0.995f, 0.005f); 708 glVertex3f(cam->x-5.0f,cam->y -100.0f, cam->z +5.0f); 709 // glColor4f(0.9,0.9,0.2,5.0); 710 // glTexCoord2f(0.995f, 0.995f); 711 glVertex3f(cam->x-5.0f, cam->y+ 100.0f, cam->z +5.0f); 712 // glColor4f(0.9,0.9,0.2,0.33); 713 // glTexCoord2f(0.005f, 0.995f); 714 glVertex3f(cam->x-5.0f, cam->y+ 100.0f, cam->z -5.0f); 715 716 glEnd(); 717 } -
branches/ODE/src/world_entities/world_entity.cc
r10147 r10355 1 1 2 2 3 3 /* … … 45 45 46 46 #include "projectiles/projectile.h" 47 48 49 #include "class_id.h" 50 #include "aabb.h" 51 #include "cr_defs.h" 52 #include "cd_engine.h" 53 #include "collision_tube.h" 54 55 #include "static_model.h" 56 57 58 59 #ifdef WITH_ODE 60 #include <ode/ode.h> 61 #endif 47 62 48 63 SHELL_COMMAND(model, WorldEntity, loadModel) … … 283 298 bool WorldEntity::buildObbTree(int depth) 284 299 { 300 301 #ifdef WITH_ODE 302 this->world = dWorldCreate(); // the World will be Static for mor efficiency 303 this->space = dSimpleSpaceCreate(0); // same for the space 304 contactgroup = dJointGroupCreate (0); 305 dWorldSetGravity (world,0,0,-0.5); 306 dWorldSetCFM (world,1e-5); 307 308 309 if(this->getModel(0)!=0) 310 { 311 if(this->getModel(0)->isA( StaticModel::staticClassID() ) ) 312 { 313 314 315 316 StaticModelData::Pointer ModelData = ((StaticModel*)this->getModel())->dataPointer(); 317 //ModelData->buildTriangleList(); 318 319 PRINTF(0)(" Dieses Model hat %i Vertices \n", ModelData->getVertices().size()); 320 PRINTF(0)(" Dieses Model hat %i Dreiecke \n",((ModelData->getTriangles()).size() )); 321 this->Ind = new unsigned int [(ModelData->getTriangles()).size()*3]; 322 for(int i = 0 ; i < (ModelData->getTriangles()).size(); i++) 323 { 324 Ind[3*i] = (ModelData->getTrianglesExt())[i].indexToVertices[0] / 3 ; 325 Ind[3*i +1] = (ModelData->getTrianglesExt())[i].indexToVertices[1] / 3; 326 Ind[3*i +2] = (ModelData->getTrianglesExt())[i].indexToVertices[2] / 3; 327 328 } 329 330 //((StaticModel*)(this->getModel()))->acquireData(ModelData); 331 this->ODE_Geometry = dGeomTriMeshDataCreate(); 332 dGeomTriMeshDataBuildSingle(this->ODE_Geometry,&((ModelData->getVertices())[0]), 3*sizeof(float),(ModelData->getVertices().size() /3 ) , &Ind[0] ,((ModelData->getTriangles()).size() *3 ), 3*sizeof(unsigned int) ); 333 // Create ODE-Data here! 334 335 336 //!fixme 337 for (int i=0; i<30; i++) { 338 contact[i].surface.mode = dContactBounce | dContactSoftCFM; 339 contact[i].surface.mu = dInfinity; 340 contact[i].surface.mu2 = 0; 341 contact[i].surface.bounce = 0.1; 342 contact[i].surface.bounce_vel = 0.1; 343 contact[i].surface.soft_cfm = 0.01; 344 } 345 346 347 this->ODE_Geom_ID = dCreateTriMesh(space,this->ODE_Geometry,0 , 0, 0); 348 349 350 //CDEngine::getInstance()->setTerrain(this); 351 //this->loaded = true; 352 //this->toList(OM_ENVIRON); 353 354 } else 355 { 356 if(this->getModelAABB() == NULL ) 357 { 358 this->ODE_Geom_ID = dCreateBox (space, 20.0f, 40.0f ,20.0f); 359 //dGeomID BBOX = dCreateBox (space,box->halfLength[0]*2.0f, box->halfLength[1]*2.0f ,2.0f* box->halfLength[2]); 360 dGeomSetPosition (this->ODE_Geom_ID, this->getAbsCoor().x ,this->getAbsCoor().y, this->getAbsCoor().z); 361 //dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x + box->center.x ,worldEntity->getAbsCoor().y+box->center.y, worldEntity->getAbsCoor().z+box->center.z); 362 } 363 } 364 365 366 if(this->getModelAABB() != NULL ) 367 { 368 AABB* box = this->getModelAABB(); 369 //this->ODE_Geom_ID = dCreateBox (space, 2.0f, 4.0f ,2.0f); 370 this->ODE_Geom_ID = dCreateBox (space,box->halfLength[0]*2.0f, box->halfLength[1]*2.0f ,2.0f* box->halfLength[2]); 371 dGeomSetPosition (this->ODE_Geom_ID, this->getAbsCoor().x ,this->getAbsCoor().y, this->getAbsCoor().z); 372 //dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x + box->center.x ,worldEntity->getAbsCoor().y+box->center.y, worldEntity->getAbsCoor().z+box->center.z); 373 } 374 } 375 376 else 377 { 378 if(this->getModelAABB() != NULL ) 379 { 380 AABB* box = this->getModelAABB(); 381 //this->ODE_Geom_ID = dCreateBox (space, 2.0f, 4.0f ,2.0f); 382 this->ODE_Geom_ID = dCreateBox (space,box->halfLength[0]*2.0f, box->halfLength[1]*2.0f ,2.0f* box->halfLength[2]); 383 dGeomSetPosition (this->ODE_Geom_ID, this->getAbsCoor().x ,this->getAbsCoor().y, this->getAbsCoor().z); 384 //dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x + box->center.x ,worldEntity->getAbsCoor().y+box->center.y, worldEntity->getAbsCoor().z+box->center.z); 385 } 386 387 if(this->getModelAABB() == NULL ) 388 { 389 this->ODE_Geom_ID = dCreateBox (space, 20.0f, 40.0f ,20.0f); 390 //dGeomID BBOX = dCreateBox (space,box->halfLength[0]*2.0f, box->halfLength[1]*2.0f ,2.0f* box->halfLength[2]); 391 dGeomSetPosition (this->ODE_Geom_ID, this->getAbsCoor().x ,this->getAbsCoor().y, this->getAbsCoor().z); 392 //dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x + box->center.x ,worldEntity->getAbsCoor().y+box->center.y, worldEntity->getAbsCoor().z+box->center.z); 393 } 394 } 395 396 397 398 #endif 399 400 285 401 if( this->obbTree != NULL) 286 402 { … … 317 433 return false; 318 434 } 435 319 436 return true; 320 437 } 438 439 440 441 void WorldEntity::checkCollision(WorldEntity* worldEntity) { 442 443 #ifndef WITH_ODE 444 return; 445 #endif 446 #ifdef WITH_ODE 447 //if(!this->loaded) return; 448 //dWorldSetQuickStepNumIterations (this->world, 1); 449 //dWorldQuickStep (this->world, 0.1); 450 451 AABB* box = worldEntity->getModelAABB(); 452 dReal aabbox [6]; 453 454 if( (this->getModel(0)!= 0) && (this->getModel(0)->isA( StaticModel::staticClassID())) ) { 455 456 dGeomSetPosition (this->ODE_Geom_ID, this->getAbsCoor().x ,this->getAbsCoor().y, this->getAbsCoor().z); 457 if(box != NULL ) 458 { 459 //PRINTF(0)("Do have abb-box! :_)\n"); 460 dGeomID RayX = dCreateRay(space,box->halfLength[0] *2.0f); 461 dGeomRaySet (RayX, worldEntity->getAbsCoor().x - box->halfLength[0] ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z, 462 1.0f, 0.0f, 0.0f); 463 dGeomID RayY = dCreateRay(space,box->halfLength[1] * 10000.0f); 464 dGeomRaySet (RayY, worldEntity->getAbsCoor().x ,worldEntity->getAbsCoor().y - 5000.0f*box->halfLength[1], worldEntity->getAbsCoor().z, 465 0.0f, 1.0f, 0.0f); 466 dGeomID RayZ = dCreateRay(space,box->halfLength[2] *2.0f); 467 dGeomRaySet (RayZ, worldEntity->getAbsCoor().x ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z - box->halfLength[2], 468 0.0f, 0.0f, 1.0f); 469 470 dGeomID RayXPos = dCreateRay(space,box->halfLength[0]); 471 dGeomRaySet (RayX, worldEntity->getAbsCoor().x ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z, 472 1.0f, 0.0f, 0.0f); 473 dGeomID RayYPos = dCreateRay(space,box->halfLength[1] * 1100.0 ); 474 dGeomRaySet (RayY, worldEntity->getAbsCoor().x ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z, 475 0.0f, 1.0f, 0.0f); 476 dGeomID RayZPos = dCreateRay(space,box->halfLength[2] ); 477 dGeomRaySet (RayZ, worldEntity->getAbsCoor().x ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z, 478 0.0f, 0.0f, 1.0f); 479 480 dGeomID RayXNeg = dCreateRay(space,box->halfLength[0] ); 481 dGeomRaySet (RayX, worldEntity->getAbsCoor().x ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z, 482 -1.0f, 0.0f, 0.0f); 483 dGeomID RayYNeg = dCreateRay(space, box->halfLength[1] * 1100.0f ); 484 dGeomRaySet (RayY, worldEntity->getAbsCoor().x ,worldEntity->getAbsCoor().y , worldEntity->getAbsCoor().z, 485 0.0f, -1.0f, 0.0f); 486 dGeomID RayZNeg = dCreateRay(space,box->halfLength[2] ); 487 dGeomRaySet (RayZ, worldEntity->getAbsCoor().x ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z , 488 0.0f, 0.0f, -1.0f); 489 490 //dGeomID BBOX = dCreateBox (space, 2.0f, 4.0f ,2.0f); 491 dGeomID BBOX = dCreateBox (space,box->halfLength[0]*0.003f, box->halfLength[1]*500.0f ,0.0030f* box->halfLength[2]); 492 dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z); 493 //dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x + box->center.x ,worldEntity->getAbsCoor().y+box->center.y, worldEntity->getAbsCoor().z+box->center.z); 494 495 496 497 498 499 int g; 500 bool collision = false; 501 502 503 // dGeomGetAABB (this->bspFile->ODE_Geom_IDs[i],aabbox ); 504 // BBOX2 = dCreateBox (space, aabbox[1]-aabbox[0], aabbox[3]-aabbox[2], aabbox[5]-aabbox[4]); 505 // dGeomSetPosition (BBOX2,(aabbox[1]+ aabbox[0])/2, (aabbox[3]+ aabbox[2])/2, (aabbox[4]+ aabbox[5])/2); 506 // dGeomDestroy(BBOX2); 507 g = 0; 508 if( dCollide(this->ODE_Geom_ID,BBOX, 2, &contact[0].geom, sizeof(dContact)) ) { 509 510 PRINTF(0)("%s :Collision wit %s at %f , %f , %f : height: %f. \n", this->getCName(),worldEntity->getCName(), contact[0].geom.pos[0],contact[0].geom.pos[1]+2.1,contact[0].geom.pos[2], (worldEntity->getAbsCoorY() - contact[0].geom.pos[1]) ); 511 for(int i = 0; i <1 ; i++) 512 { 513 CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Y_NEG , worldEntity, this, Vector(0.0f, 1.0f, 0.0f), Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 514 } 515 516 if(dCollide(this->ODE_Geom_ID,RayX, 1, &contact[0].geom, sizeof(dContact))) { 517 if(dCollide(this->ODE_Geom_ID,RayXPos, 1, &contact[0].geom, sizeof(dContact))) { 518 // worldEntity->registerCollision(COLLISION_TYPE_AXIS_X , this, worldEntity, Vector(1.0f, 0.0f, 0.0f), 519 // Vector((float)contact[0].geom.pos[0],(float)contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 520 521 }//if 522 if(dCollide(this->ODE_Geom_ID,RayXNeg, 1, &contact[0].geom, sizeof(dContact))) { 523 // worldEntity->registerCollision(COLLISION_TYPE_AXIS_X_NEG , this, worldEntity, //Vector(1.0f, 0.0f, 0.0f), 524 // Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 525 526 }//if 527 }//if 528 529 if(this->isA("Terrain")) //ClassList::StringToID) 530 { 531 532 533 534 if(this->isA("Terrain")) 535 { 536 PRINTF(0)("Ich bin ein %s \n",this->getClassCName() ); 537 } 538 539 if( dCollide(this->ODE_Geom_ID,RayY, 1, &contact[0].geom, sizeof(dContact))) { 540 541 /* 542 if(false && dCollide(this->ODE_Geom_ID,RayYNeg, 1, &contact[0].geom, sizeof(dContact))) { 543 // worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y_NEG , this, worldEntity, Vector(0.0f, ,this1.0f, 0.0f), 544 // Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 545 CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Y_NEG , worldEntity,this, Vector(0.0f, 1.0f, 0.0f), Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 546 PRINTF(0)("Kooomische ................Collision"); 547 548 }//if 549 if( false && dCollide(this->ODE_Geom_ID,RayYPos, 1, &contact[0].geom, sizeof(dContact))) { 550 551 CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Y_NEG , worldEntity,this, Vector(0.0f, -1.0f, 0.0f), Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 552 PRINTF(0)("Kooomische ................Collision"); 553 // worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y_NEG , this, worldEntity, Vector(0.0f, 1.0f, 0.0f), 554 //Vector(contact[0].geom.pos[0],contact[0].geom.pos[1] ,contact[0].geom.pos[2]), false); 555 556 }//if 557 else { */ 558 559 //CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Y_NEG , worldEntity,this, Vector(0.0f, 1.0f, 0.0f), Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 560 PRINTF(0)("Kooomische ................Collision"); 561 562 //worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y_NEG , this, worldEntity, Vector(0.0f, 1.0f, 0.0f), 563 // Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 564 565 //} 566 567 }//if 568 569 if(dCollide(this->ODE_Geom_ID,RayZ, 1, &contact[0].geom, sizeof(dContact))) { 570 if(dCollide(this->ODE_Geom_ID,RayZPos, 1, &contact[0].geom, sizeof(dContact))) { 571 CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Z , worldEntity,this, Vector(0.0f, 1.0f, 0.0f), Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 572 PRINTF(0)("Kooomische ................Collision"); 573 // worldEntity->registerCollision(COLLISION_TYPE_AXIS_Z , this, worldEntity, Vector(0.0f, 0.0f, 1.0f), 574 // Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 575 576 }//if 577 if(dCollide(this->ODE_Geom_ID,RayZNeg, 1, &contact[0].geom, sizeof(dContact))) { 578 CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Z_NEG , worldEntity,this, Vector(0.0f, 1.0f, 0.0f), Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 579 PRINTF(0)("Kooomische ................Collision"); 580 // worldEntity->registerCollision(COLLISION_TYPE_AXIS_Z_NEG , this, worldEntity, Vector(0.0f, 0.0f, 1.0f), 581 // Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 582 583 }//if 584 585 586 if(dCollide(this->ODE_Geom_ID,RayXPos, 1, &contact[0].geom, sizeof(dContact))) { 587 CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_AXIS_X , worldEntity,this, Vector(0.0f, 1.0f, 0.0f), Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 588 PRINTF(0)("Kooomische ................Collision"); 589 // worldEntity->registerCollision(COLLISION_TYPE_AXIS_Z , this, worldEntity, Vector(0.0f, 0.0f, 1.0f), 590 // Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 591 592 }//if 593 if(dCollide(this->ODE_Geom_ID,RayXNeg, 1, &contact[0].geom, sizeof(dContact))) { 594 CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_AXIS_X_NEG , worldEntity,this, Vector(0.0f, 1.0f, 0.0f), Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 595 PRINTF(0)("Kooomische ................Collision"); 596 // worldEntity->registerCollision(COLLISION_TYPE_AXIS_Z_NEG , this, worldEntity, Vector(0.0f, 0.0f, 1.0f), 597 // Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 598 599 }//if 600 601 602 }//if 603 }//if 604 605 } //if 606 607 608 dGeomDestroy(RayX); 609 dGeomDestroy(RayY); 610 dGeomDestroy(RayZ); 611 dGeomDestroy(RayXPos); 612 dGeomDestroy(RayYPos); 613 dGeomDestroy(RayZPos); 614 dGeomDestroy(RayXNeg); 615 dGeomDestroy(RayYNeg); 616 dGeomDestroy(RayZNeg); 617 618 dGeomDestroy(BBOX); 619 } // if(bbox != 0) 620 621 if(box == NULL) 622 { 623 dGeomID BBOX = dCreateBox (space, 20.0f, 40.0f ,20.0f); 624 dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z); 625 //dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x + box->center.x ,worldEntity->getAbsCoor().y+box->center.y, worldEntity->getAbsCoor().z+box->center.z); 626 if(dCollide(this->ODE_Geom_ID,BBOX, 1, &contact[0].geom, sizeof(dContact))) 627 { 628 629 PRINTF(0)("Collision wit %s at %f , %f , %f . \n", worldEntity->getCName(), contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2] ); 630 631 CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Y_NEG , this, worldEntity, Vector(1.0f, 0.0f, 0.0f), Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 632 } 633 dGeomDestroy(BBOX); 634 } 635 } 636 else { 637 dGeomSetPosition (this->ODE_Geom_ID, this->getAbsCoor().x ,this->getAbsCoor().y, this->getAbsCoor().z); 638 //if(box != NULL ) 639 dGeomID BBOX = dCreateBox (space, 10.0f, 40.0f ,10.0f); 640 dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z); 641 //dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x + box->center.x ,worldEntity->getAbsCoor().y+box->center.y, worldEntity->getAbsCoor().z+box->center.z); 642 if(dCollide(this->ODE_Geom_ID,BBOX, 1, &contact[0].geom, sizeof(dContact))) 643 { 644 645 PRINTF(5)("Collision wit %s at %f , %f , %f . \n", worldEntity->getCName(), contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2] ); 646 647 CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Y_NEG , worldEntity, this, Vector(1.0f, 0.0f, 0.0f), Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 648 } 649 dGeomDestroy(BBOX); 650 651 } 652 653 #endif 654 655 } 656 321 657 322 658 -
branches/ODE/src/world_entities/world_entity.h
r10147 r10355 22 22 #include <vector> 23 23 24 #ifdef WITH_ODE 25 #include <ode/ode.h> 26 #endif 24 27 25 28 // FORWARD DECLARATION … … 76 79 /* --- Collision Detection Block --- */ 77 80 bool buildObbTree(int depth); 81 void checkCollision(WorldEntity* worldEntity); 82 78 83 virtual void collidesWith (WorldEntity* entity, const Vector& location); 79 84 virtual void collidesWithGround(const Vector& location); … … 230 235 int healthMax_handle; 231 236 237 unsigned int* Ind; 238 239 240 #ifdef WITH_ODE 241 dTriMeshDataID ODE_Geometry; //!< ODE Geometry Data of the static model 242 dGeomID ODE_Geom_ID; //!< ID of ODE Geometry Data 243 dWorldID world; 244 dSpaceID space; 245 dJointGroupID contactgroup; 246 dContact contact[300]; 247 #endif 232 248 233 249
Note: See TracChangeset
for help on using the changeset viewer.