include/vamosworld.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *            vamosworld.h
00003  *
00004  *  Sat Mar 26 14:05:40 2005
00005  *  Copyright  2005  Joe Venzon
00006  *  joe@venzon.net
00007  ****************************************************************************/
00008 
00009 /*
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License
00021  *  along with this program; if not, write to the Free Software
00022  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00023  */
00024  
00025 #ifndef _VAMOSWORLD_H
00026 
00027 #include <stdio.h>                      // Header File For Standard Input/Output
00028 #include <GL/gl.h>
00029 #include <GL/glu.h>
00030 #include <SDL/SDL.h>
00031 #ifdef __APPLE__
00032 #include <SDL_image/SDL_image.h>
00033 #else
00034 #include <SDL/SDL_image.h>
00035 #endif
00036 #include <string>
00037 #include <iostream>
00038 #include <fstream>
00039 #include <cmath>
00040 #include <cassert>
00041 
00042 using namespace std;
00043 
00044 #include "font.h"
00045 #include "quat.h"
00046 #include "keyman.h"
00047 #include "camera.h"
00048 #include "particles.h"
00049 #include "messageq.h"
00050 #include "sound.h"
00051 #include "timer.h"
00052 #include "controls.h"
00053 #include "replay.h"
00054 #include "mouse.h"
00055 #include "gamestate.h"
00056 #include "multiplay.h"
00057 #include "track.h"
00058 
00059 #include "globals.h"
00060 
00061 #include <vamos/world/World.h>
00062 #include <vamos/body/Gl_Car.h>
00063 #include <vamos/body/Car.h>
00064 #include <vamos/body/Wheel.h>
00065 #include <vamos/body/Fuel_Tank.h>
00066 
00067 #define MAX_TRIM_LOOPS 5000
00068 
00069 #define AUTO_CLUTCH_THRESH 200.0f
00070 #define AUTO_CLUTCH_MARGIN 100.0f
00071 #define AUTO_CLUTCH_ENGAGE_TIME 1.0f
00072 
00073 enum CameraMode { CMChaseRigid=0, CMChase=1, CMOrbit=2, CMHood=3, CMFree=4, CMInCar=5, CMExternal=6, CMExtFollow=7 };
00074 
00075 enum CONTROLLERTYPE { CONT_NONE=0, CONT_PLAYERLOCAL=1, CONT_PLAYERREMOTE=2, CONT_AI=-1, CONT_REPLAY=3 };
00076 
00077 class VAMOSWORLD
00078 {
00079 private:
00080         Vamos_World::World * world;
00081         float steerpos;
00082         CameraMode cammode;
00083         bool joyinfo;
00084         bool propsteer;
00085         int oldseg;
00086         bool initdone;
00087         float shift_time;
00088         ofstream error_log;
00089         TEXTURE_HANDLE tachbase, tachredband, tachband, speedo, needle, fuelgauge, fgbox;
00090         TEXTURE_HANDLE m_ballh, m_sliderh, m_ballv, m_sliderv;
00091         TEXTURE_HANDLE sphere_reflection;
00092         TEXTURE_HANDLE car_shadow;
00093         double l_timefactor, l_fps;
00094         SDL_Joystick * joyinfo_js;
00095         SDL_Joystick ** joyinfo_jsarray;
00096         TRACK * track_p;
00097         float steervals[2];
00098         VERTEX cam_lastpos;
00099         VERTEX cam_lastpos2;
00100         VERTEX cam_lastvel;
00101         VERTEX cam_lastaccel;
00102         VERTEX cam_jerk;
00103         int tire_source[4];
00104         VERTEX oldtirepos[4];
00105         float lastcamchange; //used by the external camera mode
00106         VERTEX oldcampos;
00107         bool camneedupdate;
00108         bool MPH;
00109         bool auto_clutch;
00110         bool display_hud;
00111         bool input_graph_enabled;
00112         bool car_shadows_enabled;
00113 
00114         void PhysUpdate(float dt);
00115         void draw_cars(bool draw_interior, bool draw_focused_car);
00116         void DrawHUD();
00117         void draw_shadows();
00118         void DisplayJoyInfo();
00119         void build_track_shot();
00120         void ProcessControls(SDL_Joystick ** js, float timefactor, float fps);
00121         void steer_to(float val, float timefactor, float fps);
00122         void steer_set(float val, bool left);
00123         void steer_commit();
00124         void DoOp(Vamos_World::Car_Information * c, string dofunction, float dovalue, float dotime, bool held, float timefactor, float fps);
00125         void ShadowTexCoord(VERTEX &carpos, QUATERNION &carorientation, VERTEX & shadowdim, VERTEX &vert, float roadheight);
00126 
00127 public:
00128         VAMOSWORLD();
00129         ~VAMOSWORLD();
00130         void Init (TRACK* track);
00131         void Update(float timefactor, float fps, SDL_Joystick ** js);
00132         void UpdateSettings();
00133         void reset();
00134         void LoadHUD();
00135         void UnloadHUD();
00136         void DeInit();
00137 
00138         void Draw();
00139         void DrawShadows();
00140         void DrawCars();
00141         void DrawTopLevel();
00142 
00143         void SetCameraMode(CameraMode newmode);
00144 
00145         Vamos_Body::Car * GetPlayerCar() { return GetCar(CONT_PLAYERLOCAL)->car; }
00146         Vamos_World::Car_Information * GetCar(CONTROLLERTYPE p);
00147         void add_car (Vamos_Body::Car* car) { world->add_car(car); }
00148         void clear_cars();
00149         void FuelPlayerCar();
00150 };
00151 
00152 #define _VAMOSWORLD_H
00153 #endif /* _VAMOSWORLD_H */

Generated on Thu Oct 19 04:05:48 2006 by  doxygen 1.4.6