Lagrangian Liquid Simulation
Master Thesis project on simulation of liquids using Lagrangian approach and SPH
Simulation Class Reference

creates all other objects for the simulation and provides central management and communication with all of them and the gui More...

#include <Simulation.h>

Collaboration diagram for Simulation:

List of all members.

Public Slots

void updateCameraZoom (const int _depth)
 called when the camera zoom slider value is changed in the GUI; it slides the camera along its N vector

Public Member Functions

 Simulation (QWidget *_parent)
 ctor
 ~Simulation ()
 dtor
void keyPress (QKeyEvent *_event)
 handle keypress events
SolvergetSolver () const
 returns the solver of the simulation
EnvironmentgetEnvironment () const
 returns the environment object
IntegrationgetIntegration () const
 returns the integration object
void setup2DTopView ()
 this method is used to setup the 2D top view
void setup2DFrontView ()
 this method is used to setup the 2D front view
void toggleCache ()
 this method toggles the cache timer
void toggleAutomaticCacheFlush ()
 this method toggles the automatic cache flush timer
void updateFPSTimer ()
 this method updates the states of timers after the simulation of fluid is started/stopped
void flushCache ()
 this method flushes the cache to disk
bool getCacheEnabled () const
 return the whether cache is enabled
int getCacheSamplingInterval () const
 return cache samping interval
bool getCacheAutomaticFlushEnabled () const
 return whether automatic cache flushing is enabled
int getCacheAutomaticFlushInterval () const
 return automatic cache flushing interval
bool getCacheExportRBDEnabled () const
 return whether rbd is cached
bool getCacheExportBoundaryEnabled () const
 return boundary is cached
std::string getCachePath () const
 return the path of the cache on disk
void setCacheEnabled (const bool _v)
 set flag to determine whether cache is enabled
void setCacheSamplingInterval (const int _v)
 return cache samping interval
void setCacheAutomaticFlushEnabled (const bool _v)
 set flag to determine whether automatic cache flushing is enabled
void setCacheAutomaticFlushInterval (const int _v)
 return automatic cache flushing interval
void setCacheExportRBDEnabled (const bool _v)
 set flag to determine whether rbd is cached
void setCacheExportBoundaryEnabled (const bool _v)
 set flag to determine whether boundary is cached

Protected Member Functions

void initializeGL ()
 called when the window context is created
void resizeGL (const int _w, const int _h)
 called whenever the window is re-sized
void paintGL ()
 main gl drawing method that is called whenever the window needs to be re-drawn

Private Slots

void processFPS ()
 this method is called at every fps timer tick
void processSimulationCache ()
 this method is called at every simulation timer tick
void processSimulationCacheAutoFlush ()
 this method is called to automatically flush the cache

Private Member Functions

void timerEvent (QTimerEvent *_event)
 the timer event triggered from the timers
void createCamera ()
 this method create our camera
void createLight ()
 this method create our light
void displayHelp ()
 this method display the text help overlay on the screen
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
void mouseReleaseEvent (QMouseEvent *_event)
 this method is called everytime the mouse button is released
void initialiseSimulation ()
 this method is called to initialise all the objects/params of the simulation
void deleteSimulationObjects ()
 this method is called to delete all the objects of the simulation

Private Attributes

int m_spinXFace
 the x rotation mouse value
int m_spinYFace
 the y rotation mouse value
bool m_rotate
 flag to indicate if the mouse button is pressed when dragging
int m_origX
 the previous x mouse value
int m_origY
 the previous y mouse value
int m_moveX
 right mouse camera movement x value
int m_moveY
 right mouse camera movement y value
bool m_move
 flag to indicate if the right mouse is pressed for (x,y) mouse movement
int m_origMoveX
 starting x position of the right mouse
int m_origMoveY
 starting y position of the right mouse
bool m_drawHelp
 toggle help flag
float m_aspect
 aspect ratio of the camera
int m_mouseMoveSensitivity
 mouse move sensitivity
int m_frameRate
 frame update rate
ngl::TransformStack m_transformStack
 global transform stack
ngl::Light m_light
 ngl light object
ngl::Camera m_camera
 ngl camera object
ShaderLibrarym_shaderLibrary
 shader library
Solverm_solver
 fluid solver
Environmentm_environment
 environment
Integrationm_integration
 integration
Cachem_cache
 cache
float m_lastCamZ
 the last depth of a camera zoom operation
int m_frameCounter
 counter to keep track of number of frames for fps calculation
int m_mainSimulationTimer
 main simulation timer (continuous ticking)
QTimer * m_fpsTimer
 fps timer with interval = 1 s
bool m_fpsTimerEnabled
 fps timer toggle
QTimer * m_simulationCacheTimer
 simulation cache timer
QTimer * m_simulationCacheAutoFlushTimer
 simulation cache autoFlush timer
int m_simulationCacheFrameNumber
 cache frame number
bool m_cacheEnabled
 flag to determine if cache is enabled
int m_cacheSamplingInterval
 cache samping interval
bool m_cacheAutomaticFlushEnabled
 flag to determine automatic cache flushing is enabled
int m_cacheAutomaticFlushInterval
 automatic cache flushing interval
bool m_cacheExportRBDEnabled
 flag to determine if rbd is cached
bool m_cacheExportBoundaryEnabled
 flag to determine if boundary is cached
std::string m_cachePath
 the path of the cache on disk

Detailed Description

creates all other objects for the simulation and provides central management and communication with all of them and the gui

Definition at line 28 of file Simulation.h.


Constructor & Destructor Documentation

Simulation::Simulation ( QWidget *  _parent)

ctor

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

Definition at line 21 of file Simulation.cpp.

                  :
                QGLWidget(_parent)
{
    // set this widget to have the initial keyboard focus
    setFocusPolicy(Qt::StrongFocus);
    setFocus();

    //initialise simulation
    initialiseSimulation();
}
Simulation::~Simulation ( )

dtor

Definition at line 112 of file Simulation.cpp.

References deleteSimulationObjects().

{
    //clean up ngl
    std::cout << "\nNGL Cleanup" << std::endl;

    ngl::NGLInit* Init = ngl::NGLInit::instance();
    Init->NGLQuit();
    std::cout << "NGL shut down safely\n" << std::endl;

    //delete all current objects
    deleteSimulationObjects();
}

Here is the call graph for this function:


Member Function Documentation

void Simulation::createCamera ( ) [private]

this method create our camera

Definition at line 353 of file Simulation.cpp.

References Configuration::initialiseCamera(), m_aspect, and m_camera.

{
    //create camera from config parameters
    m_camera = Configuration::initialiseCamera(m_aspect);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Simulation::createLight ( ) [private]

this method create our light

Definition at line 359 of file Simulation.cpp.

References Configuration::initialiseLight(), and m_light.

{
    //set a material
    ngl::Material m(ngl::PEWTER); m.use();
    m.setSpecular(ngl::Colour(1,1,1));
    m.setSpecularExponent(0.2);;

    //create our light from config and enable it
    m_light = Configuration::initialiseLight(); m_light.enable();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Simulation::deleteSimulationObjects ( ) [private]

this method is called to delete all the objects of the simulation

Definition at line 100 of file Simulation.cpp.

References m_environment, m_integration, m_mainSimulationTimer, m_shaderLibrary, and m_solver.

{
    //kill timers
    killTimer(m_mainSimulationTimer);

    //delete all the current objects associated with the simulation
    delete m_shaderLibrary;
    delete m_solver;
    delete m_environment;
    delete m_integration;
}

Here is the caller graph for this function:

void Simulation::displayHelp ( ) [private]

this method display the text help overlay on the screen

Definition at line 216 of file Simulation.cpp.

References m_drawHelp.

{
    //display help menu
    if (m_drawHelp == true)
    {
        // first we need to fallback to the fixed functionality GL pipeline
        glUseProgram(0);

        //create font
        QFont font;
        font.setBold(false);
        font.setPointSize(12);
        glColor3f(1,1,0);

        //display debug and stats info
        QString text;
   }

}

Here is the caller graph for this function:

void Simulation::flushCache ( )

this method flushes the cache to disk

Definition at line 488 of file Simulation.cpp.

References Cache::flushCache(), m_cache, and m_cachePath.

{
    //flush cache to file
    m_cache->flushCache(m_cachePath);

    std::cout << "Cache Flushed\n";
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool Simulation::getCacheAutomaticFlushEnabled ( ) const [inline]

return whether automatic cache flushing is enabled

Definition at line 81 of file Simulation.h.

References m_cacheAutomaticFlushEnabled.

Here is the caller graph for this function:

int Simulation::getCacheAutomaticFlushInterval ( ) const [inline]

return automatic cache flushing interval

Definition at line 84 of file Simulation.h.

References m_cacheAutomaticFlushInterval.

Here is the caller graph for this function:

bool Simulation::getCacheEnabled ( ) const [inline]

return the whether cache is enabled

Definition at line 75 of file Simulation.h.

References m_cacheEnabled.

{ return m_cacheEnabled; }

Here is the caller graph for this function:

bool Simulation::getCacheExportBoundaryEnabled ( ) const [inline]

return boundary is cached

Definition at line 90 of file Simulation.h.

References m_cacheExportBoundaryEnabled.

Here is the caller graph for this function:

bool Simulation::getCacheExportRBDEnabled ( ) const [inline]

return whether rbd is cached

Definition at line 87 of file Simulation.h.

References m_cacheExportRBDEnabled.

Here is the caller graph for this function:

std::string Simulation::getCachePath ( ) const [inline]

return the path of the cache on disk

Definition at line 93 of file Simulation.h.

References m_cachePath.

{ return m_cachePath; }
int Simulation::getCacheSamplingInterval ( ) const [inline]

return cache samping interval

Definition at line 78 of file Simulation.h.

References m_cacheSamplingInterval.

Here is the caller graph for this function:

Environment* Simulation::getEnvironment ( ) const [inline]

returns the environment object

Definition at line 50 of file Simulation.h.

References m_environment.

{ return  m_environment; }

Here is the caller graph for this function:

Integration* Simulation::getIntegration ( ) const [inline]

returns the integration object

Definition at line 53 of file Simulation.h.

References m_integration.

{ return  m_integration; }

Here is the caller graph for this function:

Solver* Simulation::getSolver ( ) const [inline]

returns the solver of the simulation

Definition at line 47 of file Simulation.h.

References m_solver.

{ return  m_solver; }

Here is the caller graph for this function:

void Simulation::initialiseSimulation ( ) [private]

this method is called to initialise all the objects/params of the simulation

Definition at line 34 of file Simulation.cpp.

References createCamera(), createLight(), Configuration::initialiseWindow(), m_cache, m_cacheAutomaticFlushEnabled, m_cacheAutomaticFlushInterval, m_cacheEnabled, m_cacheExportBoundaryEnabled, m_cacheExportRBDEnabled, m_cachePath, m_cacheSamplingInterval, m_camera, m_drawHelp, m_environment, m_fpsTimer, m_fpsTimerEnabled, m_frameCounter, m_frameRate, m_integration, m_lastCamZ, m_mainSimulationTimer, m_mouseMoveSensitivity, m_move, m_moveX, m_moveY, m_rotate, m_shaderLibrary, m_simulationCacheAutoFlushTimer, m_simulationCacheFrameNumber, m_simulationCacheTimer, m_solver, m_spinXFace, m_spinYFace, processFPS(), processSimulationCache(), processSimulationCacheAutoFlush(), SEMI_IMPLICIT_EULER, toggleAutomaticCacheFlush(), toggleCache(), and updateFPSTimer().

{
    //initialise mouse rotation values
    m_rotate=false;
    m_spinXFace=-20;
    m_spinYFace=-40;

    //initialise mouse movement values
    m_move=false;
    m_moveX=0;
    m_moveY=0;

    //init framerate and mouse move sensitivity
    ngl::Real timestep = 0;
    Configuration::initialiseWindow(m_frameRate, m_mouseMoveSensitivity, timestep, m_fpsTimerEnabled, m_cacheEnabled, m_cacheSamplingInterval, m_cacheAutomaticFlushEnabled, m_cacheAutomaticFlushInterval, m_cacheExportRBDEnabled, m_cacheExportBoundaryEnabled, m_cachePath);

    //create camera
    createCamera();

    //create light
    createLight();

    //initialise our shader library to \0null
    m_shaderLibrary = 0;

    //create the fluid solver
    m_solver = new Solver();

    //create the environment
    m_environment = new Environment();

    //create the integration
    m_integration = new Integration(SEMI_IMPLICIT_EULER, timestep);

    //create the simulation cache
    m_cache = new Cache();

    //start main timer
    m_mainSimulationTimer = startTimer(m_frameRate);

    //initialise fps timer
    m_fpsTimer = new QTimer(this);
    connect(m_fpsTimer, SIGNAL(timeout()), this, SLOT(processFPS()));
    m_fpsTimer->setInterval(1000);
    m_frameCounter = 0;
    updateFPSTimer();

    //initialise cache timer
    m_simulationCacheTimer = new QTimer(this);
    connect(m_simulationCacheTimer, SIGNAL(timeout()), this, SLOT(processSimulationCache()));
    m_simulationCacheFrameNumber = -1;

    //initialise cache autoFlush timer
    m_simulationCacheAutoFlushTimer = new QTimer(this);
    connect(m_simulationCacheAutoFlushTimer, SIGNAL(timeout()), this, SLOT(processSimulationCacheAutoFlush()));

    toggleCache();
    toggleAutomaticCacheFlush();

    //hide help by default
    m_drawHelp = false;

    //initial camera z value
    m_lastCamZ = m_camera.getEye().m_z;
}

Here is the call graph for this function:

void Simulation::initializeGL ( ) [protected]

called when the window context is created

Definition at line 125 of file Simulation.cpp.

References Solver::initialiseDrawing(), Environment::loadGeometry(), m_camera, m_environment, m_shaderLibrary, m_solver, and ShaderLibrary::updateViewProjection().

{
    //init glew
    ngl::NGLInit* Init = ngl::NGLInit::instance();
    Init->initGlew();

    // enable depth testing for drawing
    glEnable(GL_DEPTH_TEST);

    //initialise shaders
    m_shaderLibrary = new ShaderLibrary();
    m_shaderLibrary->updateViewProjection(&m_camera);

    //initialise fluid drawing
    m_solver->initialiseDrawing();

    //initialise environment drawing
    m_environment->loadGeometry();

    //create vbo for plane grid
    ngl::VBOPrimitives *prim=ngl::VBOPrimitives::instance();
    prim->createVBOQuadPlane("plane",20,20,1,1,ngl::Vector(0,1,0));

    //create vbo for cube fluid plane [10 x 10 grid]
    prim->createVBOQuadPlane("fluidPlaneLayer", 9, 9, 9, 9, ngl::Vector(0, 1, 0));
}

Here is the call graph for this function:

void Simulation::keyPress ( QKeyEvent *  _event)

handle keypress events

Parameters:
[in]_eventthe Qt Event structure, holding information about keypresses

Definition at line 256 of file Simulation.cpp.

References Solver::injectParticles(), m_cacheEnabled, m_environment, m_integration, m_solver, toggleCache(), Solver::toggleEnableAutoFluidUpdate(), Solver::toggleNextHoseableFluid(), Solver::updateFluid(), and updateFPSTimer().

{
    switch (_event->key())
    {
        //debug info
//        case Qt::Key_D : { m_drawHelp ^=true; break; }

        //single step fluid update
        case Qt::Key_W : { m_solver->updateFluid(m_environment, m_integration); break; }

        //toggle timer to update fluid
        case Qt::Key_Q : { m_solver->toggleEnableAutoFluidUpdate(); updateFPSTimer(); break; }

        //inject particles in fluid solver
        case Qt::Key_A : { m_solver->injectParticles(); break; }

        //toggle to next hoseable fluid
        case Qt::Key_S : { m_solver->toggleNextHoseableFluid(); break; }

        //toggle cache timer
        case Qt::Key_C :
        {
            m_cacheEnabled = !m_cacheEnabled;
            toggleCache();

            break;
        }

        default : break;
    }

    // re-draw GL
    updateGL();
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

this method is called every time a mouse is moved

Parameters:
[in]_eventthe Qt Event structure

Definition at line 291 of file Simulation.cpp.

References m_camera, m_mouseMoveSensitivity, m_move, m_moveX, m_moveY, m_origMoveX, m_origMoveY, m_origX, m_origY, m_rotate, m_shaderLibrary, m_spinXFace, m_spinYFace, and ShaderLibrary::updateViewProjection().

{
    //as the left mouse is still pressed and it moves, we get the x and y spin value
    if(m_rotate && _event->buttons() == Qt::LeftButton)
    {
        m_spinYFace = ( m_spinYFace + (_event->x() - m_origX) ) % 360 ;
        m_spinXFace = ( m_spinXFace + (_event->y() - m_origY) ) % 360 ;
        m_origX = _event->x();
        m_origY = _event->y();

        // re-draw GL
        updateGL();
    }

    //move camera in the (x,y) plane
    if(m_move && _event->buttons() == Qt::RightButton)
    {
        m_moveX = _event->x() - m_origMoveX;
        m_moveY = _event->y() - m_origMoveY;
        m_origMoveX = _event->x();
        m_origMoveY = _event->y();

        //move camera eye n look by (dx, dy)
        m_camera.move(m_moveX / m_mouseMoveSensitivity, m_moveY / m_mouseMoveSensitivity, 0);

        //update view projection matrices of camera
        m_shaderLibrary->updateViewProjection(&m_camera);

        // re-draw GL
        updateGL();
    }
}

Here is the call graph for this function:

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

this method is called everytime the mouse button is pressed

Parameters:
_eventthe Qt Event structure

Definition at line 324 of file Simulation.cpp.

References m_move, m_origMoveX, m_origMoveY, m_origX, m_origY, and m_rotate.

{
    //keep track of origin of x,y movement for rotation
    if(_event->button() == Qt::LeftButton)
    {
        m_origX = _event->x();
        m_origY = _event->y();
        m_rotate =true;
    }

    //keep track of origin of x,y movement for tracking
    if(_event->button() == Qt::RightButton)
    {
        m_origMoveX = _event->x();
        m_origMoveY = _event->y();
        m_move =true;
    }
}
void Simulation::mouseReleaseEvent ( QMouseEvent *  _event) [private]

this method is called everytime the mouse button is released

Parameters:
_eventthe Qt Event structure

Definition at line 343 of file Simulation.cpp.

References m_move, and m_rotate.

{
    //disable rotation
    if (_event->button() == Qt::LeftButton) m_rotate=false;

    //disable tracking
    if (_event->button() == Qt::RightButton) m_move=false;

}
void Simulation::paintGL ( ) [protected]

main gl drawing method that is called whenever the window needs to be re-drawn

Definition at line 171 of file Simulation.cpp.

References displayHelp(), Environment::draw(), Solver::getDrawHoseMarker(), Solver::getHoseCenter(), m_environment, m_shaderLibrary, m_solver, m_spinXFace, m_spinYFace, m_transformStack, Solver::render(), ShaderLibrary::updateColor(), ShaderLibrary::updateModel(), and ShaderLibrary::useShader().

{
    // clear the screen and depth buffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glClearColor(0.4, 0.4, 0.4, 1);

    //update tx stack with global mouse movements
    ngl::Transformation trans;
    trans.setRotation(m_spinXFace, m_spinYFace, 0);
    m_transformStack.setGlobal(trans);

    m_shaderLibrary->useShader("Light");

    //visualise fluid state
    m_solver->render(m_transformStack, m_shaderLibrary, "Light");

    //draw environment
    m_environment->draw(m_transformStack, m_shaderLibrary, "Light", "Light");

    //draw grid and reference origin
    ngl::VBOPrimitives *prim=ngl::VBOPrimitives::instance();

    //draw solver hose marker if enabled
    if (m_solver->getDrawHoseMarker())
    {
        m_transformStack.pushTransform();
        {
            m_transformStack.getCurrentTransform().setPosition(m_solver->getHoseCenter().m_x, m_solver->getHoseCenter().m_y, m_solver->getHoseCenter().m_z);
            m_transformStack.getCurrentTransform().setScale(0.3,0.3,0.3);

            //pass vertex info to shader
            m_shaderLibrary->updateModel("Light", m_transformStack.getCurrAndGlobal().getMatrix(), true);

            //pass color info to shader
            m_shaderLibrary->updateColor("Light", ngl::Colour(1, 1, 1), false);

            prim->draw("cube");
        }
        m_transformStack.popTransform();
    }

    //display stats menu
    displayHelp();
}

Here is the call graph for this function:

void Simulation::processFPS ( ) [private, slot]

this method is called at every fps timer tick

Definition at line 428 of file Simulation.cpp.

References m_frameCounter.

{
    std::cout << "FPS : " << m_frameCounter << "\n";
    m_frameCounter = 0;
}

Here is the caller graph for this function:

void Simulation::processSimulationCache ( ) [private, slot]

this method is called at every simulation timer tick

Definition at line 460 of file Simulation.cpp.

References Cache::addItem(), BOUNDARY_CACHE, CAPSULE_CACHE, FLUID_CACHE, Environment::getBoundaryNameList(), Environment::getBoundaryPositionList(), Environment::getCapsuleNameList(), Environment::getCapsulePositionList(), Solver::getNameList(), Environment::getObstacleEnabled(), Solver::getPositionList(), Environment::getSphereNameList(), Environment::getSpherePositionList(), m_cache, m_cacheEnabled, m_cacheExportBoundaryEnabled, m_cacheExportRBDEnabled, m_environment, m_simulationCacheFrameNumber, m_solver, and SPHERE_CACHE.

Here is the call graph for this function:

Here is the caller graph for this function:

void Simulation::processSimulationCacheAutoFlush ( ) [private, slot]

this method is called to automatically flush the cache

Definition at line 483 of file Simulation.cpp.

References flushCache(), and m_cacheAutomaticFlushEnabled.

Here is the call graph for this function:

Here is the caller graph for this function:

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

called whenever the window is re-sized

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

Definition at line 153 of file Simulation.cpp.

{
    //set the viewport
    glViewport(0, 0, _w, _h);

    //calculate the aspect ratio
    m_aspect = (float)_w / _h;

    //update camera aspect
    m_camera.setAspect(m_aspect);

    //update shaders ProjectionMatrix
    m_shaderLibrary->updateProjection(&m_camera);
}
void Simulation::setCacheAutomaticFlushEnabled ( const bool  _v) [inline]

set flag to determine whether automatic cache flushing is enabled

Parameters:
[in]_vupdated flag

Definition at line 106 of file Simulation.h.

References m_cacheAutomaticFlushEnabled.

Here is the caller graph for this function:

void Simulation::setCacheAutomaticFlushInterval ( const int  _v) [inline]

return automatic cache flushing interval

Parameters:
[in]_vupdated value

Definition at line 110 of file Simulation.h.

References m_cacheAutomaticFlushInterval.

Here is the caller graph for this function:

void Simulation::setCacheEnabled ( const bool  _v) [inline]

set flag to determine whether cache is enabled

Parameters:
[in]_vupdated flag

Definition at line 98 of file Simulation.h.

References m_cacheEnabled.

{ m_cacheEnabled = _v; }

Here is the caller graph for this function:

void Simulation::setCacheExportBoundaryEnabled ( const bool  _v) [inline]

set flag to determine whether boundary is cached

Parameters:
[in]_vupdated flag

Definition at line 118 of file Simulation.h.

References m_cacheExportBoundaryEnabled.

Here is the caller graph for this function:

void Simulation::setCacheExportRBDEnabled ( const bool  _v) [inline]

set flag to determine whether rbd is cached

Parameters:
[in]_vupdated flag

Definition at line 114 of file Simulation.h.

References m_cacheExportRBDEnabled.

Here is the caller graph for this function:

void Simulation::setCacheSamplingInterval ( const int  _v) [inline]

return cache samping interval

Parameters:
[in]_vupdated value

Definition at line 102 of file Simulation.h.

References m_cacheSamplingInterval.

Here is the caller graph for this function:

void Simulation::setup2DFrontView ( )

this method is used to setup the 2D front view

Definition at line 401 of file Simulation.cpp.

References m_spinXFace, and m_spinYFace.

{
    //2d front view enabled -> rotate our view to give a front view
    m_spinXFace=0;
    m_spinYFace=0;

    updateGL();
}

Here is the caller graph for this function:

void Simulation::setup2DTopView ( )

this method is used to setup the 2D top view

Definition at line 392 of file Simulation.cpp.

References m_spinXFace, and m_spinYFace.

{
    //2d top view enabled -> rotate our view to give a top view
    m_spinXFace=-90;
    m_spinYFace=0;

    updateGL();
}

Here is the caller graph for this function:

void Simulation::timerEvent ( QTimerEvent *  _event) [private]

the timer event triggered from the timers

Definition at line 236 of file Simulation.cpp.

References Solver::getEnableAutoFluidUpdate(), m_environment, m_fpsTimerEnabled, m_frameCounter, m_integration, m_mainSimulationTimer, m_solver, and Solver::updateFluid().

{
    //main simulation timer
    if (_event->timerId() == m_mainSimulationTimer)
    {
        //update fluid state if fluid's auto move is enabled
        if (m_solver->getEnableAutoFluidUpdate())
        {
            //update fluid
            m_solver->updateFluid(m_environment, m_integration);

            //refresh display
            updateGL();

            //update frame counter for fps
            if (m_fpsTimerEnabled) m_frameCounter++;
        }
    }
}

Here is the call graph for this function:

void Simulation::toggleAutomaticCacheFlush ( )

this method toggles the automatic cache flush timer

Definition at line 448 of file Simulation.cpp.

References m_cacheAutomaticFlushEnabled, m_cacheAutomaticFlushInterval, and m_simulationCacheAutoFlushTimer.

Here is the caller graph for this function:

void Simulation::toggleCache ( )

this method toggles the cache timer

Definition at line 434 of file Simulation.cpp.

References m_cacheEnabled, m_cacheSamplingInterval, m_simulationCacheTimer, and processSimulationCache().

{
    m_simulationCacheTimer->stop();

    if (m_cacheEnabled)
    {
        //cache current initial frame
        m_simulationCacheTimer->singleShot(0, this, SLOT(processSimulationCache()));

        //start timers
        m_simulationCacheTimer->start(m_cacheSamplingInterval);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Simulation::updateCameraZoom ( const int  _depth) [slot]

called when the camera zoom slider value is changed in the GUI; it slides the camera along its N vector

Parameters:
[in]_depththe zoom factor to set to the camera

Definition at line 370 of file Simulation.cpp.

References m_camera, m_lastCamZ, m_shaderLibrary, and ShaderLibrary::updateViewProjection().

{
    //calculate the relative change in Z value
    float newZ = (float)(-depth);
    float changeInZ = newZ - m_lastCamZ;

    //calculate the small change in N that corresponds to the change in Z
    float dn = changeInZ / m_camera.getN().m_z;

    //slide the camera along the N vector by the change in N
    m_camera.slide(0, 0, dn);

    //save the new Z value
    m_lastCamZ = m_camera.getEye().m_z;

    //update view projection matrices of camera
    if ((m_shaderLibrary != NULL) && (m_shaderLibrary != 0)) m_shaderLibrary->updateViewProjection(&m_camera);

    //refresh display
    updateGL();
}

Here is the call graph for this function:

void Simulation::updateFPSTimer ( )

this method updates the states of timers after the simulation of fluid is started/stopped

Definition at line 410 of file Simulation.cpp.

References Solver::getEnableAutoFluidUpdate(), m_fpsTimer, m_fpsTimerEnabled, m_frameCounter, and m_solver.

{
    if (m_solver->getEnableAutoFluidUpdate())
    {
        //start timer
        if (m_fpsTimerEnabled)
        {
            m_frameCounter = 0;
            m_fpsTimer->start();
        }
    }
    else
    {
        //stop timer
        m_fpsTimer->stop();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

float Simulation::m_aspect [private]

aspect ratio of the camera

Definition at line 179 of file Simulation.h.

cache

Definition at line 209 of file Simulation.h.

flag to determine automatic cache flushing is enabled

Definition at line 242 of file Simulation.h.

automatic cache flushing interval

Definition at line 245 of file Simulation.h.

flag to determine if cache is enabled

Definition at line 236 of file Simulation.h.

flag to determine if boundary is cached

Definition at line 251 of file Simulation.h.

flag to determine if rbd is cached

Definition at line 248 of file Simulation.h.

std::string Simulation::m_cachePath [private]

the path of the cache on disk

Definition at line 254 of file Simulation.h.

cache samping interval

Definition at line 239 of file Simulation.h.

ngl::Camera Simulation::m_camera [private]

ngl camera object

Definition at line 194 of file Simulation.h.

bool Simulation::m_drawHelp [private]

toggle help flag

Definition at line 176 of file Simulation.h.

environment

Definition at line 203 of file Simulation.h.

QTimer* Simulation::m_fpsTimer [private]

fps timer with interval = 1 s

Definition at line 221 of file Simulation.h.

fps timer toggle

Definition at line 224 of file Simulation.h.

counter to keep track of number of frames for fps calculation

Definition at line 215 of file Simulation.h.

int Simulation::m_frameRate [private]

frame update rate

Definition at line 185 of file Simulation.h.

integration

Definition at line 206 of file Simulation.h.

float Simulation::m_lastCamZ [private]

the last depth of a camera zoom operation

Definition at line 212 of file Simulation.h.

ngl::Light Simulation::m_light [private]

ngl light object

Definition at line 191 of file Simulation.h.

main simulation timer (continuous ticking)

Definition at line 218 of file Simulation.h.

mouse move sensitivity

Definition at line 182 of file Simulation.h.

bool Simulation::m_move [private]

flag to indicate if the right mouse is pressed for (x,y) mouse movement

Definition at line 167 of file Simulation.h.

int Simulation::m_moveX [private]

right mouse camera movement x value

Definition at line 161 of file Simulation.h.

int Simulation::m_moveY [private]

right mouse camera movement y value

Definition at line 164 of file Simulation.h.

int Simulation::m_origMoveX [private]

starting x position of the right mouse

Definition at line 170 of file Simulation.h.

int Simulation::m_origMoveY [private]

starting y position of the right mouse

Definition at line 173 of file Simulation.h.

int Simulation::m_origX [private]

the previous x mouse value

Definition at line 155 of file Simulation.h.

int Simulation::m_origY [private]

the previous y mouse value

Definition at line 158 of file Simulation.h.

bool Simulation::m_rotate [private]

flag to indicate if the mouse button is pressed when dragging

Definition at line 152 of file Simulation.h.

shader library

Definition at line 197 of file Simulation.h.

simulation cache autoFlush timer

Definition at line 230 of file Simulation.h.

cache frame number

Definition at line 233 of file Simulation.h.

simulation cache timer

Definition at line 227 of file Simulation.h.

fluid solver

Definition at line 200 of file Simulation.h.

int Simulation::m_spinXFace [private]

the x rotation mouse value

Definition at line 146 of file Simulation.h.

int Simulation::m_spinYFace [private]

the y rotation mouse value

Definition at line 149 of file Simulation.h.

ngl::TransformStack Simulation::m_transformStack [private]

global transform stack

Definition at line 188 of file Simulation.h.


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