1 #ifndef _dynblock_h_ /* Is this your first time? */ 2 #define _dynblock_h_ 1 3 4 /*KJL**************************************************************************************** 5 * S T R U C T U R E S * 6 ****************************************************************************************KJL*/ 7 enum DYN_TYPE 8 { 9 DYN_TYPE_NO_COLLISIONS, 10 DYN_TYPE_SPRITE_COLLISIONS, 11 DYN_TYPE_SPHERE_COLLISIONS, 12 DYN_TYPE_NRBB_COLLISIONS, 13 DYN_TYPE_CUBOID_COLLISIONS, 14 }; 15 16 enum TOPPLE_FORCE 17 { 18 TOPPLE_FORCE_NONE, 19 TOPPLE_FORCE_ALIEN, 20 TOPPLE_FORCE_FULL 21 }; 22 23 /* KJL 17:19:14 11/05/96 - my 'dynamicsblock'. I'll use the enginesque lower/upper case naming convention */ 24 typedef struct dynamicsblock 25 { 26 /* representations of orientation of object */ 27 EULER OrientEuler; /* Euler Orientation */ 28 MATRIXCH OrientMat; /* Local -> World Orientation Matrix */ 29 EULER PrevOrientEuler; /* Euler Orientation */ 30 MATRIXCH PrevOrientMat; /* Local -> World Orientation Matrix */ 31 32 /* position in World Space (units mm) */ 33 VECTORCH Position; 34 VECTORCH PrevPosition; 35 36 /* component of velocity (in World Space, units mm per sec) due to internal forces 37 eg. a player walking forward, a rocket's thrust - set by strategies */ 38 VECTORCH LinVelocity; 39 /* component of velocity (in World Space, units mm per sec) due to external forces 40 eg. gravity, explosions, jumping - set by dynamics system & strategies */ 41 VECTORCH LinImpulse; 42 43 /* angular velocity in World Space */ 44 EULER AngVelocity; 45 /* rotational effects due to external forces */ 46 EULER AngImpulse; 47 48 /* pointer to report(s) on last frame's collisions (singly-linked list) */ 49 struct collisionreport *CollisionReportPtr; 50 51 /* object's normalised gravity vector - used if UseStandardGravity is set to false */ 52 VECTORCH GravityDirection; 53 int TimeNotInContactWithFloor; 54 55 /* physical constants */ 56 int Friction; /* difficult to set a scale as yet */ 57 int Elasticity; /* 0 = perfectly inelastic, 65536 = perfectly elastic */ 58 int Mass; /* integer in kg */ 59 60 /* collision flags */ 61 /* eg. can go up steps, cuboid model etc */ 62 63 enum DYN_TYPE DynamicsType; 64 enum TOPPLE_FORCE ToppleForce; 65 66 unsigned int GravityOn :1; 67 unsigned int UseStandardGravity :1; /* ie. in direction of increasing Y */ 68 unsigned int StopOnCollision :1; /* eg. missiles stop as soon as bthey hit something; players don't */ 69 unsigned int CanClimbStairs :1; 70 unsigned int IsStatic :1; 71 unsigned int OnlyCollideWithObjects :1; 72 unsigned int IsNetGhost :1; 73 unsigned int IgnoreSameObjectsAsYou :1; /* don't collide with objects which have the same behaviour type */ 74 unsigned int IgnoreThePlayer :1; 75 unsigned int UseDisplacement :1; 76 unsigned int OnlyCollideWithEnvironment :1; 77 78 unsigned int IsInContactWithFloor :1; 79 unsigned int IsInContactWithNearlyFlatFloor :1; 80 unsigned int RequestsToStandUp :1; 81 unsigned int IsFloating :1; 82 unsigned int IsPickupObject :1; 83 unsigned int IsInanimate :1; 84 unsigned int IgnoresNotVisPolys :1; 85 86 87 /* FOR INTERNAL USE ONLY */ 88 int CollisionRadius; 89 int DistanceLeftToMove; 90 VECTORCH Displacement; 91 VECTORCH ObjectVertices[8]; /* vertices of the cuboid which describes the object */ 92 93 } DYNAMICSBLOCK; 94 95 96 enum DYNAMICS_TEMPLATE_ID 97 { 98 DYNAMICS_TEMPLATE_MARINE_PLAYER, 99 DYNAMICS_TEMPLATE_ALIEN_NPC, 100 DYNAMICS_TEMPLATE_GRENADE, 101 DYNAMICS_TEMPLATE_ROCKET, 102 DYNAMICS_TEMPLATE_DEBRIS, 103 DYNAMICS_TEMPLATE_STATIC, 104 DYNAMICS_TEMPLATE_INANIMATE, 105 DYNAMICS_TEMPLATE_PICKUPOBJECT, 106 DYNAMICS_TEMPLATE_SPRITE_NPC, 107 DYNAMICS_TEMPLATE_STATIC_SPRITE, 108 DYNAMICS_TEMPLATE_PLATFORM_LIFT, 109 DYNAMICS_TEMPLATE_ALIEN_DEBRIS, 110 DYNAMICS_TEMPLATE_ACID_SMOKE, 111 DYNAMICS_TEMPLATE_NET_GHOST, 112 113 MAX_NO_OF_DYNAMICS_TEMPLATES 114 }; 115 116 typedef struct collisionreport 117 { 118 /* strategy block of whatever you've hit - this is null if you've hit the landscape */ 119 struct strategyblock *ObstacleSBPtr; 120 121 /* the normal of the obstacle's face which you've hit */ 122 VECTORCH ObstacleNormal; 123 VECTORCH ObstaclePoint; 124 125 /* ptr to the next report, null if there isn't one */ 126 struct collisionreport *NextCollisionReportPtr; 127 128 } COLLISIONREPORT; 129 130 #define MAX_NO_OF_DYNAMICS_BLOCKS maxstblocks 131 #define MAX_NO_OF_COLLISION_REPORTS 400 132 /*KJL**************************************************************************************** 133 * P R O T O T Y P E S * 134 ****************************************************************************************KJL*/ 135 extern void InitialiseDynamicsBlocks(void); 136 extern DYNAMICSBLOCK* AllocateDynamicsBlock(enum DYNAMICS_TEMPLATE_ID templateID); 137 extern void DeallocateDynamicsBlock(DYNAMICSBLOCK *dynPtr); 138 139 extern void InitialiseCollisionReports(void); 140 extern COLLISIONREPORT* AllocateCollisionReport(DYNAMICSBLOCK* dynPtr); 141 142 #endif /* end of preprocessor condition for file wrapping */ 143