-
Notifications
You must be signed in to change notification settings - Fork 1
/
SceneObject.h
executable file
·123 lines (93 loc) · 4.19 KB
/
SceneObject.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// ************************************************************************
//
// File: SceneObject.h
// Programmer: T.J. Eason
// Project: Game Engine
// Description: Generate objects within a 3D scene
// Date: 3-30-10
// Revision 1: 4-2-10
//
// *************************************************************************
#ifndef SCENE_OBJECT_H
#define SCENE_OBJECT_H
#define TYPE_SCENE_OBJECT 0
// Scene Object Class
class SceneObject : public BoundVolume
{
public:
SceneObject( unsigned long type = TYPE_SCENE_OBJECT, char *meshName = NULL, char *meshPath = "./", bool sharedMesh = true );
virtual ~SceneObject();
virtual void Update( float elapsed, bool addVelocity = true );
virtual void Render( D3DXMATRIX *world = NULL );
virtual void CollisionOccurred( SceneObject *object, unsigned long collisionStamp );
void Drive( float force, bool lockYAxis = true );
void Strafe( float force, bool lockYAxis = true );
void Jump( float force );
void Stop();
void SetTranslation( float x, float y, float z );
void SetTranslation( D3DXVECTOR3 translation );
void AddTranslation( float x, float y, float z );
void AddTranslation( D3DXVECTOR3 translation );
D3DXVECTOR3 GetTranslation();
void SetRotation( float x, float y, float z );
void SetRotation( D3DXVECTOR3 rotation );
void AddRotation( float x, float y, float z );
void AddRotation( D3DXVECTOR3 rotation );
D3DXVECTOR3 GetRotation();
void SetVelocity( float x, float y, float z );
void SetVelocity( D3DXVECTOR3 velocity );
void AddVelocity( float x, float y, float z );
void AddVelocity( D3DXVECTOR3 velocity );
D3DXVECTOR3 GetVelocity();
void SetSpin( float x, float y, float z );
void SetSpin( D3DXVECTOR3 spin );
void AddSpin( float x, float y, float z );
void AddSpin( D3DXVECTOR3 spin );
D3DXVECTOR3 GetSpin();
D3DXVECTOR3 GetForwardVector();
D3DXVECTOR3 GetRightVector();
D3DXMATRIX *GetTranslationMatrix();
D3DXMATRIX *GetRotationMatrix();
D3DXMATRIX *GetWorldMatrix();
D3DXMATRIX *GetViewMatrix();
void SetType( unsigned long type );
unsigned long GetType();
void SetFriction( float friction );
unsigned long GetCollisionStamp();
void SetVisible( bool visible );
bool GetVisible();
void SetEnabled( bool enabled );
bool GetEnabled();
void SetGhost( bool ghost );
bool GetGhost();
void SetIgnoreCollisions( bool ignoreCollisions );
bool GetIgnoreCollisions();
void SetTouchingGroundFlag( bool touchingGround );
bool IsTouchingGround();
void SetMesh( char *meshName = NULL, char *meshPath = "./", bool sharedMesh = true );
Mesh *GetMesh();
protected:
D3DXVECTOR3 m_forward; // Object's forward vector.
D3DXVECTOR3 m_right; // Object's right vector.
D3DXVECTOR3 m_upward; // Object's upward vector
D3DXMATRIX m_worldMatrix; // World matrix.
D3DXMATRIX m_viewMatrix; // View matrix.
private:
D3DXVECTOR3 m_translation; // Object's translation in 3D space.
D3DXVECTOR3 m_rotation; // Object's rotation in radians.
D3DXVECTOR3 m_velocity; // Object's velocity in units/second.
D3DXVECTOR3 m_spin; // Object's spin in radians/second.
D3DXMATRIX m_translationMatrix; // Translation matrix.
D3DXMATRIX m_rotationMatrix; // Rotation matrix.
unsigned long m_type; // Identifies the scene object's parent class.
float m_friction; // Friction applied to the object's velocity and spin.
unsigned long m_collisionStamp; // Indicates the last frame when a collision occurred.
bool m_visible; // Indicates it the object is visible. Invisible objects are not rendered.
bool m_enabled; // Indicates if the object is enabled. Disabled objects are not updated.
bool m_ghost; // Indicates if the object is a ghost. Ghost objects cannot physically collide with anything.
bool m_ignoreCollisions; // Indicates if the object is to ignore collisions. Physical collisions can still occur, they're just not registered.
bool m_touchingGround; // Indicates if the object is touching the ground.
bool m_sharedMesh; // Indicates if the object is sharing the mesh or has exclusive access.
Mesh *m_mesh; // Pointer to the object's mesh.
};
#endif