Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

merged the bsp branche back to trunk

File size: 2.0 KB
Line 
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
26#include "debug.h"
27
28#include <vector>
29
30using namespace std;
31
32
33/**
34 *  standard constructor
35 */
36CRPhysicsGroundWalk::CRPhysicsGroundWalk ()
37  : CollisionReaction()
38{
39  this->setClassID(CL_CR_PHYSICS_GROUND_WALK, "CRPhysicsGroundWalk");
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{
57  CollisionEvent* ce = collision->getCollisionEvents().front();
58  Vector normal = ce->getGroundNormal();
59  normal.normalize();
60
61  // 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();
66
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]);
72}
73
74
75
76/**
77 * use this to do some collision offline calculations, only called for bContinuousPoll == true
78 */
79void CRPhysicsGroundWalk::update(WorldEntity* owner)
80{
81  for( int i = 9; i > 0; i--) {
82    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);
84  }
85  this->lastPositions[0] = owner->getAbsCoor();
86}
87
88
Note: See TracBrowser for help on using the repository browser.