Back to index

extremetuxracer  0.5beta
Classes | Defines | Functions | Variables
course_load.h File Reference
#include "pp_types.h"
#include "pp_classes.h"
#include "ppgltk/ppgltk.h"
#include "ppgltk/model.h"
#include <list>
#include <string>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tree_type_t
struct  item_type_t
struct  terrain_tex_t
struct  terrain_tex_t.trackmark

Defines

#define STRIDE_GL_ARRAY   ( 8 * sizeof(GLfloat) + 4 * sizeof(GLubyte) )
#define ELEV(x, y)   ( elevation[(x) + nx*(y)] )
#define COURSE_VERTEX(x, y)

Functions

void load_course (std::string &course)
float * get_course_elev_data ()
int * get_course_terrain_data ()
float get_course_angle ()
void get_course_dimensions (float *width, float *length)
void get_play_dimensions (float *width, float *length)
float get_terrain_base_height (float distance)
 Returns the base (minimum) height of the terrain at distance.
float get_terrain_max_height (float distance)
 Returns the maximum height of the terrain at distance.
void get_course_divisions (int *nx, int *ny)
Treeget_tree_locs ()
int get_num_trees ()
void set_start_pt (pp::Vec2d p)
pp::Vec2d get_start_pt ()
pp::Polyhedronget_tree_polyhedron (int type)
const char * get_tree_name (int type)
std::string & get_course_author ()
std::string & get_course_name ()
light_tget_course_lights ()
void set_course_mirroring (bool state)
bool get_course_mirroring ()
void fill_gl_arrays ()
void get_gl_arrays (GLubyte **vertex_normal_arr)
void register_course_load_tcl_callbacks (Tcl_Interp *interp)
Itemget_item_locs ()
int get_num_items ()
const char * get_item_name (int type)
item_type_tget_item_types ()
int get_num_item_types ()

Variables

std::list< int > usedTerrains
 All terrains that are used in the current race. The list is sorted with respect to the terrain wheights.

Class Documentation

struct tree_type_t

Definition at line 77 of file course_load.h.

Collaboration diagram for tree_type_t:
Class Members
unsigned char blue
double diam
unsigned char green
double height
Model * model
string name
int num_trees
Polyhedron * ph
list< Vec2d > pos
unsigned char red
struct item_type_t

Definition at line 88 of file course_load.h.

Collaboration diagram for item_type_t:
Class Members
double above_ground
unsigned char blue
double diam
unsigned char green
double height
string name
Vec3d normal
int num_items
list< Vec2d > pos
unsigned char red
bool reset_point
int score
string texture
Type type
bool use_normal
struct terrain_tex_t

Definition at line 104 of file course_load.h.

Collaboration diagram for terrain_tex_t:
Class Members
double compression
int count
GLuint envmapbind
double friction
GLuint partbind
string sound
bool soundactive
GLuint texbind
struct terrain_tex_t trackmark
int type
int value
int wheight
struct terrain_tex_t.trackmark

Definition at line 114 of file course_load.h.

Class Members
GLuint head
GLuint mark
GLuint tail

Define Documentation

#define COURSE_VERTEX (   x,
 
)
Value:
pp::Vec3d( (float)(x)/(nx-1.)*course_width, \
                       ELEV((x),(y)), -(float)(y)/(ny-1.)*course_length )

Definition at line 42 of file course_load.h.

#define ELEV (   x,
 
)    ( elevation[(x) + nx*(y)] )

Definition at line 39 of file course_load.h.

#define STRIDE_GL_ARRAY   ( 8 * sizeof(GLfloat) + 4 * sizeof(GLubyte) )

Definition at line 36 of file course_load.h.


Function Documentation

void fill_gl_arrays ( )

Definition at line 273 of file course_load.cpp.

{
    int x,y;
    pp::Vec3d *normals = get_course_normals();
    pp::Vec3d nml;
    int idx;

    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_NORMAL_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);

    /* Align vertices and normals on 16-byte intervals (Q3A does this) */
    vnc_array = (GLubyte*) malloc( STRIDE_GL_ARRAY * nx * ny );

    for (x=0; x<nx; x++) {
       for (y=0; y<ny; y++) {
           idx = STRIDE_GL_ARRAY*(y*nx+x);
          
#define floatval(i) (*(GLfloat*)(vnc_array+idx+(i)*sizeof(GLfloat)))

           floatval(0) = (GLfloat)x / (nx-1.) * course_width;
           floatval(1) = ELEV(x,y);
           floatval(2) = -(GLfloat)y / (ny-1.) * course_length;

           nml = normals[ x + y * nx ];
           floatval(4) = nml.x;
           floatval(5) = nml.y;
           floatval(6) = nml.z;
           floatval(7) = 1.0f;
          
#undef floatval
#define byteval(i) (*(GLubyte*)(vnc_array+idx+8*sizeof(GLfloat) +\
    i*sizeof(GLubyte)))

           byteval(0) = 255;
           byteval(1) = 255;
           byteval(2) = 255;
           byteval(3) = 255;

#undef byteval

       }
    }

    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer( 3, GL_FLOAT, STRIDE_GL_ARRAY, vnc_array );

    glEnableClientState(GL_NORMAL_ARRAY);
    glNormalPointer( GL_FLOAT, STRIDE_GL_ARRAY, 
                   vnc_array + 4*sizeof(GLfloat) );

    glEnableClientState(GL_COLOR_ARRAY);
    glColorPointer( 4, GL_UNSIGNED_BYTE, STRIDE_GL_ARRAY, 
                  vnc_array + 8*sizeof(GLfloat) );
}

Here is the call graph for this function:

Here is the caller graph for this function:

float get_course_angle ( )

Definition at line 111 of file course_load.cpp.

{ return course_angle; } 

Here is the caller graph for this function:

std::string& get_course_author ( )

Definition at line 118 of file course_load.cpp.

{ return courseAuthor; }
void get_course_dimensions ( float *  width,
float *  length 
)

Definition at line 134 of file course_load.cpp.

{
    *width = course_width;
    *length = course_length;
} 

Here is the caller graph for this function:

void get_course_divisions ( int *  nx,
int *  ny 
)

Definition at line 185 of file course_load.cpp.

{
    *x = nx;
    *y = ny;
} 

Here is the caller graph for this function:

Definition at line 109 of file course_load.cpp.

{ return elevation; }

Here is the caller graph for this function:

Definition at line 28 of file lights.cpp.

                             { 
    return course_lights; 
}

Here is the caller graph for this function:

Definition at line 142 of file mirror_course.cpp.

{
    return mirrored;
}
std::string& get_course_name ( )

Definition at line 119 of file course_load.cpp.

{ return courseName; }

Definition at line 110 of file course_load.cpp.

{ return terrain; }

Here is the caller graph for this function:

void get_gl_arrays ( GLubyte **  vertex_normal_arr)

Definition at line 129 of file course_load.cpp.

{
    *vnc_arr = vnc_array;
}

Here is the caller graph for this function:

Definition at line 121 of file course_load.cpp.

{ return item_locs; }

Here is the caller graph for this function:

const char* get_item_name ( int  type)

Definition at line 123 of file course_load.cpp.

{ return item_types[type].name.c_str(); }

Here is the caller graph for this function:

Definition at line 125 of file course_load.cpp.

{ return item_types; }

Here is the caller graph for this function:

Definition at line 124 of file course_load.cpp.

{ return num_item_types; }

Here is the caller graph for this function:

int get_num_items ( )

Definition at line 122 of file course_load.cpp.

{ return num_items; }

Here is the caller graph for this function:

int get_num_trees ( )

Definition at line 113 of file course_load.cpp.

{ return num_trees; }

Here is the caller graph for this function:

void get_play_dimensions ( float *  width,
float *  length 
)

Definition at line 140 of file course_load.cpp.

{
    *width = play_width;
    *length = play_length;
} 

Here is the caller graph for this function:

Definition at line 116 of file course_load.cpp.

{ return start_pt; }

Here is the caller graph for this function:

float get_terrain_base_height ( float  distance)

Returns the base (minimum) height of the terrain at distance.

Precondition:
A course has been loaded
  • distance the (non-negative) distance down the course
Returns:
Minimum height (y-coord) of terrain
Author:
jfpatry
Date:
Created: 2000-08-30
Modified: 2000-08-30

Definition at line 156 of file course_load.cpp.

{
    float slope = tan( ANGLES_TO_RADIANS( course_angle ) );
    float base_height;
    
    check_assertion( distance > -EPS,
                   "distance should be positive" );

    /* This will need to be fixed once we add variably-sloped terrain */
    base_height = -slope * distance - 
       base_height_value / 255.0 * elev_scale;
    return base_height;
}

Here is the caller graph for this function:

float get_terrain_max_height ( float  distance)

Returns the maximum height of the terrain at distance.

Precondition:
A course has been loaded
  • distance the (non-negative) distance down the course
Returns:
Maximum height (y-coord) of terrain
Author:
jfpatry
Date:
Created: 2000-08-30
Modified: 2000-08-30

Definition at line 180 of file course_load.cpp.

{
    return get_terrain_base_height( distance ) + elev_scale;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 112 of file course_load.cpp.

{ return tree_locs; }

Here is the caller graph for this function:

const char* get_tree_name ( int  type)

Definition at line 115 of file course_load.cpp.

{ return tree_types[type].name.c_str(); }

Here is the caller graph for this function:

Definition at line 114 of file course_load.cpp.

{ return tree_types[type].ph; }

Here is the caller graph for this function:

void load_course ( std::string &  course)

Definition at line 329 of file course_load.cpp.

{
    char buff[BUFF_LEN];
    char cwd[BUFF_LEN];

    reset_course();
       HUD1.reset();
       
       
    if ( getcwd( cwd, BUFF_LEN ) == NULL ) {
       handle_system_error( 1, "getcwd failed" );
    }
    if (course[0]=='/'){
              if ( chdir(course.c_str() ) != 0 ) {      
                     handle_system_error( 1, "Couldn't chdir to %s", course.c_str() );
       } 
       }else{
              sprintf( buff, "%s/courses/%s", getparam_data_dir(), course.c_str() );
              if ( chdir( buff ) != 0 ) {
                     handle_system_error( 1, "Couldn't chdir to %s", buff );
       } 
       }
       
    if ( Tcl_EvalFile( tclInterp, "./course.tcl") == TCL_ERROR ) {
       handle_error( 1, "Error evaluating %s/course.tcl: %s",  
                    buff, Tcl_GetStringResult( tclInterp ) );
    } 

    if ( chdir( cwd ) != 0 ) {
       handle_system_error( 1, "Couldn't chdir to %s", cwd );
    } 

    check_assertion( !Tcl_InterpDeleted( tclInterp ),
                   "Tcl interpreter deleted" );

    calc_normals();

    fill_gl_arrays();

    init_course_quadtree( elevation, nx, ny, course_width/(nx-1.), 
                       -course_length/(ny-1),
                       players[0].view.pos, 
                       getparam_course_detail_level() );

    init_track_marks();

    course_loaded = true;

    /* flush unused audio files */
    delete_unused_audio_data();
} 

Here is the call graph for this function:

Here is the caller graph for this function:

void register_course_load_tcl_callbacks ( Tcl_Interp *  interp)

Definition at line 1764 of file course_load.cpp.

{
    Tcl_CreateCommand (ip, "tux_course_dim", course_dim_cb,  0,0);
    Tcl_CreateCommand (ip, "tux_angle",      angle_cb,  0,0);
    Tcl_CreateCommand (ip, "tux_elev_scale", elev_scale_cb,   0,0);
    Tcl_CreateCommand (ip, "tux_elev",       elev_cb,        0,0);
    Tcl_CreateCommand (ip, "tux_load_terrain",    terrain_cb,   0,0);
    Tcl_CreateCommand (ip, "tux_trees",      trees_cb,   0,0);
    Tcl_CreateCommand (ip, "tux_bgnd_img",   bgnd_img_cb,   0,0);
       Tcl_CreateCommand (ip, "tux_terrain_tex",   terrain_tex_cb,   0,0);
    Tcl_CreateCommand (ip, "tux_snow_type",   snow_type_cb,   0,0);
    Tcl_CreateCommand (ip, "tux_wind_type",   wind_type_cb,   0,0);
    Tcl_CreateCommand (ip, "tux_start_pt",   start_pt_cb,   0,0);
    Tcl_CreateCommand (ip, "tux_friction",   friction_cb,   0,0);
    Tcl_CreateCommand (ip, "tux_course_author", course_author_cb, 0,0);
    Tcl_CreateCommand (ip, "tux_course_name", course_name_cb, 0,0);
    Tcl_CreateCommand (ip, "tux_base_height_value", base_height_value_cb, 0,0);
    Tcl_CreateCommand (ip, "tux_tree_model",  tree_model_cb,   0,0);
    Tcl_CreateCommand (ip, "tux_item_spec",  item_spec_cb,   0,0);
       Tcl_CreateCommand (ip, "tux_wind_velocity",  wind_velocity_cb,   0,0);
       Tcl_CreateCommand (ip, "tux_hud",  hud_cb,   0,0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void set_course_mirroring ( bool  state)

Definition at line 131 of file mirror_course.cpp.

{
    if ( mirrored != state ) {
       mirror_key_frame();
       mirror_course();
       init_track_marks();
    }
    mirrored = state;
    
}

Here is the caller graph for this function:

void set_start_pt ( pp::Vec2d  p)

Definition at line 117 of file course_load.cpp.

{ start_pt = p; }

Here is the caller graph for this function:


Variable Documentation

std::list<int> usedTerrains

All terrains that are used in the current race. The list is sorted with respect to the terrain wheights.

Definition at line 103 of file course_load.cpp.