Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 29, 2006, 12:19:48 AM (19 years ago)
Author:
patrick
Message:

merged the branche single_player_map with the trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc

    r8796 r8894  
    11/*
    22   orxonox - the future of 3D-vertical-scrollers
    3  
     3
    44   Copyright (C) 2004 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: Patrick Boenzli
     
    2626#include <vector>
    2727
     28#include "debug.h"
     29
    2830#include "aabb.h"
     31
     32#include "cr_defs.h"
    2933
    3034using namespace std;
     
    6468  //   collision->getEntityB()->getAbsCoor().debug();
    6569
    66   Vector height;
     70  float height;
    6771  AABB* box = collision->getEntityB()->getModelAABB();
    68  
    69  
    70  
    71   if(box!=NULL)
     72  WorldEntity* entity = collision->getEntityB();
     73
     74  // collision position maths
     75  Vector collPos =  collision->getEntityB()->getAbsCoor()  + box->center - ce->getCollisionPosition();
     76
     77  float CR_MAX_WALK_HEIGHT = 2.0f;
     78  float CR_THRESHOLD = 0.2f;
     79
     80  if( box == NULL)
     81  {
     82    PRINTF(2)("this model has no aabb box so there is no correct collision reaction implemented. skipping\n");
     83    return;
     84  }
     85
     86
     87  switch( ce->getType())
     88  {
     89    case COLLISION_TYPE_AXIS_Y:
     90
     91      height = collPos.y - box->halfLength[1];
     92     // PRINTF(0)("height: %f          , model height: %f\n", height, box->halfLength[1]);
     93     // PRINTF(0)(" ground normal: %f, %f, %f\n", normal.x, normal.y, normal.z);
     94
     95      // object is beneath the plane (ground)
     96      if( height <= 0.0f )
     97      {
     98        entity->shiftCoor(Vector(0, -height, 0));
     99      }
     100      // object is already in the wall
     101      else if( ce->isInWall())
     102      {
     103        entity->setAbsCoor(entity->getLastAbsCoor());
     104      }
     105      break;
     106
     107
     108    case COLLISION_TYPE_AXIS_X:
     109    case COLLISION_TYPE_AXIS_Z:
     110      break;
     111
     112    }
     113
     114
     115
     116
     117
     118
     119
     120
     121#if 0
     122  if( box != NULL)
    72123    height = ( ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() )*(-1.0f) ;
    73124  else
    74125    height = ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() ;
    75126
    76   if(box!=NULL) {
     127
     128  if( box != NULL) {
    77129
    78130
     
    90142      return;
    91143    }
    92    
    93    
     144
     145
    94146    if(ce->getGroundNormal().len() >= 1.4f) {
    95147      downspeed++;
     
    101153    if(height.y > box->halfLength[1] + 0.0f ) // Above ground
    102154    {
    103       if(height.y < box->halfLength[1] + 1.3f) // Snap in
     155      if(height.y < box->halfLength[1] + 2.3f) // Snap in
    104156      {
    105157        downspeed = 0;
     
    116168      {
    117169        //if(downspeed <= 0) downspeed =1;
    118         collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0, -height.y  +  box->halfLength[1] + 2.0f/* 0.00001 *//*height.y+3.500005 + 10.0*/,0.0));
     170        collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0, -height.y  +  box->halfLength[1] + 2.0f,0.0));
    119171        //collision->getEntityB()->setVelocity(Vector(0.0,0.0,0.0));
    120172        downspeed = 0;
     
    124176
    125177  }// if(box!= NULL)
     178#endif
    126179  /*
    127180  PRINTF(0)("Collision with Ground: \n");
     
    131184
    132185  */
     186
    133187}
    134188
     
    141195void CRPhysicsGroundWalk::update(WorldEntity* owner)
    142196{
    143   for( int i = 9; i > 0; i--) {
    144     this->lastPositions[i] = this->lastPositions[i-1];
    145     //     PRINTF(0)("lastPosition[%i]: %f, %f, %f\n", i, lastPositions[i].x, lastPositions[i].y, lastPositions[i].z);
    146   }
    147   this->lastPositions[0] = owner->getAbsCoor();
     197
    148198}
    149199
Note: See TracChangeset for help on using the changeset viewer.