1 /***************************************************************************
2  *   Copyright (C) 2004 by Murray Evans                                    *
3  *   m.evans@rdg.ac.uk                                                     *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20 #ifndef SCENE_ENTITY_BASE
21 #define SCENE_ENTITY_BASE
22 /********************************************************************
23  *							     Dazzle								*
24  *							Base entity class						*
25  *																	*
26  *							   Murray Evans							*
27  ********************************************************************/
28 #include "Matlib.h"		// header file for matrix library
29 #include "DynArray.h"
30 #include <string>
31 #include <vector>
32 using namespace std;
33 class CEntity
34 {
35 public:
36 	CEntity(void);
37 	virtual ~CEntity(void);
38 	virtual void PrepareForDestruction();
39 protected:
40 	CVec4f				pos_v4f;		// position vector
41 	CVec3f				rot_v3f;		// axis rotations (orientation)
42 	CVec4f				vel_v4f;		// Velocity vector
43 	CVec3f				rv_v3f;			// axis velocities
44 	CDynArray<CEntity*>	sub_ents;		// sub-entities
45 
46 public:
47 	// Set translation from world origin
48 	void SetPos(float in_X_f, float in_Y_f, float in_Z_f);
49 	// Set the velocity vector using x, y, z
50 	void SetVelocity(float in_Xvel_f, float in_Yvel_f, float in_Zvel_f);
51 	// Set the velocity vector using a vec4f
52 	void SetPos(CVec4f in_v4f);
53 
54 	// Set rotation of entity by axis rotations (x,y,z)
55 	void SetRotation(float in_Xrot_f, float in_Yrot_f, float in_Zrot_f);
56 	// Set rotational velocity of entity by axis (x,y,z)
57 	void SetRotVel(float in_Xrot_f, float in_Yrot_f, float in_Zrot_f);
58 	CVec3f GetRotVel();
59 	// return x position
60 	float X(void);
61 	// return y position
62 	float Y(void);
63 	// return z position
64 	float Z(void);
65 	// return x rotation
66 	float XRot(void);
67 	// return y rotation
68 	float YRot(void);
69 	// return z rotation
70 	float ZRot(void);
71 	// put position data into the array pointed to by io_paf. Array should be float[3] for (x,y,z)
72 	void GetPos(float* io_paf);
73 	// return vec4f of position data
74 	CVec4f GetPos();
75 	// get velocity vector
76 	CVec4f GetVelocity();
77 	// Rendering function. Mostly it will be more evolved entities which actually have anythin happen here
78 	virtual void Render(void);
79 	// an update function
80 	virtual void Update(void);
81 };
82 
83 
84 #endif
85