00001
00002
00003 #ifndef __NEWCAR_H__
00004 #define __NEWCAR_H__
00005
00006 #define NEWCAR_PIECEPRESENT (0x1)
00007 #define NEWCAR_PICKED_UP (0x2)
00008
00009 #define NEWCAR_PRMLEVEL 1
00010 #define NEWCAR_NWHEELS 4
00011
00012 #define CAR_SHIFT_MAG Real(5)
00013
00014
00015 typedef struct {
00016 long Status;
00017 int ModelNumber;
00018 VECTOR ModelOffset;
00019 } NEWCAR_PIECEINFO;
00020
00021
00022 typedef struct {
00023 int TPage;
00024 NEWCAR_PIECEINFO Body;
00025 NEWCAR_PIECEINFO Wheel[NEWCAR_NWHEELS];
00026 NEWCAR_PIECEINFO Springs[NEWCAR_NWHEELS];
00027 NEWCAR_PIECEINFO Pins[NEWCAR_NWHEELS];
00028 NEWCAR_PIECEINFO Axles[NEWCAR_NWHEELS];
00029 } NEWCAR_RENDERINFO;
00030
00031
00032
00033 typedef struct {
00034 REAL Mass;
00035 REAL Radius;
00036
00037 REAL AxleFriction;
00038 REAL StaticFriction;
00039 REAL KineticFriction;
00040 REAL Gravity;
00041
00042 VECTOR WheelOffset;
00043 } NEWWHEEL_DATA;
00044
00045 typedef struct {
00046 REAL Mass;
00047 MATRIX Inertia;
00048
00049 REAL Hardness;
00050 REAL Resistance;
00051 REAL StaticFriction;
00052 REAL KineticFriction;
00053
00054 REAL Gravity;
00055
00056 VECTOR BodyOffset;
00057 NEWWHEEL_DATA WheelData[NEWCAR_NWHEELS];
00058 } NEWCAR_DATA;
00059
00060
00061
00062
00063 typedef struct {
00064
00065 int NBodies, NWheels, NSprings, NPins, NAxles;
00066 MODEL *Bodies;
00067 MODEL *Wheels;
00068 MODEL *Springs;
00069 MODEL *Pins;
00070 MODEL *Axles;
00071
00072 } CARSTORE, *PCARSTORE;
00073
00074 typedef struct {
00075
00076 int TurnLeft;
00077 int TurnRight;
00078 int Accelerate;
00079 int Decelerate;
00080
00081 int Reset;
00082
00083 int Pickup;
00084 int Drop;
00085 int MoveXPos;
00086 int MoveXNeg;
00087 int MoveYPos;
00088 int MoveYNeg;
00089 int MoveZPos;
00090 int MoveZNeg;
00091 } NEWCARKEYS;
00092
00093
00094 typedef struct {
00095 long Status;
00096
00097 REAL SteerAngle;
00098 REAL SteerStep;
00099 REAL EngineVolt;
00100 REAL EngineStep;
00101
00102
00103 NEWBODY Body;
00104 MODEL *BodyModel;
00105 VECTOR BodyOffset;
00106
00107 AERIAL Aerial;
00108 MODEL *AerialModel[2];
00109 VECTOR AerialOffset;
00110
00111 WHEEL Wheel[NEWCAR_NWHEELS];
00112 MODEL *WheelModel[NEWCAR_NWHEELS];
00113 VECTOR WheelOffset[NEWCAR_NWHEELS];
00114
00115 } NEWCAR, *PNEWCAR;
00116
00118
00119 #define IsPiecePresent(piece) ((piece)->Status & NEWCAR_PIECEPRESENT)
00120
00121 #define IsCarPickedUp(pCar) ((pCar)->Status & NEWCAR_PICKED_UP)
00122 #define CarPickup(pCar) ((pCar)->Status |= NEWCAR_PICKED_UP)
00123 #define CarDrop(pCar) ((pCar)->Status &= ~NEWCAR_PICKED_UP)
00124
00125 #define CarTurnLeft(pCar) \
00126 { \
00127 (pCar)->SteerAngle -= (pCar)->SteerStep; \
00128 if ((pCar)->SteerAngle < -ONE) (pCar)->SteerAngle = -ONE; \
00129 }
00130 #define CarTurnRight(pCar) \
00131 { \
00132 (pCar)->SteerAngle += (pCar)->SteerStep; \
00133 if ((pCar)->SteerAngle > ONE) (pCar)->SteerAngle = ONE; \
00134 }
00135
00136 #define CarAccelerate(pCar) \
00137 { \
00138 (pCar)->EngineVolt += (pCar)->EngineStep; \
00139 if ((pCar)->EngineVolt > ONE) (pCar)->EngineVolt = ONE; \
00140 }
00141 #define CarDecelerate(pCar) \
00142 { \
00143 (pCar)->EngineVolt -= (pCar)->EngineStep; \
00144 if ((pCar)->EngineVolt < -ONE) (pCar)->EngineVolt = -ONE; \
00145 }
00146
00147 #define CarTranslate(pCar, trans) \
00148 { \
00149 VecPlusEqVec(&(pCar)->Body.Centre.Pos, trans); \
00150 }
00151
00152 #define CarReset(pCar) NULL;
00153
00155
00156 extern NEWCAR *CreateNewCars(unsigned short nCars);
00157 extern void DestroyNewCars(NEWCAR *car);
00158 extern void SetupNewCar(NEWCAR *car, int CarNumber);
00159 extern void SetNewCarPos(NEWCAR *car, VECTOR *pos);
00160
00161 extern void BuildNewCarEyeMatrix(NEWCAR *pCar);
00162 extern void DrawNewCar(NEWCAR *car);
00163
00164 extern CARSTORE *CreateCarStore(int nBodies,
00165 int nWheels,
00166 int nSprings,
00167 int nPins,
00168 int nAxles);
00169 extern void DestroyCarStore(CARSTORE *carStore);
00170 extern bool LoadCarStoreModels(CARSTORE *carStore);
00171
00172 extern void NewCarProcessKeys(NEWCAR *pCar, NEWCARKEYS *carKeys);
00173 extern void UpdateNewCars(REAL dt);
00174
00175
00176
00178
00179 extern char PrmLevel;
00180
00181
00182 #endif