Back to index

supertuxkart  0.5+dfsg1
Public Member Functions | Protected Member Functions | Protected Attributes
CollectableManager Class Reference

#include <collectable_manager.hpp>

Collaboration diagram for CollectableManager:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CollectableManager ()
void loadCollectables ()
void removeTextures ()
void Load (int collectType, const char *filename)
MaterialgetIcon (int type) const
ssgEntity * getModel (int type) const
float getForceToTarget (int type) const
float getMaxDistance (int type) const
float getMaxTurnAngle (int type) const
const btVector3getExtend (int type) const

Protected Member Functions

void LoadNode (const lisp::Lisp *lisp, int collectType)

Protected Attributes

Materialm_all_icons [COLLECT_MAX]
float m_all_max_distance [COLLECT_MAX]
float m_all_force_to_target [COLLECT_MAX]
float m_all_max_turn_angle [COLLECT_MAX]
ssgEntity * m_all_models [COLLECT_MAX]
btVector3 m_all_extends [COLLECT_MAX]

Detailed Description

Definition at line 38 of file collectable_manager.hpp.


Constructor & Destructor Documentation

Definition at line 57 of file collectable_manager.cpp.

{
    for(int i=0; i<COLLECT_MAX; i++)
    {
        m_all_models[i] = (ssgEntity*)NULL;
        m_all_icons[i]  = (Material*)NULL;
    }
}   // CollectableManager

Member Function Documentation

const btVector3& CollectableManager::getExtend ( int  type) const [inline]

Definition at line 59 of file collectable_manager.hpp.

{return m_all_extends[type];     }
float CollectableManager::getForceToTarget ( int  type) const [inline]

Definition at line 56 of file collectable_manager.hpp.

{return m_all_force_to_target[type]; }
Material* CollectableManager::getIcon ( int  type) const [inline]

Definition at line 54 of file collectable_manager.hpp.

{return m_all_icons [type];      }

Here is the caller graph for this function:

float CollectableManager::getMaxDistance ( int  type) const [inline]

Definition at line 57 of file collectable_manager.hpp.

{return m_all_max_distance[type];}
float CollectableManager::getMaxTurnAngle ( int  type) const [inline]

Definition at line 58 of file collectable_manager.hpp.

{return m_all_max_turn_angle[type];}
ssgEntity* CollectableManager::getModel ( int  type) const [inline]

Definition at line 55 of file collectable_manager.hpp.

{return m_all_models[type];      }
void CollectableManager::Load ( int  collectType,
const char *  filename 
)

Definition at line 88 of file collectable_manager.cpp.

{
    const lisp::Lisp* ROOT = 0;

    lisp::Parser parser;
    std::string tmp= "data/" + (std::string)filename;
    ROOT = parser.parse(file_manager->getConfigFile(filename));
        
    const lisp::Lisp* lisp = ROOT->getLisp("tuxkart-collectable");
    if(!lisp)
    {
        char msg[MAX_ERROR_MESSAGE_LENGTH];
        snprintf(msg, sizeof(msg), 
                 "No 'tuxkart-collectable' node found while parsing '%s'.",
                 filename);
        throw std::runtime_error(msg);
    }
    LoadNode(lisp, collectType);

    delete ROOT;

}   // Load

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 79 of file collectable_manager.cpp.

{
    for(int i=0; ict[i].collectable != COLLECT_MAX; i++)
    {
        Load(ict[i].collectable, ict[i].dataFile);
    }
}  // loadCollectables

Here is the call graph for this function:

void CollectableManager::LoadNode ( const lisp::Lisp lisp,
int  collectType 
) [protected]

Definition at line 112 of file collectable_manager.cpp.

{
    std::string sName, sModel, sIconFile; 
    lisp->get("name",            sName                              );
    lisp->get("model",           sModel                             );
    lisp->get("icon",            sIconFile                          );
 
    // load material
    m_all_icons[collectType] = material_manager->getMaterial(sIconFile);
    m_all_icons[collectType]->getState()->ref();

    //FIXME: something probably forgets to disable GL_CULL_FACE after enabling it,
    //this is just a quick fix.
    if(collectType == COLLECT_SPARK) m_all_icons[COLLECT_SPARK]->getState()->disable ( GL_CULL_FACE ) ;

    if(sModel!="")
    {
        ssgEntity* e = loader->load(sModel, CB_COLLECTABLE);
        m_all_models[collectType] = e;
        e->ref();
        e->clrTraversalMaskBits(SSGTRAV_ISECT|SSGTRAV_HOT);
    }
    else
    {
        m_all_models[collectType] = 0;
        m_all_extends[collectType] = btVector3(0.0f,0.0f,0.0f);
    }

    // Load special attributes for certain collectables
    switch (collectType) {
        case COLLECT_SPARK:          
             Spark::init  (lisp, m_all_models[collectType]); break;
        case COLLECT_MISSILE:        
             Missile::init(lisp, m_all_models[collectType]); break;
        case COLLECT_HOMING: 
             Homing::init (lisp, m_all_models[collectType]); break;
        default:;
    }   // switch

}   // LoadNode

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 67 of file collectable_manager.cpp.

{
    for(int i=0; i<COLLECT_MAX; i++)
    {
        if(m_all_icons [i]) ssgDeRefDelete(m_all_icons [i]->getState());
        if(m_all_models[i]) ssgDeRefDelete(m_all_models[i]            );
    }   // for
    callback_manager->clear(CB_COLLECTABLE);

}   // removeTextures

Here is the call graph for this function:


Member Data Documentation

Definition at line 47 of file collectable_manager.hpp.

Definition at line 43 of file collectable_manager.hpp.

Definition at line 41 of file collectable_manager.hpp.

Definition at line 42 of file collectable_manager.hpp.

Definition at line 45 of file collectable_manager.hpp.

Definition at line 46 of file collectable_manager.hpp.


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