00001 #include <vamos/geometry/Gl_Texture_Image.h>
00002 #include <vamos/geometry/Three_Vector.h>
00003 #include <vamos/geometry/Two_Point.h>
00004
00005 #include <GL/gl.h>
00006
00007 #include <vector>
00008
00009 namespace Vamos_Body
00010 {
00011 class Facade : public Vamos_Geometry::Gl_Texture_Image
00012 {
00013 double m_x;
00014 double m_y;
00015 double m_above;
00016 double m_width;
00017 double m_height;
00018 GLuint m_list_index;
00019
00020 void build_facade ();
00021 void build_image ();
00022
00023 public:
00024 Facade (double x, double y, double above, double width, double height,
00025 std::string image);
00026
00027 Facade (double center_x, double center_y, double above, double radius,
00028 std::string image);
00029
00030 void rotate (double degrees) const;
00031 virtual void draw () const;
00032 };
00033
00034 class Scaler
00035 {
00036 double m_minimum_input;
00037 double m_maximum_input;
00038 double m_offset;
00039 double m_factor;
00040
00041 public:
00042 Scaler (double min_in, double min_out, double max_in, double max_out);
00043 double scale (double value_in);
00044 };
00045
00046 class Steering_Wheel : public Facade
00047 {
00048 double m_center_x;
00049 double m_center_y;
00050 double m_angle;
00051 Scaler m_scaler;
00052
00053 public:
00054 Steering_Wheel (double center_x, double center_y, double above,
00055 double radius, double min, double min_angle,
00056 double max, double max_angle,
00057 std::string image);
00058
00059 void set (double value);
00060 void draw () const;
00061 };
00062
00063 class Gauge
00064 {
00065 protected:
00066 bool m_on_steering_wheel;
00067
00068 public:
00069 Gauge () : m_on_steering_wheel (false) {};
00070 virtual ~Gauge () {};
00071 virtual void set (double value) = 0;
00072 virtual void draw () const = 0;
00073 bool on_steering_wheel () const { return m_on_steering_wheel; }
00074 };
00075
00076 class Dial : public Gauge
00077 {
00078 double m_above;
00079 Scaler m_scaler;
00080
00081 Facade* mp_face;
00082 Facade* mp_needle;
00083
00084 protected:
00085 double m_center_x;
00086 double m_center_y;
00087 double m_angle;
00088
00089 public:
00090 Dial (double center_x, double center_y, double above, double radius,
00091 double min, double min_angle, double max, double max_angle,
00092 std::string face_image, std::string needle_image);
00093
00094 ~Dial ();
00095
00096 void set (double value);
00097 void draw () const;
00098
00099
00100 };
00101
00102 class LED_Gauge : public Gauge
00103 {
00104 double m_x;
00105 double m_y;
00106 double m_above;
00107 double m_width;
00108 double m_height;
00109 int m_elements;
00110 double m_min;
00111 double m_range;
00112
00113 int m_leds_on;
00114
00115 Vamos_Geometry::Gl_Texture_Image* mp_leds;
00116
00117 GLuint m_list_index;
00118
00119 public:
00120 LED_Gauge (double x, double y, double above, double width, int elements,
00121 double min, double redline, std::string image, bool on_wheel);
00122 ~LED_Gauge ();
00123
00124 void set (double value);
00125 void draw () const;
00126 };
00127
00128 class Digital_Gauge : public Gauge
00129 {
00130 double m_x;
00131 double m_y;
00132 double m_above;
00133 double m_width;
00134 double m_height;
00135 size_t m_places;
00136
00137 std::vector <int> m_digits;
00138
00139 Vamos_Geometry::Gl_Texture_Image* mp_digits;
00140
00141 public:
00142 Digital_Gauge (double x, double y, double above,
00143 double width, double height, size_t places,
00144 std::string digits, bool on_wheel);
00145 ~Digital_Gauge ();
00146
00147 void set (double value);
00148 void draw () const;
00149 };
00150
00151
00152 class Gear_Indicator
00153 {
00154 bool m_on_steering_wheel;
00155
00156 double m_number_width;
00157
00158 Vamos_Geometry::Gl_Texture_Image* mp_numbers;
00159
00160 protected:
00161 double m_x;
00162 double m_y;
00163 double m_above;
00164 double m_width;
00165 double m_height;
00166 int m_gear;
00167
00168 public:
00169 Gear_Indicator (double x, double y, double above,
00170 double width, double height,
00171 int numbers, std::string image, bool on_wheel);
00172 ~Gear_Indicator ();
00173
00174 virtual void set (int gear) { m_gear = gear; }
00175 virtual void draw () const;
00176 bool on_steering_wheel () const { return m_on_steering_wheel; }
00177 };
00178
00179
00180 class Gear_Shift : public Gear_Indicator
00181 {
00182 double m_stick_width;
00183 double m_stick_height;
00184
00185 Vamos_Geometry::Three_Vector m_rotation;
00186 std::vector <Vamos_Geometry::Two_Point> m_positions;
00187 int m_top_gear;
00188
00189 Vamos_Geometry::Gl_Texture_Image* mp_gate;
00190 Vamos_Geometry::Gl_Texture_Image* mp_stick;
00191
00192 GLuint m_list_index;
00193
00194 public:
00195 Gear_Shift (double x, double y, double z, double width, double height,
00196 const Vamos_Geometry::Three_Vector& rotation,
00197 const std::vector <Vamos_Geometry::Two_Point>& positions,
00198 std::string gate_image, std::string stick_image);
00199 ~Gear_Shift ();
00200
00201 void set (int gear);
00202 void draw () const;
00203 };
00204
00205
00206 class Dashboard
00207 {
00208 double m_x;
00209 double m_y;
00210 double m_z;
00211 double m_tilt;
00212
00213 Gauge* mp_tachometer;
00214 Gauge* mp_speedometer;
00215 Gauge* mp_fuel_gauge;
00216 Gear_Indicator* mp_gear_indicator;
00217 Steering_Wheel* mp_steering_wheel;
00218 std::vector <Facade*> ma_facades;
00219
00220 public:
00221 Dashboard (double x, double y, double z, double tilt);
00222 ~Dashboard ();
00223
00224 void add_tachometer (Gauge* tachometer);
00225 void add_speedometer (Gauge* speedometer);
00226 void add_fuel_gauge (Gauge* fuel_gauge);
00227 void add_gear_indicator (Gear_Indicator* gear_indicator);
00228 void add_steering_wheel (Steering_Wheel* steering_wheel);
00229 void add_facade (Facade* facade);
00230
00231 void set_tachometer (double rpm);
00232 void set_speedometer (double speed);
00233 void set_fuel_gauge (double fuel);
00234 void set_gear_indicator (int gear);
00235 void set_steering_wheel (double angle);
00236
00237 void draw () const;
00238 };
00239 }