Back to index

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

#include <herring.hpp>

List of all members.

Public Member Functions

 Herring (herringType type, sgVec3 *xyz, ssgEntity *model)
 ~Herring ()
void update (float delta)
bool wasEaten ()
void isEaten ()
herringType getType ()
int hitKart (Kart *kart)
void reset ()
ssgTransform * getRoot () const

Private Attributes

herringType m_type
bool m_eaten
float m_time_to_return
sgCoord m_coord
ssgTransform * m_root
ssgTransform * m_rotate
float m_rotation

Detailed Description

Definition at line 33 of file herring.hpp.


Constructor & Destructor Documentation

Herring::Herring ( herringType  type,
sgVec3 *  xyz,
ssgEntity *  model 
)

Definition at line 25 of file herring.cpp.

{
    sgSetVec3(m_coord.hpr, 0.0f, 0.0f, 0.0f);

    sgCopyVec3(m_coord.xyz, *xyz);
    m_root   = new ssgTransform();
    m_root->ref();
    m_root->setTransform(&m_coord);

    m_rotate = new ssgTransform();
    m_rotate->ref();
    m_rotate->addKid(model);
    m_root->addKid(m_rotate);
    scene->add(m_root);

    m_type           = _type;
    m_eaten         = false;
    m_rotation       = 0.0f;
    m_time_to_return = 0.0f;  // not strictly necessary, see isEaten()
}   // Herring

Here is the call graph for this function:

Definition at line 47 of file herring.cpp.

{
    ssgDeRefDelete(m_root);
    ssgDeRefDelete(m_rotate);
}   // ~Herring

Member Function Documentation

ssgTransform* Herring::getRoot ( ) const [inline]

Definition at line 54 of file herring.hpp.

{return m_root;}

Definition at line 51 of file herring.hpp.

{return m_type;}

Here is the caller graph for this function:

int Herring::hitKart ( Kart kart)

Definition at line 62 of file herring.cpp.

{
    return sgDistanceSquaredVec3 ( kart->getCoord()->xyz, m_coord.xyz ) < 0.8f;
}   // hitKart

Here is the call graph for this function:

void Herring::isEaten ( )

Definition at line 99 of file herring.cpp.

Here is the call graph for this function:

void Herring::reset ( )

Definition at line 54 of file herring.cpp.

{
    m_eaten         = false;
    m_time_to_return = 0.0f;
    m_root->setTransform(&m_coord);
}   // reset
void Herring::update ( float  delta)

Definition at line 68 of file herring.cpp.

{
    if(m_eaten)
    {
        const float T = m_time_to_return - world->getTime();
        if ( T > 0 )
        {
            sgVec3 hell;
            sgCopyVec3(hell, m_coord.xyz);

            hell[2] = ( T > 1.0f ) ? -1000000.0f : m_coord.xyz[2] - T / 2.0f;
            m_root -> setTransform(hell);
        }
        else
        {
            m_eaten   = false;
            m_rotation = 0.0f;
            m_root -> setTransform(&m_coord);
        }   // T>0

    }
    else
    {   // not m_eaten
        sgCoord c = { { 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 } } ;
        c.hpr[0] = m_rotation;
        m_rotation += 180.0f*delta;
        m_rotate -> setTransform ( &c ) ;
    }
}   // update

Here is the call graph for this function:

bool Herring::wasEaten ( ) [inline]

Definition at line 49 of file herring.hpp.

{return m_eaten;}

Member Data Documentation

sgCoord Herring::m_coord [private]

Definition at line 39 of file herring.hpp.

bool Herring::m_eaten [private]

Definition at line 37 of file herring.hpp.

ssgTransform* Herring::m_root [private]

Definition at line 41 of file herring.hpp.

ssgTransform* Herring::m_rotate [private]

Definition at line 42 of file herring.hpp.

float Herring::m_rotation [private]

Definition at line 43 of file herring.hpp.

float Herring::m_time_to_return [private]

Definition at line 38 of file herring.hpp.

Definition at line 36 of file herring.hpp.


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