Public Slots | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
GLWindow Class Reference

The functions and elements of a GLWindow. More...

#include <GLWindow.h>

List of all members.

Public Slots

void reset ()
 reset the simulation
void resetToDefaultValues ()
 reset the simulation values and UI elements to default values
void setAbsoluteTolerance (double _val)
 a slot to change the absolute tolerance for the pressure
void setBoundaryCondition (int _mode)
 a slot to change the boundary condition
void setEmitDensityRate (double _val)
 a slot to change the density rate of the emitter
void setEmitTemperatureRate (double _val)
 a slot to change the temperature rate of the emitter
void setEmitterSize (double _val)
 a slot to change the size of the emitter
void setEmitterSize (int _val)
 a slot to change the size of the emitter
void setGravity (double _val)
 a slot to change the gravity force
void setGridBaseRes (int _res)
 a slot to change the base resolution of the voxel grid
void setGridLengthX (double _length)
 a slot to change the x length of the voxel grid
void setGridLengthY (double _length)
 a slot to change the y length of the voxel grid
void setGridLengthZ (double _length)
 a slot to change the z length of the voxel grid
void setH (double _val)
 a slot to change the scale of the voxel grid
void setKDensityDiss (double _val)
 a slot to change the k density dissipation constant
void setKFall (double _val)
 a slot to change the k fall buoyancy constant
void setKRise (double _val)
 a slot to change the k rise buoyancy constant
void setKTemperDiss (double _val)
 a slot to change the k temperature dissipation constant
void setKVorticity (double _val)
 a slot to change the vorticity confinement constant
void setMaxFPS (double _fps)
 a slot to change the max fps
void setNoiseFrequency (double _val)
 a slot to change frequency of the noise
void setNoiseMagnitude (double _val)
 a slot to change the magnitude of the force of the noise
void setNoiseOctaveCount (double _val)
 a slot to change octave count of the noise
void setNoisePersistence (double _val)
 a slot to change persistence of the noise
void setNoiseSpeed (double _val)
 a slot to change the speed of the noise
void setObstacle (int _mode)
 a slot to change the obstacle
void setOpacityStrength (int _val)
 a slot to change the shadow strength
void setPrecisionX (int _precision)
 a slot to change the x precision of the voxel grid
void setPrecisionY (int _precision)
 a slot to change the y precision of the voxel grid
void setPrecisionZ (int _precision)
 a slot to change the z precision of the voxel grid
void setRelaxationRate (double _val)
 a slot to change the relaxation rate for the pressure
void setShadowStrength (int _val)
 a slot to change the shadow strength
void setSpriteSize (int _size)
 a slot to change the sprite size
void setTimeStep (double _dt)
 a slot to change the time step
void setViscosity (double _val)
 a slot to change the viscosity of the fluid
void toggleDepthTest (bool _mode)
 a slot to toggle the depth test
void toggleTemperature (bool _mode)
 a slot to toggle the displaying of the temperature
void toggleVelocityArrows (bool _mode)
 a slot to toggle the velocity arrows
void toggleVoxelGrid (bool _mode)
 a slot to toggle voxel grid
void toggleWireframe (bool _mode)
 a slot to toggle wireframe mode

Signals

void setUIBuoyancyValues (float _kRise, float _kFall)
 Signal sent to the UI to set the dissipation values.
void setUIDissipationValues (float _kDensityDiss, float _kTemperDiss)
 Signal sent to the UI to set the dissipation values.
void setUIEmitterValues (ngl::Vec3 _emitterLoc, float _emitterSize, float _emitDensityRate, float _emitTemperatureRate)
 Signal sent to the UI to set the emitter values.
void setUIFluidValues (float _viscosity, float _gravity, float _kVorticity)
 Signal sent to the UI to set the fluid values.
void setUIObstacleValues ()
 Signal sent to the UI to set the obstacle values.
void setUINoiseValues (float _frequency, float _octaveCount, float _persistence, float _speed, float _magnitude)
 Signal sent to the UI to set the sprite values.
void setUIPressureValues (float _absoluteTolerance, float _relaxationRate)
 Signal sent to the UI to set the fluid values.
void setUISpriteValues (int _spriteSize, float _opacityStrength, float _shadowStrength)
 Signal sent to the UI to set the sprite values.
void setUITimeValues (float _timeStep, float _maxFPS)
 Signal sent to the UI to set the time values.
void setUIVoxelGridValues (float _gridLengthX, float _gridLengthY, float _gridLengthZ, int _gridBaseRes, int _gridPrecisionX, int _gridPrecisionY, int _gridPrecisionZ, float _h, BOUNDARYCONDITION _condition)
 Signal sent to the UI to set the Voxel Grid UI Values.

Public Member Functions

 GLWindow (QWidget *_parent)
 Constructor for GLWindow.
 ~GLWindow ()
 dtor
void decTime ()
 decrement the time
void displayScreenText ()
 Displays text on the screen like FPS etc.
void drawInWireframe ()
 Draws in wireframe based on the m_wireframe boolean.
void drawSmokeSprites ()
 Draws the smoke sprites.
void drawVelocityField ()
 Draws the velocity field.
void drawVoxelGrid ()
 Draws the voxel grid.
void drawObstacle ()
 Draws the obstacle.
SmokeSystemgetSmokeSystem ()
 An accessor to get the m_smokeSystem variable.
void incTime ()
 increment the time
void initLight ()
 Initialize the light.
void initPhongShader (ngl::Material &_m)
 Initialize the Phong shader.
void initPointSpriteShader ()
 Initialize the PointSprite shader.
void initTextureShader ()
 Initialize the Texture shader.
void moveEmitter ()
 Move the emitter position based on keys pressed.
void processKeyDown (QKeyEvent *_event)
 processKeyDown passed from the main window class
void processKeyUp (QKeyEvent *_event)
 processKeyUp passed from the main window class
void resetTime ()
 reset the time
void toggleAnimation ()
 toggle the animation
void updateTransformStack ()
 update the global and current transform stack
void updateUI ()
 update the UI by emitting signals

Protected Member Functions

void initializeGL ()
 The following methods must be implimented in the sub class this is called when the window is created.
void resizeGL (const int _w, const int _h)
 this is called whenever the window is re-sized
void paintGL ()
 this is the main gl drawing routine which is called whenever the window needs to

Protected Attributes

ngl::Camera * m_camera
 our camera
ngl::TransformStack m_transformStack
 our transform for objects

Private Member Functions

void mouseMoveEvent (QMouseEvent *_event)
 this method is called every time a mouse is moved
void mousePressEvent (QMouseEvent *_event)
 this method is called everytime the mouse button is pressed inherited from QObject and overridden here.
void mouseReleaseEvent (QMouseEvent *_event)
 this method is called everytime the mouse button is released inherited from QObject and overridden here.
void wheelEvent (QWheelEvent *_event)
 this method is called everytime the mouse wheel is moved inherited from QObject and overridden here.
void timerEvent (QTimerEvent *)
 this method deals with what to do over time inherited from QObject and overridden here.
void loadMatricesToShader (ngl::TransformStack &_tx)

Private Attributes

bool m_animate
 flag to indicate if animation is active or not
bool m_depthTestEnabled
 flag to indicate if gl depth test is enabled
QTime m_currentTime
 the current time to calculate framerate
int m_gridBaseRes
 The base resolution of the grid.
float m_gridLengthX
 The length of the grid in the x direction.
float m_gridLengthY
 The length of the grid in the y direction.
float m_gridLengthZ
 The length of the grid in the z direction.
QSet< Qt::Key > m_keysPressed
 the keys being pressed
ngl::Vec3 m_modelPos
 the model position for mouse movement
int m_origX
 the previous x mouse value
int m_origXPos
 the previous x mouse value for Position changes
int m_origY
 the previous y mouse value
int m_origYPos
 the previous y mouse value for Position changes
int m_precisionX
 The precision of the grid in the x direction.
int m_precisionY
 The precision of the grid in the y direction.
int m_precisionZ
 The precision of the grid in the z direction.
bool m_rotate
 flag to indicate if the mouse button is pressed when dragging
float m_scale
 The scale size of the grid.
SmokeSystemm_smokeSystem
 the smoke system
int m_spinXFace
 used to store the x rotation mouse value
int m_spinYFace
 used to store the y rotation mouse value
bool m_showTemperature
 toggle for the displaying the temperature
bool m_showVelocityArrows
 toggle for the displaying of the velocity arrows
bool m_showVoxelGrid
 toggle for the displaying of the voxel grid
int m_spriteSize
 the size of the point sprites
ngl::Text * m_text
 the font
float m_time
 the time
float m_timeStep
 the time step
int m_timer
 the timer
float m_timerVal
 the timer value (ms)
bool m_translate
 flag to indicate if the Right mouse button is pressed when dragging
bool m_wireframe
 m_wireframe mode

Detailed Description

The functions and elements of a GLWindow.


Constructor & Destructor Documentation

GLWindow::GLWindow ( QWidget *  _parent)

Constructor for GLWindow.

Parameters:
[in]_parentthe parent window to create the GL context in

1. Initialize the class member variables.

dtor

1. De-allocate memory.


Member Function Documentation

Displays text on the screen like FPS etc.

1. Calculate and display the frames per second.

2. Calculate and display the max frames per second.

3. If not simulating in real-time, display the speed percentage.

4. Display the total number of pressure iterations.

Draws in wireframe based on the m_wireframe boolean.

1. If wireframe flag is enabled, draw in wireframe.

Draws the obstacle.

1. Draw the obstacle using the Phong shader.

Draws the smoke sprites.

1. Draw the smoke sprites using the PointSprite shader.

Draws the velocity field.

1. Draw the velocity field arrows using the Phong Shader.

Draws the voxel grid.

1. Draw the voxel grid lines using the Phong shader.

An accessor to get the m_smokeSystem variable.

Returns:
the m_smokeSystem variable
void GLWindow::initializeGL ( ) [protected]

The following methods must be implimented in the sub class this is called when the window is created.

1. Initialize the camera.

create our camera

2. Initialize the material.

3. Initialize the phong shader.

4. Initialize the texture shader.

5. Initialize the point sprite shader.

6. Initialize the light in the scene.

7. Initialize the text.

8. Initialize the class member values.

9. Initialize the Smoke System.

10. Update the UI.

Initialize the light.

1. Initialize the light in the scene and load the light to all three shaders.

void GLWindow::initPhongShader ( ngl::Material &  _m)

Initialize the Phong shader.

Parameters:
_ma reference of the material passed in from initializeGL

1. Initialize the Phong shader and load the material to it.

Initialize the PointSprite shader.

1. Initialize the PointSprite shader.

Initialize the Texture shader.

1. Initialize the Texture shader.

void GLWindow::loadMatricesToShader ( ngl::TransformStack &  _tx) [private]

1. Load the matricies to the shader.

void GLWindow::mouseMoveEvent ( QMouseEvent *  _event) [private]

this method is called every time a mouse is moved

Parameters:
_eventthe Qt Event structure

1. Update the class members based on the mouse move event so the transform stack can be updated when updateGL is called.

void GLWindow::mousePressEvent ( QMouseEvent *  _event) [private]

this method is called everytime the mouse button is pressed inherited from QObject and overridden here.

Parameters:
_eventthe Qt Event structure

1. Update the class members based on the mouse press event so the transform stack can be updated when updateGL is called.

void GLWindow::mouseReleaseEvent ( QMouseEvent *  _event) [private]

this method is called everytime the mouse button is released inherited from QObject and overridden here.

Parameters:
_eventthe Qt Event structure

1. Update the class members based on the mouse release event so the transform stack can be updated when updateGL is called.

Move the emitter position based on keys pressed.

1. Move the emitter based on the keys pressed by using a move factor and updating the location of the emitter.

void GLWindow::paintGL ( ) [protected]

this is the main gl drawing routine which is called whenever the window needs to

1. Update the transform stack based on the camera movements.

2. Draw in wireframe (if the flag is toggled).

3. Display the text on the screen (fps, pressure iters, etc.).

4. If obstacle flag is enabled, draw the obstacle.

5. Draw the voxel grid lines.

6. Move the emitter based on the pressed arrow keys.

7. Update the smoke simulator by performing the calculations.

8. Draw the velocity field arrows.

9. Draw the smoke sprites.

void GLWindow::processKeyDown ( QKeyEvent *  _event)

processKeyDown passed from the main window class

Parameters:
*_eventa pointer to the QKeyEvent passed from main window class

1. If a key is pressed, add it to the m_keysPressed vector and set the focus to the gl window.

void GLWindow::processKeyUp ( QKeyEvent *  _event)

processKeyUp passed from the main window class

Parameters:
*_eventa pointer to the QKeyEvent passed from main window class

1. If a key is released, delete it from the m_keysPressed vector and set the focus to the gl window.

reset the simulation values and UI elements to default values

1. Re-initialize the values.

2. Re-calculate the voxel grid values.

3. Set all of the voxels to the cell type of SMOKE.

4. Update the UI.

void GLWindow::resizeGL ( const int  _w,
const int  _h 
) [protected]

this is called whenever the window is re-sized

Parameters:
[in]_wthe width of the resized window
[in]_hthe height of the resized window

1. Resize the gl window based on the width and height of the viewport.

void GLWindow::setAbsoluteTolerance ( double  _val) [inline, slot]

a slot to change the absolute tolerance for the pressure

Parameters:
[in]_valthe value to be set to the absolute tolerance value
void GLWindow::setBoundaryCondition ( int  _mode) [slot]

a slot to change the boundary condition

Parameters:
[in]_modethe value to be set to the boundary condition

1. Set the boundary condition based on the parameter.

void GLWindow::setEmitDensityRate ( double  _val) [inline, slot]

a slot to change the density rate of the emitter

Parameters:
[in]_valthe value to be set to the density rate of the emitter
void GLWindow::setEmitTemperatureRate ( double  _val) [inline, slot]

a slot to change the temperature rate of the emitter

Parameters:
[in]_valthe value to be set to the temperature rate of the emitter
void GLWindow::setEmitterSize ( double  _val) [slot]

a slot to change the size of the emitter

Parameters:
[in]_valthe value to be set to the size of the emitter

1. Set the size of the emitter and update the UI.

void GLWindow::setEmitterSize ( int  _val) [slot]

a slot to change the size of the emitter

Parameters:
[in]_valthe value to be set to the size of the emitter

1. Set the size of the emitter and update the UI.

void GLWindow::setGravity ( double  _val) [inline, slot]

a slot to change the gravity force

Parameters:
[in]_valthe value to be set to the gravity force
void GLWindow::setGridBaseRes ( int  _res) [slot]

a slot to change the base resolution of the voxel grid

Parameters:
[in]_resthe value to be set to the base resolution of the voxel grid

1. Set the voxel grid base resolution and update the UI.

void GLWindow::setGridLengthX ( double  _length) [slot]

a slot to change the x length of the voxel grid

Parameters:
[in]_lengththe value to be set to the x grid length of the voxel grid

1. Set the length of the voxel grid in the x direction and update the UI.

void GLWindow::setGridLengthY ( double  _length) [slot]

a slot to change the y length of the voxel grid

Parameters:
[in]_lengththe value to be set to the y grid length of the voxel grid

1. Set the length of the voxel grid in the y direction and update the UI.

void GLWindow::setGridLengthZ ( double  _length) [slot]

a slot to change the z length of the voxel grid

Parameters:
[in]_lengththe value to be set to the z grid length of the voxel grid

1. Set the length of the voxel grid in the z direction and update the UI.

void GLWindow::setH ( double  _val) [inline, slot]

a slot to change the scale of the voxel grid

Parameters:
[in]_scalethe value to be set to the scale of the voxel grid
void GLWindow::setKDensityDiss ( double  _val) [inline, slot]

a slot to change the k density dissipation constant

Parameters:
[in]_valthe value to be set to the k density dissipation constant
void GLWindow::setKFall ( double  _val) [inline, slot]

a slot to change the k fall buoyancy constant

Parameters:
[in]_valthe value to be set to the k fall buoyancy constant
void GLWindow::setKRise ( double  _val) [inline, slot]

a slot to change the k rise buoyancy constant

Parameters:
[in]_valthe value to be set to the k rise buoyancy constant
void GLWindow::setKTemperDiss ( double  _val) [inline, slot]

a slot to change the k temperature dissipation constant

Parameters:
[in]_valthe value to be set to the k temperature dissipation constant
void GLWindow::setKVorticity ( double  _val) [inline, slot]

a slot to change the vorticity confinement constant

Parameters:
[in]_valthe value to be set to the vorticity confinement constant
void GLWindow::setMaxFPS ( double  _fps) [inline, slot]

a slot to change the max fps

Parameters:
[in]_fpsthe value to be set to max fps
void GLWindow::setNoiseFrequency ( double  _val) [inline, slot]

a slot to change frequency of the noise

Parameters:
[in]_valthe value to be set to the frequency of the noise
void GLWindow::setNoiseMagnitude ( double  _val) [inline, slot]

a slot to change the magnitude of the force of the noise

Parameters:
[in]_valthe value to be set to the magnitude of the force of the noise
void GLWindow::setNoiseOctaveCount ( double  _val) [inline, slot]

a slot to change octave count of the noise

Parameters:
[in]_valthe value to be set to the octave count of the noise
void GLWindow::setNoisePersistence ( double  _val) [inline, slot]

a slot to change persistence of the noise

Parameters:
[in]_valthe value to be set to the persistence of the noise
void GLWindow::setNoiseSpeed ( double  _val) [inline, slot]

a slot to change the speed of the noise

Parameters:
[in]_valthe value to be set to the speed of the noise
void GLWindow::setObstacle ( int  _mode) [slot]

a slot to change the obstacle

Parameters:
[in]_modethe value to be set to the obstacle

1. Delete the mesh of the obstacle.

1. Re-create the mesh based on the parameter.

1. Re-set the simulation.

void GLWindow::setOpacityStrength ( int  _val) [inline, slot]

a slot to change the shadow strength

Parameters:
[in]_valthe value to be set to the shadow strength
void GLWindow::setPrecisionX ( int  _precision) [inline, slot]

a slot to change the x precision of the voxel grid

Parameters:
[in]_precisionthe value to be set to the x precision of the voxel grid
void GLWindow::setPrecisionY ( int  _precision) [inline, slot]

a slot to change the y precision of the voxel grid

Parameters:
[in]_precisionthe value to be set to the y precision of the voxel grid
void GLWindow::setPrecisionZ ( int  _precision) [inline, slot]

a slot to change the z precision of the voxel grid

Parameters:
[in]_precisionthe value to be set to the z precision of the voxel grid
void GLWindow::setRelaxationRate ( double  _val) [inline, slot]

a slot to change the relaxation rate for the pressure

Parameters:
[in]_valthe value to be set to the relaxation rate
void GLWindow::setShadowStrength ( int  _val) [inline, slot]

a slot to change the shadow strength

Parameters:
[in]_valthe value to be set to the shadow strength
void GLWindow::setSpriteSize ( int  _size) [inline, slot]

a slot to change the sprite size

Parameters:
[in]_sizethe value to be set to the sprite size
void GLWindow::setTimeStep ( double  _dt) [slot]

a slot to change the time step

Parameters:
[in]_dtthe value to be set to the time step

1. Set the time step, restart the timer and update the UI.

void GLWindow::setUIBuoyancyValues ( float  _kRise,
float  _kFall 
) [signal]

Signal sent to the UI to set the dissipation values.

Parameters:
[in]_kRisethe value to be set to the k buoyancy rise value
[in]_kFallthe value to be set to the k buoyancy fall value
void GLWindow::setUIDissipationValues ( float  _kDensityDiss,
float  _kTemperDiss 
) [signal]

Signal sent to the UI to set the dissipation values.

Parameters:
[in]_kDensityDissthe value to be set to the k density dissipation value
[in]_kTemperDissthe value to be set to the k temperature dissipation value
void GLWindow::setUIEmitterValues ( ngl::Vec3  _emitterLoc,
float  _emitterSize,
float  _emitDensityRate,
float  _emitTemperatureRate 
) [signal]

Signal sent to the UI to set the emitter values.

Parameters:
[in]_emitterLocthe value to be set to the location of the emitter
[in]_emitterSizethe value to be set to the size of the emitter
[in]_emitDensityRatethe value to be set to the emit rate of the density
[in]_emitTemperatureRatethe value to be set to the emit rate of the temperature
void GLWindow::setUIFluidValues ( float  _viscosity,
float  _gravity,
float  _kVorticity 
) [signal]

Signal sent to the UI to set the fluid values.

Parameters:
[in]_viscositythe value to be set to the viscosity
[in]_gravitythe value to be set to the gravity force
[in]_kVorticitythe value to be set to vorticity confinement constant
void GLWindow::setUINoiseValues ( float  _frequency,
float  _octaveCount,
float  _persistence,
float  _speed,
float  _magnitude 
) [signal]

Signal sent to the UI to set the sprite values.

Parameters:
[in]_frequencythe value to be set to the frequency of the noise
[in]_octaveCountthe value to be set to the octave count of the noise
[in]_persistencethe value to be set to the persistence of the noise
[in]_speedthe value to be set to the speed of the noise
[in]_magnitudethe value to be set to the magnitude of the force the noise
void GLWindow::setUIPressureValues ( float  _absoluteTolerance,
float  _relaxationRate 
) [signal]

Signal sent to the UI to set the fluid values.

Parameters:
[in]_absoluteTolerancethe value to be set to the absolute tolerance of the pressure
[in]_relaxationRatethe value to be set to the relaxation rate of the pressure
void GLWindow::setUISpriteValues ( int  _spriteSize,
float  _opacityStrength,
float  _shadowStrength 
) [signal]

Signal sent to the UI to set the sprite values.

Parameters:
[in]_spriteSizethe value to be set to the k sprite size value
[in]_opacityStrengththe value to be set to the strength of the opacity
[in]_shadowStrengththe value to be set to the strength of the opacity
void GLWindow::setUITimeValues ( float  _timeStep,
float  _maxFPS 
) [signal]

Signal sent to the UI to set the time values.

Parameters:
[in]_timeStepthe value to be set to the time step
[in]_maxFPSthe value to be set to the max fps
void GLWindow::setUIVoxelGridValues ( float  _gridLengthX,
float  _gridLengthY,
float  _gridLengthZ,
int  _gridBaseRes,
int  _gridPrecisionX,
int  _gridPrecisionY,
int  _gridPrecisionZ,
float  _h,
BOUNDARYCONDITION  _condition 
) [signal]

Signal sent to the UI to set the Voxel Grid UI Values.

Parameters:
[in]_gridLengthXthe x length of the voxel grid
[in]_gridLengthYthe y length of the voxel grid
[in]_gridLengthZthe z length of the voxel grid
[in]_gridBaseResthe base resolution of the voxel grid
[in]_gridPrecisionXthe x precision of the voxel grid
[in]_gridPrecisionYthe y precision of the voxel grid
[in]_gridPrecisionZthe z precision of the voxel grid
[in]_hthe width of the voxels
[in]_conditionthe boundary condition
void GLWindow::setViscosity ( double  _val) [inline, slot]

a slot to change the viscosity of the fluid

Parameters:
[in]_valthe value to be set to the viscosity of the fluid
void GLWindow::timerEvent ( QTimerEvent *  _event) [private]

this method deals with what to do over time inherited from QObject and overridden here.

Parameters:
_eventthe Qt Timer Event structure

1. Increment the time and call updateGL if the m_animate flag is enabled.

void GLWindow::toggleDepthTest ( bool  _mode) [inline, slot]

a slot to toggle the depth test

Parameters:
[in]_modethe mode passed from the toggle
void GLWindow::toggleTemperature ( bool  _mode) [inline, slot]

a slot to toggle the displaying of the temperature

Parameters:
[in]_modethe mode passed from the toggle
void GLWindow::toggleVelocityArrows ( bool  _mode) [inline, slot]

a slot to toggle the velocity arrows

Parameters:
[in]_modethe mode passed from the toggle
void GLWindow::toggleVoxelGrid ( bool  _mode) [inline, slot]

a slot to toggle voxel grid

Parameters:
[in]_modethe mode passed from the toggle
void GLWindow::toggleWireframe ( bool  _mode) [inline, slot]

a slot to toggle wireframe mode

Parameters:
[in]_modethe mode passed from the toggle

update the global and current transform stack

1. Update the transform stack based on the camera movements.

update the UI by emitting signals

1. Update the UI by emitting signals.

void GLWindow::wheelEvent ( QWheelEvent *  _event) [private]

this method is called everytime the mouse wheel is moved inherited from QObject and overridden here.

Parameters:
_eventthe Qt Event structure

1. Update the class members based on the wheel event so the transform stack can be updated when updateGL is called.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables