Menge
Modular Pedestrian Simulation Framework for Research and Development
|
Class for defining an OpenGL Viewer. More...
#include <GLViewer.h>
Public Member Functions | |
GLViewer (int width, int height) | |
Default constructor based on preferred viewer size. More... | |
GLViewer (ViewConfig &cfg) | |
Constructor based on configuration in a ViewConfig instance. More... | |
~GLViewer (void) | |
Destructor. | |
void | run () |
Runs the main loop – including advancing the scene in time. Exiting this function means the main event loop is no longer running. | |
bool | setBGImage (const std::string &imgName) |
Sets the optional background image to the viewer. More... | |
bool | hasBGImage () const |
Reports if the viewer has a background image. More... | |
bool | setWatermark (const std::string &imgName) |
Sets the watermark to the viewer. More... | |
bool | hasWatermark () const |
Reports if the viewer has a watermark. More... | |
void | clearBGImage () |
Clears the background image from the viewer. | |
bool | initViewer (const std::string &title) |
Initializes the viewer with the given title. More... | |
void | resizeGL (int w, int h) |
Resizes the window to the indicated size. More... | |
void | initGL () |
Initializes the opengl mechanism. | |
void | setScene (SceneGraph::GLScene *scene) |
Sets the GLScene to be drawn. A viewer can only draw a single scene; all drawn elements belong either to the GLScene or a GLContext. More... | |
void | newGLContext () |
Causes the viewer to recognize that a new OpenGL context has been created (such as window resizes). | |
void | drawGL () |
Main drawing function – draws scene and context as available. | |
bool | handleMouse (SDL_Event &e) |
Processes a mouse event. More... | |
bool | handleKeyboard (SDL_Event &e) |
Processes a keyboard event. More... | |
void | setDrawWorldAxis (bool state) |
Sets whether the world axis is drawn or not. More... | |
bool | getDrawWorldAxis () const |
Reports the state of whether the world axis is drawn or not. More... | |
void | drawRecordingFrame () const |
Draws a red frame around the viewer, indicating that images are being saved. | |
void | setCameraFOV (int i, float fov) |
Sets the horizontal field of view for the ith camera. More... | |
void | setCameraFarPlane (int i, float dist) |
Sets the distance to the camera's far clipping plane. More... | |
void | offsetTime (float delta) |
Change the scene time by the given offset. More... | |
void | setTime (float t) |
Sets the current time. More... | |
void | setBGColor (float r, float g, float b) |
Sets the view's background color. This must be called AFTER the view has been initialized. More... | |
SceneGraph::GLCamera * | getCamera (int i=0) |
Gets a pointer to the ith camera. More... | |
void | setFixedStep (float stepSize) |
Sets the simulator to use a fixed time step, with the given value. More... | |
void | setDumpPath (const std::string &path) |
Sets the path for when outputting screen capture images. More... | |
Protected Member Functions | |
void | initLighting () |
Initizlies the OpenGL lighting based on the set of lights. | |
bool | initSDL (const std::string &title) |
Initializes the SDL mechanism for event handling and context creation. | |
void | drawWorldAxis () const |
Draws a simple, three-color world axis at the origin of world space. | |
Protected Attributes | |
int | _width |
The width of the viewer window (in pixels). | |
int | _height |
The height of the viewer window (in pixels). | |
SceneGraph::GLScene * | _scene |
The GLScene to draw. | |
std::vector< SceneGraph::GLCamera > | _cameras |
A set of cameras from which to draw the scene. | |
size_t | _currCam |
The index of camera currently being used to draw the scene. | |
int | _downX |
The x-position of the mouse when a mouse button was depressed (in screen space). | |
int | _downY |
The y-position of the mouse when a mouse button was depressed (in screen space). | |
bool | _update |
Determines if the GLScene needs to update. | |
bool | _drawWorldAxis |
Determines whether a world-aligned axis is drawn. | |
bool | _showFPS |
Determines whether the frame rate is displayed in the viewer. | |
SampleTimer | _fpsDisplayTimer |
A timer to determine the displayed frame rate value. | |
bool | _pause |
Controls whether the viewer advances the GLScene (true) or not (false). | |
bool | _running |
Determines if the viewer should still operate – as long as it is true, it will continue its main loop (. More... | |
float | _viewTime |
The current time at which the viewer is running. Modified by calls to GLViewer::setTime and GLViewer::offsetTime. | |
Vector3 | _bgColor |
The viewer's background color. | |
float | _stepSize |
The step size for fixed-step simulation. | |
Image * | _bgImg |
A pointer to the optional background image. | |
Watermark * | _waterMark |
An optional watermark. | |
bool | _dumpImages |
Determines if screen capture images will be output at each time advance. | |
bool | _validDumpPath |
Reports if the screen capture output path is valid. | |
std::string | _dumpPath |
The path to the folder in which to write screen capture images. | |
size_t | _imgCount |
The number of images which have been output. Used for labeling the image file names into a sequential order. | |
std::vector< SceneGraph::GLLight > | _lights |
The set of lights to use in rendering. | |
Static Protected Attributes | |
static Uint32 | FLAGS = SDL_OPENGL | SDL_DOUBLEBUF | SDL_RESIZABLE |
The various SDL flags which determine the view. | |
Class for defining an OpenGL Viewer.
Menge::Vis::GLViewer::GLViewer | ( | int | width, |
int | height | ||
) |
Default constructor based on preferred viewer size.
width | The width of the view window, in pixels. |
height | The height of the view window, in pixels. |
Menge::Vis::GLViewer::GLViewer | ( | ViewConfig & | cfg | ) |
Constructor based on configuration in a ViewConfig instance.
cfg | A fully specified view configuration. |
|
inline |
Gets a pointer to the ith camera.
i | The index of the desired camera. The index value is not checked. |
|
inline |
Reports the state of whether the world axis is drawn or not.
bool Menge::Vis::GLViewer::handleKeyboard | ( | SDL_Event & | e | ) |
Processes a keyboard event.
e | An SDL_Event corresponding with an appropriate SDL keyboard event (key up/down). |
bool Menge::Vis::GLViewer::handleMouse | ( | SDL_Event & | e | ) |
Processes a mouse event.
e | An SDL_Event corresponding with an appropriate SDL mouse event (button up/down, move). |
This scale should be the size of a pixel at the target depth
|
inline |
Reports if the viewer has a background image.
|
inline |
Reports if the viewer has a watermark.
bool Menge::Vis::GLViewer::initViewer | ( | const std::string & | title | ) |
Initializes the viewer with the given title.
title | The name displayed at the top of the window. |
void Menge::Vis::GLViewer::offsetTime | ( | float | delta | ) |
Change the scene time by the given offset.
delta | The amount of time change. Can be negative, but only meaningful if the GLScene can support negative time changes. |
void Menge::Vis::GLViewer::resizeGL | ( | int | w, |
int | h | ||
) |
Resizes the window to the indicated size.
w | The new width of the viewer window. |
h | The new height of the viewer window. |
void Menge::Vis::GLViewer::setBGColor | ( | float | r, |
float | g, | ||
float | b | ||
) |
Sets the view's background color. This must be called AFTER the view has been initialized.
r | The red component of the background color (must be in the range [0, 1]). |
g | The green component of the background color (must be in the range [0, 1]). |
b | The blue component of the background color (must be in the range [0, 1]). |
bool Menge::Vis::GLViewer::setBGImage | ( | const std::string & | imgName | ) |
Sets the optional background image to the viewer.
imgName | A valid path to a valid image to load. |
|
inline |
Sets the distance to the camera's far clipping plane.
i | The index of the camera - index value is NOT checked. |
dist | The distance, from the camera, to its far clipping plane. Value is not validated. |
|
inline |
Sets the horizontal field of view for the ith camera.
i | The index of the camera - index value is NOT checked. |
fov | The horizontal field of view for the indicated camera. Value is not validated. |
|
inline |
Sets whether the world axis is drawn or not.
state | A boolean controlling whether the world axis is drawn (true) or not (false). |
void Menge::Vis::GLViewer::setDumpPath | ( | const std::string & | path | ) |
Sets the path for when outputting screen capture images.
path | The path to which output images should be written. |
void Menge::Vis::GLViewer::setFixedStep | ( | float | stepSize | ) |
Sets the simulator to use a fixed time step, with the given value.
stepSize | The size of the fixed step the viewer should advance its GLScene. |
void Menge::Vis::GLViewer::setScene | ( | SceneGraph::GLScene * | scene | ) |
Sets the GLScene to be drawn. A viewer can only draw a single scene; all drawn elements belong either to the GLScene or a GLContext.
scene | The GLScene to be rendered and temporally advanced. |
|
inline |
Sets the current time.
t | The current time for the viewer and its GLScene. |
bool Menge::Vis::GLViewer::setWatermark | ( | const std::string & | imgName | ) |
Sets the watermark to the viewer.
imgName | A valid path to a valid image to load. |
|
protected |
Determines if the viewer should still operate – as long as it is true, it will continue its main loop (.