00001
00002 #ifndef __WHEEL_H__
00003 #define __WHEEL_H__
00004
00005
00007
00009 typedef struct {
00010 VEC Corner[4];
00011 VEC Centre;
00012 long RGB;
00013 VISIMASK VisiMask;
00014 } SKIDMARK;
00015
00016
00017 typedef struct {
00018 long Started;
00019 REAL LastSmokeTime;
00020
00021 VEC Pos;
00022 VEC Dir;
00023 VEC Normal;
00024 REAL Width;
00025
00026 MATERIAL *Material;
00027 SKIDMARK *CurrentSkid;
00028 } SKIDMARK_START;
00029
00030 #ifdef _PSX
00031 #define SKID_MAX_SKIDS (128) // Max number of skids allowed
00032 #else
00033 #define SKID_MAX_SKIDS (1000) // Max number of skids allowed
00034 #endif
00035
00036 #define SKID_MAX_LEN TO_LENGTH(Real(128)) // Max length of a skidmark
00037 #define SKID_HALF_LEN TO_LENGTH(Real(64)) // Half the max length
00038 #define SKID_MIN_LEN TO_LENGTH(Real(10)) // Min length of a skidmark
00039 #define SKID_MAX_DOT (Real(0.98)) // Dot product of skid direction cannot change below this
00040 #define SKID_RAISE TO_LENGTH(Real(0.2)) // Distance above floor of skidmarks
00041 #define SKID_FADE_NUM (100) // number of skids to fade out
00042 #define SKID_FADE_START (SKID_MAX_SKIDS - SKID_FADE_NUM)
00043 #define SKID_FADE_FACTOR (2) // Amount to reduce fading skids alpha by
00044 #ifdef _PC
00045 #define SKID_SMOKE_TIME (Real(0.03)) // Amount of time between smoke generations
00046 #endif
00047 #ifdef _N64
00048 #define SKID_SMOKE_TIME (Real(0.01)) // Amount of time between smoke generations
00049 #endif
00050
00052
00054 typedef struct {
00055 REAL Stiffness;
00056 REAL Damping;
00057 REAL Restitution;
00058 } SPRING;
00059
00060 #define SpringForce(spring, extension) \
00061 ( - (spring)->Stiffness * (extension) )
00062
00063
00065
00067 typedef struct {
00068 long ModelNum;
00069 VEC Offset1;
00070 VEC Offset2;
00071 REAL Radius;
00072 REAL Mass;
00073 REAL Gravity;
00074 REAL Grip;
00075 REAL StaticFriction;
00076 REAL KineticFriction;
00077 REAL AxleFriction;
00078 REAL SteerRatio;
00079 REAL EngineRatio;
00080 REAL MaxPos;
00081 REAL SkidWidth;
00082
00083 bool IsPresent;
00084 bool IsTurnable;
00085 bool IsPowered;
00086
00087 } WHEEL_INFO;
00088
00090
00092 typedef struct {
00093 long ModelNum;
00094 VEC Offset;
00095 REAL Length;
00096 REAL Stiffness;
00097 REAL Damping;
00098 REAL Restitution;
00099 } SPRING_INFO;
00100
00102
00104 typedef struct {
00105
00106 unsigned long Status;
00107
00108 REAL Mass, InvMass;
00109 REAL Inertia, InvInertia;
00110 REAL Radius;
00111 REAL Gravity;
00112
00113 REAL Grip;
00114 REAL StaticFriction;
00115 REAL KineticFriction;
00116
00117 REAL SteerRatio;
00118 REAL EngineRatio;
00119 REAL AxleFriction;
00120
00121 BBOX BBox;
00122 REAL BBRadius;
00123
00124 REAL Pos;
00125 REAL AngPos;
00126 REAL Vel;
00127 REAL AngVel;
00128 REAL Acc;
00129 REAL AngAcc;
00130 REAL Impulse;
00131 REAL AngImpulse;
00132
00133 REAL MaxPos;
00134 REAL MaxAngVel;
00135
00136 REAL SpinAngImp;
00137
00138 MAT WMatrix;
00139 VEC WPos;
00140 VEC OldWPos;
00141 VEC CentrePos;
00142 VEC OldCentrePos;
00143 MAT Axes;
00144
00145 MAT EyeMatrix;
00146 VEC EyeTrans;
00147
00148 REAL TurnAngle;
00149
00150 SKIDMARK_START Skid;
00151 REAL SkidWidth;
00152
00153 REAL OilTime;
00154
00155 } WHEEL;
00156
00157 #define WHEEL_PRESENT (1)
00158 #define WHEEL_STEERED (2)
00159 #define WHEEL_POWERED (4)
00160 #define WHEEL_CONTACT (8)
00161 #define WHEEL_SPIN (16)
00162 #define WHEEL_SLIDE (32)
00163 #define WHEEL_LOCKED (64)
00164 #define WHEEL_OIL (128)
00165 #define WHEEL_SKID (WHEEL_SPIN | WHEEL_SLIDE)
00166
00167
00168 #define IsWheelPresent(wheel) ((wheel)->Status & WHEEL_PRESENT)
00169 #define IsWheelTurnable(wheel) ((wheel)->Status & WHEEL_STEERED)
00170 #define IsWheelPowered(wheel) ((wheel)->Status & WHEEL_POWERED)
00171 #define IsWheelInContact(wheel) ((wheel)->Status & WHEEL_CONTACT)
00172 #define IsWheelSpinning(wheel) ((wheel)->Status & WHEEL_SPIN)
00173 #define IsWheelSliding(wheel) ((wheel)->Status & WHEEL_SLIDE)
00174 #define IsWheelSkidding(wheel) ((wheel)->Status & WHEEL_SKID)
00175 #define IsWheelLocked(wheel) ((wheel)->Status & WHEEL_LOCKED)
00176 #define IsWheelinOil(wheel) ((wheel)->Status & WHEEL_OIL)
00177 #define SetWheelPresent(wheel) {(wheel)->Status |= WHEEL_PRESENT;}
00178 #define SetWheelTurnable(wheel) {(wheel)->Status |= WHEEL_STEERED;}
00179 #define SetWheelPowered(wheel) {(wheel)->Status |= WHEEL_POWERED;}
00180 #define SetWheelInContact(wheel) {(wheel)->Status |= WHEEL_CONTACT;}
00181 #define SetWheelSpinning(wheel) {(wheel)->Status |= WHEEL_SPIN;}
00182 #define SetWheelSliding(wheel) {(wheel)->Status |= WHEEL_SLIDE;}
00183 #define SetWheelLocked(wheel) {(wheel)->Status |= WHEEL_LOCKED;}
00184 #define SetWheelInOil(wheel) {(wheel)->Status |= WHEEL_OIL;}
00185 #define SetWheelNotPresent(wheel) {(wheel)->Status &= ~WHEEL_PRESENT;}
00186 #define SetWheelNotTurnable(wheel) {(wheel)->Status &= ~WHEEL_STEERED;}
00187 #define SetWheelNotPowered(wheel) {(wheel)->Status &= ~WHEEL_POWERED;}
00188 #define SetWheelNotInContact(wheel) {(wheel)->Status &= ~WHEEL_CONTACT;}
00189 #define SetWheelNotSpinning(wheel) {(wheel)->Status &= ~WHEEL_SPIN;}
00190 #define SetWheelNotSliding(wheel) {(wheel)->Status &= ~WHEEL_SLIDE;}
00191 #define SetWheelNotLocked(wheel) {(wheel)->Status &= ~WHEEL_LOCKED;}
00192 #define SetWheelNotInOil(wheel) {(wheel)->Status &= ~WHEEL_OIL;}
00193
00194 #define SetWheelStatus(wheel, present, steered, powered) \
00195 {(wheel)->Status |= ((present) | (steered) | (powered));}
00196
00197
00198 extern void SetupWheel(WHEEL *wheel, WHEEL_INFO *wheelInfo);
00199 extern void SetupSuspension(SPRING *spring, SPRING_INFO *info);
00200 extern REAL SpringDampedForce(SPRING *spring, REAL extension, REAL velocity);
00201
00202 extern SKIDMARK *AddSkid(SKIDMARK_START *skidStart, SKIDMARK_START *skidEnd, long rgb);
00203 extern void MoveSkidEnd(SKIDMARK *skid, SKIDMARK_START *skidEnd);
00204 extern void ClearSkids();
00205 extern void FadeSkidMarks();
00206
00207 extern int WHL_NSkids;
00208 extern int WHL_SkidHead;
00209 extern SKIDMARK WHL_SkidMark[SKID_MAX_SKIDS];
00210
00211
00212 #endif