Back to index

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

#include <scene.hpp>

Collaboration diagram for Scene:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void clear ()
 Scene ()
 ~Scene ()
void reset ()
void add (ssgEntity *kid)
void remove (ssgEntity *kid)
void draw (float dt)
CameracreateCamera (int playerId, const Kart *kart)

Private Types

typedef std::vector< Camera * > Cameras

Private Attributes

ssgRoot * m_scenegraph
Cameras m_cameras

Detailed Description

Definition at line 31 of file scene.hpp.


Member Typedef Documentation

typedef std::vector<Camera*> Scene::Cameras [private]

Definition at line 34 of file scene.hpp.


Constructor & Destructor Documentation

Definition at line 38 of file scene.cpp.

             :
m_scenegraph(new ssgRoot)
{
}

Definition at line 44 of file scene.cpp.

{
    delete m_scenegraph;
}

Member Function Documentation

void Scene::add ( ssgEntity *  kid)

Definition at line 75 of file scene.cpp.

{
    m_scenegraph->addKid( kid );
}

Here is the caller graph for this function:

void Scene::clear ( )

Definition at line 50 of file scene.cpp.

{
    if(m_scenegraph != 0)
    {
        m_scenegraph->removeAllKids();
    }

    for (Cameras::iterator i = m_cameras.begin(); i != m_cameras.end(); ++i)
        delete *i;

    m_cameras.clear();
}

Here is the caller graph for this function:

Camera * Scene::createCamera ( int  playerId,
const Kart kart 
)

Definition at line 65 of file scene.cpp.

{
  Camera *cam = new Camera(playerId, kart);

  m_cameras.push_back(cam);

  return cam;
}

Here is the caller graph for this function:

void Scene::draw ( float  dt)

Definition at line 95 of file scene.cpp.

{
    glEnable ( GL_DEPTH_TEST ) ;

    const Track* TRACK = world->m_track;

    ssgGetLight ( 0 ) -> setPosition ( TRACK->getSunPos() ) ;
    ssgGetLight ( 0 ) -> setColour ( GL_AMBIENT , TRACK->getAmbientCol()  ) ;
    ssgGetLight ( 0 ) -> setColour ( GL_DIFFUSE , TRACK->getDiffuseCol() ) ;
    ssgGetLight ( 0 ) -> setColour ( GL_SPECULAR, TRACK->getSpecularCol() ) ;

    if (TRACK->useFog())
    {
        glEnable ( GL_FOG ) ;

        glFogf ( GL_FOG_DENSITY, TRACK->getFogDensity() ) ;
        glFogfv( GL_FOG_COLOR  , TRACK->getFogColor() ) ;
        glFogf ( GL_FOG_START  , TRACK->getFogStart() ) ;
        glFogf ( GL_FOG_END    , TRACK->getFogEnd() ) ;
        glFogi ( GL_FOG_MODE   , GL_EXP2   ) ;
        glHint ( GL_FOG_HINT   , GL_NICEST ) ;

        /* Clear the screen */
        glClearColor (TRACK->getFogColor()[0],
                      TRACK->getFogColor()[1],
                      TRACK->getFogColor()[2],
                      TRACK->getFogColor()[3]);
    }
    else
    {
        /* Clear the screen */
        glClearColor (TRACK->getSkyColor()[0],
                      TRACK->getSkyColor()[1],
                      TRACK->getSkyColor()[2],
                      TRACK->getSkyColor()[3]);
    }

    glClear      ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;

    for (Cameras::iterator i = m_cameras.begin(); i != m_cameras.end(); ++i)
    {
        (*i)->update(dt);
        (*i)->apply ();

        if(!user_config->m_bullet_debug)
        {
            // Use this for faster profiling by disabling drawing the scene graph
            //if(!user_config->m_profile)ssgCullAndDraw ( m_scenegraph );
            ssgCullAndDraw ( m_scenegraph );
        }
        else
        {
            // Use bullets debug drawer
            GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
            GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
            GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 };
            /*       light_position is NOT default value       */
            GLfloat light_position0[] = { 1.0, 1.0, 1.0, 0.0 };
            GLfloat light_position1[] = { -1.0, -1.0, -1.0, 0.0 };
            
            glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
            glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
            glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
            glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
            
            glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);
            glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);
            glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);
            glLightfv(GL_LIGHT1, GL_POSITION, light_position1);
            
            glEnable(GL_LIGHTING);
            glEnable(GL_LIGHT0);
            glEnable(GL_LIGHT1);
            
            glShadeModel(GL_SMOOTH);
            glEnable(GL_DEPTH_TEST);
            glDepthFunc(GL_LESS);
            
            glClearColor(0.8,0.8,0.8,0);
            
            glMatrixMode(GL_PROJECTION);
            glLoadIdentity();
            float f=2.0f;
            glFrustum(-f, f, -f, f, 1.0, 1000.0);
            
            btVector3 pos;
            sgCoord *c = world->getKart(race_manager->getNumKarts()-1)->getCoord();
            gluLookAt(c->xyz[0], c->xyz[1]-5.f, c->xyz[2]+4,
                      c->xyz[0], c->xyz[1],     c->xyz[2],
                      0.0f, 0.0f, 1.0f);
            glMatrixMode(GL_MODELVIEW);
            
            for (World::Karts::size_type i = 0 ; i < race_manager->getNumKarts(); ++i)
            {
                Kart *kart=world->getKart((int)i);
                if(!kart->isEliminated()) kart->draw();
            }
            world->getPhysics()->draw();
        }   //  bullet_debug
    }   // for cameras

    if (TRACK->useFog())
    {
        glDisable ( GL_FOG ) ;
    }

    glViewport ( 0, 0, user_config->m_width, user_config->m_height ) ;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Scene::remove ( ssgEntity *  kid)

Definition at line 81 of file scene.cpp.

{
    m_scenegraph->removeKid( kid );
}

Here is the caller graph for this function:

void Scene::reset ( )

Definition at line 87 of file scene.cpp.

{
    for (Cameras::iterator i = m_cameras.begin(); i != m_cameras.end(); ++i)
    {
        (*i)->reset();
    }
}   // reset

Here is the caller graph for this function:


Member Data Documentation

Definition at line 35 of file scene.hpp.

ssgRoot* Scene::m_scenegraph [private]

Definition at line 33 of file scene.hpp.


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