Back to index

supertuxkart  0.5+dfsg1
Functions
ssg_help.hpp File Reference
#include <plib/ssg.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void createDisplayLists (ssgEntity *entity)
 Make VtTables use display lists.
ssgTransform * add_transform (ssgBranch *branch)
 Adds a transform node to the branch.
void print_model (ssgEntity *entity, const int indent, const int maxLevel)
 Recursively prints a model.
void MinMax (ssgEntity *p, float *x_min, float *x_max, float *y_min, float *y_max, float *z_min=NULL, float *z_max=NULL)
 Computes the minimum and maximum x/y coordinates for a ssgEntity.
void MinMax (ssgEntity *p, sgMat4 m, float *x_min, float *x_max, float *y_min, float *y_max, float *z_min=NULL, float *z_max=NULL)
 Internal function used by MinMax.

Function Documentation

ssgTransform* add_transform ( ssgBranch *  branch)

Adds a transform node to the branch.

Creates a new ssgTransform node to which all children of the branch are added. The new ssgTransform is then set as the only child of the branch.

Parameters:
branchThe branch to which a transform node is added.

Definition at line 62 of file ssg_help.cpp.

{
    if (!branch) return 0;

    ssgTransform* transform = new ssgTransform;
    transform->ref();
    for(ssgEntity* i = branch->getKid(0); i != NULL; i = branch->getNextKid())
    {
        transform->addKid(i);
    }

    branch->removeAllKids();
    branch->addKid(transform);

    // Set some user data, so that the wheel isn't ssgFlatten()'ed
    branch->setUserData(new ssgBase());
    transform->setUserData(new ssgBase());

    return transform;
}   // add_transform

Here is the caller graph for this function:

void createDisplayLists ( ssgEntity *  entity)

Make VtTables use display lists.

Calls recursively 'makeDList' in all ssgVtxTable of the entity.

Parameters:
entityTree in which to create display lists.

Definition at line 32 of file ssg_help.cpp.

{
    if (!entity) return;

    ssgVtxTable* table = dynamic_cast<ssgVtxTable*>(entity);
    if(table)
    {
        if(table->getNumTriangles()>1) table->makeDList();
    }
    ssgBranch* branch = dynamic_cast<ssgBranch*>(entity);

    if (branch)
    {
        for(ssgEntity* i = branch->getKid(0); i != NULL;
            i = branch->getNextKid())
        {
            createDisplayLists(i);
        }   // for
    }   // if branch

}  // createDisplayLists

Here is the call graph for this function:

Here is the caller graph for this function:

void MinMax ( ssgEntity *  p,
float *  x_min,
float *  x_max,
float *  y_min,
float *  y_max,
float *  z_min,
float *  z_max 
)

Computes the minimum and maximum x/y coordinates for a ssgEntity.

Recursively computes the minimum x and y coordinates of a ssgEntity.

Parameters:
pssgEntity for which t compute the extend (can't be constant because of plib not const correct)
x_minminimum x value
x_maxmaximum x value
y_minminimum y value
y_maxmaximum y value
z_minminimum z value, optional parameter!
z_maxminimum z value, optional parameter!

Definition at line 133 of file ssg_help.cpp.

{
    sgMat4 mat;
    sgMakeIdentMat4(mat);
    *x_min = *y_min =  10000.0f; if(z_min) *z_min =  10000.0f;
    *x_max = *y_max = -10000.0f; if(z_max) *z_max = -10000.0f;
    MinMax(p, mat, x_min, x_max, y_min, y_max, z_min, z_max);

}   // MinMax

Here is the call graph for this function:

Here is the caller graph for this function:

void MinMax ( ssgEntity *  p,
sgMat4  m,
float *  x_min,
float *  x_max,
float *  y_min,
float *  y_max,
float *  z_min,
float *  z_max 
)

Internal function used by MinMax.

Definition at line 146 of file ssg_help.cpp.

{
    if(p->isAKindOf(ssgTypeLeaf()))
    {
        ssgLeaf* l=(ssgLeaf*)p;
        for(int i=0; i<l->getNumTriangles(); i++)
        {
            short v1,v2,v3;
            sgVec3 vv1, vv2, vv3;

            l->getTriangle(i, &v1, &v2, &v3);

            sgXformPnt3 ( vv1, l->getVertex(v1), m );
            sgXformPnt3 ( vv2, l->getVertex(v2), m );
            sgXformPnt3 ( vv3, l->getVertex(v3), m );
            *x_min = std::min(*x_min, vv1[0]); *x_max = std::max(*x_max, vv1[0]);
            *x_min = std::min(*x_min, vv2[0]); *x_max = std::max(*x_max, vv2[0]);
            *x_min = std::min(*x_min, vv3[0]); *x_max = std::max(*x_max, vv3[0]);
            *y_min = std::min(*y_min, vv1[1]); *y_max = std::max(*y_max, vv1[1]);
            *y_min = std::min(*y_min, vv2[1]); *y_max = std::max(*y_max, vv2[1]);
            *y_min = std::min(*y_min, vv3[1]); *y_max = std::max(*y_max, vv3[1]);
            if(z_min)
            {
                *z_min = std::min(*z_min, vv1[2]);
                *z_min = std::min(*z_min, vv2[2]);
                *z_min = std::min(*z_min, vv3[2]);
            }
            if(z_max)
            {
                *z_max = std::max(*z_max, vv1[2]);
                *z_max = std::max(*z_max, vv2[2]);
                *z_max = std::max(*z_max, vv3[2]);
            }

        }   // for i<p->getNumTriangles
    }
    else if (p->isAKindOf(ssgTypeTransform()))
    {
        ssgBaseTransform* t=(ssgBaseTransform*)p;

        sgMat4 tmpT, tmpM;
        t->getTransform(tmpT);
        sgCopyMat4(tmpM, m);
        sgPreMultMat4(tmpM,tmpT);

        for(ssgEntity* e=t->getKid(0); e!=NULL; e=t->getNextKid())
        {
            MinMax(e, tmpM, x_min, x_max, y_min, y_max, z_min, z_max);
        }   // for i<getNumKids

    }
    else if (p->isAKindOf(ssgTypeBranch()))
    {
        ssgBranch* b =(ssgBranch*)p;
        for(ssgEntity* e=b->getKid(0); e!=NULL; e=b->getNextKid())
        {
            MinMax(e, m, x_min, x_max, y_min, y_max, z_min, z_max);
        }   // for i<getNumKids
    }
    else
    {
        printf("StaticSSG::MinMax: unkown type\n");
        p->print(stdout, 0, 0);
    }
}   // MinMax

Here is the call graph for this function:

void print_model ( ssgEntity *  entity,
const int  indent,
const int  maxLevel 
)

Recursively prints a model.

Recursively prints a model. That function can most likely be removed, the print method of the ssg objects do the same.

Parameters:
entityThe entity ro print (can't be constant because of ssg functions which are not const correct)
indentIndentation to use
maxLevelmaximum number of levels to print

Definition at line 93 of file ssg_help.cpp.

{
    if(maxLevel <0) return;
    if (entity)
    {
        for(int i = 0; i < indent; ++i)
            std::cout << "  ";

        std::cout << entity->getTypeName() << " " << entity->getType() << " '"
        << entity->getPrintableName()
        << "' '"
        << (entity->getName() ? entity->getName() : "null")
        << "' " << entity << std::endl;

        ssgBranch* branch = dynamic_cast<ssgBranch*>(entity);

        if (branch)
        {
            for(ssgEntity* i = branch->getKid(0); i != NULL;
                i = branch->getNextKid())
            {
                print_model(i, indent + 1, maxLevel-1);
            }
        }   // if branch
    }   // if entity
}   // print_model

Here is the call graph for this function:

Here is the caller graph for this function: