NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgSimViewGraphics Class Reference
Inheritance diagram for tgSimViewGraphics:
Collaboration diagram for tgSimViewGraphics:

Public Member Functions

 tgSimViewGraphics (tgWorld &world, double stepSize=1.0/120.0, double renderRate=1.0/60.0)
 
void run ()
 
void setup ()
 
void teardown ()
 
void render ()
 
virtual void run (int steps)
 
void reset ()
 
void initPhysics ()
 
void exitPhysics ()
 
virtual void clientMoveAndDisplay ()
 
virtual void displayCallback ()
 
virtual void clientResetScene ()
 
tgWorldworld ()
 
virtual void render () const
 
virtual void render (const tgModelVisitor &r) const
 
void setRenderRate (double renderRate)
 
double getRenderRate () const
 
void setStepSize (double stepSize)
 
double getStepSize () const
 

Protected Member Functions

void bindToSimulation (tgSimulation &simulation)
 
void releaseFromSimulation ()
 
void bindToWorld (tgWorld &world)
 
bool isInitialzed () const
 

Protected Attributes

tgSimulationm_pSimulation
 
tgModelVisitorm_pModelVisitor
 
double m_stepSize
 
double m_renderRate
 
double m_renderTime
 

Detailed Description

Definition at line 53 of file tgSimViewGraphics.h.

Constructor & Destructor Documentation

tgSimViewGraphics::tgSimViewGraphics ( tgWorld world,
double  stepSize = 1.0/120.0,
double  renderRate = 1.0/60.0 
)

The only constructor.

Parameters
[in]worlda reference to the tgWorld being simulated.
[in]stepSizethe time interval for advancing the simulation; std::invalid_argument is thrown if not positive
[in]renderRatethe time interval for updating the graphics; std::invalid_argument is thrown if less than stepSize
Exceptions
std::invalid_argumentif stepSize is not positive or renderRate is less than stepSize
Todo:
figure out a good time to delete this

Definition at line 36 of file tgSimViewGraphics.cpp.

Member Function Documentation

void tgSimView::bindToSimulation ( tgSimulation simulation)
protectedinherited

Called by a constructor of friend class tgSimulation when an instance of this class is passed as argument to the constructor. Cache a back pointer to the tgSimulation

Parameters
[in,out]simulationa reference to the tgSimulation being constructed
Exceptions
std::invalid_argumentif the tgSimView already has a back pointer.

Definition at line 77 of file tgSimView.cpp.

Here is the caller graph for this function:

void tgSimView::bindToWorld ( tgWorld world)
protectedinherited

When bound to a tgSimulation, a tgWorld becomes available for the first time.

Parameters
[in,out]worlda reference to a newly-available tgWorld

Definition at line 105 of file tgSimView.cpp.

Here is the caller graph for this function:

void tgSimViewGraphics::clientMoveAndDisplay ( )
virtual

Requried by tgDemoApplication. Handles Rendering

Definition at line 140 of file tgSimViewGraphics.cpp.

Here is the caller graph for this function:

void tgSimViewGraphics::clientResetScene ( )
virtual

Called when the space bar is pressed. Calls reset, then updates the pointers to the world and glDebugDrawer

Definition at line 175 of file tgSimViewGraphics.cpp.

void tgSimViewGraphics::displayCallback ( )
virtual

Contains a smaller set of rendering functions than clientMoveAndDisplay

Definition at line 159 of file tgSimViewGraphics.cpp.

Here is the call graph for this function:

double tgSimView::getRenderRate ( ) const
inlineinherited

Return the interval in seconds at which the graphics are rendered.

Returns
the interval in seconds at which the graphics are rendered

Definition at line 118 of file tgSimView.h.

double tgSimView::getStepSize ( ) const
inlineinherited

Return the interval in seconds at which the graphics are rendered.

Returns
the interval in seconds at which the graphics are rendered

Definition at line 133 of file tgSimView.h.

bool tgSimView::isInitialzed ( ) const
inlineprotectedinherited
Todo:
Get rid of this. May only be possible once we're no longer using GLUT

Definition at line 162 of file tgSimView.h.

void tgSimView::releaseFromSimulation ( )
protectedinherited

Called by the destructor of friend class tgSimulation. Assure that m_pView has a NULL back pointer to its tgSimulation. This allows the tgSimView to be re-used.

Definition at line 96 of file tgSimView.cpp.

void tgSimView::render ( ) const
virtualinherited

Send the tgModelVisitor to the simulation

Definition at line 161 of file tgSimView.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void tgSimView::render ( const tgModelVisitor r) const
virtualinherited

Send the tgModelVisitor that was passed in to the simulation

Definition at line 170 of file tgSimView.cpp.

Here is the call graph for this function:

void tgSimViewGraphics::render ( )

Clears the openGL buffer and dispatches a tgBulletRenderer to the world

Definition at line 85 of file tgSimViewGraphics.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void tgSimViewGraphics::reset ( )
virtual

Resets the simulation using simulation->reset() the simulation will call setup and teardown on this as appropreate

Reimplemented from tgSimView.

Definition at line 133 of file tgSimViewGraphics.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void tgSimViewGraphics::run ( )
inlinevirtual

Run until user stops - currently the same as run(steps) due to use of GLUT

Reimplemented from tgSimView.

Definition at line 79 of file tgSimViewGraphics.h.

void tgSimViewGraphics::run ( int  steps)
virtual

Run for a specified number of steps. Currently performs the role of run() at this level

Todo:
doesn't work until FreeGLUT or another rendering engine is implemented

Reimplemented from tgSimView.

Definition at line 104 of file tgSimViewGraphics.cpp.

Here is the call graph for this function:

void tgSimView::setRenderRate ( double  renderRate)
inherited

Set the interval in seconds at which the graphics are to be rendered. It is set to the minimum of the renderRate argument and the current step size.

Parameters
[in]renderRatethe interval in seconds at which the graphics are to be rendered

Definition at line 188 of file tgSimView.cpp.

Here is the caller graph for this function:

void tgSimView::setStepSize ( double  stepSize)
inherited

Set the interval in seconds at which the simulation is advanced. The render rate is adjusted to be no less than stepSize.

Parameters
[in]stepSizethe interval in seconds at which the simulation is advanced; std::invalid_argument is thrown if stepSize is not positive
Exceptions
std::invalid_argumentif stepSize is not positive

Definition at line 196 of file tgSimView.cpp.

Here is the call graph for this function:

void tgSimViewGraphics::setup ( )
virtual

Gives us a pointer to the world, sets up the debug drawer for the dynamics world and sets up a new tgBulletRenderer

Todo:
Can this pointer become invalid if a reset occurs?

Reimplemented from tgSimView.

Definition at line 56 of file tgSimViewGraphics.cpp.

void tgSimViewGraphics::teardown ( )
virtual

Nullifies the pointer to the dynamics world, calls tgSimView::teardown()

Reimplemented from tgSimView.

Definition at line 78 of file tgSimViewGraphics.cpp.

Here is the call graph for this function:

tgWorld& tgSimView::world ( )
inlineinherited

Return a reference to the tgWorld being simulated.

Returns
a reference to the tgWorld being simulated

Definition at line 65 of file tgSimView.h.

Member Data Documentation

tgModelVisitor* tgSimView::m_pModelVisitor
protectedinherited

An object that knows how to visit the various models for rendering or data logging.

Note
This is a pointer to avoid #including the header file.

Definition at line 179 of file tgSimView.h.

tgSimulation* tgSimView::m_pSimulation
protectedinherited

A back pointer to the simulation that owns this view. Made protected to allow tgSimulatorWithGraphics to inherit it. The constructor initializes it to NULL and it becomes non-NULL when added to a simulation.

Definition at line 172 of file tgSimView.h.

double tgSimView::m_renderRate
protectedinherited

The interval in seconds at which the graphics are rendered. It must be be greater than or equal to m_stepSize. Note that Bullet is set to render at 60 hz (60 fps), so changing this from 60 may cause the simulation to run faster or slower than real time.

Todo:
See about maintaining real time simulation with a different rendering rate

Definition at line 199 of file tgSimView.h.

double tgSimView::m_renderTime
protectedinherited

The time in seconds when the next render should be. It must be non-negative.

Definition at line 205 of file tgSimView.h.

double tgSimView::m_stepSize
protectedinherited

The interval in seconds at which the simulation is advanced. It must be positive and it must be less than or equal to m_renderRate. Typically between 1/1000 and 1/4000 will run close to real time. Slower simulations will run faster but be less accurate.

Definition at line 188 of file tgSimView.h.


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