Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc @ 8490

Last change on this file since 8490 was 8490, checked in by patrick, 18 years ago

merged the bsp branche back to trunk

File size: 2.0 KB
RevLine 
[8200]1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Patrick Boenzli
13   co-programmer: ...
14*/
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION_REACTION
17
18#include "collision.h"
19#include "collision_event.h"
20
21#include "physics_interface.h"
22
23#include "world_entity.h"
24#include "cr_physics_ground_walk.h"
25
[8490]26#include "debug.h"
27
[8288]28#include <vector>
29
[8200]30using namespace std;
31
32
33/**
34 *  standard constructor
35 */
36CRPhysicsGroundWalk::CRPhysicsGroundWalk ()
37  : CollisionReaction()
38{
[8203]39  this->setClassID(CL_CR_PHYSICS_GROUND_WALK, "CRPhysicsGroundWalk");
[8200]40}
41
42
43/**
44 *  standard deconstructor
45 */
46CRPhysicsGroundWalk::~CRPhysicsGroundWalk ()
47{
48}
49
50
51/**
52 * caluculates and applys the reaction to a specific collision
53 *  @param collision the collision
54 */
55void CRPhysicsGroundWalk::reactToCollision(Collision* collision)
56{
[8334]57  CollisionEvent* ce = collision->getCollisionEvents().front();
58  Vector normal = ce->getGroundNormal();
59  normal.normalize();
[8288]60
61  // put it back
[8336]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();
[8323]66
[8341]67  PRINTF(0)("Collision with Ground: \n");
68  collision->getEntityB()->getAbsCoor().debug();
69
70  //collision->getEntityB()->setVelocity(Vector());
71  //collision->getEntityB()->setAbsCoor(this->lastPositions[5]);
[8256]72}
[8200]73
[8256]74
75
76/**
77 * use this to do some collision offline calculations, only called for bContinuousPoll == true
78 */
79void CRPhysicsGroundWalk::update(WorldEntity* owner)
80{
[8337]81  for( int i = 9; i > 0; i--) {
[8336]82    this->lastPositions[i] = this->lastPositions[i-1];
[8337]83//     PRINTF(0)("lastPosition[%i]: %f, %f, %f\n", i, lastPositions[i].x, lastPositions[i].y, lastPositions[i].z);
84  }
[8336]85  this->lastPositions[0] = owner->getAbsCoor();
[8200]86}
87
[8256]88
Note: See TracBrowser for help on using the repository browser.