Back to index

extremetuxracer  0.5beta
course_load.h
Go to the documentation of this file.
00001 /* 
00002  * PPRacer 
00003  * Copyright (C) 2004-2005 Volker Stroebel <volker@planetpenguin.de>
00004  *
00005  * Copyright (C) 1999-2001 Jasmin F. Patry
00006  * 
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  * 
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020  */
00021 
00022 #include "pp_types.h"
00023 #include "pp_classes.h"
00024 
00025 #include "ppgltk/ppgltk.h"
00026 
00027 #include "ppgltk/model.h"
00028 
00029 
00030 #include <list>
00031 #include <string>
00032 
00033 #ifndef _COURSE_LOAD_H_
00034 #define _COURSE_LOAD_H_
00035 
00036 #define STRIDE_GL_ARRAY ( 8 * sizeof(GLfloat) + 4 * sizeof(GLubyte) )
00037 
00038 /* Convenience macro for accessing terrain elevations */
00039 #define ELEV(x,y) ( elevation[(x) + nx*(y)] )
00040 
00041 /* Convenience acro to create a course vertex */
00042 #define COURSE_VERTEX(x,y) pp::Vec3d( (float)(x)/(nx-1.)*course_width, \
00043                        ELEV((x),(y)), -(float)(y)/(ny-1.)*course_length ) 
00044 
00045 void load_course( std::string& course );
00046 
00047 float     *get_course_elev_data();
00048 int    *get_course_terrain_data();
00049 float      get_course_angle();
00050 void          get_course_dimensions( float *width, float *length );
00051 void          get_play_dimensions( float *width, float *length );
00052 float      get_terrain_base_height( float distance );
00053 float      get_terrain_max_height( float distance );
00054 void          get_course_divisions( int *nx, int *ny );
00055 Tree       *get_tree_locs();
00056 int           get_num_trees();
00057 void          set_start_pt( pp::Vec2d p );
00058 pp::Vec2d     get_start_pt();
00059 pp::Polyhedron*  get_tree_polyhedron( int type );
00060 const char         *get_tree_name(int type);
00061 
00062 std::string& get_course_author();
00063 std::string& get_course_name(); 
00064 
00065 light_t      *get_course_lights();
00066 void          set_course_mirroring( bool state );
00067 bool        get_course_mirroring( );
00068 void          fill_gl_arrays();
00069 void          get_gl_arrays( GLubyte **vertex_normal_arr );
00070 
00071 void          register_course_load_tcl_callbacks( Tcl_Interp *interp );
00072 
00073 Item       *get_item_locs();
00074 int           get_num_items();
00075 const char         *get_item_name(int type);
00076 
00077 typedef struct {
00078        std::string name;
00079     double height;
00080        double diam;
00081     int  num_trees;
00082     unsigned char red, green, blue;
00083     std::list<pp::Vec2d> pos;
00084        pp::Model* model;
00085        pp::Polyhedron* ph;
00086 } tree_type_t;
00087 
00088 typedef struct {
00089     std::string name;
00090     std::string texture;
00091     double diam, height;
00092     double above_ground;
00093     unsigned char red, green, blue;
00094     //bool nocollision;
00095        Item::Type type;
00096        int score;
00097     bool reset_point;
00098     std::list<pp::Vec2d> pos;
00099     int  num_items;
00100     bool use_normal;
00101     pp::Vec3d normal;
00102 } item_type_t;
00103 
00104 typedef struct {
00105     int type;
00106        int value;
00107        double friction;
00108        double compression;
00109        GLuint texbind;
00110        GLuint partbind;
00111        GLuint envmapbind;
00112        std::string sound;
00113        bool soundactive;
00114        struct { GLuint head,mark,tail; }trackmark;
00115        int wheight;
00116        int count;
00117 } terrain_tex_t;
00118 
00119 
00120 item_type_t*  get_item_types();
00121 int           get_num_item_types();
00122 
00123 
00124 extern std::list<int> usedTerrains;
00125 
00126 #endif