Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8724 in orxonox.OLD for trunk/src/lib/collision_reaction


Ignore:
Timestamp:
Jun 22, 2006, 3:14:58 PM (19 years ago)
Author:
bensch
Message:

merged the bsp-model-stuff back here

Location:
trunk/src/lib/collision_reaction
Files:
4 edited

Legend:

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

    r8495 r8724  
    101101      return;
    102102
    103    // add element
    104    //PRINTF(0)("addTarget: %i \n", target);
     103  // add element
     104   PRINTF(5)("addTarget: %i \n", target);
    105105
    106106   this->targetList.push_back(target);
     
    177177
    178178 c->registerCollisionEvent(collisionEvent);
    179  PRINTF(0)("Registering Collision Event: %s, %s\n", collisionEvent->getEntityA()->getClassName(), collisionEvent->getEntityB()->getClassName());
     179 PRINTF(5)("Registering Collision Event: %s, %s\n", collisionEvent->getEntityA()->getClassName(), collisionEvent->getEntityB()->getClassName());
    180180}
    181181
     
    231231    if( collisionEvent->getEntityA() == this->owner) {
    232232      if( collisionEvent->getEntityB()->isA((ClassID)(*it))) {
    233         PRINTF(0)("I am: %s colliding with: %s is a %i filter ok\n", owner->getClassName(),
     233        PRINTF(5)("I am: %s colliding with: %s is a %i filter ok\n", owner->getClassName(),
    234234                  collisionEvent->getEntityB()->getClassName(), *it);
    235235        return true; }
     
    237237    else {
    238238      if( collisionEvent->getEntityA()->isA((ClassID)(*it))) {
    239         PRINTF(0)("I am: %s colliding with: %s is a %i filter ok\n", owner->getClassName(),
     239        PRINTF(5)("I am: %s colliding with: %s is a %i filter ok\n", owner->getClassName(),
    240240                  collisionEvent->getEntityA()->getClassName(), *it);
    241241      return true; }
  • trunk/src/lib/collision_reaction/cr_object_damage.cc

    r8490 r8724  
    6363  if( collision->isEntityACollide()) {
    6464    damage = collision->getEntityB()->getDamage();
    65     collision->getEntityA()->decreaseHealth(damage);
     65    collision->getEntityA()->hit(damage);
    6666  }
    6767  PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityA()->getClassName());
     
    6969  if( collision->isEntityBCollide()) {
    7070    damage = collision->getEntityA()->getDamage();
    71     collision->getEntityB()->decreaseHealth(damage);
     71    collision->getEntityB()->hit(damage);
    7272  }
    7373  PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityB()->getClassName());
  • trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc

    r8490 r8724  
    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
     
    2424#include "cr_physics_ground_walk.h"
    2525
    26 #include "debug.h"
    27 
    2826#include <vector>
    2927
     
    3533 */
    3634CRPhysicsGroundWalk::CRPhysicsGroundWalk ()
    37   : CollisionReaction()
     35    : CollisionReaction()
    3836{
    3937  this->setClassID(CL_CR_PHYSICS_GROUND_WALK, "CRPhysicsGroundWalk");
     
    4543 */
    4644CRPhysicsGroundWalk::~CRPhysicsGroundWalk ()
    47 {
    48 }
     45{}
    4946
    5047
     
    5754  CollisionEvent* ce = collision->getCollisionEvents().front();
    5855  Vector normal = ce->getGroundNormal();
    59   normal.normalize();
     56  // normal.normalize();
    6057
    6158  // put it back
    62 //   PRINTF(0)("putting it back to lastPos: \n");
    63 //   this->lastPositions[0].debug();
    64 //   PRINTF(0)("current pos:\n");
    65 //   collision->getEntityB()->getAbsCoor().debug();
     59  //   PRINTF(0)("putting it back to lastPos: \n");
     60  //   this->lastPositions[0].debug();
     61  //   PRINTF(0)("current pos:\n");
     62  //   collision->getEntityB()->getAbsCoor().debug();
    6663
     64
     65  Vector height = ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor();
     66
     67  if(ce->getCollisionPosition().x <= 0.9 && ce->getGroundNormal().len() <= 1.4f) {
     68    collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
     69    return;
     70  }
     71  if(ce->getGroundNormal().len() <= 0.1f) {
     72    collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
     73    return;
     74  }
     75  if(ce->getGroundNormal().len() >= 1.4f) {
     76    downspeed++;
     77    collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,-0.08*downspeed,0.0));
     78    return;
     79  }
     80
     81
     82  if(height.y < -3.510001 + 10.0) // Above ground
     83  {
     84    if(height.y > -15.6) // Snap in
     85    {
     86      downspeed = 0;
     87      collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,height.y+3.500005 + 10.0,0.0));
     88    } else
     89    {
     90      downspeed++;
     91      collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,-0.08*downspeed,0.0));
     92    }
     93
     94  }
     95  else {
     96    if(height.y > -3.50000 + 10.0  && height.y <    9.9+ 10.0) // below ground
     97    {
     98      //if(downspeed <= 0) downspeed =1;
     99      collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0, 0.00001 /*height.y+3.500005 + 10.0*/,0.0));
     100      //collision->getEntityB()->setVelocity(Vector(0.0,0.0,0.0));
     101      downspeed = 0;
     102    }
     103
     104  }
     105
     106
     107  /*
    67108  PRINTF(0)("Collision with Ground: \n");
    68109  collision->getEntityB()->getAbsCoor().debug();
     110  collision->getEntityB()->setVelocity(Vector());
     111  collision->getEntityB()->setAbsCoor(this->lastPositions[1]);
    69112
    70   //collision->getEntityB()->setVelocity(Vector());
    71   //collision->getEntityB()->setAbsCoor(this->lastPositions[5]);
     113  */
    72114}
     115
    73116
    74117
     
    81124  for( int i = 9; i > 0; i--) {
    82125    this->lastPositions[i] = this->lastPositions[i-1];
    83 //     PRINTF(0)("lastPosition[%i]: %f, %f, %f\n", i, lastPositions[i].x, lastPositions[i].y, lastPositions[i].z);
     126    //     PRINTF(0)("lastPosition[%i]: %f, %f, %f\n", i, lastPositions[i].x, lastPositions[i].y, lastPositions[i].z);
    84127  }
    85128  this->lastPositions[0] = owner->getAbsCoor();
  • trunk/src/lib/collision_reaction/cr_physics_ground_walk.h

    r8490 r8724  
    2929
    3030    Vector       lastPositions[10];           //!< last 10 positions
     31    float        downspeed;
    3132};
    3233
Note: See TracChangeset for help on using the changeset viewer.