Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8864 in orxonox.OLD for branches/single_player_map/src


Ignore:
Timestamp:
Jun 28, 2006, 3:51:36 PM (18 years ago)
Author:
patrick
Message:

new collision registration functions

Location:
branches/single_player_map/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/single_player_map/src/lib/collision_reaction/collision_event.h

    r8862 r8864  
    99#include "vector.h"
    1010
     11#include "cr_defs.h"
     12
     13
    1114class WorldEntity;
    1215class BoundingVolume;
    1316class Plane;
     17
    1418
    1519
     
    2226
    2327  /** collides two WorldEntities @param entityA world entity A, @param entityB world entity B, @param bvA volume A @param bvB volumeB */
    24   inline void collide(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB)
    25   { this->entityA = entityA; this->entityB = entityB; this->bvA = bvA; this->bvB = bvB; }
     28  inline void collide(int type, WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB)
     29  { this->collisionType = type; this->entityA = entityA; this->entityB = entityB; this->bvA = bvA; this->bvB = bvB; }
    2630  /** collides two WorldEntities @param entity world entity , @param ground ground plane, @param position position on the ground */
    27   inline void collide(WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall)
    28   { this->entityA = entity; this->entityB = groundEntity, this->groundNormal = normal; this->position = position; this->bInWall = bInWall; }
     31  inline void collide(int type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall)
     32  { this->collisionType = type; this->entityA = entity; this->entityB = groundEntity, this->groundNormal = normal; this->position = position; this->bInWall = bInWall; }
    2933
    3034
     
    4448  inline Vector getCollisionPosition() { return this->position; }
    4549
     50  /** @return the type of the collision */
     51  inline int getType() { return this->collisionType; }
     52
    4653  /** @return true if the entity is in the wall */
    4754  inline bool isInWall() { return this->bInWall; }
     
    5966
    6067  bool              bInWall;                       //!< true if is in wall
     68  int               collisionType;                 //!< collision type
    6169};
    6270
  • branches/single_player_map/src/lib/collision_reaction/cr_defs.h

    r8190 r8864  
    2828
    2929
     30//!< the collision axis x collision event
     31#define COLLISION_TYPE_AXIS_X   1
     32//!< the collision axis y collision event
     33#define COLLISION_TYPE_AXIS_Y   2
     34//!< the collision axis z collision event
     35#define COLLISION_TYPE_AXIS_Z   4
     36//!< the collision is a obb collision
     37#define COLLISION_TYPE_OBB      8
     38
    3039
    3140#endif /* _NETWORK_MANAGER */
  • branches/single_player_map/src/lib/collision_reaction/cr_physics_ground_walk.cc

    r8863 r8864  
    6666  //   collision->getEntityB()->getAbsCoor().debug();
    6767
    68   Vector height;
     68  float height;
    6969  AABB* box = collision->getEntityB()->getModelAABB();
    7070  WorldEntity* entity = collision->getEntityB();
     
    7373  float CR_THRESHOLD = 0.2f;
    7474
    75 //   if( box != NULL)
    76 //   {
    77 //
    78 //     Vector collPos =  collision->getEntityB()->getAbsCoor()  + box->center - ce->getCollisionPosition();
    79 //     height = collPos.y - box->halfLength[1];
    80 //
    81 //     PRINTF(0)("height: %f          , model height: %f\n", height, box->halfLength[1]);
    82 //     PRINTF(0)(" ground normal: %f, %f, %f\n", normal.x, normal.y, normal.z);
    83 //
    84 //     // object is beneath the plane (ground)
    85 //     if( height < 0.0f )
    86 //     {
    87 //       entity->shiftCoor(Vector(0, -height, 0));
    88 //     }
    89 //     // object is already in the wall
    90 //     else if( ce->isInWall())
    91 //     {
    92 //
    93 //     }
    94 //
    95 //
    96 //
    97 //   }
     75  if( box != NULL)
     76  {
     77
     78    Vector collPos =  collision->getEntityB()->getAbsCoor()  + box->center - ce->getCollisionPosition();
     79    height = collPos.y - box->halfLength[1];
     80
     81    PRINTF(0)("height: %f          , model height: %f\n", height, box->halfLength[1]);
     82    PRINTF(0)(" ground normal: %f, %f, %f\n", normal.x, normal.y, normal.z);
     83
     84    // object is beneath the plane (ground)
     85    if( height < 0.0f )
     86    {
     87      entity->shiftCoor(Vector(0, -height, 0));
     88    }
     89    // object is already in the wall
     90    else if( ce->isInWall())
     91    {
     92      entity->setAbsCoor(entity->getLastAbsCoor());
     93    }
     94
     95
     96
     97  }
    9898
    9999
     
    101101
    102102
    103 // #if 0
     103#if 0
    104104  if( box != NULL)
    105105    height = ( ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() )*(-1.0f) ;
     
    158158
    159159  }// if(box!= NULL)
    160 // #endif
     160#endif
    161161  /*
    162162  PRINTF(0)("Collision with Ground: \n");
  • branches/single_player_map/src/lib/graphics/importer/bsp_manager.cc

    r8796 r8864  
    11/*
    22   orxonox - the future of 3D-vertical-scrollers
    3  
     3
    44   Copyright (C) 2006 orx
    5  
     5
    66   This program is free software; you can redistribute it and/or modify
    77   it under the terms of the GNU General Public License as published by
    88   the Free Software Foundation; either version 2, or (at your option)
    99   any later version.
    10  
     10
    1111   ### File Specific:
    1212   main-programmer: bottac@ee.ethz.ch
    13  
     13
    1414   Inspired by:
    1515   Rendering Q3 Maps by Morgan McGuire                  http://graphics.cs.brown.edu/games/quake/quake3.html
    1616   Unofficial Quake 3 Map Specs by Kekoa Proudfoot      http://graphics.stanford.edu/~kekoa/q3/
    17  
     17
    1818   Collision detection adapted from:
    1919   Quake 3 Collision Detection by Nathan Ostgard        http://www.devmaster.net/articles/quake3collision/
     
    4545
    4646#include "aabb.h"
    47 
     47#include "cr_defs.h"
    4848
    4949
     
    6969BspManager::BspManager(const TiXmlElement* root)
    7070{
    71  
    72  
     71
     72
    7373  if( root != NULL)
    7474    this->loadParams(root);
    75  
     75
    7676  CDEngine::getInstance()->setBSPModel(this);
    7777} */
     
    9999  this->root  = this->bspFile->get_root();
    100100  this->alreadyVisible = new bool [this->bspFile->numFaces];
    101  
     101
    102102  CDEngine::getInstance()->setBSPModel(this);
    103103}
     
    962962  upDir.z = 0.0;
    963963  Vector dest;
    964    
     964
    965965
    966966  Vector position = worldEntity->getAbsCoor();       //+ upDir*10.0f ;
     
    978978  Vector out2;
    979979
    980  
     980
    981981
    982982  float height = 40;
    983  
    984  
     983
     984
    985985  if( box != NULL)
    986986  {
    987987    position = worldEntity->getAbsCoor() +  box->center; // + box->axis[1] * box->halfLength[1];
    988988    dest     = worldEntity->getAbsCoor() +  box->center - box->axis[1] * box->halfLength[1] * 40.0;
    989    
     989
    990990    position1 = worldEntity->getAbsCoor() +  box->center + box->axis[0] * box->halfLength[0] * 2.0f;
    991991    dest1     = worldEntity->getAbsCoor() +  box->center - box->axis[0] * box->halfLength[0] *2.0f;
    992    
    993        
     992
     993
    994994    position2 = worldEntity->getAbsCoor() +  box->center + box->axis[2] * box->halfLength[2] * 2.0f;
    995995    dest2     = worldEntity->getAbsCoor() +  box->center - box->axis[2] * box->halfLength[2] * 2.0f;
    996    
     996
    997997  }
    998998  else
    999999  {
    1000    
    1001   }
    1002 
    1003  
    1004  
     1000
     1001  }
     1002
     1003
     1004
    10051005  //
    10061006  this->inputStart =  position;
     
    10251025        this->collPlane->z = 0.0f;
    10261026        collision = true;
    1027       } else 
     1027      } else
    10281028        collision = false;
    1029        
    1030        
     1029
     1030
    10311031        out = dest;
    1032      
     1032
    10331033    } else {
    10341034      collision = true;
     
    10461046  plane* testPlane = this->collPlane;
    10471047
    1048  
     1048
    10491049  // 2nd Collision Detection
    10501050  this->outputStartsOut = true;
     
    10561056  out.x = this->outputFraction;
    10571057  //out.z = this->outputFraction;
    1058  
    1059  
     1058
     1059
    10601060    // 3rd Collision Detection
    10611061  this->outputStartsOut = true;
     
    10671067  //out.x = this->outputFraction;
    10681068  out.z = this->outputFraction;
    1069  
     1069
    10701070
    10711071  /*
     
    10771077
    10781078  // Return the normal here: Normal's stored in this->collPlane;
    1079   if( collision) 
     1079  if( collision)
    10801080  {
    10811081    PRINTF(5)("We got a collision!! Are you sure: outputFraction = %f\n", this->outputFraction);
    1082     worldEntity->registerCollision(this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out);
    1083   } 
    1084   else  worldEntity->registerCollision(this->parent, worldEntity, Vector(0.0, 2.0, 0.0), dest);
     1082    worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y, this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out);
     1083  }
     1084  else  worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y, this->parent, worldEntity, Vector(0.0, 2.0, 0.0), dest);
    10851085
    10861086}
  • branches/single_player_map/src/world_entities/world_entity.cc

    r8853 r8864  
    418418  CollisionEvent* c = CREngine::getInstance()->popCollisionEventObject();
    419419  assert(c != NULL); // if this should fail: we got not enough precached CollisionEvents: alter value in cr_defs.h
    420   c->collide(entityA, entityB, bvA, bvB);
     420  c->collide(COLLISION_TYPE_OBB, entityA, entityB, bvA, bvB);
    421421
    422422  for( int i = 0; i < CREngine::CR_NUMBER; ++i)
     
    433433 *  @param position it collides on the plane
    434434 */
    435 bool WorldEntity::registerCollision(WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall)
     435bool WorldEntity::registerCollision(int type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall)
    436436{
    437437  // is there any handler listening?
     
    442442  CollisionEvent* c = CREngine::getInstance()->popCollisionEventObject();
    443443  assert(c != NULL); // if this should fail: we got not enough precached CollisionEvents: alter value in cr_defs.h
    444   c->collide(entity, groundEntity, normal, position, bInWall);
     444  c->collide(type, entity, groundEntity, normal, position, bInWall);
    445445
    446446  for( int i = 0; i < CREngine::CR_NUMBER; ++i)
  • branches/single_player_map/src/world_entities/world_entity.h

    r8862 r8864  
    8888
    8989  bool registerCollision(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB);
    90   bool registerCollision(WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall = false);
     90  bool registerCollision(int type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall = false);
    9191  /** @return true if there is at least on collision reaction subscribed */
    9292  inline bool isReactive() const { return this->bReactive; }
Note: See TracChangeset for help on using the changeset viewer.