Back to index

extremetuxracer  0.5beta
Defines | Functions
hier.h File Reference
#include "pp_types.h"
#include "ppgltk/alg/poly.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define MIN_SPHERE_DIVISIONS   3
#define MAX_SPHERE_DIVISIONS   16

Functions

int get_scene_node (const char *node_name, scene_node_t **node)
char * reset_scene_node (char *node)
char * rotate_scene_node (const char *node, char axis, double angle)
char * translate_scene_node (const char *node, pp::Vec3d trans)
char * scale_scene_node (const char *node, pp::Vec3d origin, double factor[3])
char * transform_scene_node (char *node, pp::Matrix mat, pp::Matrix invMat)
char * set_scene_node_material (const char *node, const char *mat)
char * create_material (const char *mat, pp::Color d, pp::Color s, double s_exp)
char * set_scene_resolution (char *resolution)
char * set_scene_node_shadow_state (const char *node, const char *state)
char * set_scene_node_eye (const char *node, const char *which_eye)
char * create_tranform_node (const char *parent, const char *name)
char * create_sphere_node (const char *parent_name, const char *child_name, double resolution)
void initialize_scene_graph ()
void draw_scene_graph (char *node)
bool collide (char *node, pp::Polyhedron ph)

Define Documentation

#define MAX_SPHERE_DIVISIONS   16

Definition at line 31 of file hier.h.

#define MIN_SPHERE_DIVISIONS   3

Definition at line 30 of file hier.h.


Function Documentation

bool collide ( char *  node,
pp::Polyhedron  ph 
)

Definition at line 439 of file hier.cpp.

{
    scene_node_t *nodePtr;
    pp::Matrix mat, invmat;

    mat.makeIdentity();
    invmat.makeIdentity();

    if ( get_scene_node( node, &nodePtr ) != TCL_OK ) {
        handle_error( 1, "draw_scene_graph: No such node `%s'", node );
    } 

    return check_polyhedron_collision_with_dag( nodePtr, mat, invmat, ph );
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* create_material ( const char *  mat,
pp::Color  d,
pp::Color  s,
double  s_exp 
)

Definition at line 380 of file hier.cpp.

{
    material_t *matPtr;

    matPtr = (material_t *)malloc( sizeof( material_t ) );

    matPtr->diffuse.r = diffuse.r;
    matPtr->diffuse.g = diffuse.g;
    matPtr->diffuse.b = diffuse.b;
    matPtr->diffuse.a = 1.0;

    matPtr->specular.r = specular.r;
    matPtr->specular.g = specular.g;
    matPtr->specular.b = specular.b;
    matPtr->specular.a = 1.0;

    matPtr->specular_exp = specular_exp;

    if ( add_material( mat, matPtr ) != TCL_OK ) {
        free( matPtr );
        return "Material already exists";
    } 

    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* create_sphere_node ( const char *  parent_name,
const char *  child_name,
double  resolution 
)

Definition at line 358 of file hier.cpp.

{
    scene_node_t *node;
    char *msg;

    msg = create_scene_node(parent_name, child_name, &node);
    if ( msg != NULL ) {
        return msg;
    } 

    node->geom = Sphere;
    node->param.sphere.radius = 1.0;
    node->param.sphere.divisions = MIN( 
       MAX_SPHERE_DIVISIONS, MAX( 
           MIN_SPHERE_DIVISIONS, 
           ROUND_TO_NEAREST( getparam_tux_sphere_divisions() * resolution ) 
           ) );

    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* create_tranform_node ( const char *  parent,
const char *  name 
)

Definition at line 342 of file hier.cpp.

{
    scene_node_t *node;
    char *msg;

    msg = create_scene_node(parent_name, child_name, &node);
    if ( msg != NULL ) {
        return msg;
    } 

    node->geom = Empty;

    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void draw_scene_graph ( char *  node)

Definition at line 427 of file hier.cpp.

{
    scene_node_t *nodePtr;

    if ( get_scene_node( node, &nodePtr ) != TCL_OK ) {
        handle_error( 1, "draw_scene_graph: No such node `%s'", node );
    } 

    traverse_dag( nodePtr, &g_hier_default_material );
    
} 

Here is the call graph for this function:

Here is the caller graph for this function:

int get_scene_node ( const char *  node_name,
scene_node_t **  node 
)

Definition at line 83 of file hier.cpp.

{
    Tcl_HashEntry *entry;
  
    entry = Tcl_FindHashEntry(&g_hier_node_table, node_name);
    if (0 == entry) {
        if(0 == strcmp(node_name, ":")) {
            /* the root has been specified 
             */
            *node = 0;
        } else {
            return TCL_ERROR;
        }
    } else {
        *node = (scene_node_t*)Tcl_GetHashValue(entry);
    }

    return TCL_OK;
}

Here is the caller graph for this function:

Definition at line 407 of file hier.cpp.

Here is the caller graph for this function:

char* reset_scene_node ( char *  node)

Definition at line 182 of file hier.cpp.

{  
    scene_node_t *nodePtr;

    if ( get_scene_node( node, &nodePtr ) != TCL_OK ) {
        return "No such node";
    } 

    nodePtr->trans.makeIdentity();
    nodePtr->invtrans.makeIdentity();

    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* rotate_scene_node ( const char *  node,
char  axis,
double  angle 
)

Definition at line 197 of file hier.cpp.

{
    scene_node_t *nodePtr;
    pp::Matrix rotMatrix;

    if ( get_scene_node( node, &nodePtr ) != TCL_OK ) {
        return "No such node";
    } 

    rotMatrix.makeRotation( angle, axis );
    nodePtr->trans=nodePtr->trans*rotMatrix;
       
    rotMatrix.makeRotation( -angle, axis );
    nodePtr->invtrans=rotMatrix*nodePtr->invtrans;

    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* scale_scene_node ( const char *  node,
pp::Vec3d  origin,
double  factor[3] 
)

Definition at line 235 of file hier.cpp.

{
    scene_node_t *nodePtr;
    pp::Matrix matrix;

    if ( get_scene_node( node, &nodePtr ) != TCL_OK ) {
        return "No such node";
    } 

    matrix.makeTranslation( -center.x, -center.y, -center.z );
    nodePtr->trans=nodePtr->trans*matrix;
       
    matrix.makeTranslation( center.x, center.y, center.z );
    nodePtr->invtrans=matrix*nodePtr->invtrans;

    matrix.makeScaling( factor[0], factor[1], factor[2] );
    nodePtr->trans=nodePtr->trans*matrix;
       
    matrix.makeScaling( 1./factor[0], 1./factor[1], 1./factor[2] );
    nodePtr->invtrans=matrix*nodePtr->invtrans;

    matrix.makeTranslation( center.x, center.y, center.z );
    nodePtr->trans=nodePtr->trans*matrix;
       
    matrix.makeTranslation( -center.x, -center.y, -center.z );
    nodePtr->invtrans=matrix*nodePtr->invtrans;

    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* set_scene_node_eye ( const char *  node,
const char *  which_eye 
)

Definition at line 320 of file hier.cpp.

{
    scene_node_t *nodePtr;

    if ( get_scene_node( node, &nodePtr ) != TCL_OK ) {
        return "No such node";
    } 

    if ( strcmp( which_eye, "right" ) == 0 ) {
       nodePtr->eye = true;
       nodePtr->which_eye = TuxRightEye;
    } else if ( strcmp ( which_eye, "left" ) == 0 ) {
       nodePtr->eye = true;
       nodePtr->which_eye = TuxLeftEye;
    } else {
       return "'eye' must be right or left";
    }

    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* set_scene_node_material ( const char *  node,
const char *  mat 
)

Definition at line 281 of file hier.cpp.

{
    material_t *matPtr;
    scene_node_t *nodePtr;

    if ( get_scene_node( node, &nodePtr ) != TCL_OK ) {
        return "No such node";
    } 

    if ( get_material( mat, &matPtr ) != TCL_OK ) {
        return "No such material";
    } 

    nodePtr->mat = matPtr;

    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* set_scene_node_shadow_state ( const char *  node,
const char *  state 
)

Definition at line 300 of file hier.cpp.

{
    scene_node_t *nodePtr;

    if ( get_scene_node( node, &nodePtr ) != TCL_OK ) {
        return "No such node";
    } 

    if ( strcmp( state, "off" ) == 0 ) {
       nodePtr->render_shadow = false;
    } else if ( strcmp ( state, "on" ) == 0 ) {
       nodePtr->render_shadow = true;
    } else {
       return "Shadow state must be 'on' or 'off'";
    }

    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* set_scene_resolution ( char *  resolution)
char* transform_scene_node ( char *  node,
pp::Matrix  mat,
pp::Matrix  invMat 
)

Definition at line 266 of file hier.cpp.

{
    scene_node_t *nodePtr;

    if ( get_scene_node( node, &nodePtr ) != TCL_OK ) {
        return "No such node";
    } 

    nodePtr->trans=nodePtr->trans*mat;
    nodePtr->invtrans=invmat*nodePtr->invtrans;

    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* translate_scene_node ( const char *  node,
pp::Vec3d  trans 
)

Definition at line 216 of file hier.cpp.

{
    scene_node_t *nodePtr;
    pp::Matrix xlateMatrix;

    if ( get_scene_node( node, &nodePtr ) != TCL_OK ) {
        return "No such node";
    } 

    xlateMatrix.makeTranslation( vec.x, vec.y, vec.z );
       nodePtr->trans=nodePtr->trans*xlateMatrix;
       
    xlateMatrix.makeTranslation( -vec.x, -vec.y, -vec.z );
    nodePtr->invtrans=xlateMatrix*nodePtr->invtrans;

    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function: