Back to index

extremetuxracer  0.5beta
Functions
course_quad.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void reset_course_quadtree ()
void init_course_quadtree (float *elevation, int nx, int nz, double scalex, double scalez, pp::Vec3d view_pos, double detail)
void update_course_quadtree (const pp::Vec3d view_pos, const float detail)
void render_course_quadtree ()

Function Documentation

void init_course_quadtree ( float *  elevation,
int  nx,
int  nz,
double  scalex,
double  scalez,
pp::Vec3d  view_pos,
double  detail 
)

Definition at line 75 of file course_quad.cpp.

{
    HeightMapInfo hm;
    int i;

    hm.Data = elevation;
    hm.XOrigin = 0;
    hm.ZOrigin = 0;
    hm.XSize = nx;
    hm.ZSize = nz;
    hm.RowWidth = hm.XSize;
    hm.Scale = 0;

    root_corner_data.Square = (quadsquare*)NULL;
    root_corner_data.ChildIndex = 0;
    root_corner_data.Level = get_root_level( nx, nz );
    root_corner_data.xorg = 0;
    root_corner_data.zorg = 0;

    for (i=0; i<4; i++) {
       root_corner_data.Verts[i] = 0;
       root_corner_data.Verts[i] = 0;
    }

    root = new quadsquare( &root_corner_data );

    root->AddHeightMap( root_corner_data, hm );
    root->SetScale( scalex, scalez );
    root->SetTerrain( get_course_terrain_data() );

    // Debug info.
    //print_debug( DEBUG_QUADTREE, "nodes = %d\n", root->CountNodes());
    print_debug( DEBUG_QUADTREE, "max error = %g\n", 
               root->RecomputeError(root_corner_data));

    // Get rid of unnecessary nodes in flat-ish areas.
    print_debug( DEBUG_QUADTREE, 
               "Culling unnecessary nodes (detail factor = %d)...\n",
               CULL_DETAIL_FACTOR);
    root->StaticCullData(root_corner_data, CULL_DETAIL_FACTOR);

    // Post-cull debug info.
    print_debug( DEBUG_QUADTREE, "nodes = %d\n", root->CountNodes());
    print_debug( DEBUG_QUADTREE, "max error = %g\n", 
               root->RecomputeError(root_corner_data));


    // Run the update function a few times before we start rendering
    // to disable unnecessary quadsquares, so the first frame won't
    // be overloaded with tons of triangles.

    float ViewerLoc[3];
    Vec3fo_float_array( ViewerLoc, view_pos );

    for (i = 0; i < 10; i++) {
       root->Update(root_corner_data, (const float*) ViewerLoc, 
                   detail);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 147 of file course_quad.cpp.

{
    GLubyte *vnc_array;

    get_gl_arrays( &vnc_array );

    root->Render( root_corner_data, vnc_array );
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 33 of file course_quad.cpp.

{
    delete root;
    root = (quadsquare*)NULL;
}

Here is the caller graph for this function:

void update_course_quadtree ( const pp::Vec3d  view_pos,
const float  detail 
)

Definition at line 138 of file course_quad.cpp.

{
    float ViewerLoc[3];

    Vec3fo_float_array( ViewerLoc, view_pos );

    root->Update( root_corner_data, ViewerLoc, detail );
}

Here is the call graph for this function:

Here is the caller graph for this function: