Back to index

supertuxkart  0.5+dfsg1
Public Member Functions | Private Attributes
TriangleMesh Class Reference

A special class to store a triangle mesh with a separate material per triangle. More...

#include <triangle_mesh.hpp>

Collaboration diagram for TriangleMesh:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TriangleMesh ()
 ~TriangleMesh ()
void addTriangle (btVector3 t1, btVector3 t2, btVector3 t3, const Material *m)
void createBody (btCollisionObject::CollisionFlags flags=(btCollisionObject::CollisionFlags) 0)
const MaterialgetMaterial (int n) const

Private Attributes

UserPointer m_user_pointer
std::vector< const Material * > m_triangleIndex2Material
btRigidBodym_body
btTriangleMesh m_mesh
btDefaultMotionStatem_motion_state
btCollisionShapem_collision_shape

Detailed Description

A special class to store a triangle mesh with a separate material per triangle.

Definition at line 31 of file triangle_mesh.hpp.


Constructor & Destructor Documentation

Definition at line 41 of file triangle_mesh.hpp.

: m_mesh() {};

Definition at line 24 of file triangle_mesh.cpp.

{
    if(m_body)
    {
        world->getPhysics()->removeBody(m_body);
        delete m_body;
        delete m_motion_state;
        delete m_collision_shape;
    }
}   // ~TriangleMesh

Here is the call graph for this function:


Member Function Documentation

void TriangleMesh::addTriangle ( btVector3  t1,
btVector3  t2,
btVector3  t3,
const Material m 
)

Definition at line 36 of file triangle_mesh.cpp.

{
    m_triangleIndex2Material.push_back(m);
    m_mesh.addTriangle(t1, t2, t3);
}   // addTriangle

Here is the call graph for this function:

Here is the caller graph for this function:

void TriangleMesh::createBody ( btCollisionObject::CollisionFlags  flags = (btCollisionObject::CollisionFlags)0)

Definition at line 44 of file triangle_mesh.cpp.

{
    if(m_triangleIndex2Material.size()==0)
    {
        m_collision_shape = NULL;
        m_motion_state    = NULL;
        m_body            = NULL;
        return;
    }
    // Now convert the triangle mesh into a static rigid body
    m_collision_shape = new btBvhTriangleMeshShape(&m_mesh, true);
    btTransform startTransform;
    startTransform.setIdentity();
    m_motion_state = new btDefaultMotionState(startTransform);
    btRigidBody::btRigidBodyConstructionInfo info(0.0f, m_motion_state, m_collision_shape);
    m_body=new btRigidBody(info);

    world->getPhysics()->addBody(m_body);
    m_user_pointer.set(this);
    m_body->setUserPointer(&m_user_pointer);
    m_body->setCollisionFlags(m_body->getCollisionFlags()  | 
                              flags                        |
                              btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
}   // createBody

Here is the call graph for this function:

Here is the caller graph for this function:

const Material* TriangleMesh::getMaterial ( int  n) const [inline]

Definition at line 47 of file triangle_mesh.hpp.


Member Data Documentation

Definition at line 36 of file triangle_mesh.hpp.

Definition at line 39 of file triangle_mesh.hpp.

Definition at line 37 of file triangle_mesh.hpp.

Definition at line 38 of file triangle_mesh.hpp.

std::vector<const Material*> TriangleMesh::m_triangleIndex2Material [private]

Definition at line 35 of file triangle_mesh.hpp.

Definition at line 34 of file triangle_mesh.hpp.


The documentation for this class was generated from the following files: