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