DLA-Fire-Prediction-Thesis 1.0
|
our main glwindow widget for NGL applications all drawing elements are put in this file More...
#include <GLWindow.h>
Public Slots | |
void | pickCamera (int _i) |
set the camera from selected number | |
void | setColour () |
a slot to set the colour | |
void | toggleWireframe (bool _mode) |
a slot to toggle wireframe mode | |
void | zoomIn () |
a slot to zoom in the scene | |
void | zoomOut () |
a slot to zoom out the scene | |
void | increaseTerrainHeight () |
a slot to increase the terrain height | |
void | decreaseTerrainHeight () |
a slot to decrease the terrain height | |
void | toggleTerrain (bool _mode) |
a slot to toggle the terrain generating | |
void | resetMountain () |
a slot to re-random the terrain generating with the specified iterations number | |
void | setNewMountainIterations (int _newIterations) |
a slot to assign new iterations number for generating terrain | |
void | moveOriginLeft () |
a slot to move the current origin point to the left direction | |
void | moveOriginRight () |
a slot to move the current origin point to the right direction | |
void | moveOriginUp () |
a slot to move the current origin point to the upper direction (north) | |
void | moveOriginDown () |
a slot to move the current origin point to the lower direction (south) | |
void | adjustObstacleAmount (int _newNumber) |
a slot to change the amount of obstacle or non-flammable object | |
void | generateNewFirePath () |
a slot to generate new fire path from the edited scene | |
void | editDLA () |
a slot to edit the scene for generating new DLS form | |
void | pauseAnimation () |
a slot to pause the fire path animation | |
void | playAnimation () |
a slot to play the fire path animation | |
void | assignNewOrigin (int _newOriginAmount) |
a slot to change the amount of origin | |
void | selectMovingOrigin (int _indexOfOrigin) |
a slot to select the origin point that is wished to be moved | |
void | toggleShowMark (bool _mode) |
a slot to toggle the origin's marks showing | |
void | toggleShowLine (bool _mode) |
a slot to toggle to show only line of fire | |
void | adjustFuelAmount (int _newAmount) |
a slot to change the amount of fuel object | |
void | enableWind (bool _mode) |
a slot to toggle the wind | |
void | showWindDir (bool _mode) |
a slot to toggle the showing of wind's arrow | |
void | assignWindSpeed (int _newWindSpeed) |
a slot to change the wind speed | |
void | changeWindDirection (int _newDir) |
a slot to change the wind direction | |
void | changeTemperature (double _newTemp) |
a slot to assign the scene temperature | |
void | changeMoistureOfTheScene (double _newSceneMoisture) |
a slot to assign the new moisture of the scene | |
void | changeObjMoisture (double _newObjMoisture) |
a slot to assign the new moisture of the fuel object | |
void | adjustFuelSize (int _side, int _type) |
a slot to adjust the size of fuel object | |
void | selectObjIndexToAdjustSize (int _objIndex) |
a slot to select the index number of fuel object that wishes to change the size | |
Public Member Functions | |
GLWindow (QWidget *_parent) | |
ctor of GLWindow | |
~GLWindow () | |
dtor free up the GLWindow and all resources | |
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 be re-drawn | |
Private Types | |
enum | CAMMODE { MOVEEYE, MOVELOOK, MOVEBOTH, MOVESLIDE } |
the camera move mode More... | |
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 | timerEvent (QTimerEvent *_event) |
this method is called to counting the time | |
void | createCameras () |
this method creates the cameras in different viewing | |
void | setCameraShape () |
this method is called everytime the window is resized or the camera is adjusted to set the current camera value and the scene | |
void | drawAxis (const std::string &m_shaderName, ngl::TransformStack &m_axisTransformStack, float m_scale, int m_xRot, int m_yRot) |
this method would draw the arrow of wind direction | |
Private Attributes | |
bool | m_wireframe |
flag of wireframe mode | |
bool | m_enableMountain |
flag of mountain drawing | |
int | m_mountainIterations |
number of iterations for generating mountain or terrain | |
int | m_spinXFace |
used to store the x rotation mouse value | |
int | m_spinYFace |
used to store 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 | |
ngl::TransformStack | m_transformStack |
transformation stack for the gl transformations etc | |
int | m_drawHelp |
toggle help flag | |
std::vector< ngl::Camera > | m_cameras |
a container for our Cameras | |
int | m_cameraIndex |
an index into the active camera list | |
ngl::Light * | m_light |
the light for the shading | |
float | m_fov |
fov value for the camera | |
float | m_aspect |
aspect ratio of the camera | |
ngl::CAMERAPROJECTION | m_projection |
projection mode | |
float | m_objectRadius |
radius of fuel object | |
float | m_objectHeight |
height of fuel object | |
int | m_fpsTimer |
flag for the fps timer | |
int | m_fps |
the fps to draw | |
int | m_frames |
the frame number | |
QTime | m_timer |
the time counter | |
int | m_sceneWidth |
scene width size | |
int | m_sceneHeight |
scene height size | |
FireArea * | fireScene |
create scene object | |
int | m_newIndexOfOrigin |
the index of origin that is wished to be moved | |
int | m_windDirectionRot |
the rotation value, refers to the wind direction | |
bool | m_showWindDir |
the flag of showing arrow of the wind direction | |
double | m_temperature |
the scene temperature | |
double | m_sceneMoisture |
the scene moisture |
our main glwindow widget for NGL applications all drawing elements are put in this file
Definition at line 27 of file GLWindow.h.
enum GLWindow::CAMMODE [private] |
GLWindow::GLWindow | ( | QWidget * | _parent | ) |
ctor of GLWindow
Part of this function was originally written by Jon Macey.
[in] | _parent | the parent window to create the GL context in |
Definition at line 24 of file GLWindow.cpp.
References m_aspect, m_cameraIndex, m_drawHelp, m_enableMountain, m_fov, m_fps, m_fpsTimer, m_frames, m_mountainIterations, m_newIndexOfOrigin, m_objectHeight, m_objectRadius, m_projection, m_rotate, m_sceneHeight, m_sceneMoisture, m_sceneWidth, m_showWindDir, m_spinXFace, m_spinYFace, m_temperature, m_timer, m_windDirectionRot, and m_wireframe.
: QGLWidget(_parent) { // set this widget to have the initial keyboard focus setFocus(); // re-size the widget to that of the parent (in this case the GLFrame passed in on construction) this->resize(_parent->size()); // Now set the initial GLWindow attributes to default values // Roate is false m_rotate=false; // mouse rotation values set to 0 m_spinXFace=0; m_spinYFace=0; // flag of showing help m_drawHelp=0; m_wireframe=false; m_enableMountain=true; m_mountainIterations=15; // now set the inital camera values m_cameraIndex=0; m_fov=65.0; m_aspect=972.0/656.0; m_projection=ngl::PERSPECTIVE; m_fpsTimer =startTimer(0); m_fps=0; m_frames=0; m_timer.start(); // now set size of scene m_sceneWidth=50; m_sceneHeight=50; // set non-flammbale object size m_objectRadius = 0.3; m_objectHeight = 0.2; m_newIndexOfOrigin = 0; m_windDirectionRot = 90; m_showWindDir = false; m_temperature = 23.0; m_sceneMoisture = 15.0; }
GLWindow::~GLWindow | ( | ) |
dtor free up the GLWindow and all resources
End of function.
This function was originally written by Jon Macey
Definition at line 78 of file GLWindow.cpp.
{
ngl::NGLInit *Init = ngl::NGLInit::instance();
std::cout<<"Shutting down NGL, removing VBO's and Shaders\n";
Init->NGLQuit();
}
void GLWindow::adjustFuelAmount | ( | int | _newAmount | ) | [slot] |
a slot to change the amount of fuel object
[in] | _newAmount | the new amount of fuel object |
Definition at line 676 of file GLWindow.cpp.
References fireScene, FireArea::pickFlammableObjectPosition(), FireArea::seperateList(), and FireArea::updateGridPoint().
{ fireScene->pickFlammableObjectPosition(_newAmount); fireScene->updateGridPoint(); fireScene->seperateList(); }
void GLWindow::adjustFuelSize | ( | int | _side, |
int | _type | ||
) | [slot] |
a slot to adjust the size of fuel object
[in] | _side | the side of object that would be adjusted, that will be height or length of fuel object |
[in] | _type | the type of adjusting the fuel object size that will increase or decrease |
Definition at line 802 of file GLWindow.cpp.
References FireArea::adjustObjSize(), fireScene, FireArea::seperateList(), and FireArea::updateGridPoint().
{ fireScene->adjustObjSize(_side, _type); fireScene->updateGridPoint(); fireScene->seperateList(); }
void GLWindow::adjustObstacleAmount | ( | int | _newNumber | ) | [slot] |
a slot to change the amount of obstacle or non-flammable object
[in] | _newNumber | the new number of obstacle |
Definition at line 666 of file GLWindow.cpp.
References fireScene, FireArea::pickObjectPosition(), FireArea::seperateList(), and FireArea::updateGridPoint().
{ fireScene->pickObjectPosition(_newNumber); fireScene->updateGridPoint(); fireScene->seperateList(); }
void GLWindow::assignNewOrigin | ( | int | _newOriginAmount | ) | [slot] |
a slot to change the amount of origin
[in] | _newOriginAmount | the new amount of origin that would be in the scene |
Definition at line 708 of file GLWindow.cpp.
References FireArea::adjustOriginAmount(), and fireScene.
{ fireScene->adjustOriginAmount(_newOriginAmount); }
void GLWindow::assignWindSpeed | ( | int | _newWindSpeed | ) | [slot] |
a slot to change the wind speed
[in] | _newWindSpeed | the new wind speed |
Definition at line 754 of file GLWindow.cpp.
References FireArea::assignWindSpeed(), and fireScene.
{ if(_newWindSpeed<4) _newWindSpeed = 4; fireScene->assignWindSpeed(_newWindSpeed); }
void GLWindow::changeMoistureOfTheScene | ( | double | _newSceneMoisture | ) | [slot] |
a slot to assign the new moisture of the scene
[in] | _newSceneMoisture | the new moisture of the scene |
Definition at line 783 of file GLWindow.cpp.
References FireArea::assignNewMoisture(), fireScene, and m_sceneMoisture.
{ m_sceneMoisture = _newSceneMoisture; fireScene->assignNewMoisture(_newSceneMoisture, 2); }
void GLWindow::changeObjMoisture | ( | double | _newObjMoisture | ) | [slot] |
a slot to assign the new moisture of the fuel object
[in] | _newObjMoisture | the new moisture of the object |
Definition at line 792 of file GLWindow.cpp.
References FireArea::assignNewObjMoisture(), fireScene, FireArea::seperateList(), and FireArea::updateGridPoint().
{ fireScene->assignNewObjMoisture(_newObjMoisture); fireScene->updateGridPoint(); fireScene->seperateList(); }
void GLWindow::changeTemperature | ( | double | _newTemp | ) | [slot] |
a slot to assign the scene temperature
[in] | _newTemp | the new temperature of the scene |
Definition at line 774 of file GLWindow.cpp.
References FireArea::assignNewMoisture(), fireScene, and m_temperature.
{ m_temperature = _newTemp; fireScene->assignNewMoisture(_newTemp, 1); }
void GLWindow::changeWindDirection | ( | int | _newDir | ) | [slot] |
a slot to change the wind direction
[in] | _newDir | the adjusting number of wind direction |
Definition at line 765 of file GLWindow.cpp.
References FireArea::assignWindDirection(), fireScene, and m_windDirectionRot.
{ m_windDirectionRot = _newDir; fireScene->assignWindDirection(ngl::Vector(m_windDirectionRot,0.0,m_windDirectionRot)); }
void GLWindow::createCameras | ( | ) | [private] |
this method creates the cameras in different viewing
End of function.
This function was originally written by Jon Macey
Definition at line 88 of file GLWindow.cpp.
References m_aspect, m_cameras, m_fov, and m_projection.
{ // create a load of cameras ngl::Camera cam; ngl::Camera Tcam; ngl::Camera Scam; ngl::Camera Fcam; // set the different vectors for the camera positions ngl::Vector EYE(0,5,8); ngl::Vector LOOK=0.0; ngl::Vector UP(0,1,0); ngl::Vector TEYE(0,8,0); ngl::Vector TLOOK=0.0; ngl::Vector TUP(0,0,1); ngl::Vector SEYE(2,2,2); ngl::Vector SLOOK=0.0; ngl::Vector SUP(0,1,0); ngl::Vector FEYE(5,2,8); ngl::Vector FLOOK(0.0,0.0,0.0); ngl::Vector FUP(0,1,0); // finally set the cameras shape and position cam.set(EYE,LOOK,UP); cam.setShape(m_fov,m_aspect, 0.2f,150.0f,m_projection); cam.setOrthoParams(-1,1,-1,1,0.1,10.0); m_cameras.push_back(cam); Tcam.set(TEYE,TLOOK,TUP); Tcam.setShape(m_fov,m_aspect, 0.2f,150.0f,m_projection); Tcam.setOrthoParams(-0.1,0.1,-0.1,0.1,0.1,10.0); m_cameras.push_back(Tcam); Scam.set(SEYE,SLOOK,SUP); Scam.setShape(m_fov,m_aspect, 0.2f,150.0f,m_projection); Scam.setOrthoParams(-0.1,0.1,-0.1,0.1,0.1,10.0); m_cameras.push_back(Scam); Fcam.set(FEYE,FLOOK,FUP); Fcam.setShape(m_fov,m_aspect, 0.2f,150.0f,m_projection); Fcam.setOrthoParams(-0.1,0.1,-0.1,0.1,0.1,10.0); m_cameras.push_back(Fcam); }
void GLWindow::decreaseTerrainHeight | ( | ) | [slot] |
a slot to decrease the terrain height
Definition at line 577 of file GLWindow.cpp.
References FireArea::adjustMountainHeight(), fireScene, FireArea::seperateList(), and FireArea::updateGridPoint().
{ fireScene->adjustMountainHeight(0.01, 1); fireScene->updateGridPoint(); fireScene->seperateList(); }
void GLWindow::drawAxis | ( | const std::string & | m_shaderName, |
ngl::TransformStack & | m_axisTransformStack, | ||
float | m_scale, | ||
int | m_xRot, | ||
int | m_yRot | ||
) | [private] |
this method would draw the arrow of wind direction
Part of this function was originally written by Jon Macey.
&_shaderName | refers to the shader of arrow, |
&_transformStack | refers to the transform stack of arrow |
Definition at line 823 of file GLWindow.cpp.
References m_windDirectionRot.
{ ngl::VBOPrimitives *prim=ngl::VBOPrimitives::instance(); // grab an instance of the shader manager ngl::ShaderManager *shader=ngl::ShaderManager::instance(); ngl::Transformation tx; ngl::Vector m_colour = ngl::Vector(0.8,0.6,1.0); m_axisTransformStack.pushTransform(); { (*shader)[m_shaderName]->use(); shader->setShaderParamFromMatrix(m_shaderName,"ModelMatrix",m_axisTransformStack.getCurrAndGlobal().getMatrix()); // ----- set colour to each point shader->setShaderParam4f(m_shaderName,m_shaderName,m_colour.m_x,m_colour.m_y,m_colour.m_z,1.0); // set the global rotation tx.setRotation(m_xRot,m_yRot,0.0); m_axisTransformStack.setCurrent(tx); // set the global rotation m_axisTransformStack.pushTransform(); { float m_rot = m_windDirectionRot - 180; m_axisTransformStack.getCurrentTransform().setScale(m_scale,m_scale,m_scale); m_axisTransformStack.getCurrentTransform().setPosition(ngl::Vector(0,5,0)); m_axisTransformStack.getCurrentTransform().setRotation(0,m_rot,0); m_axisTransformStack.loadGlobalMatrixToShader(m_shaderName,"ModelMatrix"); prim->draw("nglAXISCylinder"); m_axisTransformStack.getCurrentTransform().setPosition(ngl::Vector(0,5,0)); m_axisTransformStack.getCurrentTransform().setRotation(0, m_windDirectionRot,0); m_axisTransformStack.loadGlobalMatrixToShader(m_shaderName,"ModelMatrix"); prim->draw("nglAXISCone"); } m_axisTransformStack.popTransform(); } m_axisTransformStack.popTransform(); }
void GLWindow::editDLA | ( | ) | [slot] |
a slot to edit the scene for generating new DLS form
Definition at line 690 of file GLWindow.cpp.
References fireScene, and FireArea::pauseTime().
void GLWindow::enableWind | ( | bool | _mode | ) | [slot] |
a slot to toggle the wind
[in] | _mode | the mode of enabling wind |
Definition at line 733 of file GLWindow.cpp.
References FireArea::assignWind(), fireScene, and m_showWindDir.
{ fireScene->assignWind(_mode); if(_mode==false) { m_showWindDir = false; } }
void GLWindow::generateNewFirePath | ( | ) | [slot] |
a slot to generate new fire path from the edited scene
Definition at line 684 of file GLWindow.cpp.
References fireScene, and FireArea::generateNewDLA().
{ fireScene->generateNewDLA(); }
void GLWindow::increaseTerrainHeight | ( | ) | [slot] |
a slot to increase the terrain height
Definition at line 569 of file GLWindow.cpp.
References FireArea::adjustMountainHeight(), fireScene, FireArea::seperateList(), and FireArea::updateGridPoint().
{ fireScene->adjustMountainHeight(0.01, 2); fireScene->updateGridPoint(); fireScene->seperateList(); }
void GLWindow::initializeGL | ( | ) | [protected] |
The following methods must be implimented in the sub class this is called when the window is created.
End of function.
Part of this function was originally written by Jon Macey
---------------------------------------------------------------------------------------------------------------------- The following texture is from :- Eternix (2009). TUTORIAL 17 [online]. [Accessed 16 July 2011]. Available from: http://www.eternix.com.br/pt/3dgamebuilder/Tutorial17.php
end of Citation ----------------------------------------------------------------------------------------------------------------------
Definition at line 158 of file GLWindow.cpp.
References createCameras(), fireScene, m_enableMountain, m_light, m_mountainIterations, m_objectHeight, m_objectRadius, m_sceneHeight, and m_sceneWidth.
{ // set up light glEnable(GL_LIGHTING); // enable depth testing for drawing glEnable(GL_DEPTH_TEST); glClearColor(0.3f, 0.3f, 0.3f, 1.0f); // Grey Background ngl::NGLInit *Init = ngl::NGLInit::instance(); #ifdef WIN32 glewInit(); #endif Init->initGlew(); createCameras(); // now to load the shader and set the values // grab an instance of shader manager ngl::ShaderManager *shader=ngl::ShaderManager::instance(); m_light = new ngl::Light(ngl::Vector(1,1,1,1),ngl::Colour(1,1,1,1),ngl::LIGHTREMOTE); // ----- Colour Shader // create shader program shader->createShaderProgram("Colour"); // load shader sources shader->attachShader("cvertex",ngl::VERTEX); shader->attachShader("cfragment",ngl::FRAGMENT); shader->loadShaderSource("cvertex","shaders/Colour.vs"); shader->loadShaderSource("cfragment","shaders/Colour.fs"); // compile shader->compileShader("cvertex"); shader->compileShader("cfragment"); // link shader->attachShaderToProgram("Colour","cvertex"); shader->attachShaderToProgram("Colour","cfragment"); shader->linkProgramObject("Colour"); // use (*shader)["Colour"]->use(); // ----- Blinn Shader // create shader program shader->createShaderProgram("Blinn"); // load shader sources shader->attachShader("overtex",ngl::VERTEX); shader->attachShader("ofragment",ngl::FRAGMENT); shader->loadShaderSource("overtex","shaders/Vertex_obj.vs"); shader->loadShaderSource("ofragment","shaders/Fragment_obj.fs"); // compile shader->compileShader("overtex"); shader->compileShader("ofragment"); // link shader->attachShaderToProgram("Blinn","overtex"); shader->attachShaderToProgram("Blinn","ofragment"); shader->linkProgramObject("Blinn"); // use (*shader)["Blinn"]->use(); // create an instance of the VBO primitive ngl::VBOPrimitives *prim=ngl::VBOPrimitives::instance(); // create sphere prim->createVBOSphere("sphere",1.0,20); // create cylinder prim->createVBOCylinder("cylinder", m_objectRadius, m_objectHeight, 50, 10); // create disk prim->createVBODisk("disk", m_objectRadius, 50); // create cone prim->createVBOCone("cone", 0.9, 2.0, 50, 50); // primitive for wind axis prim->createVBOCylinder("nglAXISCylinder",0.03,0.4,60,60); prim->createVBOCone("nglAXISCone",0.07,0.2,30,30); m_light->enable(); // --- assign texture to Blinn Shader // load and set a texture ngl::Texture t("resources/textures/Grass.bmp"); t.setTextureGL(); glGenerateMipmap(GL_TEXTURE_2D); glEnable(GL_MULTISAMPLE); // the shader will use the currently active material and light0 so set them ngl::Material m(ngl::GOLD); m.use(); ngl::Light *L1 = new ngl::Light(ngl::Vector(0,5,4,1),ngl::Colour(1,1,1,1),ngl::LIGHTLOCAL); L1->enable(); // ----- create fire scene object fireScene = new FireArea(m_sceneWidth, m_sceneHeight, m_objectRadius, m_objectHeight, m_enableMountain, m_mountainIterations); }
void GLWindow::mouseMoveEvent | ( | QMouseEvent * | _event | ) | [private] |
this method is called every time a mouse is moved
End of function.
_event | the Qt Event structure |
This function was originally written by Jon Macey
Definition at line 466 of file GLWindow.cpp.
References m_origX, m_origY, m_rotate, m_spinXFace, and m_spinYFace.
{ // note the method buttons() is the button state when event was called // this is different from button() which is used to check which button was // pressed when the mousePress/Release event is generated 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(); }
void GLWindow::mousePressEvent | ( | QMouseEvent * | _event | ) | [private] |
this method is called everytime the mouse button is pressed inherited from QObject and overridden here.
End of function.
_event | the Qt Event structure |
This function was originally written by Jon Macey
Definition at line 487 of file GLWindow.cpp.
void GLWindow::mouseReleaseEvent | ( | QMouseEvent * | _event | ) | [private] |
this method is called everytime the mouse button is released inherited from QObject and overridden here.
End of function.
_event | the Qt Event structure |
This function was originally written by Jon Macey
Definition at line 504 of file GLWindow.cpp.
References m_rotate.
{ // this event is called when the mouse button is released // we then set Rotate to false if (_event->button() == Qt::LeftButton) { m_rotate=false; } }
void GLWindow::moveOriginDown | ( | ) | [slot] |
a slot to move the current origin point to the lower direction (south)
Definition at line 642 of file GLWindow.cpp.
References FireArea::adjustOrigin(), and fireScene.
{ fireScene->adjustOrigin(4); }
void GLWindow::moveOriginLeft | ( | ) | [slot] |
a slot to move the current origin point to the left direction
Definition at line 648 of file GLWindow.cpp.
References FireArea::adjustOrigin(), and fireScene.
{ fireScene->adjustOrigin(1); }
void GLWindow::moveOriginRight | ( | ) | [slot] |
a slot to move the current origin point to the right direction
Definition at line 654 of file GLWindow.cpp.
References FireArea::adjustOrigin(), and fireScene.
{ fireScene->adjustOrigin(2); }
void GLWindow::moveOriginUp | ( | ) | [slot] |
a slot to move the current origin point to the upper direction (north)
Definition at line 660 of file GLWindow.cpp.
References FireArea::adjustOrigin(), and fireScene.
{ fireScene->adjustOrigin(3); }
void GLWindow::paintGL | ( | ) | [protected] |
this is the main gl drawing routine which is called whenever the window needs to be re-drawn
End of function.
Part of this function was originally written by Jon Macey
Definition at line 285 of file GLWindow.cpp.
References FireArea::drawArea(), drawAxis(), FireArea::drawBase(), FireArea::drawGrid(), FireArea::drawRandomobject(), fireScene, m_cameraIndex, m_cameras, m_frames, m_light, m_showWindDir, m_spinXFace, m_spinYFace, m_transformStack, m_wireframe, and FireArea::timestep().
{ // create an instance of the VBO primitive //ngl::VBOPrimitives *prim=ngl::VBOPrimitives::instance(); // grab an instance of the shader manager ngl::ShaderManager *shader=ngl::ShaderManager::instance(); // clear the screen and depth buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Rotation based on the mouse position for our global // transform ngl::Transformation trans; trans.setRotation(m_spinXFace,m_spinYFace,0); // set this in the TX stack m_transformStack.setGlobal(trans); m_light->enable(); // now set this value in the shader for the current Camera, we do all 3 elements as they // can all change per frame (*shader)["Blinn"]->use(); shader->setShaderParamFromMatrix("Blinn","ViewMatrix",m_cameras[m_cameraIndex].getModelView()); shader->setShaderParamFromMatrix("Blinn","projectionMatrix",m_cameras[m_cameraIndex].getProjection()); // now set this value in the shader for the current ModelMatrix shader->setShaderParamFromMatrix("Blinn","ModelMatrix",m_transformStack.getCurrAndGlobal().getMatrix()); (*shader)["Colour"]->use(); shader->setShaderParamFromMatrix("Colour","ViewMatrix",m_cameras[m_cameraIndex].getModelView()); shader->setShaderParamFromMatrix("Colour","projectionMatrix",m_cameras[m_cameraIndex].getProjection()); shader->setShaderParam4f("Colour","Colour",0,0,0,1); // now go back to solid drawing glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); // ----- draw scene m_transformStack.pushTransform(); { (*shader)["Colour"]->use(); fireScene->drawArea("Colour", m_transformStack); // set colour back to black for the base grid colour shader->setShaderParam4f("Colour","Colour",0.0,0.0,0.0,1.0); } m_transformStack.popTransform(); // ----- draw dla path m_transformStack.pushTransform(); { (*shader)["Colour"]->use(); shader->setShaderParamFromMatrix("Colour","ModelMatrix",m_transformStack.getCurrAndGlobal().getMatrix()); shader->setShaderParam4f("Colour","Colour",1.0,0.5,0.8,1.0); fireScene->timestep("Colour", m_transformStack); } m_transformStack.popTransform(); // ----- draw grid m_transformStack.pushTransform(); { if(m_wireframe==false) { (*shader)["Blinn"]->use(); fireScene->drawGrid(m_wireframe); fireScene->drawBase(); } else { (*shader)["Colour"]->use(); shader->setShaderParamFromMatrix("Colour","ModelMatrix",m_transformStack.getCurrAndGlobal().getMatrix()); shader->setShaderParam4f("Colour","Colour",0.0,0.0,0.0,1.0); fireScene->drawGrid(m_wireframe); } } m_transformStack.popTransform(); // ----- draw fuel object m_transformStack.pushTransform(); { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); //glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); fireScene->drawRandomobject("Colour", m_transformStack); // glDisable(GL_BLEND); } m_transformStack.popTransform(); // ----- draw AXIS for wind direction m_transformStack.pushTransform(); { if(m_showWindDir==true) { m_transformStack.loadGlobalMatrixToShader("Colour","ModelMatrix"); drawAxis("Colour",m_transformStack, 2.0, m_spinXFace, m_spinYFace); } } m_transformStack.popTransform(); // ----- calculate and draw FPS ++m_frames; glUseProgramObjectARB(0); // ----- showing text glUseProgram(0); glColor3f(0.9,0.85,0.8); QFont font; font.setPointSize(10); // now we are going to construct a string to draw the mode information /* QString text; switch ( m_moveMode) { case MOVEEYE : mode=QString("Move Eye"); break; case MOVELOOK : mode=QString("Move Look"); break; case MOVEBOTH : mode=QString("Move Both"); break; case MOVESLIDE : mode=QString("Move Slide"); break; } QString text=QString("Active Camera : %1 ,Current mode = %2").arg(m_cameraIndex).arg(mode); renderText(10,18,text,font); text=QString("FOV = %1 ").arg(m_fov); renderText(10,18*2,text,font); font.setPointSize(8); renderText(10,18*3,"ModelView Matrix",font); // now we use the QString sprintf ngl::Matrix m=m_cameras[m_cameraIndex].getModelView(); text.sprintf("[ %+0.4f %+0.4f %+0.4f %+0.4f]",m.openGL()[0],m.openGL()[1],m.openGL()[2],m.openGL()[3]); renderText(10,16*4,text,font); text.sprintf("[ %+0.4f %+0.4f %+0.4f %+0.4f]",m.openGL()[4],m.openGL()[5],m.openGL()[6],m.openGL()[7]); renderText(10,16*5,text,font); text.sprintf("[ %+0.4f %+0.4f %+0.4f %+0.4f]",m.openGL()[8],m.openGL()[9],m.openGL()[10],m.openGL()[11]); renderText(10,16*6,text,font); text.sprintf("[ %+0.4f %+0.4f %+0.4f %+0.4f]",m.openGL()[12],m.openGL()[13],m.openGL()[14],m.openGL()[15]); renderText(10,16*7,text,font); renderText(10,16*8,"Projection Matrix",font); // now we use the QString sprintf m=m_cameras[m_cameraIndex].getProjection(); text.sprintf("[ %+0.4f %+0.4f %+0.4f %+0.4f]",m.openGL()[0],m.openGL()[1],m.openGL()[2],m.openGL()[3]); renderText(10,16*9,text,font); text.sprintf("[ %+0.4f %+0.4f %+0.4f %+0.4f]",m.openGL()[4],m.openGL()[5],m.openGL()[6],m.openGL()[7]); renderText(10,16*10,text,font); text.sprintf("[ %+0.4f %+0.4f %+0.4f %+0.4f]",m.openGL()[8],m.openGL()[9],m.openGL()[10],m.openGL()[11]); renderText(10,16*11,text,font); text.sprintf("[ %+0.4f %+0.4f %+0.4f %+0.4f]",m.openGL()[12],m.openGL()[13],m.openGL()[14],m.openGL()[15]); renderText(10,16*12,text,font); font.setPointSize(10); font.setBold(true); renderText(10,16*14,"Press 'h' to display Help",font); // ----- draw help int m_showHelp = m_drawHelp%2; if (m_showHelp==1) { font.setPointSize(9); font.setBold(false); // now render the text using the QT renderText helper function renderText(10,18*14,"Arrow Keys : move Camera",font); renderText(10,18*15,"0-4 : switch cameras",font); renderText(10,18*16,"z/x : decrease/increase terrain height",font); renderText(10,18*17,"xxxx",font); renderText(10,18*18,"c : d",font); renderText(10,18*19,"v : increase terrain size",font); renderText(10,18*20,"+/- : change fov of Camera",font); renderText(10,18*21,"5/6 : ortho/perspective projection",font); renderText(10,18*22,"i/o : move camera in/out",font); } */ }
void GLWindow::pauseAnimation | ( | ) | [slot] |
a slot to pause the fire path animation
Definition at line 696 of file GLWindow.cpp.
References fireScene, and FireArea::pauseTime().
void GLWindow::pickCamera | ( | int | _i | ) | [slot] |
set the camera from selected number
[in] | _i | the index of the camera number |
Definition at line 599 of file GLWindow.cpp.
References m_cameraIndex.
{ m_cameraIndex = _i; updateGL(); }
void GLWindow::playAnimation | ( | ) | [slot] |
a slot to play the fire path animation
Definition at line 702 of file GLWindow.cpp.
References fireScene, and FireArea::pauseTime().
void GLWindow::resetMountain | ( | ) | [slot] |
a slot to re-random the terrain generating with the specified iterations number
end of function
Definition at line 623 of file GLWindow.cpp.
References FireArea::buildMountain(), fireScene, FireArea::seperateList(), and FireArea::updateGridPoint().
{ fireScene->buildMountain(); fireScene->updateGridPoint(); fireScene->seperateList(); }
void GLWindow::resizeGL | ( | const int | _w, |
const int | _h | ||
) | [protected] |
this is called whenever the window is re-sized
End of function.
[in] | _w | the width of the resized window |
[in] | _h | the height of the resized window |
This function was originally written by Jon Macey
Definition at line 265 of file GLWindow.cpp.
References m_aspect, and setCameraShape().
{ glViewport(0,0,_w,_h); // calculate the aspect ratio m_aspect=(float)_w/_h; // now set the camera values setCameraShape(); }
void GLWindow::selectMovingOrigin | ( | int | _indexOfOrigin | ) | [slot] |
a slot to select the origin point that is wished to be moved
[in] | _indexOfOrigin | the index of selected origin point |
Definition at line 716 of file GLWindow.cpp.
References FireArea::changeMovingOriginIndex(), fireScene, and m_newIndexOfOrigin.
{ m_newIndexOfOrigin = _indexOfOrigin-1; fireScene->changeMovingOriginIndex(m_newIndexOfOrigin); }
void GLWindow::selectObjIndexToAdjustSize | ( | int | _objIndex | ) | [slot] |
a slot to select the index number of fuel object that wishes to change the size
[in] | _objIndex | the index number of fuel object |
Definition at line 813 of file GLWindow.cpp.
References FireArea::changeIndexOfObj(), and fireScene.
{ int m_objIndex = _objIndex-1; fireScene->changeIndexOfObj(m_objIndex); }
void GLWindow::setCameraShape | ( | ) | [private] |
this method is called everytime the window is resized or the camera is adjusted to set the current camera value and the scene
End of function.
This function was originally written by Jon Macey
Definition at line 136 of file GLWindow.cpp.
References m_aspect, m_cameraIndex, m_cameras, m_fov, and m_projection.
{ ngl::ShaderManager *shader=ngl::ShaderManager::instance(); int cameraSize=m_cameras.size(); for(int i=0; i<cameraSize; ++i) { m_cameras[i].setShape(m_fov,m_aspect, 0.2f,150.0f,m_projection); m_cameras[i].setOrthoParams(-1,1,-1,1,1,10.0); } (*shader)["Colour"]->use(); shader->setShaderParamFromMatrix("Colour","projectionMatrix",m_cameras[m_cameraIndex].getProjection()); (*shader)["Blinn"]->use(); shader->setShaderParamFromMatrix("Blinn","projectionMatrix",m_cameras[m_cameraIndex].getProjection()); }
void GLWindow::setColour | ( | ) | [slot] |
a slot to set the colour
This function was originally written by Jon Macey.
Definition at line 609 of file GLWindow.cpp.
{ QColor colour = QColorDialog::getColor(); if( colour.isValid()) { ngl::ShaderManager *shader=ngl::ShaderManager::instance(); (*shader)["Colour"]->use(); shader->setShaderParam4f("Colour","Colour",colour.redF(),colour.greenF(),colour.blueF(),1.0); updateGL(); } }
void GLWindow::setNewMountainIterations | ( | int | _newIterations | ) | [slot] |
a slot to assign new iterations number for generating terrain
[in] | _newIterations | the new number of iterations |
Definition at line 631 of file GLWindow.cpp.
References fireScene, m_enableMountain, m_mountainIterations, FireArea::seperateList(), FireArea::toggleMountainDraw(), and FireArea::updateGridPoint().
{ m_mountainIterations = _newIterations; fireScene->toggleMountainDraw(m_enableMountain,m_mountainIterations); fireScene->updateGridPoint(); fireScene->seperateList(); }
void GLWindow::showWindDir | ( | bool | _mode | ) | [slot] |
a slot to toggle the showing of wind's arrow
[in] | _mode | the mode of showing arrow of wind direction |
Definition at line 746 of file GLWindow.cpp.
References m_showWindDir.
{ m_showWindDir = _mode; }
void GLWindow::timerEvent | ( | QTimerEvent * | _event | ) | [private] |
this method is called to counting the time
End of function.
_event | the Qt Event structure |
This function was originally written by Jon Macey
Definition at line 519 of file GLWindow.cpp.
References m_fps, m_fpsTimer, m_frames, and m_timer.
void GLWindow::toggleShowLine | ( | bool | _mode | ) | [slot] |
a slot to toggle to show only line of fire
end of function
[in] | _mode | the mode passed from only line showing checkbox |
Definition at line 550 of file GLWindow.cpp.
References fireScene, and FireArea::showLine().
void GLWindow::toggleShowMark | ( | bool | _mode | ) | [slot] |
a slot to toggle the origin's marks showing
[in] | _mode | the mode passed from mark showing checkbox |
Definition at line 725 of file GLWindow.cpp.
References fireScene, and FireArea::showMark().
void GLWindow::toggleTerrain | ( | bool | _mode | ) | [slot] |
a slot to toggle the terrain generating
[in] | _mode | the mode passed from terrain generating checkbox |
Definition at line 558 of file GLWindow.cpp.
References fireScene, m_enableMountain, m_mountainIterations, FireArea::seperateList(), FireArea::toggleMountainDraw(), and FireArea::updateGridPoint().
{ m_enableMountain = _mode; fireScene->toggleMountainDraw(m_enableMountain, m_mountainIterations); fireScene->updateGridPoint(); fireScene->seperateList(); }
void GLWindow::toggleWireframe | ( | bool | _mode | ) | [slot] |
a slot to toggle wireframe mode
end of function
[in] | _mode | the mode passed from the wireframe checkbox |
This function was originally written by Jon Macey
Definition at line 538 of file GLWindow.cpp.
References FireArea::drawGrid(), fireScene, and m_wireframe.
{ m_wireframe=_mode; fireScene->drawGrid(m_wireframe); updateGL(); }
void GLWindow::zoomIn | ( | ) | [slot] |
a slot to zoom in the scene
Definition at line 585 of file GLWindow.cpp.
References m_fov, and setCameraShape().
{ --m_fov; setCameraShape(); }
void GLWindow::zoomOut | ( | ) | [slot] |
a slot to zoom out the scene
Definition at line 592 of file GLWindow.cpp.
References m_fov, and setCameraShape().
{ ++m_fov; setCameraShape(); }
FireArea* GLWindow::fireScene [private] |
create scene object
Definition at line 157 of file GLWindow.h.
float GLWindow::m_aspect [private] |
aspect ratio of the camera
Definition at line 114 of file GLWindow.h.
int GLWindow::m_cameraIndex [private] |
an index into the active camera list
Definition at line 102 of file GLWindow.h.
std::vector<ngl::Camera > GLWindow::m_cameras [private] |
a container for our Cameras
Definition at line 98 of file GLWindow.h.
int GLWindow::m_drawHelp [private] |
toggle help flag
Definition at line 93 of file GLWindow.h.
bool GLWindow::m_enableMountain [private] |
flag of mountain drawing
Definition at line 53 of file GLWindow.h.
float GLWindow::m_fov [private] |
fov value for the camera
Definition at line 110 of file GLWindow.h.
int GLWindow::m_fps [private] |
the fps to draw
Definition at line 135 of file GLWindow.h.
int GLWindow::m_fpsTimer [private] |
flag for the fps timer
Definition at line 131 of file GLWindow.h.
int GLWindow::m_frames [private] |
the frame number
Definition at line 139 of file GLWindow.h.
ngl::Light* GLWindow::m_light [private] |
the light for the shading
Definition at line 106 of file GLWindow.h.
int GLWindow::m_mountainIterations [private] |
number of iterations for generating mountain or terrain
Definition at line 57 of file GLWindow.h.
int GLWindow::m_newIndexOfOrigin [private] |
the index of origin that is wished to be moved
Definition at line 162 of file GLWindow.h.
float GLWindow::m_objectHeight [private] |
height of fuel object
Definition at line 127 of file GLWindow.h.
float GLWindow::m_objectRadius [private] |
radius of fuel object
Definition at line 123 of file GLWindow.h.
int GLWindow::m_origX [private] |
the previous x mouse value
Definition at line 79 of file GLWindow.h.
int GLWindow::m_origY [private] |
the previous y mouse value
Definition at line 83 of file GLWindow.h.
ngl::CAMERAPROJECTION GLWindow::m_projection [private] |
projection mode
Definition at line 118 of file GLWindow.h.
bool GLWindow::m_rotate [private] |
flag to indicate if the mouse button is pressed when dragging
Definition at line 75 of file GLWindow.h.
int GLWindow::m_sceneHeight [private] |
scene height size
Definition at line 152 of file GLWindow.h.
double GLWindow::m_sceneMoisture [private] |
the scene moisture
Definition at line 178 of file GLWindow.h.
int GLWindow::m_sceneWidth [private] |
scene width size
Definition at line 148 of file GLWindow.h.
bool GLWindow::m_showWindDir [private] |
the flag of showing arrow of the wind direction
Definition at line 170 of file GLWindow.h.
int GLWindow::m_spinXFace [private] |
used to store the x rotation mouse value
Definition at line 67 of file GLWindow.h.
int GLWindow::m_spinYFace [private] |
used to store the y rotation mouse value
Definition at line 71 of file GLWindow.h.
double GLWindow::m_temperature [private] |
the scene temperature
Definition at line 174 of file GLWindow.h.
QTime GLWindow::m_timer [private] |
the time counter
Definition at line 143 of file GLWindow.h.
ngl::TransformStack GLWindow::m_transformStack [private] |
transformation stack for the gl transformations etc
Definition at line 88 of file GLWindow.h.
int GLWindow::m_windDirectionRot [private] |
the rotation value, refers to the wind direction
Definition at line 166 of file GLWindow.h.
bool GLWindow::m_wireframe [private] |
flag of wireframe mode
Definition at line 49 of file GLWindow.h.