Subversion Repositories Games.Carmageddon

Rev

Rev 18 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #ifndef _CAR_H_
  2. #define _CAR_H_
  3.  
  4. #include "brender/br_types.h"
  5. #include "dr_types.h"
  6.  
  7. #define CAR_MAX_SIMPLIFICATION_LEVEL 4
  8.  
  9. extern int gDoing_physics;
  10. extern br_scalar gDt;
  11. extern int gCollision_detection_on__car; // suffix added to avoid duplicate symbol
  12. extern br_vector3 gGround_normal__car; // suffix added to avoid duplicate symbol
  13. extern void (*ControlCar__car[6])(tCar_spec*, br_scalar); // suffix added to avoid duplicate symbol
  14. extern int gControl__car; // suffix added to avoid duplicate symbol
  15. extern int gFace_num__car; // suffix added to avoid duplicate symbol
  16. extern br_angle gOld_yaw__car; // suffix added to avoid duplicate symbol
  17. extern br_angle gOld_zoom;
  18. extern br_vector3 gCamera_pos_before_collide;
  19. extern int gMetal_crunch_sound_id__car[5]; // suffix added to avoid duplicate symbol
  20. extern int gMetal_scrape_sound_id__car[3]; // suffix added to avoid duplicate symbol
  21. extern int gCar_car_collisions;
  22. extern int gFreeze_mechanics;
  23. extern tU32 gLast_cunning_stunt;
  24. extern tU32 gWild_start;
  25. extern tU32 gQuite_wild_start;
  26. extern tU32 gQuite_wild_end;
  27. extern tU32 gOn_me_wheels_start;
  28. extern int gWoz_upside_down_at_all;
  29. extern tS3_sound_tag gSkid_tag[2];
  30. extern tCar_spec* gLast_car_to_skid[2];
  31. extern int gEliminate_faces;
  32. extern br_vector3 gZero_v__car; // suffix added to avoid duplicate symbol
  33. extern tU32 gSwitch_time;
  34. extern tSave_camera gSave_camera[2];
  35. extern tU32 gLast_mechanics_time;
  36. extern int gOpponent_viewing_mode;
  37. extern int gNet_player_to_view_index;
  38. extern int gDouble_pling_water;
  39. extern int gStop_opponents_moving;
  40. extern float gDefensive_powerup_factor[6];
  41. extern float gOffensive_powerup_factor[6];
  42. extern float gEngine_powerup_factor[6];
  43. extern br_angle gPanning_camera_angle;
  44. extern br_scalar gPanning_camera_height;
  45. extern int gFace_count;
  46. extern float gCar_simplification_factor[2][5];
  47. extern int gCar_simplification_level;
  48. extern int gNum_active_non_cars;
  49. extern int gCamera_has_collided;
  50. extern tFace_ref gFace_list__car[150]; // suffix added to avoid duplicate symbol
  51. extern tNon_car_spec* gActive_non_car_list[50];
  52. extern int gOver_shoot;
  53. extern br_scalar gMin_world_y;
  54. extern br_scalar gAccel;
  55. extern br_vector3 gAverage_grid_position;
  56. extern br_actor* gPed_actor;
  57. extern int gCollision_count;
  58. extern int gCamera_frozen;
  59. extern int gMaterial_index;
  60. extern int gInTheSea;
  61. extern int gCamera_mode;
  62. extern br_scalar gOur_yaw__car; // suffix added to avoid duplicate symbol
  63. extern br_scalar gGravity__car; // suffix added to avoid duplicate symbol
  64. extern br_vector3 gNew_ground_normal__car; // suffix added to avoid duplicate symbol
  65. extern char gNon_car_spec_list[100];
  66. extern tU32 gMechanics_time_sync;
  67. extern int gNum_cars_and_non_cars;
  68.  
  69. void DamageUnit(tCar_spec* pCar, int pUnit_type, int pDamage_amount);
  70.  
  71. void DamageUnitWithSmoke(tCar_spec* pCar, int pUnit_type, int pDamage_amount);
  72.  
  73. void DamageEngine(int pDamage_amount);
  74.  
  75. void DamageTrans(int pDamage_amount);
  76.  
  77. void DamageSteering(int pDamage_amount);
  78.  
  79. void DamageLFWheel(int pDamage_amount);
  80.  
  81. void DamageLFBrake(int pDamage_amount);
  82.  
  83. void DamageLRBrake(int pDamage_amount);
  84.  
  85. void DamageLRWheel(int pDamage_amount);
  86.  
  87. void DamageRFWheel(int pDamage_amount);
  88.  
  89. void DamageRFBrake(int pDamage_amount);
  90.  
  91. void DamageRRBrake(int pDamage_amount);
  92.  
  93. void DamageRRWheel(int pDamage_amount);
  94.  
  95. void CalculatePlaneNormal(br_vector3* pP1, br_vector3* pP2, br_vector3* pP3, br_vector3* pNormal);
  96.  
  97. void CalculateGroundNormal(br_model* pThe_model, int pFace_index);
  98.  
  99. void ChangeYCoordinate(br_scalar pNew_y, tU32 pTime_taken, br_model* pThe_model, int pFace_index);
  100.  
  101. void SwitchCarActor(tCar_spec* pCar_spec, int pModel_index);
  102.  
  103. void InitialiseCar2(tCar_spec* pCar, int pClear_disabled_flag);
  104.  
  105. void InitialiseCar(tCar_spec* pCar);
  106.  
  107. void InitialiseCarsEtc(tRace_info* pThe_race);
  108.  
  109. void GetAverageGridPosition(tRace_info* pThe_race);
  110.  
  111. void SetInitialPosition(tRace_info* pThe_race, int pCar_index, int pGrid_index);
  112.  
  113. void SetInitialPositions(tRace_info* pThe_race);
  114.  
  115. void InitialiseNonCar(tNon_car_spec* non_car);
  116.  
  117. void GetFacesInBox(tCollision_info* c);
  118.  
  119. int IsCarInTheSea(void);
  120.  
  121. void RememberSafePosition(tCar_spec* car, tU32 pTime);
  122.  
  123. void ControlOurCar(tU32 pTime_difference);
  124.  
  125. void CalcEngineForce(tCar_spec* c, br_scalar dt);
  126.  
  127. void PrepareCars(tU32 pFrame_start_time);
  128.  
  129. void FinishCars(tU32 pLast_frame_time, tU32 pTime);
  130.  
  131. void InterpolateCars(tU32 pLast_frame_time, tU32 pTime);
  132.  
  133. void ResetOldmat(void);
  134.  
  135. void GetNonCars(void);
  136.  
  137. void GetNetPos(tCar_spec* pCar);
  138.  
  139. void ApplyPhysicsToCars(tU32 last_frame_time, tU32 pTime_difference);
  140.  
  141. void MungeSpecialVolume(tCollision_info* pCar);
  142.  
  143. void ResetCarSpecialVolume(tCollision_info* pCar);
  144.  
  145. void TestAutoSpecialVolume(tCollision_info* pCar);
  146.  
  147. void MoveAndCollideCar(tCar_spec* car, br_scalar dt);
  148.  
  149. void MoveAndCollideNonCar(tNon_car_spec* non_car, br_scalar dt);
  150.  
  151. int CollideCarWithWall(tCollision_info* car, br_scalar dt);
  152.  
  153. void ToggleControls(void);
  154.  
  155. void ControlCar2(tCar_spec* c, br_scalar dt);
  156.  
  157. void ControlCar3(tCar_spec* c, br_scalar dt);
  158.  
  159. void ControlCar4(tCar_spec* c, br_scalar dt);
  160.  
  161. void ControlCar5(tCar_spec* c, br_scalar dt);
  162.  
  163. void ControlCar1(tCar_spec* c, br_scalar dt);
  164.  
  165. void setrotate(br_vector3* wdt, br_matrix34* m);
  166.  
  167. void RotateCar2(tCollision_info* c, br_scalar dt);
  168.  
  169. void RotateCarSecondOrder(tCollision_info* c, br_scalar dt);
  170.  
  171. void RotateCarFirstOrder(tCollision_info* c, br_scalar dt);
  172.  
  173. void SimpleRotate(tCollision_info* c, br_scalar dt);
  174.  
  175. void RotateCar(tCollision_info* c, br_scalar dt);
  176.  
  177. void SteeringSelfCentre(tCar_spec* c, br_scalar dt, br_vector3* n);
  178.  
  179. void NonCarCalcForce(tNon_car_spec* nc, br_scalar dt);
  180.  
  181. void AddDrag(tCar_spec* c, br_scalar dt);
  182.  
  183. void DoBumpiness(tCar_spec* c, br_vector3* wheel_pos, br_vector3* norm, br_scalar* d, int n);
  184.  
  185. void CalcForce(tCar_spec* c, br_scalar dt);
  186.  
  187. void DoRevs(tCar_spec* c, br_scalar dt);
  188.  
  189. void ApplyTorque(tCar_spec* c, br_vector3* tdt);
  190.  
  191. void TranslateCar(tCollision_info* c, br_scalar dt);
  192.  
  193. int CollCheck(tCollision_info* c, br_scalar dt);
  194.  
  195. br_scalar AddFriction(tCollision_info* c, br_vector3* vel, br_vector3* normal_force, br_vector3* pos, br_scalar total_force, br_vector3* max_friction);
  196.  
  197. void AddFrictionCarToCar(tCollision_info* car1, tCollision_info* car2, br_vector3* vel1, br_vector3* vel2, br_vector3* normal_force1, br_vector3* pos1, br_vector3* pos2, br_scalar total_force, br_vector3* max_friction);
  198.  
  199. void ScrapeNoise(br_scalar vel, br_vector3* position, int material);
  200.  
  201. void SkidNoise(tCar_spec* pC, int pWheel_num, br_scalar pV, int material);
  202.  
  203. void StopSkid(tCar_spec* pC);
  204.  
  205. void CrashNoise(br_vector3* pForce, br_vector3* position, int material);
  206.  
  207. void CrushAndDamageCar(tCar_spec* c, br_vector3* pPosition, br_vector3* pForce_car_space, tCar_spec* car2);
  208.  
  209. int ExpandBoundingBox(tCar_spec* c);
  210.  
  211. void CrushBoundingBox(tCar_spec* c, int crush_only);
  212.  
  213. void AddCollPoint(br_scalar dist, br_vector3* p, br_vector3* norm, br_vector3* r, br_vector3* n, br_vector3* dir, int num, tCollision_info* c);
  214.  
  215. br_scalar SinglePointColl(br_scalar* f, br_matrix4* m, br_scalar* d);
  216.  
  217. br_scalar TwoPointColl(br_scalar* f, br_matrix4* m, br_scalar* d, br_vector3* tau, br_vector3* n);
  218.  
  219. br_scalar DrMatrix4Inverse(br_matrix4* mi, br_matrix4* mc);
  220.  
  221. br_scalar ThreePointColl(br_scalar* f, br_matrix4* m, br_scalar* d);
  222.  
  223. br_scalar ThreePointCollRec(br_scalar* f, br_matrix4* m, br_scalar* d, br_vector3* tau, br_vector3* n, tCollision_info* c);
  224.  
  225. br_scalar FourPointColl(br_scalar* f, br_matrix4* m, br_scalar* d, br_vector3* tau, br_vector3* n, tCollision_info* c);
  226.  
  227. void MultiFindFloorInBoxM(int pNum_rays, br_vector3* a, br_vector3* b, br_vector3* nor, br_scalar* d, tCar_spec* c, int* mat_ref);
  228.  
  229. void MultiFindFloorInBoxBU(int pNum_rays, br_vector3* a, br_vector3* b, br_vector3* nor, br_scalar* d, tCar_spec* c, int* mat_ref);
  230.  
  231. void findfloor(br_vector3* a, br_vector3* b, br_vector3* nor, br_scalar* d);
  232.  
  233. int FindFloorInBoxM(br_vector3* a, br_vector3* b, br_vector3* nor, br_scalar* d, tCollision_info* c);
  234.  
  235. int FindFloorInBoxBU(br_vector3* a, br_vector3* b, br_vector3* nor, br_scalar* d, tCollision_info* c);
  236.  
  237. int FindFloorInBoxBU2(br_vector3* a, br_vector3* b, br_vector3* nor, br_scalar* d, tCollision_info* c);
  238.  
  239. int FindFloorInBoxM2(br_vector3* a, br_vector3* b, br_vector3* nor, br_scalar* d, tCollision_info* c);
  240.  
  241. int BoxFaceIntersect(br_bounds* pB, br_matrix34* pM, br_matrix34* pMold, br_vector3* pPoint_list, br_vector3* pNorm_list, br_scalar* pDist_list, int pMax_pnts, tCollision_info* c);
  242.  
  243. int AddEdgeCollPoints(br_vector3* p1, br_vector3* p2, br_bounds* pB, br_matrix34* pMold, br_vector3* pPoint_list, br_vector3* pNorm_list, int n, int pMax_pnts, tCollision_info* c);
  244.  
  245. void GetPlaneNormal(br_vector3* n, int p);
  246.  
  247. int GetBoundsEdge(br_vector3* pos, br_vector3* edge, br_bounds* pB, int plane1, int plane2, br_vector3* a, br_vector3* b, br_vector3* c, int flag);
  248.  
  249. void oldMoveOurCar(tU32 pTime_difference);
  250.  
  251. void ToggleCollisionDetection(void);
  252.  
  253. void CancelPendingCunningStunt(void);
  254.  
  255. float frac(float pN);
  256.  
  257. void SetAmbientPratCam(tCar_spec* pCar);
  258.  
  259. void MungeCarGraphics(tU32 pFrame_period);
  260.  
  261. void ResetCarScreens(void);
  262.  
  263. tCar_spec* GetRaceLeader(void);
  264.  
  265. void AmIGettingBoredWatchingCameraSpin(void);
  266.  
  267. void ViewNetPlayer(void);
  268.  
  269. void ViewOpponent(void);
  270.  
  271. void ToggleCarToCarCollisions(void);
  272.  
  273. void SwapCar(void);
  274.  
  275. void AdjustDownForce(void);
  276.  
  277. void FreezeMechanics(void);
  278.  
  279. void PutOpponentsInNeutral(void);
  280.  
  281. void SetPanningFieldOfView(void);
  282.  
  283. void CheckDisablePlingMaterials(tCar_spec* pCar);
  284.  
  285. void PositionExternalCamera(tCar_spec* c, tU32 pTime);
  286.  
  287. void CameraBugFix(tCar_spec* c, tU32 pTime);
  288.  
  289. int PossibleRemoveNonCarFromWorld(br_actor* pActor);
  290.  
  291. void PutNonCarBackInWorld(br_actor* pActor);
  292.  
  293. int IncidentCam(tCar_spec* c, tU32 pTime);
  294.  
  295. int MoveCamToIncident(tCar_spec* c, tIncident_type* type, float* severity, tIncident_info* info, tU32* next_incident_time);
  296.  
  297. void PanningExternalCamera(tCar_spec* c, tU32 pTime);
  298.  
  299. int CheckForWall(br_vector3* start, br_vector3* end);
  300.  
  301. void SetUpPanningCamera(tCar_spec* c);
  302.  
  303. void SaveCameraPosition(int i);
  304.  
  305. void RestoreCameraPosition(int i);
  306.  
  307. void NormalPositionExternalCamera(tCar_spec* c, tU32 pTime);
  308.  
  309. void MoveWithWheels(tCar_spec* c, br_vector3* vn, int manual_swing);
  310.  
  311. void SwingCamera(tCar_spec* c, br_matrix34* m1, br_matrix34* m2, br_vector3* vn, tU32 pTime);
  312.  
  313. void PointCameraAtCar(tCar_spec* c, br_matrix34* m1, br_matrix34* m2);
  314.  
  315. void PointCamera(br_vector3* pos, br_matrix34* m2);
  316.  
  317. int CollideCamera2(br_vector3* car_pos, br_vector3* cam_pos, br_vector3* old_camera_pos, int manual_move);
  318.  
  319. int BoundsTest(br_bounds* bnds, br_vector3* p);
  320.  
  321. int CollideCameraWithOtherCars(br_vector3* car_pos, br_vector3* cam_pos);
  322.  
  323. void InitialiseExternalCamera(void);
  324.  
  325. void FreezeCamera(void);
  326.  
  327. void FlyCar(tCar_spec* c, br_scalar dt);
  328.  
  329. void DrVector3RotateY(br_vector3* v, br_angle t);
  330.  
  331. void CrashCarsTogether(br_scalar dt);
  332.  
  333. int CrashCarsTogetherSinglePass(br_scalar dt, int pPass, tCollison_data* collide_list);
  334.  
  335. void BringCarToAGrindingHalt(tCollision_info* car);
  336.  
  337. int BoundsOverlapTest_car(br_bounds* b1, br_bounds* b2);
  338.  
  339. int SimpleCarCarCollisionTest(tCollision_info* car1, tCollision_info* car2);
  340.  
  341. int CollideTwoCarsWithWalls(tCollision_info* car1, tCollision_info* car2, br_scalar dt);
  342.  
  343. int CollideTwoCarsRepeatedly(tCollision_info* car1, tCollision_info* car2, br_scalar dt);
  344.  
  345. int CollideTwoCars(tCollision_info* car1, tCollision_info* car2, int pPass);
  346.  
  347. int GetEdgeEdgeCollisions(br_bounds* pB1, br_bounds* pB2, br_matrix34* pM21, br_matrix34* pM12, br_matrix34* pMo21, br_matrix34* pMo12, br_matrix34* pM1o1, br_vector3* pPoint_list, br_vector3* pNorm_list, int pMax);
  348.  
  349. int FacePointCarCarCollide(tCollision_info* car1, tCollision_info* car2, br_matrix34* pMms, br_matrix34* pMoms, br_matrix34* pMsos, br_vector3* pPoint_list, br_vector3* pNorm_list, int pMax, int order);
  350.  
  351. void MungeCarsMass(tCollision_info* pCar, br_scalar pFactor);
  352.  
  353. void ModifyCarsMass(tCollision_info* pCar_1, tCollision_info* pCar_2);
  354.  
  355. void ResetCarsMass(tCollision_info* pCar_1, tCollision_info* pCar_2);
  356.  
  357. int DoCollide(tCollision_info* car1, tCollision_info* car2, br_vector3* r, br_vector3* n, int k, int pPass, br_matrix34* mat1_to_mat2);
  358.  
  359. br_scalar TwoPointCollB(br_scalar* f, br_matrix4* m, br_scalar* d, br_vector3* tau, br_vector3* n);
  360.  
  361. br_scalar ThreePointCollRecB(br_scalar* f, br_matrix4* m, br_scalar* d, br_vector3* tau, br_vector3* n);
  362.  
  363. br_scalar FourPointCollB(br_scalar* f, br_matrix4* m, br_scalar* d, br_vector3* tau, br_vector3* n);
  364.  
  365. int TestForNan(float* f);
  366.  
  367. void CheckCameraHither(void);
  368.  
  369. void SetCarSuspGiveAndHeight(tCar_spec* pCar, br_scalar pFront_give_factor, br_scalar pRear_give_factor, br_scalar pDamping_factor, br_scalar pExtra_front_height, br_scalar pExtra_rear_height);
  370.  
  371. int TestForCarInSensiblePlace(tCar_spec* car);
  372.  
  373. int TestOldMats(tCollision_info* c1, tCollision_info* c2, int newmats);
  374.  
  375. int PullActorFromWorld(br_actor* pActor);
  376.  
  377. int DoPullActorFromWorld(br_actor* pActor);
  378.  
  379. void CheckForDeAttachmentOfNonCars(tU32 pTime);
  380.  
  381. void AdjustNonCar(br_actor* pActor, br_matrix34* pMat);
  382.  
  383. void PipeSingleNonCar(tCollision_info* c);
  384.  
  385. int GetPrecalculatedFacesUnderCar(tCar_spec* pCar, tFace_ref** pFace_refs);
  386.  
  387. br_material* SomeNearbyMaterial(void);
  388.  
  389. #endif
  390.