Back to index

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

#include <moving_texture.hpp>

Inheritance diagram for MovingTexture:
Inheritance graph
[legend]
Collaboration diagram for MovingTexture:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MovingTexture (char *data, ssgBranch *branch_)
 ~MovingTexture ()
void update (float dt)
void init ()
virtual void reset ()
virtual void handleExplosion (const btVector3 &pos, bool directHit)

Private Types

enum  allCallbackModesType {
  MODE_NONE, MODE_FORWARD, MODE_CYCLE, MODE_SHUTTLE,
  MODE_SINESHUTTLE
}

Private Member Functions

void parseData (char *data)

Private Attributes

sgCoord m_delta
sgCoord m_now
float m_phase
float m_cycle
int m_mode
ssgBranch * m_branch

Detailed Description

Definition at line 28 of file moving_texture.hpp.


Member Enumeration Documentation

Enumerator:
MODE_NONE 
MODE_FORWARD 
MODE_CYCLE 
MODE_SHUTTLE 
MODE_SINESHUTTLE 

Definition at line 32 of file moving_texture.hpp.


Constructor & Destructor Documentation

MovingTexture::MovingTexture ( char *  data,
ssgBranch *  branch_ 
)

Definition at line 26 of file moving_texture.cpp.

{
    m_branch = branch;
    branch->setUserData(new ssgBase());
    branch->setName("MovingTexture");

    m_branch->ref();
    m_phase  = 0.0f;
    m_mode   = MODE_FORWARD;
    m_cycle  = 30.0f;
    sgSetCoord(&m_now,   0, 0, 0, 0, 0, 0 ) ;
    sgSetCoord(&m_delta, 0, 0, 0, 0, 0, 0 ) ;
    parseData(data);


}   // MovingTexture

Here is the call graph for this function:

Definition at line 44 of file moving_texture.cpp.

{
    ssgDeRefDelete(m_branch);

}   // ~MovingTexture

Member Function Documentation

virtual void Callback::handleExplosion ( const btVector3 pos,
bool  directHit 
) [inline, virtual, inherited]

Reimplemented in MovingPhysics.

Definition at line 32 of file callback.hpp.

{};
void MovingTexture::init ( ) [inline, virtual]

Implements Callback.

Definition at line 48 of file moving_texture.hpp.

{};
void MovingTexture::parseData ( char *  data) [private]

Definition at line 51 of file moving_texture.cpp.

{
    char *s = data;

    // convert to uppercase
    while(*s!='\0')
    {
        if( *s>='a' && *s<='z' ) *s = *s - 'a' + 'A' ;
        s++;
    }
    s = data;

    while ( s != NULL && *s != '\0' )
    {
        while ( *s > ' '                ) s++ ;     /* Skip previous token */
        while ( *s <= ' ' && *s != '\0' ) s++ ;     /* Skip spaces         */

        if ( *s == '\0' ) break ;

        float f ;

        if ( sscanf ( s,  "H=%f", & f ) == 1 ) m_delta.hpr[0] = f ; else
        if ( sscanf ( s,  "P=%f", & f ) == 1 ) m_delta.hpr[1] = f ; else
        if ( sscanf ( s,  "R=%f", & f ) == 1 ) m_delta.hpr[2] = f ; else
        if ( sscanf ( s,  "X=%f", & f ) == 1 ) m_delta.xyz[0] = f ; else
        if ( sscanf ( s,  "Y=%f", & f ) == 1 ) m_delta.xyz[1] = f ; else
        if ( sscanf ( s,  "Z=%f", & f ) == 1 ) m_delta.xyz[2] = f ; else
        if ( sscanf ( s,  "C=%f", & f ) == 1 ) m_cycle        = f ; else
        if ( sscanf ( s,  "M=%f", & f ) == 1 ) m_mode         = (int) f ; else
        if ( sscanf ( s,  "O=%f", & f ) == 1 ) m_phase        = f ; else
            fprintf ( stderr, "Unrecognised @autodcs string: '%s'\n", data );
    }   // while s!=NULL&&s!='\0'
}   // parseData

Here is the caller graph for this function:

virtual void Callback::reset ( ) [inline, virtual, inherited]

Reimplemented in MovingPhysics.

Definition at line 31 of file callback.hpp.

{};
void MovingTexture::update ( float  dt) [virtual]

Implements Callback.

Definition at line 86 of file moving_texture.cpp.

{
    sgCoord add;


    float timer = world->getTime() + m_phase ;

    if ( m_cycle != 0.0 && m_mode != MODE_FORWARD )
    {
        if ( m_mode == MODE_SHUTTLE )
        {
            const float CTIMER = fmod ( timer, m_cycle ) ;

            if ( CTIMER > m_cycle / 2.0f )
                timer = m_cycle - CTIMER ;
            else
                timer = CTIMER ;
        }
        else
        {
            if ( m_mode == MODE_SINESHUTTLE )
                timer = sin ( timer * 2.0f * M_PI / m_cycle ) * m_cycle / 2.0f ;
            else
                timer = fmod ( timer, m_cycle ) ;
        }
    }   // m_mode!=MODE_FORWARD

    sgCopyCoord(&add, &m_delta  );
    sgScaleVec3(add.xyz, dt);
    sgScaleVec3(add.hpr, dt);

    sgAddVec3(m_now.xyz, add.xyz);
    sgAddVec3(m_now.hpr, add.hpr);

    /*
      To avoid roundoff problems with very large values
      accumulated after long runs all rotations
      can be modulo-360 degrees.
    */

    m_now.hpr[0] = fmod ( m_now.hpr[0], 360.0f);
    m_now.hpr[1] = fmod ( m_now.hpr[1], 360.0f);
    m_now.hpr[2] = fmod ( m_now.hpr[2], 360.0f);

    if ( m_branch->isAKindOf(ssgTypeTexTrans()) )
    {
        m_now.xyz[0] = fmod( m_now.xyz[0], 1.0f);
        m_now.xyz[1] = fmod( m_now.xyz[1], 1.0f);
        m_now.xyz[2] = fmod( m_now.xyz[2], 1.0f);
    }
    ((ssgBaseTransform *) m_branch) -> setTransform(&m_now);
}   // update

Here is the call graph for this function:


Member Data Documentation

ssgBranch* MovingTexture::m_branch [private]

Definition at line 40 of file moving_texture.hpp.

float MovingTexture::m_cycle [private]

Definition at line 38 of file moving_texture.hpp.

sgCoord MovingTexture::m_delta [private]

Definition at line 35 of file moving_texture.hpp.

int MovingTexture::m_mode [private]

Definition at line 39 of file moving_texture.hpp.

sgCoord MovingTexture::m_now [private]

Definition at line 36 of file moving_texture.hpp.

float MovingTexture::m_phase [private]

Definition at line 37 of file moving_texture.hpp.


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