2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
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.
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.
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/>.
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.
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.
26 ===========================================================================
29 #ifndef __PHYSICS_PARAMETRIC_H__
30 #define __PHYSICS_PARAMETRIC_H__
33 ===================================================================================
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,
42 ===================================================================================
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
62 class idPhysics_Parametric : public idPhysics_Base {
65 CLASS_PROTOTYPE( idPhysics_Parametric );
67 idPhysics_Parametric( void );
68 ~idPhysics_Parametric( void );
70 void Save( idSaveGame *savefile ) const;
71 void Restore( idRestoreGame *savefile );
73 void SetPusher( int flags );
74 bool IsPusher( void ) const;
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 );
78 extrapolation_t GetLinearExtrapolationType( void ) const;
79 extrapolation_t GetAngularExtrapolationType( void ) const;
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 );
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;
90 void GetLocalOrigin( idVec3 &curOrigin ) const;
91 void GetLocalAngles( idAngles &curAngles ) const;
93 void GetAngles( idAngles &curAngles ) const;
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;
100 void SetMass( float mass, int id = -1 );
101 float GetMass( int id = -1 ) const;
103 void SetContents( int contents, int id = -1 );
104 int GetContents( int id = -1 ) const;
106 const idBounds & GetBounds( int id = -1 ) const;
107 const idBounds & GetAbsBounds( int id = -1 ) const;
109 bool Evaluate( int timeStepMSec, int endTimeMSec );
110 void UpdateTime( int endTimeMSec );
111 int GetTime( void ) const;
113 void Activate( void );
114 bool IsAtRest( void ) const;
115 int GetRestStartTime( void ) const;
116 bool IsPushable( void ) const;
118 void SaveState( void );
119 void RestoreState( void );
121 void SetOrigin( const idVec3 &newOrigin, int id = -1 );
122 void SetAxis( const idMat3 &newAxis, int id = -1 );
124 void Translate( const idVec3 &translation, int id = -1 );
125 void Rotate( const idRotation &rotation, int id = -1 );
127 const idVec3 & GetOrigin( int id = 0 ) const;
128 const idMat3 & GetAxis( int id = 0 ) const;
130 void SetLinearVelocity( const idVec3 &newLinearVelocity, int id = 0 );
131 void SetAngularVelocity( const idVec3 &newAngularVelocity, int id = 0 );
133 const idVec3 & GetLinearVelocity( int id = 0 ) const;
134 const idVec3 & GetAngularVelocity( int id = 0 ) const;
136 void DisableClip( void );
137 void EnableClip( void );
139 void UnlinkClip( void );
140 void LinkClip( void );
142 void SetMaster( idEntity *master, const bool orientated = true );
144 const trace_t * GetBlockingInfo( void ) const;
145 idEntity * GetBlockingEntity( void ) const;
147 int GetLinearEndTime( void ) const;
148 int GetAngularEndTime( void ) const;
150 void WriteToSnapshot( idBitMsgDelta &msg ) const;
151 void ReadFromSnapshot( const idBitMsgDelta &msg );
154 // parametric physics state
155 parametricPState_t current;
156 parametricPState_t saved;
160 idClipModel * clipModel;
163 // results of last evaluate
172 bool TestIfAtRest( void ) const;
176 #endif /* !__PHYSICS_PARAMETRIC_H__ */