Back to index

supertuxkart  0.5+dfsg1
Classes | Public Member Functions | Private Attributes | Static Private Attributes
SkidMark Class Reference

#include <skid_mark.hpp>

Collaboration diagram for SkidMark:
Collaboration graph
[legend]

List of all members.

Classes

class  SkidMarkPos

Public Member Functions

 SkidMark (float angle_sign)
 ~SkidMark ()
void add (const sgCoord &coord, float angle, float length)
void addBreak (const sgCoord &coord, float angle, float length)
bool wasSkidMarking () const

Private Attributes

float m_angle_sign
bool m_skid_marking
std::vector< SkidMarkPos * > m_skid_marks
ssgSimpleState * m_skid_state

Static Private Attributes

static float m_global_track_offset = 0.005f

Detailed Description

Definition at line 27 of file skid_mark.hpp.


Constructor & Destructor Documentation

SkidMark::SkidMark ( float  angle_sign)

Definition at line 25 of file skid_mark.cpp.

{
    m_skid_state = new ssgSimpleState();
    m_angle_sign = angle_sign;
    m_skid_state->ref();
    m_skid_state -> enable (GL_BLEND);
    //This is just for the skidmarks, so the ones drawn when the kart is in
    //reverse get drawn
    m_skid_state -> disable (GL_CULL_FACE);
    m_skid_marking = false;
}   // SkidMark

Definition at line 38 of file skid_mark.cpp.

{
    if(!m_skid_marks.empty())
    {
        const unsigned int SIZE = (unsigned int)m_skid_marks.size() -1;
        for(unsigned int i = 0; i < SIZE; ++i)
        {
            ssgDeRefDelete(m_skid_marks[i]);
        }   // for
    }   // if !empty
    ssgDeRefDelete(m_skid_state);
}   // ~SkidMark

Member Function Documentation

void SkidMark::add ( const sgCoord &  coord,
float  angle,
float  length 
)

Definition at line 52 of file skid_mark.cpp.

{
    if(m_skid_marking)
    {
        const int CURRENT = (int)m_skid_marks.size() - 1;
        m_skid_marks[CURRENT]->add(coord, m_angle_sign*angle, length);
    }
    else
    {
        addBreak(coord, angle, length);
    }
}   // add

Here is the call graph for this function:

Here is the caller graph for this function:

void SkidMark::addBreak ( const sgCoord &  coord,
float  angle,
float  length 
)

Definition at line 66 of file skid_mark.cpp.

{
    sgCoord coord(kart_coord);
    coord.xyz[0] += length * sgSin(coord.hpr[0] + m_angle_sign*angle);
    coord.xyz[1] += length* -sgCos(coord.hpr[0] + m_angle_sign*angle);


    const unsigned int CURRENT = (unsigned int)m_skid_marks.size() - 1;
    if(m_skid_marking)
        m_skid_marks[CURRENT]->addEnd(coord);
    else
    {
        m_global_track_offset += 0.005f;
        if(m_global_track_offset > 0.05f) m_global_track_offset = 0.01f;

        // Width of the skidmark
        const float WIDTH = 0.1f;

        sgVec3 pos;
        sgSetVec3(pos,
                  coord.xyz[0] + sgSin(coord.hpr[0]-90) * WIDTH,
                  coord.xyz[1] - sgCos(coord.hpr[0]-90) * WIDTH,
                  coord.xyz[2] + m_global_track_offset);
        ssgVertexArray* SkidMarkVertices = new ssgVertexArray;
        SkidMarkVertices->add(pos);

        sgSetVec3(pos,
                  coord.xyz[0] + sgSin(coord.hpr[0]+90) * WIDTH,
                  coord.xyz[1] - sgCos(coord.hpr[0]+90) * WIDTH,
                  coord.xyz[2] + m_global_track_offset);
        SkidMarkVertices->add(pos);

        sgVec3 norm;
        sgSetVec3(norm, 0, 0, 1);

        ssgNormalArray* SkidMarkNormals = new ssgNormalArray;
        SkidMarkNormals->add(norm);
        SkidMarkNormals->add(norm);

        sgVec4 color;
        sgSetVec4(color, 0, 0, 0, 1);

        ssgColourArray* SkidMarkColors = new ssgColourArray;
        SkidMarkColors->add(color);
        SkidMarkColors->add(color);

        SkidMarkPos* new_skid_mark = new SkidMarkPos( SkidMarkVertices,
                                   SkidMarkNormals,
                                   SkidMarkColors,
                                   m_global_track_offset);
        new_skid_mark->ref();
        scene->add(new_skid_mark);
        new_skid_mark-> setState (m_skid_state);

        m_skid_marks.push_back(new_skid_mark);
    }   // if m_skid_marking

    m_skid_marking = !m_skid_marking;
}   // addBreak

Here is the call graph for this function:

Here is the caller graph for this function:

bool SkidMark::wasSkidMarking ( ) const

Definition at line 127 of file skid_mark.cpp.

{
    return m_skid_marking;
}   // wasSkidMarking

Here is the caller graph for this function:


Member Data Documentation

float SkidMark::m_angle_sign [private]

Definition at line 30 of file skid_mark.hpp.

float SkidMark::m_global_track_offset = 0.005f [static, private]

Definition at line 65 of file skid_mark.hpp.

bool SkidMark::m_skid_marking [private]

Definition at line 64 of file skid_mark.hpp.

std::vector<SkidMarkPos *> SkidMark::m_skid_marks [private]

Definition at line 69 of file skid_mark.hpp.

ssgSimpleState* SkidMark::m_skid_state [private]

Definition at line 70 of file skid_mark.hpp.


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