Car.h

Go to the documentation of this file.
00001 
00005 /* Copyright © 2009, 2010 James Legg.
00006     This program is free software: you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation, either version 3 of the License, or
00009     (at your option) any later version.
00010 */
00011 #ifndef CAR_H_
00012 #define CAR_H_
00013 
00014 #include <btBulletDynamicsCommon.h>
00015 
00016 #include <libtrack/AABBDrawable.h>
00017 #include <libtrack/Texture.h>
00018 #include <libtrack/Mesh/BulletMesh.h>
00019 #include <libtrack/NearTrack.h>
00020 
00021 #include "../Physics/World.h"
00022 #include "../Physics/TickObserver.h"
00023 #include "../InputReport.h"
00024 #include "../Audio.h"
00025 
00026 namespace Engine
00027 {
00028     class InputDevice;
00029 
00031 namespace GameObjects
00032 {
00033 
00036 class Car
00037     :   public Track::AABBDrawable
00038     ,   public Physics::TickObserver
00039     ,   private Track::NearTrack 
00040 {
00041     Car(Car & car);
00042     Car & operator=(Car & car);
00043 public:
00045     const static unsigned int NUM_SENSORS_FEELERS = 8;
00047     const static unsigned int NUM_FEELER_PROPERTIES = Track::SENSOR_COUNT;
00049     const static unsigned int NUM_SENSORS = NUM_SENSORS_FEELERS * NUM_FEELER_PROPERTIES + 14;
00050     
00061     Car(Physics::World & world, btTransform start, InputDevice * input_device,
00062         unsigned int car_model, const btVector3 & plane_normal,
00063         const btScalar & plane_distance, const btVector3 & start_point);
00064     virtual ~Car();
00065     virtual void draw() const;
00066     virtual Track::AxisAlignedBoundingBox get_bounds() const;
00067     
00069     void take_input(InputReport & report);
00070     
00072     virtual void set_forces();
00073     
00075     virtual void posttick();
00076     
00077     void get_transform(btTransform & transform);
00078     
00080     signed int get_lap();
00081     
00083     unsigned long int get_last_lap_ticks();
00084     
00086     unsigned long int get_best_lap_ticks();
00087     
00089     btScalar get_speed();
00090     
00092     btScalar get_lap_distance() const;
00093     
00095     bool get_finished() const;
00097     bool get_disqualified() const;
00102     unsigned long int get_finish_time() const;
00103     
00109     int get_facing_backwards() const;
00110     
00114     btScalar get_camera_height() const;
00115     
00122     void get_sensors(float results[NUM_SENSORS]) const;
00123 private:
00124     // graphical representation
00125     Track::Texture *texture;
00126     Track::BulletMesh *mesh;
00128     Track::Texture *flame_texture;
00130     Track::BulletMesh *flame_mesh;
00131     // physical representation
00132     Physics::World & world;
00133     btRigidBody * rigid_body;
00134     InputDevice * input_device;
00135     btVector3 force, torque, local_force, local_torque;
00136     
00139     bool floor_stick;
00140     
00142     unsigned int car_model;
00143     
00145     signed int lap;
00147     signed int max_lap;
00149     unsigned long int lap_start_ticks;
00151     unsigned long int last_lap_ticks;
00153     unsigned long int best_lap_ticks;
00154     
00156     bool infront_of_start;
00157     
00158     const btVector3 & plane_normal;
00159     const btScalar & plane_distance;
00160     const btVector3 & start_point;
00161     
00163     btScalar elastic_potential_energy;
00165     btScalar tick_energy_absorbed;
00167     btScalar used_energy_boost;
00168     
00170     unsigned int boost_timer;
00171     
00173     bool m_course_complete; 
00175     unsigned long int m_course_complete_time;
00180     bool m_removed;
00181     
00183     btTransform m_last_transform;
00184     
00186     void remove();
00187     
00189     boost::shared_ptr<SoundSource> m_engine_sound_source;
00191     boost::shared_ptr<SoundSource> m_drag_sound_source;
00193     boost::shared_ptr<SoundSource> m_break_sound_source;
00195     boost::shared_ptr<SoundSource> m_boost_sound_source;
00197     boost::shared_ptr<SoundSource> m_release_energy_sound_source;
00199     boost::shared_ptr<SoundSource> m_slide_sound_source;
00200     
00202     void update_sounds();
00203 };
00204 
00205 }
00206 
00207 }
00208 
00209 #endif /*CAR_H_*/

Get Racer at SourceForge.net. Fast, secure and Free Open Source software downloads

Generated at Mon Sep 6 00:41:12 2010 by Doxygen version 1.4.7 for Racer version svn335.