Back to index

extremetuxracer  0.5beta
Functions
hier_cb.cpp File Reference
#include "hier.h"
#include "tcl_util.h"

Go to the source code of this file.

Functions

int tux_rotate (ClientData cd, Tcl_Interp *ip, int argc, CONST84 char *argv[])
int tux_translate (ClientData cd, Tcl_Interp *ip, int argc, CONST84 char *argv[])
int tux_scale (ClientData cd, Tcl_Interp *ip, int argc, CONST84 char *argv[])
int tux_transform (ClientData cd, Tcl_Interp *ip, int argc, CONST84 char *argv[])
int tux_sphere (ClientData cd, Tcl_Interp *ip, int argc, CONST84 char *argv[])
int tux_material (ClientData cd, Tcl_Interp *ip, int argc, CONST84 char *argv[])
int tux_surfaceproperty (ClientData cd, Tcl_Interp *ip, int argc, CONST84 char *argv[])
int tux_shadow (ClientData cd, Tcl_Interp *ip, int argc, CONST84 char *argv[])
int tux_eye (ClientData cd, Tcl_Interp *ip, int argc, CONST84 char *argv[])
int registerHierCallbacks (Tcl_Interp *ip)

Function Documentation

int registerHierCallbacks ( Tcl_Interp *  ip)

Definition at line 358 of file hier_cb.cpp.

  {
    Tcl_CreateCommand(ip, "tux_rotate",          tux_rotate,          0,0);
    Tcl_CreateCommand(ip, "tux_translate",       tux_translate,       0,0);
    Tcl_CreateCommand(ip, "tux_scale",           tux_scale,           0,0);
    Tcl_CreateCommand(ip, "tux_sphere",          tux_sphere,          0,0);
    Tcl_CreateCommand(ip, "tux_transform",       tux_transform,       0,0);
    Tcl_CreateCommand(ip, "tux_material",        tux_material,        0,0);
    Tcl_CreateCommand(ip, "tux_surfaceproperty", tux_surfaceproperty, 0,0);
    Tcl_CreateCommand(ip, "tux_shadow",          tux_shadow,          0,0);
    Tcl_CreateCommand(ip, "tux_eye",             tux_eye,             0,0);

    return TCL_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int tux_eye ( ClientData  cd,
Tcl_Interp *  ip,
int  argc,
CONST84 char *  argv[] 
)

Definition at line 331 of file hier_cb.cpp.

{
    char *errmsg;

    const char *node_name;
    const char *which_eye;

    if (3 != argc) {
        Tcl_AppendResult(ip, argv[0], ": invalid number of arguments\n", 
                      "Usage: ", argv[0], " <node> [left|right]",
                      (char *)0 );
        return TCL_ERROR;
    }

    node_name = argv[1];
    which_eye = argv[2];

    errmsg = set_scene_node_eye( node_name, which_eye );

    /* report error, if any */
    if (errmsg) {
        Tcl_AppendResult(ip, argv[0], ": ", errmsg, (char *)0 );
        return TCL_ERROR;
    }
    return TCL_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int tux_material ( ClientData  cd,
Tcl_Interp *  ip,
int  argc,
CONST84 char *  argv[] 
)

Definition at line 221 of file hier_cb.cpp.

{
    char *errmsg;

    const char *mat_name;
    double diffuse[3];
    double specular[3];
    double spec_exp;

    if (5 != argc) {
        Tcl_AppendResult(ip, argv[0], ": invalid number of arguments\n", 
                      "Usage: ", argv[0], " <name> { <ambient color> } "
                      "{ <specular color> } <specular exponent",
                      (char *)0 );
        return TCL_ERROR;
    }

    /* obtain material name */
    mat_name = argv[1];

    /* obtain diffuse color */
    if (TCL_OK != get_tcl_tuple(ip,argv[2],diffuse,3)) {
        Tcl_AppendResult(ip, argv[0], ": invalid diffuse color", 
                      (char *)0 );
        return TCL_ERROR;
    }

    /* obtain specular color */
    if (TCL_OK != get_tcl_tuple(ip,argv[3],specular,3)) {
        Tcl_AppendResult(ip, argv[0], ": invalid specular color", 
                      (char *)0 );
        return TCL_ERROR;
    }

    /* obtain specular exponent */
    if (TCL_OK != Tcl_GetDouble(ip,argv[4],&spec_exp)) {
        Tcl_AppendResult(ip, argv[0], ": invalid specular exponent", 
                      (char *)0 );
        return TCL_ERROR;
    }

    errmsg = create_material(mat_name,pp::Color(diffuse),
                pp::Color(specular), spec_exp);

    /* report error, if any */
    if (errmsg) {
        Tcl_AppendResult(ip, argv[0], ": ", errmsg, (char *)0 );
        return TCL_ERROR;
    }
    return TCL_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int tux_rotate ( ClientData  cd,
Tcl_Interp *  ip,
int  argc,
CONST84 char *  argv[] 
)

Definition at line 29 of file hier_cb.cpp.

{
    char *errmsg;

    const char *nodename;
    char axis;
    double angle ;

    if (4 != argc) {
        Tcl_AppendResult(ip, argv[0], ": wrong number of arguments\n", 
                      "Usage: ", argv[0], " <node> [x|y|z] <angle>",
                      (char *)0 );
        return TCL_ERROR;
    }

    /* obtain the nodename */
    nodename = argv[1];

    /* obtain the axis */
    axis = argv[2][0];
    if ('x' != axis && 'y' != axis && 'z' != axis) {
        Tcl_AppendResult(ip, argv[0], ": invalid rotation axes", 
                      (char *)0 );
        return TCL_ERROR;
    }
    
    /* obtain the angle */
    if (TCL_OK != Tcl_GetDouble(ip, argv[3], &angle)) {
        Tcl_AppendResult(ip, argv[0], ": invalid rotation angle", 
                      (char *)0 );
        return TCL_ERROR;
    }
    
    errmsg = rotate_scene_node(nodename,axis,angle);

    /* report error, if any */
    if (errmsg) {
        Tcl_AppendResult(ip, argv[0], ": ", errmsg, (char *)0 );
        return TCL_ERROR;
    }
  
    return TCL_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int tux_scale ( ClientData  cd,
Tcl_Interp *  ip,
int  argc,
CONST84 char *  argv[] 
)

Definition at line 108 of file hier_cb.cpp.

{
    char *errmsg;

    const char *nodename;
    double origin[3];
    double factors[3]; 

    if (4 != argc) {
        Tcl_AppendResult(ip, argv[0], ": invalid number of arguments\n", 
                      "Usage: ", argv[0], " <node> { <origin> } "
                      "{ <translation vector> }",
                      (char *)0 );
        return TCL_ERROR;
    }

    /* obtain the nodename */
    nodename = argv[1];

    /* obtain the origin point */
    if (TCL_OK != get_tcl_tuple(ip,argv[2],origin,3)) {
        Tcl_AppendResult(ip, argv[0], ": invalid origin point", 
                      (char *)0 );
        return TCL_ERROR;
    }

    /* obtain the scale factors */
    if (TCL_OK != get_tcl_tuple(ip,argv[3],factors,3)) {
        Tcl_AppendResult(ip, argv[0], ": invalid scale factors", 
                      (char *)0 );
        return TCL_ERROR;
    }
    
    errmsg = scale_scene_node(nodename,pp::Vec3d(origin),factors);

    /* report error, if any */
    if (errmsg) {
        Tcl_AppendResult(ip, argv[0], ": ", errmsg, (char *)0 );
        return TCL_ERROR;
    }
  
    return TCL_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int tux_shadow ( ClientData  cd,
Tcl_Interp *  ip,
int  argc,
CONST84 char *  argv[] 
)

Definition at line 304 of file hier_cb.cpp.

{
    char *errmsg;

    const char *node_name;
    const char *state;

    if (3 != argc) {
        Tcl_AppendResult(ip, argv[0], ": invalid number of arguments\n", 
                      "Usage: ", argv[0], " <node> [on|off]",
                      (char *)0 );
        return TCL_ERROR;
    }

    node_name = argv[1];
    state = argv[2];

    errmsg = set_scene_node_shadow_state(node_name, state);

    /* report error, if any */
    if (errmsg) {
        Tcl_AppendResult(ip, argv[0], ": ", errmsg, (char *)0 );
        return TCL_ERROR;
    }
    return TCL_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int tux_sphere ( ClientData  cd,
Tcl_Interp *  ip,
int  argc,
CONST84 char *  argv[] 
)

Definition at line 182 of file hier_cb.cpp.

{
    char *errmsg;

    const char *parent_name;
    const char *child_name;
    double resolution;

    if (4 != argc) {
       Tcl_AppendResult( ip, argv[0], ": wrong number of arguments\n",
                      "Usage: ", argv[0], " <parent node> <child node> "
                       "<radius>",
                       (char*) 0 );
        return TCL_ERROR;
    }

    /* obtain parent's name */
    parent_name = argv[1];

    /* obtain child's name */
    child_name  = argv[2];

    if ( TCL_OK != Tcl_GetDouble( ip, argv[3], &resolution ) ) {
       Tcl_AppendResult( ip, argv[0], ": resolution is invalid",
                       (char*) 0 );
       return TCL_ERROR;
    }

    errmsg = create_sphere_node(parent_name, child_name, resolution);

    /* report error, if any */
    if (errmsg) {
        Tcl_AppendResult(ip, argv[0], ": ", errmsg, (char *)0 );
        return TCL_ERROR;
    }
    return TCL_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int tux_surfaceproperty ( ClientData  cd,
Tcl_Interp *  ip,
int  argc,
CONST84 char *  argv[] 
)

Definition at line 273 of file hier_cb.cpp.

{
    char *errmsg;

    const char *node_name;
    const char *mat_name;

    if (3 != argc) {
        Tcl_AppendResult(ip, argv[0], ": invalid number of arguments\n", 
                      "Usage: ", argv[0], " <node> <material name>",
                      (char *)0 );
        return TCL_ERROR;
    }

    /* obtain node name */
    node_name = argv[1];

    /* obtain material name */
    mat_name  = argv[2];

    errmsg = set_scene_node_material(node_name, mat_name);

    /* report error, if any */
    if (errmsg) {
        Tcl_AppendResult(ip, argv[0], ": ", errmsg, (char *)0 );
        return TCL_ERROR;
    }
    return TCL_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int tux_transform ( ClientData  cd,
Tcl_Interp *  ip,
int  argc,
CONST84 char *  argv[] 
)

Definition at line 152 of file hier_cb.cpp.

{
    char *errmsg;

    const char *parent_name;
    const char *child_name;

    if (3 != argc) {
        Tcl_AppendResult(ip, argv[0], ": invalid number of arguments\n", 
                      "Usage: ", argv[0], " <parent node> <child node>",
                      (char *)0 );
        return TCL_ERROR;
    }

    /* obtain parent's name */
    parent_name = argv[1];

    /* obtain child's name */
    child_name  = argv[2];

    errmsg = create_tranform_node(parent_name, child_name);

    /* report error, if any */
    if (errmsg) {
        Tcl_AppendResult(ip, argv[0], ": ", errmsg, (char *)0 );
        return TCL_ERROR;
    }
    return TCL_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int tux_translate ( ClientData  cd,
Tcl_Interp *  ip,
int  argc,
CONST84 char *  argv[] 
)

Definition at line 73 of file hier_cb.cpp.

{
    char *errmsg;

    const char *nodename;
    double vec[3];

    if (3 != argc) {
        Tcl_AppendResult(ip, argv[0], ": invalid number of arguments\n", 
                      "Usage: ", argv[0], " <node> { <x> <y> <z> }",
                      (char *)0 );
        return TCL_ERROR;
    }

    /* obtain the nodename */
    nodename = argv[1];

    /* obtain the translation vector */
    if (TCL_OK != get_tcl_tuple(ip,argv[2],vec,3)) {
        Tcl_AppendResult(ip, argv[0], ": invalid translation vector", 
                      (char *)0 );
        return TCL_ERROR;
    }
    
    errmsg = translate_scene_node(nodename,pp::Vec3d(vec));

    /* report error, if any */
    if (errmsg) {
        Tcl_AppendResult(ip, argv[0], ": ", errmsg, (char *)0 );
        return TCL_ERROR;
    }
  
    return TCL_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function: