doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Physics_Parametric.h
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 
29 #ifndef __PHYSICS_PARAMETRIC_H__
30 #define __PHYSICS_PARAMETRIC_H__
31 
32 /*
33 ===================================================================================
34 
35  Parametric physics
36 
37  Used for predefined or scripted motion. The motion of an object is completely
38  parametrized. By adjusting the parameters an object is forced to follow a
39  predefined path. The parametric physics is typically used for doors, bridges,
40  rotating fans etc.
41 
42 ===================================================================================
43 */
44 
45 typedef struct parametricPState_s {
46  int time; // physics time
47  int atRest; // set when simulation is suspended
48  idVec3 origin; // world origin
49  idAngles angles; // world angles
50  idMat3 axis; // world axis
51  idVec3 localOrigin; // local origin
52  idAngles localAngles; // local angles
53  idExtrapolate<idVec3> linearExtrapolation; // extrapolation based description of the position over time
54  idExtrapolate<idAngles> angularExtrapolation; // extrapolation based description of the orientation over time
55  idInterpolateAccelDecelLinear<idVec3> linearInterpolation; // interpolation based description of the position over time
56  idInterpolateAccelDecelLinear<idAngles> angularInterpolation; // interpolation based description of the orientation over time
57  idCurve_Spline<idVec3> * spline; // spline based description of the position over time
58  idInterpolateAccelDecelLinear<float> splineInterpolate; // position along the spline over time
59  bool useSplineAngles; // set the orientation using the spline
61 
63 
64 public:
66 
67  idPhysics_Parametric( void );
68  ~idPhysics_Parametric( void );
69 
70  void Save( idSaveGame *savefile ) const;
71  void Restore( idRestoreGame *savefile );
72 
73  void SetPusher( int flags );
74  bool IsPusher( void ) const;
75 
76  void SetLinearExtrapolation( extrapolation_t type, int time, int duration, const idVec3 &base, const idVec3 &speed, const idVec3 &baseSpeed );
77  void SetAngularExtrapolation( extrapolation_t type, int time, int duration, const idAngles &base, const idAngles &speed, const idAngles &baseSpeed );
80 
81  void SetLinearInterpolation( int time, int accelTime, int decelTime, int duration, const idVec3 &startPos, const idVec3 &endPos );
82  void SetAngularInterpolation( int time, int accelTime, int decelTime, int duration, const idAngles &startAng, const idAngles &endAng );
83 
84  void SetSpline( idCurve_Spline<idVec3> *spline, int accelTime, int decelTime, bool useSplineAngles );
85  idCurve_Spline<idVec3> *GetSpline( void ) const;
86  int GetSplineAcceleration( void ) const;
87  int GetSplineDeceleration( void ) const;
88  bool UsingSplineAngles( void ) const;
89 
90  void GetLocalOrigin( idVec3 &curOrigin ) const;
91  void GetLocalAngles( idAngles &curAngles ) const;
92 
93  void GetAngles( idAngles &curAngles ) const;
94 
95 public: // common physics interface
96  void SetClipModel( idClipModel *model, float density, int id = 0, bool freeOld = true );
97  idClipModel * GetClipModel( int id = 0 ) const;
98  int GetNumClipModels( void ) const;
99 
100  void SetMass( float mass, int id = -1 );
101  float GetMass( int id = -1 ) const;
102 
103  void SetContents( int contents, int id = -1 );
104  int GetContents( int id = -1 ) const;
105 
106  const idBounds & GetBounds( int id = -1 ) const;
107  const idBounds & GetAbsBounds( int id = -1 ) const;
108 
109  bool Evaluate( int timeStepMSec, int endTimeMSec );
110  void UpdateTime( int endTimeMSec );
111  int GetTime( void ) const;
112 
113  void Activate( void );
114  bool IsAtRest( void ) const;
115  int GetRestStartTime( void ) const;
116  bool IsPushable( void ) const;
117 
118  void SaveState( void );
119  void RestoreState( void );
120 
121  void SetOrigin( const idVec3 &newOrigin, int id = -1 );
122  void SetAxis( const idMat3 &newAxis, int id = -1 );
123 
124  void Translate( const idVec3 &translation, int id = -1 );
125  void Rotate( const idRotation &rotation, int id = -1 );
126 
127  const idVec3 & GetOrigin( int id = 0 ) const;
128  const idMat3 & GetAxis( int id = 0 ) const;
129 
130  void SetLinearVelocity( const idVec3 &newLinearVelocity, int id = 0 );
131  void SetAngularVelocity( const idVec3 &newAngularVelocity, int id = 0 );
132 
133  const idVec3 & GetLinearVelocity( int id = 0 ) const;
134  const idVec3 & GetAngularVelocity( int id = 0 ) const;
135 
136  void DisableClip( void );
137  void EnableClip( void );
138 
139  void UnlinkClip( void );
140  void LinkClip( void );
141 
142  void SetMaster( idEntity *master, const bool orientated = true );
143 
144  const trace_t * GetBlockingInfo( void ) const;
145  idEntity * GetBlockingEntity( void ) const;
146 
147  int GetLinearEndTime( void ) const;
148  int GetAngularEndTime( void ) const;
149 
150  void WriteToSnapshot( idBitMsgDelta &msg ) const;
151  void ReadFromSnapshot( const idBitMsgDelta &msg );
152 
153 private:
154  // parametric physics state
157 
158  // pusher
159  bool isPusher;
162 
163  // results of last evaluate
165  bool isBlocked;
166 
167  // master
168  bool hasMaster;
170 
171 private:
172  bool TestIfAtRest( void ) const;
173  void Rest( void );
174 };
175 
176 #endif /* !__PHYSICS_PARAMETRIC_H__ */
const idVec3 & GetOrigin(int id=0) const
const trace_t * GetBlockingInfo(void) const
void Restore(idRestoreGame *savefile)
bool IsPushable(void) const
void UpdateTime(int endTimeMSec)
void SetContents(int contents, int id=-1)
void SetMaster(idEntity *master, const bool orientated=true)
extrapolation_t
Definition: Extrapolate.h:40
const idMat3 & GetAxis(int id=0) const
void SetAngularExtrapolation(extrapolation_t type, int time, int duration, const idAngles &base, const idAngles &speed, const idAngles &baseSpeed)
struct parametricPState_s parametricPState_t
extrapolation_t GetLinearExtrapolationType(void) const
idExtrapolate< idAngles > angularExtrapolation
void SetLinearVelocity(const idVec3 &newLinearVelocity, int id=0)
idCurve_Spline< idVec3 > * spline
void Translate(const idVec3 &translation, int id=-1)
Definition: Vector.h:316
int GetContents(int id=-1) const
const idBounds & GetAbsBounds(int id=-1) const
idInterpolateAccelDecelLinear< idAngles > angularInterpolation
GLuint GLuint GLsizei GLenum type
Definition: glext.h:2845
void SetLinearExtrapolation(extrapolation_t type, int time, int duration, const idVec3 &base, const idVec3 &speed, const idVec3 &baseSpeed)
void SetAngularInterpolation(int time, int accelTime, int decelTime, int duration, const idAngles &startAng, const idAngles &endAng)
extrapolation_t GetAngularExtrapolationType(void) const
float GetMass(int id=-1) const
void SetAxis(const idMat3 &newAxis, int id=-1)
void Save(idSaveGame *savefile) const
void SetClipModel(idClipModel *model, float density, int id=0, bool freeOld=true)
int GetAngularEndTime(void) const
int GetNumClipModels(void) const
idExtrapolate< idVec3 > linearExtrapolation
bool Evaluate(int timeStepMSec, int endTimeMSec)
void SetOrigin(const idVec3 &newOrigin, int id=-1)
int GetSplineDeceleration(void) const
void GetAngles(idAngles &curAngles) const
int GetRestStartTime(void) const
void GetLocalAngles(idAngles &curAngles) const
void Rotate(const idRotation &rotation, int id=-1)
int GetLinearEndTime(void) const
idEntity * GetBlockingEntity(void) const
bool UsingSplineAngles(void) const
idInterpolateAccelDecelLinear< float > splineInterpolate
parametricPState_t current
idClipModel * GetClipModel(int id=0) const
void SetAngularVelocity(const idVec3 &newAngularVelocity, int id=0)
const idVec3 & GetLinearVelocity(int id=0) const
Definition: Matrix.h:333
void SetLinearInterpolation(int time, int accelTime, int decelTime, int duration, const idVec3 &startPos, const idVec3 &endPos)
void GetLocalOrigin(idVec3 &curOrigin) const
bool TestIfAtRest(void) const
bool IsAtRest(void) const
parametricPState_t saved
CLASS_PROTOTYPE(idPhysics_Parametric)
void SetSpline(idCurve_Spline< idVec3 > *spline, int accelTime, int decelTime, bool useSplineAngles)
const idBounds & GetBounds(int id=-1) const
void ReadFromSnapshot(const idBitMsgDelta &msg)
bool IsPusher(void) const
idInterpolateAccelDecelLinear< idVec3 > linearInterpolation
void WriteToSnapshot(idBitMsgDelta &msg) const
const idVec3 & GetAngularVelocity(int id=0) const
int GetSplineAcceleration(void) const
void SetMass(float mass, int id=-1)
idCurve_Spline< idVec3 > * GetSpline(void) const