1 /***************************************************************************
2 						movement.h  -  description
3 							-------------------
4 	begin                : may 16th, 2004
5 	copyright            : (C) 2004-2007 by Duong Khang NGUYEN
6 	email                : neoneurone @ gmail com
7 
8 	$Id: movement.h 375 2008-10-28 14:47:15Z neoneurone $
9  ***************************************************************************/
10 
11 /***************************************************************************
12  *                                                                         *
13  *   This program is free software; you can redistribute it and/or modify  *
14  *   it under the terms of the GNU General Public License as published by  *
15  *   the Free Software Foundation; either version 2 of the License, or     *
16  *   any later version.                                                    *
17  *                                                                         *
18  ***************************************************************************/
19 
20 #ifndef _OPENCITY_MOVEMENT_H_
21 #define _OPENCITY_MOVEMENT_H_ 1
22 
23 #include "main.h"
24 #include "destination.h"
25 
26 #include <vector>
27 
28 using std::vector;
29 
30 
31 //========================================================================
32 /** This is a base class for everything that can move in OpenCity. It
33 	contains general informations about the current OC W, H coordinates
34 	of the moving (or not) object and a path which is a vector of
35 	"Destination" objects
36 */
37 class Movement {
38 public:
39 	Movement();
40 	virtual ~Movement();
41 
42 
43 //========================================================================
44 /** Tell the object to move
45 	\return True if the object has moved successfully, false otherwise
46 */
47 	virtual const bool
48 	Move() = 0;
49 
50 
51 //========================================================================
52 /** Initialize the movement. It should be called before any call to
53 the Move() method
54 	\sa Move()
55 */
56 	virtual void
57 	Start() = 0;
58 
59 	void
60 	SetPath( vector<Destination> newPath );
61 
62 	const OPENCITY_GRAPHIC_CODE &
63 	GetGraphicCode() const;
64 
65 
66 //========================================================================
67 /** Set the rotation of the model according to the destination's direction.
68 This method also sets the compensation translation vector in order to help
69 the GraphicManager render method to make a "in place" rotation
70 	\param rcD The destination object
71 	\see GraphicManager::Display()
72 */
73 	void
74 	SetAngle( const Destination & rcD );
75 
76 
77 //========================================================================
78 /** Set the slope of the model. It shoulds be called after a call to
79 SetAngle()
80 	\see GraphicManager::Display()
81 	\see SetAngle()
82 */
83 	void
84 	SetSlope(
85 		const Destination & rcA,
86 		const Destination & rcB );
87 
88 
89 public:
90 	OC_FLOAT _fCurrentW;			///< current OC W, L, H coordinates
91 	OC_FLOAT _fCurrentL;
92 	OC_FLOAT _fCurrentH;
93 	OC_FLOAT _fDeltaW;				///< W, L, H variations for next destination
94 	OC_FLOAT _fDeltaL;
95 	OC_FLOAT _fDeltaH;
96 
97 	GLfloat _fRY;					///< The model's rotation angle
98 	GLfloat _fRX, _fRZ;				///< The model's X and Z rotation slope
99 	GLfloat _fTX, _fTY, _fTZ;		///< The rotation compensation translation vector
100 
101 protected:
102 	OPENCITY_DIRECTION		_eDir;	///< Last vehicle direction. According to the graphic code convention, it's OC_DIR_S by default
103 	OPENCITY_GRAPHIC_CODE	_eGC;	///< Vehicle's graphic code
104 
105 	uint uiCurrentTime;				///< current number of times that we've moved so far into the current direction
106 	int iCurrentSpeed;
107 	uint uiNumberOfFrame;			///< Number of frames counted till now
108 	uint uiFramePerUnit;			///< Number of frames to count before going to next W/H coordinates
109 	vector<Destination> vdest;		///< this contains a path that this movement follows
110 	uint uiCurrentIndex;			///< point to the current destination
111 	Destination destCurrent;		///< current copy of vdest[ uiCurrentIndex ]
112 };
113 
114 #endif
115 
116 
117 
118 
119 
120 
121 
122 
123 
124 
125 
126 
127 
128 
129 
130 
131 
132 
133 
134 
135 
136 
137 
138 
139 
140 
141 
142 
143 
144 
145 
146 
147