1
// $Id: moveable.hpp 702 2006-08-31 03:17:18Z hiker $
3
// SuperTuxKart - a fun racing game with go-kart
4
// Copyright (C) 2004-2005 Steve Baker <sjbaker1@airmail.net>
5
// Copyright (C) 2006 Joerg Henrichs, Steve Baker
7
// This program is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU General Public License
9
// as published by the Free Software Foundation; either version 2
10
// of the License, or (at your option) any later version.
12
// This program is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
17
// You should have received a copy of the GNU General Public License
18
// along with this program; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
#ifndef HEADER_MOVEABLE_H
22
#define HEADER_MOVEABLE_H
25
#include "material.hpp"
27
/* Limits of Kart performance */
28
#define CRASH_PITCH -45.0f
30
#define MAX_NATURAL_VELOCITY ( 60.0f * KILOMETERS_PER_HOUR )
31
#define MIN_CRASH_VELOCITY (MAX_NATURAL_VELOCITY * 0.2f)
32
#define MIN_COLLIDE_VELOCITY (MAX_NATURAL_VELOCITY * 0.1f)
33
#define COLLIDE_BRAKING_RATE (MAX_NATURAL_VELOCITY * 1.0f)
35
#define MAX_HERRING_EATEN 20
40
sgCoord reset_pos; /* Where to start in case of a reset */
41
sgCoord curr_pos; /* current position */
42
sgCoord velocity; /* current velocity in local coordinates */
43
sgVec3 abs_velocity; /* world coordinates' velocity vector */
44
sgVec4* normalHOT; /* plane on which HOT was computed */
45
Material* materialHOT; /* Material at HOT */
50
sgVec3 surface_avoidance_vector ;
55
float collectIsectData ( sgVec3 start, sgVec3 end ) ;
56
sgCoord* historyVelocity;
57
sgCoord* historyPosition;
61
/* start - New Physics */
64
Moveable (bool bHasHistory=false);
67
void setReset (sgCoord* pos) {sgCopyCoord( &reset_pos, pos ); }
68
ssgTransform* getModel () {return model ; }
69
int isOnGround () {return on_ground; }
70
sgCoord* getVelocity () {return & velocity; }
71
sgCoord* getCoord () {return &curr_pos; }
72
void setCoord (sgCoord* pos) {sgCopyCoord ( &curr_pos,pos); }
73
virtual void placeModel () {model->setTransform(&curr_pos); }
74
virtual void handleZipper () {};
75
virtual void reset ();
76
virtual void update (float dt) ;
77
virtual void updatePosition(float dt, sgMat4 result);
78
virtual void doCollisionAnalysis(float dt, float hot);
80
// Gets called when no high of terrain can be determined (isReset=0), or
81
// there is a 'reset' material under the moveable --> karts need to be
82
// rescued, missiles should explode.
83
virtual void OutsideTrack (int isReset) {}
85
float getIsectData (sgVec3 start, sgVec3 end );
86
void WriteHistory (char* s, int kartNumber, int indx);
87
void ReadHistory (char* s, int kartNumber, int indx);