DLA-Fire-Prediction-Thesis 1.0

FireArea Class Reference

This class will create scene for fire area with the wind direction, slope, and the amount of origin point and objects. More...

#include <FireArea.h>

Collaboration diagram for FireArea:

List of all members.

Public Member Functions

 FireArea (int _sceneWidth, int _sceneHeight, float _objectRadius, float _objectHeight, bool _drawMountain, int _iterations)
 ctor of scene area. It would assign the size of fire area
void calculateArea ()
 This method will calculate grid point from the assigned width and height size of fire area.
void drawArea (const std::string &_shaderName, ngl::TransformStack &_transformStack) const
 This method will draw fire area from the calculated object point position list.
void seperateList ()
 This method will categorize type of point to flammable and non-flammable list.
void timestep (const std::string &_shaderName, ngl::TransformStack &_transformStack)
 This method updates the point to current state.
void drawDLAPath ()
 This method would call the draw path method of DLAStructure class.
void drawRandomobject (const std::string &_shaderName, ngl::TransformStack &_transformStack) const
 This method will draw fuel object.
void pickObjectPosition (int m_amountobject)
 This method would randomly assign the non-flammable object's position and shape.
int identifyArea (ngl::Vector m_checkingArea)
 This method would find the place on fire area to specify as non-flammable area. Thus, fire path would not go thrugh this part.
void buildMountain ()
 This method would build the mountain from the specific mountain number and assign the point to be centre of mountain. The size and height of each mountain would random adjusted within the decided maximum value.
void drawGrid (bool _wireframe)
 This method would draw the grid.
void drawBase ()
 This method would draw base of the scene, including the ground.
void adjustMountainHeight (float _adjustingHeight, int _adjustStatus)
 This method would adjust the size of mountain.
void adjustMountain (int m_adjustStatus)
 This method would build the mountain with the current value.
void toggleMountainDraw (bool _mountainDraw, int _iterations)
 This method would toggle the drawing or generating the mountain or terrain.
void adjustOrigin (int _direction)
 This method would move the position of origin with the specified direction.
void updateGridPoint ()
 This method would update the new grid point after the new amount of obstacle is created.
void pauseTime (bool _pauseStatus, bool _editFlag)
 This method would pause the animation of fire path.
void generateNewDLA ()
 This method would be called when the new scene is edited and the generate button is clicked for creating the fire path.
void adjustOriginAmount (int _newAmount)
 This method would adjust the amount of fire origin of the whole scene.
void changeMovingOriginIndex (int _currentIndex)
 This method would select which origin point would be able to move.
void showMark (bool _showingMode)
 This method would be called when the mark's check box has been toggled.
void showLine (bool _showingMode)
 This method would be called when the showing line only's check box has been toggled.
void pickFlammableObjectPosition (int m_amountobject)
 This method would randomly assign the fuel object's position.
ngl::Vector getFuelColourInTheArea (ngl::Vector m_checkingArea)
 This method would return the colour of point that is located in the fire area.
void assignWindDirection (ngl::Vector _windDir)
 This method would assign the new wind direction from user.
void assignWindSpeed (int _newWindSpeed)
 This method would assign the new wind speed from user.
void assignWind (bool _mode)
 This method would toggle the wind function.
void assignNewMoisture (double _newMoisture, int _mode)
 This method would assign the new moisture and temperature of the fire scene.
void assignNewObjMoisture (double _newMoisture)
 This method would assign the new moisture of the fuel object.
void changeIndexOfObj (int _newSelectedIndex)
 This method would assign the new index of the fuel object that will be adjusted the size.
void adjustObjSize (int _side, int _mode)
 This method would adjust the radius and height of selecting fuel object.
std::vector< FuelPointanalyzeGridPoint (std::vector< FuelPoint > m_newDLAForm)
 This method would return the grid area of current dla form.

Private Attributes

int m_areaWidth
 width size of fire area
int m_areaHeight
 height size of fire area
DLAStructurem_dlaStructureOne
 create DLA object
FirePathm_firePathOne
 create firePath object
std::vector< FuelPointm_gridPointList
 the list contains every point on the fire area
std::vector< FuelPointm_initPointList
 the list contains initial point on the fire area
std::vector< FuelPointm_flammableList
 the list contains flammable point
std::vector< FuelPointm_nonflammableList
 the list contains non-flammable point
std::vector< FuelObjectm_nonflammableObjectList
 the list contains non-flammable object
int m_timeStep
 time step number
float m_pointRadius
 radius of the point
float m_objRadius
 radius of fuel object
float m_objHeight
 height of fuel object
int m_mountainNumber
 number of mountain that would generate on the scene
float m_displacement
 displacement for building mountain (height of mountain)
float m_terrainCircleSize
 size of circle represents mountain (sphere radius*2)
int m_indexOfOrigin
 the index of origin point, according to grid point list
bool m_drawMountain
 the flag of drawing or generating terrain
bool m_pauseAnimation
 the flag of pausing animation
bool m_showPath
 the flag of showing DLA form
ngl::Vector m_originPosition
 origin point position
int m_numberOfOrigin
 the amount of origin number of the entire scene
int m_originIndex
 the current index of origin number in the origin point list
std::vector< FuelPointm_originList
 the origin point list
bool m_markShowing
 the flag of showing mark of origin point
std::vector< FuelPointm_currentDLAList
 list of current built DLA point
std::vector< FuelPointm_currentDLALine
 list of current built DLA seed point
int m_dlaAmount
 the amount of dla stucture of the entire scene
std::vector< ngl::Vector > m_currentNonFlammableList
 the list of current non-flammable object's position
int m_approxDLASize
 the size of DLA that is assigned by users and calculated the approximate value (with the scene) by the program
std::vector< ngl::Vector > m_currentFlammableList
 the list of current non-flammable object's position
std::vector< FuelObjectm_flammableObjectList
 the list contains non-flammable object
ngl::Vector m_windDirection
 the wind direction
int m_windSpeed
 the wind speed
bool m_addWind
 the flag of wind enable
double m_sceneTemperature
 the temperature of the scene
double m_sceneMoisture
 the moisture of the scene
float m_approxObjMoisture
 the moisture of the fuel object
int m_objIndex
 index of fuel object

Detailed Description

This class will create scene for fire area with the wind direction, slope, and the amount of origin point and objects.

This class will control the animation of fire path, referred to the fire variables.

Definition at line 30 of file FireArea.h.


Constructor & Destructor Documentation

FireArea::FireArea ( int  _sceneWidth,
int  _sceneHeight,
float  _objectRadius,
float  _objectHeight,
bool  _drawMountain,
int  _iterations 
)

ctor of scene area. It would assign the size of fire area

Parameters:
_sceneWidthis the width of fire area
_sceneHeightis the height of fire area
_objectRadiusis the initial radius of fuel object
_objectHeightis the initial height value of fuel object
_drawMountainis the flag of enabling and disabling terrain creation
_iterationsis the number of terrain creaing iterations

Definition at line 20 of file FireArea.cpp.

References buildMountain(), calculateArea(), DLAStructure::getDLALine(), DLAStructure::getDLAList(), m_addWind, m_approxDLASize, m_approxObjMoisture, m_areaHeight, m_areaWidth, m_currentDLALine, m_currentDLAList, m_currentFlammableList, m_currentNonFlammableList, m_displacement, m_dlaAmount, m_dlaStructureOne, m_drawMountain, m_firePathOne, m_flammableList, m_gridPointList, m_indexOfOrigin, m_initPointList, m_markShowing, m_mountainNumber, m_nonflammableList, m_nonflammableObjectList, m_numberOfOrigin, m_objHeight, m_objIndex, m_objRadius, m_originIndex, m_originList, m_originPosition, m_pauseAnimation, m_pointRadius, m_sceneMoisture, m_sceneTemperature, m_showPath, m_terrainCircleSize, m_timeStep, m_windDirection, m_windSpeed, pickFlammableObjectPosition(), pickObjectPosition(), seperateList(), and FuelPoint::setToOrigin().

{
    m_areaWidth = _sceneWidth;
    m_areaHeight = _sceneHeight;

    m_objRadius = _objectRadius;
    m_objHeight = _objectHeight;

    m_pointRadius = 0.1;

    m_mountainNumber = _iterations;
    m_displacement = 0.5;
    m_terrainCircleSize = 5.0;

    m_drawMountain = _drawMountain;
    m_pauseAnimation = false;

    std::vector<FuelPoint> m_pointZero;
    m_gridPointList = m_pointZero;
    m_initPointList = m_pointZero;
    m_flammableList = m_pointZero;
    m_nonflammableList = m_pointZero;
    m_originList = m_pointZero;

    std::vector<ngl::Vector> m_posZero;
    m_currentNonFlammableList = m_posZero;
    m_currentFlammableList = m_posZero;

    // assign non-flammable object to the list by randomly pick it within the fire area
    pickObjectPosition(10);
    pickFlammableObjectPosition(4);

    // calculate the initial fire area
    // value of each point will be first indentified
    calculateArea();
    seperateList();

    // add terrain
    if(m_drawMountain==true)
        buildMountain();

    seperateList();

    m_timeStep = 0;
    m_showPath = true;
    m_markShowing = true;

    // initial amount of origin point
    m_numberOfOrigin = 1;

    // initial origin is at the centre of the scene
    m_indexOfOrigin = ((m_areaHeight/2)*m_areaWidth) + (m_areaWidth/2);

    m_originIndex = 0;
    m_originPosition = ngl::Vector(0.0,0.0,0.0);
    m_originPosition.m_w = m_indexOfOrigin;
    m_originList.push_back(FuelPoint(m_originPosition, 0));

    m_objIndex = 0;

    FuelPoint m_seed = m_gridPointList[m_indexOfOrigin];
    m_seed.setToOrigin();
    m_gridPointList[m_indexOfOrigin] = m_seed;

    m_dlaAmount = 1;
    m_approxDLASize = 3000;
    //m_approxDLASize = 1000;

    m_windDirection = ngl::Vector(5.0,-0.5,0.0);
    m_windSpeed = 10;
    m_addWind = false;

    if(m_addWind==false)
    {
        m_windDirection.m_y = 500.0;
    }
    else
    {
        m_windDirection.m_y = 0.0;
    }

    m_sceneTemperature = 23.0;
    m_sceneMoisture = 15.0;
    m_approxObjMoisture = 0.5;

 //   m_dlaStructureOne = new DLAStructure();
    m_dlaStructureOne = new DLAStructure(m_gridPointList, m_nonflammableObjectList, m_originPosition, m_areaWidth, m_areaHeight, m_pointRadius, m_approxDLASize, m_windDirection, m_windSpeed);
    m_currentDLAList = m_dlaStructureOne->getDLAList();
    m_currentDLALine = m_dlaStructureOne->getDLALine();

    m_firePathOne = new FirePath(m_currentDLAList, m_currentDLALine, m_gridPointList, m_approxObjMoisture, m_originList, m_addWind, m_windSpeed, m_windDirection);
}

Here is the call graph for this function:


Member Function Documentation

void FireArea::adjustMountain ( int  m_adjustStatus)

This method would build the mountain with the current value.

Parameters:
m_adjustStatusis the flag to know that the value would increase or decrease the current size

---------------------------------------------------------------------------------------------------------------------- The following section is from :- António R. Fernandes (2010). Terrain Tutorial [online]. [Accessed 20 July 2011]. Available from: <http://www.lighthouse3d.com/opengl/terrain/index.php?circles>.

end of Citation ----------------------------------------------------------------------------------------------------------------------

Definition at line 560 of file FireArea.cpp.

References FuelPoint::getCircleHeight(), FuelPoint::getCircleSize(), FuelPoint::getPosition(), FuelPoint::isMointain(), m_gridPointList, and FuelPoint::setPosition().

{
    for(unsigned int p=0; p<m_gridPointList.size(); ++p)
    {
        FuelPoint m_checkingPoint = m_gridPointList[p];

        float m_circleSize = m_checkingPoint.getCircleSize();
        float m_circleDisp = m_checkingPoint.getCircleHeight();

        ngl::Vector m_mountainCentre = m_checkingPoint.getPosition();

        if(m_checkingPoint.isMointain()==true)
        {
            for(unsigned int k=0; k<m_gridPointList.size(); ++k)
            {
                FuelPoint m_initPoint = m_gridPointList[k];
                ngl::Vector m_initPos = m_initPoint.getPosition();

                float m_yPos = m_initPos.m_y;

                ngl::Vector m_deltaSphere = m_initPos - m_mountainCentre;
                float m_distSphere = m_deltaSphere.length();

                // ----- from pd = distance from circle center * 2 / terrainCircleSize
                float pd = (m_distSphere*2)/m_circleSize;

                // ----- from y = height(tx,tz) +=  disp/2 + cos(pd*3.14)*disp/2;
                if (fabs(pd) <=1.0)
                {
                    if(m_adjustStatus==2)
                        m_yPos += (m_circleDisp/2) + cos(pd*3.14)*(m_circleDisp/2);
                    else
                        m_yPos -= (m_circleDisp/2) + cos(pd*3.14)*(m_circleDisp/2);
                }

                m_initPos.m_y = m_yPos;

                m_initPoint.setPosition(m_initPos);

                m_gridPointList[k] = m_initPoint;
            }

        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::adjustMountainHeight ( float  _adjustingHeight,
int  _adjustStatus 
)

This method would adjust the size of mountain.

Parameters:
_adjustingHeightis the adjusting value for the current size of mountain
_adjustStatusis the flag to know that the value would increase or decrease the current size

Definition at line 541 of file FireArea.cpp.

References adjustMountain(), FuelPoint::isMointain(), m_gridPointList, and FuelPoint::setCircleHeight().

{
    for(unsigned int a=0; a<m_gridPointList.size(); ++a)
    {
        FuelPoint m_adjustingPoint = m_gridPointList[a];

        if(m_adjustingPoint.isMointain()==true)
        {
            m_adjustingPoint.setCircleHeight(_adjustingHeight);
            m_gridPointList[a] = m_adjustingPoint;
        }
    }
    adjustMountain(_adjustStatus);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::adjustObjSize ( int  _side,
int  _mode 
)

This method would adjust the radius and height of selecting fuel object.

Parameters:
_sideis the type of value that is radius or heigt of fuel object that will be changed
_modeis the mode of adjusting value that would be increase or decrease

Definition at line 2492 of file FireArea.cpp.

References FuelObject::getCurrentFuelValue(), FuelObject::getRadius(), m_flammableObjectList, m_objIndex, FuelObject::setFuelAmount(), and FuelObject::setRadius().

{
    if(_side==1)                    // side Length = 1
    {
        if(_mode==1)                // increase mode = 1
        {
            FuelObject m_selectedObject = m_flammableObjectList[m_objIndex];
            float m_radius = m_selectedObject.getRadius();
            float m_increaseStep = 0.15;

            if(m_radius<1.5)
            {
                m_selectedObject.setRadius(m_radius+m_increaseStep);
                m_flammableObjectList[m_objIndex] = m_selectedObject;
            }
        }
        else
        {
            FuelObject m_selectedObject = m_flammableObjectList[m_objIndex];
            float m_radius = m_selectedObject.getRadius();
            float m_decreaseStep = 0.15;
            if(m_radius>0.3)
            {
                m_selectedObject.setRadius(m_radius-m_decreaseStep);
                m_flammableObjectList[m_objIndex] = m_selectedObject;
            }
        } // end if mode
    }
    else
    {
        if(_mode==1)                // increase mode = 1
        {
            FuelObject m_selectedObject = m_flammableObjectList[m_objIndex];
            float m_fuel = m_selectedObject.getCurrentFuelValue();
            if(m_fuel>150)
                m_fuel = 150;
            m_selectedObject.setFuelAmount(m_fuel+2);
            m_flammableObjectList[m_objIndex] = m_selectedObject;

        }
        else
        {
            FuelObject m_selectedObject = m_flammableObjectList[m_objIndex];
            float m_fuel = m_selectedObject.getCurrentFuelValue();
            if(m_fuel<60)
                m_fuel = 60;
            m_selectedObject.setFuelAmount(m_fuel-2);
            m_flammableObjectList[m_objIndex] = m_selectedObject;
        }
    } // end if-else side variables
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::adjustOrigin ( int  _direction)

This method would move the position of origin with the specified direction.

Parameters:
_directionis the number that would specify the direction to move to the new origin point

Definition at line 235 of file FireArea.cpp.

References FuelPoint::getPosition(), FuelPoint::isFlammable(), FuelPoint::isOrigin(), m_areaHeight, m_areaWidth, m_firePathOne, m_gridPointList, m_indexOfOrigin, m_originIndex, m_originList, m_originPosition, m_pointRadius, FirePath::setNewOriginList(), FuelPoint::setPosition(), FuelPoint::setToOrigin(), and FuelPoint::setToRegular().

{
    // assign current origin value
    FuelPoint m_currentOrigin = m_originList[m_originIndex];
    m_originPosition = m_currentOrigin.getPosition();
    m_indexOfOrigin = m_originPosition.m_w;

    int m_inWidth = m_indexOfOrigin%m_areaWidth;
    int m_inHeight = (m_indexOfOrigin-m_inWidth)/m_areaWidth;

    // change status on gridpoint list to be normal first
    FuelPoint m_pointOnGridList = m_gridPointList[m_indexOfOrigin];
    m_pointOnGridList.setToRegular();
    m_gridPointList[m_indexOfOrigin] = m_pointOnGridList;

    if(_direction==1)
    {
        // left
        if(m_inWidth>0)
        {
            m_indexOfOrigin -= 1;
            m_originPosition.m_x -= m_pointRadius*2;

            FuelPoint m_currentPoint = m_gridPointList[m_indexOfOrigin];
            bool m_pointType = m_currentPoint.isFlammable();
            bool m_seedType = m_currentPoint.isOrigin();
            while((m_pointType==false)||(m_seedType==true))
            {
                m_indexOfOrigin -= 1;
                m_currentPoint = m_gridPointList[m_indexOfOrigin];
                m_pointType = m_currentPoint.isFlammable();
                m_originPosition.m_x -= m_pointRadius*2;
                m_seedType = m_currentPoint.isOrigin();
            }

            m_originPosition.m_w = m_indexOfOrigin;
            m_currentOrigin.setPosition(m_originPosition);
            m_originList[m_originIndex] = m_currentOrigin;

            // set status on gridlist
            FuelPoint m_newPointOnGrid = m_gridPointList[m_indexOfOrigin];
            m_newPointOnGrid.setToOrigin();
            m_gridPointList[m_indexOfOrigin] = m_newPointOnGrid;
        }
    }
    else if(_direction==2)
    {
        // right
        if(m_inWidth!=m_areaWidth-1)
        {
            m_indexOfOrigin += 1;
            m_originPosition.m_x += m_pointRadius*2;

            FuelPoint m_currentPoint = m_gridPointList[m_indexOfOrigin];
            bool m_pointType = m_currentPoint.isFlammable();
            bool m_seedType = m_currentPoint.isOrigin();
            while((m_pointType==false)||(m_seedType==true))
            {
                m_indexOfOrigin += 1;
                m_currentPoint = m_gridPointList[m_indexOfOrigin];
                m_pointType = m_currentPoint.isFlammable();
                m_originPosition.m_x += m_pointRadius*2;
                m_seedType = m_currentPoint.isOrigin();
            }

            m_originPosition.m_w = m_indexOfOrigin;
            m_currentOrigin.setPosition(m_originPosition);
            m_originList[m_originIndex] = m_currentOrigin;

            // set status on gridlist
            FuelPoint m_newPointOnGrid = m_gridPointList[m_indexOfOrigin];
            m_newPointOnGrid.setToOrigin();
            m_gridPointList[m_indexOfOrigin] = m_newPointOnGrid;
        }
    }
    else if(_direction==3)
    {
        // up
        if(m_inHeight>0)
        {
            m_indexOfOrigin -= m_areaHeight;
            m_originPosition.m_z -= m_pointRadius*2;

            FuelPoint m_currentPoint = m_gridPointList[m_indexOfOrigin];
            bool m_pointType = m_currentPoint.isFlammable();
            bool m_seedType = m_currentPoint.isOrigin();
            while((m_pointType==false)||(m_seedType==true))
            {
                m_indexOfOrigin -= m_areaHeight;
                m_currentPoint = m_gridPointList[m_indexOfOrigin];
                m_pointType = m_currentPoint.isFlammable();
                m_originPosition.m_z -= m_pointRadius*2;
                m_seedType = m_currentPoint.isOrigin();
            }

            m_originPosition.m_w = m_indexOfOrigin;
            m_currentOrigin.setPosition(m_originPosition);
            m_originList[m_originIndex] = m_currentOrigin;

            // set status on gridlist
            FuelPoint m_newPointOnGrid = m_gridPointList[m_indexOfOrigin];
            m_newPointOnGrid.setToOrigin();
            m_gridPointList[m_indexOfOrigin] = m_newPointOnGrid;
        }
    }
    else
    {
        // down
        if(m_inHeight!=m_areaHeight-1)
        {
            m_indexOfOrigin += m_areaHeight;
            m_originPosition.m_z += m_pointRadius*2;

            FuelPoint m_currentPoint = m_gridPointList[m_indexOfOrigin];
            bool m_pointType = m_currentPoint.isFlammable();
            bool m_seedType = m_currentPoint.isOrigin();
            while((m_pointType==false)||(m_seedType==true))
            {
                m_indexOfOrigin += m_areaHeight;
                m_currentPoint = m_gridPointList[m_indexOfOrigin];
                m_pointType = m_currentPoint.isFlammable();
                m_originPosition.m_z += m_pointRadius*2;
                m_seedType = m_currentPoint.isOrigin();
            }

            m_originPosition.m_w = m_indexOfOrigin;
            m_currentOrigin.setPosition(m_originPosition);
            m_originList[m_originIndex] = m_currentOrigin;

            // set status on gridlist
            FuelPoint m_newPointOnGrid = m_gridPointList[m_indexOfOrigin];
            m_newPointOnGrid.setToOrigin();
            m_gridPointList[m_indexOfOrigin] = m_newPointOnGrid;
        }
    }

    m_firePathOne->setNewOriginList(m_originList);

}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::adjustOriginAmount ( int  _newAmount)

This method would adjust the amount of fire origin of the whole scene.

Parameters:
_newAmountis the satisfied number of fire origin, which will be assigned by user

Definition at line 2381 of file FireArea.cpp.

References FirePath::assignNewObjMoisture(), FuelPoint::getPosition(), FuelPoint::isFlammable(), m_approxObjMoisture, m_dlaAmount, m_firePathOne, m_gridPointList, m_indexOfOrigin, m_originList, m_originPosition, FirePath::resetFuelListToOriginal(), and FuelPoint::setToOrigin().

{
    m_firePathOne->resetFuelListToOriginal();
    m_firePathOne->assignNewObjMoisture(m_approxObjMoisture);

    m_dlaAmount = _newAmount;
    std::vector<FuelPoint> m_emptyList;
    m_originList = m_emptyList;
    m_originPosition.m_w = m_indexOfOrigin;
    float m_yOrigin = m_originPosition.m_y;
    m_originList.push_back(FuelPoint(m_originPosition, 0));

    FuelPoint m_firstOrg = m_originList[0];
    ngl::Vector m_firstSeedPos = m_firstOrg.getPosition();
    int m_firstIndex = m_firstSeedPos.m_w;

    FuelPoint m_firstSeed = m_gridPointList[m_firstIndex];
    m_firstSeed.setToOrigin();
    m_gridPointList[m_firstIndex] = m_firstSeed;

    // set the closest distance between origin
    float m_minDistance = 5.0;

    if((m_dlaAmount>4)&&(m_dlaAmount<=6))
        m_minDistance = 4.0;
    else if((m_dlaAmount>6)&&(m_dlaAmount<9))
        m_minDistance = 3.0;
    else if(m_dlaAmount>=9)
        m_minDistance = 2.0;

    for(int f=1; f<m_dlaAmount; ++f)
    {
        int m_randNewPoint = 0;
        bool m_farEnough = false;

        while(m_farEnough==false)
        {
            m_randNewPoint = rand()%m_gridPointList.size();
            FuelPoint m_pointOnGrid = m_gridPointList[m_randNewPoint];

            if(m_pointOnGrid.isFlammable()==true)
            {
                ngl::Vector m_posOnGrid = m_pointOnGrid.getPosition();
                int m_tooClosedCount = 0;

                // check with previous origin point
                for(int g=0; g<f; ++g)
                {
                    FuelPoint m_previousOrigin = m_originList[g];
                    ngl::Vector m_previousOriginPos = m_previousOrigin.getPosition();

                    m_previousOriginPos.m_y = 0.0;
                    m_posOnGrid.m_y = 0.0;

                    ngl::Vector m_distanceBetweenOrigin = m_posOnGrid - m_previousOriginPos;
                    float m_distanceBetweenOriginLength = m_distanceBetweenOrigin.length();

                    if(m_distanceBetweenOriginLength<0)
                        m_distanceBetweenOriginLength *= -1;

                    if(m_distanceBetweenOriginLength<m_minDistance)
                        ++m_tooClosedCount;
                }

                if(m_tooClosedCount==0)
                    m_farEnough = true;
                else
                    m_farEnough = false;
            }
            else
                m_farEnough = false;
        } // end while loop

        // ----- assign variables to origin list
        FuelPoint m_newPoint = m_gridPointList[m_randNewPoint];
        ngl::Vector m_newOriginPosition = m_newPoint.getPosition();
        m_newOriginPosition.m_w = m_randNewPoint;
        m_newOriginPosition.m_y = m_yOrigin;

        m_originList.push_back(FuelPoint(m_newOriginPosition, 0));

        FuelPoint m_seed = m_gridPointList[m_randNewPoint];
        m_seed.setToOrigin();
        m_gridPointList[m_randNewPoint] = m_seed;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector< FuelPoint > FireArea::analyzeGridPoint ( std::vector< FuelPoint m_newDLAForm)

This method would return the grid area of current dla form.

Parameters:
m_newDLAFormis the current DLA point list
Returns:
m_takenGridPoint the grid point that would be effected from dla fire path

Definition at line 2338 of file FireArea.cpp.

References FuelPoint::getPosition(), and m_gridPointList.

{
    std::vector<FuelPoint> m_takenGridPointList;

    // ----- analyze grid point
    for(unsigned int y=0; y<m_newDLAForm.size(); ++y)
    {
        FuelPoint m_burningPoint = m_newDLAForm[y];
        ngl::Vector m_burningPointPos = m_burningPoint.getPosition();

        for(unsigned int z=0; z<m_gridPointList.size(); ++z)
        {
            FuelPoint m_scenePoint = m_gridPointList[z];

            ngl::Vector m_scenePointPos = m_scenePoint.getPosition();

            ngl::Vector m_distanceVector = m_scenePointPos - m_burningPointPos;
            float m_burningDistance = m_distanceVector.length();

            if(m_burningDistance<0.4)
            {
                bool m_available = true;
                for(unsigned int j=0; j<m_takenGridPointList.size(); ++j)
                {
                    FuelPoint m_takenPoint = m_takenGridPointList[j];
                    ngl::Vector m_takenPos = m_takenPoint.getPosition();

                    if(m_scenePointPos==m_takenPos)
                        m_available = false;
                }

                if(m_available==true)
                    m_takenGridPointList.push_back(m_scenePoint);
            }
        } // end for grid point list
   } // end for loop of new dla form

   return m_takenGridPointList;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::assignNewMoisture ( double  _newMoisture,
int  _mode 
)

This method would assign the new moisture and temperature of the fire scene.

Parameters:
_newMoistureis the type of adjusting variables that is temperature or moiture value
_modeis the mode of adjusting value that would increase or decrease

Definition at line 121 of file FireArea.cpp.

References FirePath::assignNewMoisture(), FirePath::assignNewTemp(), m_firePathOne, m_sceneMoisture, and m_sceneTemperature.

{
    if(_mode == 1)
    {
        m_firePathOne->assignNewTemp(_newMoisture);
        m_sceneTemperature = _newMoisture;
    }
    else if(_mode == 2)          // moisture
    {
        m_firePathOne->assignNewMoisture(_newMoisture);
        m_sceneMoisture = _newMoisture;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::assignNewObjMoisture ( double  _newMoisture)

This method would assign the new moisture of the fuel object.

Parameters:
_newMoistureis the new moisture of fuel object

Definition at line 2645 of file FireArea.cpp.

References FirePath::assignNewObjMoisture(), m_approxObjMoisture, and m_firePathOne.

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::assignWind ( bool  _mode)

This method would toggle the wind function.

Parameters:
_modeis the flag of wind

Definition at line 2630 of file FireArea.cpp.

References m_addWind, and m_windDirection.

{
    m_addWind = _mode;

    if(m_addWind==false)
    {
        m_windDirection.m_y = 500.0;
    }
    else
    {
        m_windDirection.m_y = 0.0;
    }
}

Here is the caller graph for this function:

void FireArea::assignWindDirection ( ngl::Vector  _windDir)

This method would assign the new wind direction from user.

Parameters:
_windDiris the new wind direction

Definition at line 2564 of file FireArea.cpp.

References m_windDirection.

{
    m_windDirection = _windDir;

    float m_markZ = 0.0;
    float m_markX = 0.0;

    if((m_windDirection.m_x>=0)&&(m_windDirection.m_x<180))
    {
        if((m_windDirection.m_x>=45)&&(m_windDirection.m_x<=135))
        {
            m_markX = 5.0;

            int m_diffZAxis = 90 - m_windDirection.m_x;
            m_markZ = m_diffZAxis * 0.11;
        }
        else if(m_windDirection.m_x<45)
        {
            m_markZ = 5.0;
            int m_diffXAxis = 45 - (45 - m_windDirection.m_x);
            m_markX = m_diffXAxis * 0.11;
        }
        else
        {
            m_markZ = -5.0;
            int m_diffXAxis = 180 - m_windDirection.m_x;
            m_markX = m_diffXAxis * 0.11;
        }

        ngl::Vector m_newWind = ngl::Vector(m_markX, -0.5, m_markZ);
        m_windDirection = m_newWind;
    }
    else
    {
        if((m_windDirection.m_z>=225)&&(m_windDirection.m_z<315))
        {
            m_markX = -5.0;
            int m_diffZAxis = m_windDirection.m_z - 270;
            m_markZ = m_diffZAxis * 0.11;
        }
        else if(m_windDirection.m_z<225)
        {
            m_markZ = -5.0;
            int m_diffXAxis = 180 - m_windDirection.m_x;
            m_markX = m_diffXAxis * 0.11;
        }
        else
        {
            m_markZ = 5.0;
            int m_diffXAxis = m_windDirection.m_x - 360;
            m_markX = m_diffXAxis * 0.11;
        }

        ngl::Vector m_newWind = ngl::Vector(m_markX, -0.5, m_markZ);
        m_windDirection = m_newWind;
    } // end if-else

}

Here is the caller graph for this function:

void FireArea::assignWindSpeed ( int  _newWindSpeed)

This method would assign the new wind speed from user.

Parameters:
_newWindSpeedis the new wind speed

Definition at line 2624 of file FireArea.cpp.

References m_windSpeed.

{
    m_windSpeed = _newWindSpeed;
}

Here is the caller graph for this function:

void FireArea::buildMountain ( )

This method would build the mountain from the specific mountain number and assign the point to be centre of mountain. The size and height of each mountain would random adjusted within the decided maximum value.

Definition at line 491 of file FireArea.cpp.

References adjustMountain(), FuelPoint::getPosition(), m_areaHeight, m_areaWidth, m_displacement, m_gridPointList, m_initPointList, m_mountainNumber, m_terrainCircleSize, and FuelPoint::setToBeMountain().

{
    m_gridPointList = m_initPointList;

    for(int q=0;q<m_mountainNumber;++q)
    {
        int m_firstRandom = rand()%m_areaWidth;
        int m_secondRandom = rand()%(m_areaWidth*m_areaHeight);

        int m_firstIndex = m_firstRandom;
        int m_secondIndex = m_secondRandom;

        int m_selectedIndex = m_firstIndex;

        FuelPoint m_terrainPoint = m_gridPointList[m_firstIndex];
        ngl::Vector m_firstTerrainPos = m_terrainPoint.getPosition();

        m_terrainPoint = m_gridPointList[m_secondIndex];
        ngl::Vector m_secondTerrainPos = m_terrainPoint.getPosition();

        ngl::Vector m_mountainCentre = m_firstTerrainPos;

        // choose the circle centre
        int m_randOne = rand()%2 + 1;
        if(m_randOne==1)
        {
            m_mountainCentre = m_secondTerrainPos;
            m_selectedIndex = m_secondIndex;
        }
        else
            m_terrainPoint = m_gridPointList[m_firstIndex];

        // random circle variables
        int m_maxCircleSize = m_terrainCircleSize*10;
        int m_terrainCircle = rand()%m_maxCircleSize + 10;
        float m_circleSize = (float)m_terrainCircle/10;
        int m_maxDisp = m_displacement*1000;
        int m_randDisp = rand()%m_maxDisp;
        while(m_randDisp<100)
            m_randDisp = rand()%m_maxDisp;
        float m_circleDisp = (float)m_randDisp/1000 ;

        m_terrainPoint.setToBeMountain(m_circleSize, m_circleDisp);
        m_gridPointList[m_selectedIndex] = m_terrainPoint;

    }
    adjustMountain(2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::calculateArea ( )

This method will calculate grid point from the assigned width and height size of fire area.

Definition at line 136 of file FireArea.cpp.

References FuelPoint::changeColour(), getFuelColourInTheArea(), FuelPoint::getPosition(), identifyArea(), m_areaHeight, m_areaWidth, m_gridPointList, m_initPointList, m_pointRadius, FuelPoint::setFuelAmount(), FuelPoint::setPosition(), FuelPoint::setToBeBigFuel(), and FuelPoint::setToBeNonBigFuel().

{
    // starter point
    // divided by 2 for making the first point to be the outermost point at the corner
    // diveded by 10 because the distance between each point is equal to 0.1
    ngl::Vector m_startPoint = ngl::Vector(-m_areaWidth/10, -0.5f, -m_areaHeight/10);
    //ngl::Vector m_startPoint = ngl::Vector(0.0f, -0.5f, 0.0f);

    // grid value in x-axis
    float m_xStartPoint = m_startPoint.m_x;
    // grid value in y-axis
    float m_yStartPoint = m_startPoint.m_y;
    // grid value in z-axis
    float m_zStartPoint = m_startPoint.m_z;

    // expanding point to preferred grid area
    for(int i=0; i<m_areaHeight; ++i)
    {
        for(int j=0; j<m_areaWidth; ++j)
        {
            ngl::Vector m_currentPoint = ngl::Vector(m_xStartPoint,m_yStartPoint,m_zStartPoint);

            int m_fuelArea = identifyArea(m_currentPoint);

            if(m_fuelArea==0)
            {
                ngl::Vector m_currentSlope = m_currentPoint;

                // assign each position to the point list
                m_initPointList.push_back(FuelPoint(m_currentSlope, 0));

                FuelPoint m_current = m_initPointList[(i*m_areaWidth)+j];
                m_current.setToBeNonBigFuel();
                m_initPointList[(i*m_areaWidth)+j] = m_current;
            }
            else if(m_fuelArea==1)
            {
                // assign each position to the point list
                m_initPointList.push_back(FuelPoint(m_currentPoint, 1));

                // set random fuel
                FuelPoint m_current = m_initPointList[(i*m_areaWidth)+j];

                int m_randomFuel = rand()%100 + 50;
                m_current.setFuelAmount(m_randomFuel);
                m_current.setToBeNonBigFuel();

                m_initPointList[(i*m_areaWidth)+j] = m_current;
            }
            else
            {
                // assign each position to the point list
                m_initPointList.push_back(FuelPoint(m_currentPoint, 2));

                ngl::Vector m_fuelAmount = getFuelColourInTheArea(m_currentPoint);

                FuelPoint m_current = m_initPointList[(i*m_areaWidth)+j];

                m_current.setFuelAmount(m_fuelAmount.m_x*100);
                m_current.changeColour(m_fuelAmount);
                m_current.setToBeBigFuel(m_fuelAmount.m_x*100);

                // assign index of obj that would identify this point
                ngl::Vector m_currentPos = m_current.getPosition();
                m_currentPos.m_w = m_fuelArea-2;
                m_current.setPosition(m_currentPos);

                m_initPointList[(i*m_areaWidth)+j] = m_current;
            }

            m_xStartPoint=m_xStartPoint+(m_pointRadius*2);
        }
        m_zStartPoint=m_zStartPoint+(m_pointRadius*2);
        m_xStartPoint=m_startPoint.m_x;
    }
    m_gridPointList = m_initPointList;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::changeIndexOfObj ( int  _newSelectedIndex)

This method would assign the new index of the fuel object that will be adjusted the size.

Parameters:
_newSelectedIndexis the index of fuel object

Definition at line 2484 of file FireArea.cpp.

References m_objIndex.

{
    m_objIndex = _newSelectedIndex;
}

Here is the caller graph for this function:

void FireArea::changeMovingOriginIndex ( int  _currentIndex)

This method would select which origin point would be able to move.

Parameters:
_currentIndexis the index number of selected origin that will be moved, which will be assigned by user

Definition at line 2472 of file FireArea.cpp.

References FuelPoint::getPosition(), m_indexOfOrigin, m_originIndex, and m_originList.

{
    m_originIndex = _currentIndex;

    FuelPoint m_currentMovingOrigin = m_originList[m_originIndex];
    ngl::Vector m_currentMovingOriginPos = m_currentMovingOrigin.getPosition();
    m_indexOfOrigin = m_currentMovingOriginPos.m_w;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::drawArea ( const std::string &  _shaderName,
ngl::TransformStack &  _transformStack 
) const

This method will draw fire area from the calculated object point position list.

Parameters:
&_shaderNamerefers to the shader of point's appearance,
&_transformStackrefers to the transform stack of points

Definition at line 1066 of file FireArea.cpp.

References FirePath::controlFirePathColour(), FuelPoint::getCurrentFuelValue(), FuelPoint::getPosition(), FuelPoint::isFuel(), m_addWind, m_areaHeight, m_areaWidth, m_firePathOne, m_gridPointList, m_indexOfOrigin, m_markShowing, m_originList, m_originPosition, m_pointRadius, m_showPath, m_windDirection, and m_windSpeed.

{
    ngl::ShaderManager *shader=ngl::ShaderManager::instance();
    ngl::VBOPrimitives *prim=ngl::VBOPrimitives::instance();

    // ----- draw wind point
    _transformStack.pushTransform();
    {
        ngl::Vector m_currentWindDirection = m_originPosition;

        if(m_addWind==true)
        {
            ngl::Vector m_newOrigin = m_originPosition;
            ngl::Vector m_originAtCentre = ngl::Vector(0.0,0.0,0.0);

            float m_xDiff = m_newOrigin.m_x - m_originAtCentre.m_x;
            float m_zDiff = m_newOrigin.m_z - m_originAtCentre.m_z;

            ngl::Vector m_adaptedOrigin = m_windDirection;//(m_windDirection*m_windSpeed)/10;
            m_currentWindDirection = ngl::Vector(m_adaptedOrigin.m_x+m_xDiff, m_adaptedOrigin.m_y, m_adaptedOrigin.m_z+m_zDiff);

            float m_windXDiff = m_currentWindDirection.m_x - m_newOrigin.m_x;
            float m_windZDiff = m_currentWindDirection.m_z - m_newOrigin.m_z;

            float m_adjustWindXDiff = (m_windSpeed*m_windXDiff)/10;
            float m_adjustWindZDiff = (m_windSpeed*m_windZDiff)/10;

            m_currentWindDirection = ngl::Vector(m_newOrigin.m_x+m_adjustWindXDiff, m_currentWindDirection.m_y, m_newOrigin.m_z+m_adjustWindZDiff);

           if(m_currentWindDirection.m_x>m_areaWidth/10)
                m_currentWindDirection.m_x = m_areaWidth/10;
            else if(m_currentWindDirection.m_x<-(m_areaWidth/10))
                m_currentWindDirection.m_x = -(m_areaWidth/10);

            if(m_currentWindDirection.m_z>m_areaHeight/10)
                m_currentWindDirection.m_z = m_areaHeight/10;
            else if(m_currentWindDirection.m_z<-(m_areaHeight/10))
                m_currentWindDirection.m_z = -(m_areaHeight/10);
        }

        _transformStack.getCurrentTransform().setPosition(m_currentWindDirection);
        _transformStack.getCurrentTransform().setScale(m_pointRadius,m_pointRadius,m_pointRadius);

        (*shader)[_shaderName]->use();
        shader->setShaderParamFromMatrix(_shaderName,"ModelMatrix",_transformStack.getCurrAndGlobal().getMatrix());
        shader->setShaderParam4f(_shaderName,_shaderName,0.8,0.6,1.0,1.0);

        if(m_addWind==true)
            prim->draw("sphere");

        // ----- draw origin
        if(m_markShowing==true)
        {
            for(unsigned int k=0; k<m_originList.size(); ++k)
            {
                FuelPoint m_originPoint = m_originList[k];
                ngl::Vector m_originPos = m_originPoint.getPosition();
                int m_inOrigin = m_originPos.m_w;

                for(unsigned int j=0; j<m_gridPointList.size(); ++j)
                {
                    FuelPoint m_point = m_gridPointList[j];
                    ngl::Vector m_pointPosition = m_point.getPosition();

                    float m_adjustY = 0.25;

                    if(m_point.isFuel()==true)
                    {
                        float m_objFuel = m_point.getCurrentFuelValue();
                        m_adjustY = m_objFuel/100;
                        m_adjustY *= 0.8;
                        m_adjustY += 0.05;
                    }

                    if(j==(unsigned)m_inOrigin)
                    {
                        ngl::Vector m_colour = ngl::Vector(1.0,1.0,1.0);

                        // assign colour of origin
                        if(j==(unsigned)m_indexOfOrigin)
                        {
                            m_colour = ngl::Vector(1.0,0.7,0.0);
                        }

                        _transformStack.getCurrentTransform().setRotation(90.0,0.0,0.0);
                        _transformStack.getCurrentTransform().setPosition(m_originPos.m_x, m_pointPosition.m_y+m_adjustY-0.01, m_originPos.m_z);
                        (*shader)[_shaderName]->use();
                        shader->setShaderParamFromMatrix(_shaderName,"ModelMatrix",_transformStack.getCurrAndGlobal().getMatrix());
                        shader->setShaderParam4f(_shaderName,_shaderName,m_colour.m_x,m_colour.m_y,m_colour.m_z,1.0);
                        prim->draw("disk");

                        _transformStack.getCurrentTransform().setPosition(m_originPos.m_x, m_pointPosition.m_y+m_adjustY, m_originPos.m_z);
                        _transformStack.getCurrentTransform().setRotation(-270.0,0.0,0.0);
                        _transformStack.getCurrentTransform().setScale(m_pointRadius,m_pointRadius,m_pointRadius);
                        shader->setShaderParamFromMatrix(_shaderName,"ModelMatrix",_transformStack.getCurrAndGlobal().getMatrix());
                        shader->setShaderParam4f(_shaderName,_shaderName,m_colour.m_x,m_colour.m_y,m_colour.m_z,1.0);
                        prim->draw("cone");
                    }
                }
            } // end for loop
        } // end if draw mark is true condition
    }
    _transformStack.popTransform();

    _transformStack.pushTransform();
    {
        if(m_showPath)
        {
            m_firePathOne->controlFirePathColour();
        }
    }
    _transformStack.popTransform();

}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::drawBase ( )

This method would draw base of the scene, including the ground.

Definition at line 2104 of file FireArea.cpp.

References FuelPoint::getPosition(), m_areaHeight, m_areaWidth, m_gridPointList, and m_pointRadius.

{
    // draw terrain base
    for(int a=0; a<m_areaWidth-1; ++a)
    {
        int m_index = m_gridPointList.size() - m_areaWidth;

        FuelPoint m_point = m_gridPointList[m_index+a];
        ngl::Vector m_pointPos = m_point.getPosition();

        ngl::Vector m_basePos = ngl::Vector(-m_areaWidth/10,-1.5,(m_areaHeight/10)-0.2);

        glBegin(GL_QUADS);
            glVertex3f(m_pointPos.m_x, m_pointPos.m_y, m_pointPos.m_z);
            glVertex3f(m_basePos.m_x+(a*(m_pointRadius*2)), m_basePos.m_y, m_basePos.m_z);
            m_point = m_gridPointList[m_index+1+a];
            m_pointPos = m_point.getPosition();
            glVertex3f(m_basePos.m_x+((a+1)*(m_pointRadius*2)), m_basePos.m_y, m_basePos.m_z);
            glVertex3f(m_pointPos.m_x, m_pointPos.m_y, m_pointPos.m_z);
        glEnd();

        m_index = 0;
        m_point = m_gridPointList[m_index+a];
        m_pointPos = m_point.getPosition();
        m_basePos = ngl::Vector(-m_areaWidth/10,-1.5,-m_areaHeight/10);

        glBegin(GL_QUADS);
            glVertex3f(m_pointPos.m_x, m_pointPos.m_y, m_pointPos.m_z);
            glVertex3f(m_basePos.m_x+(a*(m_pointRadius*2)), m_basePos.m_y, m_basePos.m_z);
            m_point = m_gridPointList[m_index+1+a];
            m_pointPos = m_point.getPosition();
            glVertex3f(m_basePos.m_x+((a+1)*(m_pointRadius*2)), m_basePos.m_y, m_basePos.m_z);
            glVertex3f(m_pointPos.m_x, m_pointPos.m_y, m_pointPos.m_z);
        glEnd();
    }

    for(int b=0; b<m_areaHeight-1; ++b)
    {
        int m_index = b*m_areaWidth;

        FuelPoint m_point = m_gridPointList[m_index];
        ngl::Vector m_pointPos = m_point.getPosition();

        ngl::Vector m_basePos = ngl::Vector(-m_areaWidth/10,-1.5,-m_areaHeight/10);

        glBegin(GL_QUADS);
            glVertex3f(m_pointPos.m_x, m_pointPos.m_y, m_pointPos.m_z);
            glVertex3f(m_basePos.m_x, m_basePos.m_y, m_basePos.m_z+(b*(m_pointRadius*2)));
            m_point = m_gridPointList[m_index+m_areaWidth];
            m_pointPos = m_point.getPosition();
            glVertex3f(m_basePos.m_x, m_basePos.m_y, m_basePos.m_z+((b+1)*(m_pointRadius*2)));
            glVertex3f(m_pointPos.m_x, m_pointPos.m_y, m_pointPos.m_z);
        glEnd();

        m_index = m_areaWidth-1 + (b*m_areaWidth);
        m_point = m_gridPointList[m_index];
        m_pointPos = m_point.getPosition();
        m_basePos = ngl::Vector((m_areaWidth/10)-0.2, -1.5, -m_areaHeight/10);

        glBegin(GL_QUADS);
            glVertex3f(m_pointPos.m_x, m_pointPos.m_y, m_pointPos.m_z);
            glVertex3f(m_basePos.m_x, m_basePos.m_y, m_basePos.m_z+(b*(m_pointRadius*2)));
            m_point = m_gridPointList[m_index+m_areaWidth];
            m_pointPos = m_point.getPosition();
            glVertex3f(m_basePos.m_x, m_basePos.m_y, m_basePos.m_z+((b+1)*(m_pointRadius*2)));
            glVertex3f(m_pointPos.m_x, m_pointPos.m_y, m_pointPos.m_z);
        glEnd();
    }

    // draw base
    glBegin(GL_QUADS);

        glVertex3f(-m_areaWidth/10,-1.5,(m_areaHeight/10)-0.2);
        glVertex3f((m_areaWidth/10)-0.2, -1.5,(m_areaHeight/10)-0.2);
        glVertex3f((m_areaWidth/10)-0.2,-1.5,-m_areaHeight/10);
        glVertex3f(-m_areaWidth/10,-1.5,-m_areaHeight/10);

    glEnd();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::drawDLAPath ( )

This method would call the draw path method of DLAStructure class.

void FireArea::drawGrid ( bool  _wireframe)

This method would draw the grid.

Parameters:
_wireframeis the wirefram flag

---------------------------------------------------------------------------------------------------------------------- The following section is modified from :- Jeff Molofee (2000). Flag Effect (Waving Texture) [online]. [Accessed 12 July 2011]. Available from: <http://nehe.gamedev.net/tutorial/flag_effect_%28waving_texture%29/16002/>.

end of Citation ----------------------------------------------------------------------------------------------------------------------

Definition at line 1937 of file FireArea.cpp.

References FuelPoint::getPosition(), m_areaHeight, m_areaWidth, and m_gridPointList.

{
    // ----- Grid drawing
    // horizontal line
    for(int i=0; i<m_areaHeight; ++i)
    {
       for(int j=0; j<m_areaWidth-1; ++j)
       {
           int d = j+(m_areaHeight*i);

           FuelPoint m_gridPoint = m_gridPointList[d];
           ngl::Vector m_pointPosition = m_gridPoint.getPosition();

           glLineWidth(1.0);
           // ----- draw line
           glBegin(GL_LINES);
                glVertex3f(m_pointPosition.m_x, m_pointPosition.m_y-0.02, m_pointPosition.m_z);

                m_gridPoint = m_gridPointList[d+1];
                m_pointPosition = m_gridPoint.getPosition();

                glVertex3f(m_pointPosition.m_x, m_pointPosition.m_y-0.02, m_pointPosition.m_z);
           glEnd();
       }
    }

    // vertical line
    for(int j=0; j<m_areaWidth; ++j)
    {
       for(int i=0; i<m_areaHeight-1; ++i)
       {
           int d = j+(m_areaHeight*i);

           FuelPoint m_gridPoint = m_gridPointList[d];
           ngl::Vector m_pointPosition = m_gridPoint.getPosition();

           // ----- draw line
           glBegin(GL_LINES);
               glVertex3f(m_pointPosition.m_x, m_pointPosition.m_y-0.02, m_pointPosition.m_z);
               d = d + m_areaHeight;
               m_gridPoint = m_gridPointList[d];
               m_pointPosition = m_gridPoint.getPosition();

               glVertex3f(m_pointPosition.m_x, m_pointPosition.m_y-0.02, m_pointPosition.m_z);
           glEnd();
       }
    }

    // diagonal line
    for(int j=0; j<m_areaWidth-1; ++j)
    {
       for(int i=0; i<m_areaHeight-1; ++i)
       {
           int d = j+(m_areaHeight*i);

           FuelPoint m_gridPoint = m_gridPointList[d];
           ngl::Vector m_pointPosition = m_gridPoint.getPosition();

           // ----- draw line
           glBegin(GL_LINES);
               glVertex3f(m_pointPosition.m_x, m_pointPosition.m_y-0.02, m_pointPosition.m_z);
               d = d + m_areaHeight;
               m_gridPoint = m_gridPointList[d+1];
               m_pointPosition = m_gridPoint.getPosition();

               glVertex3f(m_pointPosition.m_x, m_pointPosition.m_y-0.02, m_pointPosition.m_z);
           glEnd();

       }
    }

    // draw boundary
    glBegin(GL_LINES);
        glVertex3f(-m_areaWidth/10,-1.5,(m_areaHeight/10)-0.2);
        glVertex3f((m_areaWidth/10)-0.2, -1.5,(m_areaHeight/10)-0.2);

        glVertex3f((m_areaWidth/10)-0.2,-1.5,-m_areaHeight/10);
        glVertex3f(-m_areaWidth/10,-1.5,-m_areaHeight/10);

        glVertex3f(-m_areaWidth/10,-1.5,-m_areaHeight/10);
        glVertex3f(-m_areaWidth/10,-1.5,(m_areaHeight/10)-0.2);

        glVertex3f((m_areaWidth/10)-0.2, -1.5, -m_areaHeight/10);
        glVertex3f((m_areaWidth/10)-0.2, -1.5, (m_areaHeight/10)-0.2);

        glVertex3f(-m_areaWidth/10,-1.5,-m_areaHeight/10);
        FuelPoint m_gridPoint = m_gridPointList[0];
        ngl::Vector m_gridPos = m_gridPoint.getPosition();
        glVertex3f( m_gridPos.m_x, m_gridPos.m_y, m_gridPos.m_z);

        glVertex3f((m_areaWidth/10)-0.2,-1.5,-m_areaHeight/10);

        m_gridPoint = m_gridPointList[m_areaWidth-1];
        m_gridPos = m_gridPoint.getPosition();
        glVertex3f( m_gridPos.m_x, m_gridPos.m_y, m_gridPos.m_z);
        glVertex3f((m_areaWidth/10)-0.2, -1.5,(m_areaHeight/10)-0.2);

        m_gridPoint = m_gridPointList[m_gridPointList.size()-1];
        m_gridPos = m_gridPoint.getPosition();
        glVertex3f( m_gridPos.m_x, m_gridPos.m_y, m_gridPos.m_z);

        glVertex3f(-m_areaWidth/10,-1.5,(m_areaHeight/10)-0.2);
        m_gridPoint = m_gridPointList[m_gridPointList.size()-m_areaWidth];
        m_gridPos = m_gridPoint.getPosition();
        glVertex3f( m_gridPos.m_x, m_gridPos.m_y, m_gridPos.m_z);

    glEnd();

    float float_x;
    float float_y;
    float float_xb;
    float float_yb;

    if(_wireframe==false)
    {
        glBegin(GL_QUADS);
        for( int x=0; x<m_areaHeight-1; x++ )
        {
                for( int y=0; y<m_areaWidth-1; y++ )
                {
                        float_x = float(x)/m_areaWidth;
                        float_y = float(y)/m_areaHeight;
                        float_xb = float(x+1)/m_areaWidth;
                        float_yb = float(y+1)/m_areaHeight;

                        FuelPoint m_gridPoint = m_gridPointList[y+(x*m_areaWidth)];
                        ngl::Vector m_gridPos = m_gridPoint.getPosition();

                        glTexCoord2f( float_x, float_y);
                        glVertex3f( m_gridPos.m_x, m_gridPos.m_y, m_gridPos.m_z);

                        int m_lowerIndex = y+(x*m_areaWidth)+m_areaWidth;
                        m_gridPoint = m_gridPointList[m_lowerIndex];
                        m_gridPos = m_gridPoint.getPosition();

                        glTexCoord2f( float_x, float_yb );
                        glVertex3f( m_gridPos.m_x, m_gridPos.m_y, m_gridPos.m_z);

                        int m_lowerNextIndex = y+(x*m_areaWidth)+m_areaWidth+1;
                        m_gridPoint = m_gridPointList[m_lowerNextIndex];
                        m_gridPos = m_gridPoint.getPosition();

                        glTexCoord2f( float_xb, float_yb );
                        glVertex3f( m_gridPos.m_x, m_gridPos.m_y, m_gridPos.m_z);

                        int m_nextIndex = y+(x*m_areaWidth)+1;
                        m_gridPoint = m_gridPointList[m_nextIndex];
                        m_gridPos = m_gridPoint.getPosition();

                        glTexCoord2f( float_xb, float_y );
                        glVertex3f( m_gridPos.m_x, m_gridPos.m_y, m_gridPos.m_z);

                }
        }
        glEnd();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::drawRandomobject ( const std::string &  _shaderName,
ngl::TransformStack &  _transformStack 
) const

This method will draw fuel object.

Parameters:
&_shaderNamerefers to the shader of point's appearance,
&_transformStackrefers to the transform stack of points

Definition at line 1185 of file FireArea.cpp.

References FuelPoint::getColour(), FuelObject::getColour(), FirePath::getCurrentFuelList(), FuelPoint::getCurrentFuelValue(), FuelObject::getHeight(), FuelPoint::getMoisture(), FuelPoint::getPosition(), FuelObject::getRadius(), FuelObject::getShape(), FuelPoint::isFuel(), m_currentNonFlammableList, m_firePathOne, m_nonflammableObjectList, m_objHeight, m_objIndex, m_pauseAnimation, m_pointRadius, and m_showPath.

{
    ngl::ShaderManager *shader=ngl::ShaderManager::instance();

    int m_pointRad = m_pointRadius*2*10;

    float m_transparency = 0.6;

    // ----- draw object
    _transformStack.pushTransform();
    {
        for(unsigned int u=0; u<m_nonflammableObjectList.size(); ++u)
        {
            FuelObject m_currentObj = m_nonflammableObjectList[u];
            int m_shapeType = m_currentObj.getShape();

            std::vector<ngl::Vector> m_currentNonFuelList;

            ngl::Vector m_colour = m_currentObj.getColour();

            float m_objHeight = m_currentObj.getHeight()/2;
            m_objHeight -= 0.05;

            if(m_objHeight<=0.001)
                m_objHeight = 0.2;

            (*shader)[_shaderName]->use();
            shader->setShaderParamFromMatrix(_shaderName,"ModelMatrix",_transformStack.getCurrAndGlobal().getMatrix());

            // ----- set colour to each point
            shader->setShaderParam4f(_shaderName,_shaderName,m_colour.m_x,m_colour.m_y,m_colour.m_z,m_transparency);

            for(unsigned int v=0;v<m_currentNonFlammableList.size(); ++v)
            {
                ngl::Vector m_currentPoint = m_currentNonFlammableList[v];
                int m_currentObjIndex = m_currentPoint.m_w;

                if((unsigned)m_currentObjIndex==u)
                {
                    m_currentNonFuelList.push_back(m_currentPoint);
                }
            }

            // find width and height size of each set of obj points
            ngl::Vector m_previousPosition = m_currentNonFuelList[0];
            ngl::Vector m_currentPosition = m_currentNonFuelList[m_currentNonFuelList.size()-1];

            float m_distanceX = (m_previousPosition.m_x - m_currentPosition.m_x)*100;
            float m_distanceZ = (m_previousPosition.m_z - m_currentPosition.m_z)*100;

            m_distanceX = floor(m_distanceX);
            m_distanceZ = floor(m_distanceZ);

            int m_distX = m_distanceX/10;
            int m_distZ = m_distanceZ/10;
            m_distX = abs(m_distX);
            m_distZ = abs(m_distZ);

            // amount of point per column-z and row-x
            m_distX = (m_distX/m_pointRad) + 1;
            m_distZ = (m_distZ/m_pointRad) + 1;

            // square
            if(m_shapeType==2)
            {
                // ----- draw plane for non-fuel object
                for(int m_height = 0; m_height<m_distZ-1; ++m_height)
                {
                    for(int m_width = 0; m_width<m_distX-1; ++m_width)
                    {
                        int m_indexWH = m_width + (m_height*m_distX);
                        ngl::Vector m_posWH = m_currentNonFuelList[m_indexWH];

                        // base
                        glBegin(GL_QUADS);
                            glVertex3f(m_posWH.m_x, m_posWH.m_y-0.05, m_posWH.m_z);

                            m_posWH = m_currentNonFuelList[m_indexWH+1];
                            glVertex3f(m_posWH.m_x, m_posWH.m_y-0.05, m_posWH.m_z);

                            m_posWH = m_currentNonFuelList[m_indexWH+m_distX+1];
                            glVertex3f(m_posWH.m_x, m_posWH.m_y-0.05, m_posWH.m_z);

                            m_posWH = m_currentNonFuelList[m_indexWH+m_distX];
                            glVertex3f(m_posWH.m_x, m_posWH.m_y-0.05, m_posWH.m_z);
                        glEnd();

                        m_posWH = m_currentNonFuelList[m_indexWH];

                        // top
                        glBegin(GL_QUADS);
                            glVertex3f(m_posWH.m_x, m_posWH.m_y+m_objHeight, m_posWH.m_z);

                            m_posWH = m_currentNonFuelList[m_indexWH+1];
                            glVertex3f(m_posWH.m_x, m_posWH.m_y+m_objHeight, m_posWH.m_z);

                            m_posWH = m_currentNonFuelList[m_indexWH+m_distX+1];
                            glVertex3f(m_posWH.m_x, m_posWH.m_y+m_objHeight, m_posWH.m_z);

                            m_posWH = m_currentNonFuelList[m_indexWH+m_distX];
                            glVertex3f(m_posWH.m_x, m_posWH.m_y+m_objHeight, m_posWH.m_z);
                        glEnd();
                    }
                }

                // draw side LR
                for(int m_height = 0; m_height<m_distZ-1; ++m_height)
                {
                    for(int m_width = 0; m_width<m_distX; m_width += m_distX-1)
                    {
                        int m_indexWH = m_width + (m_height*m_distX);
                        ngl::Vector m_posWH = m_currentNonFuelList[m_indexWH];

                        // side
                        glBegin(GL_QUADS);

                            glVertex3f(m_posWH.m_x, m_posWH.m_y+m_objHeight, m_posWH.m_z);

                            m_posWH = m_currentNonFuelList[m_indexWH+m_distX];
                            glVertex3f(m_posWH.m_x, m_posWH.m_y+m_objHeight, m_posWH.m_z);

                            m_posWH = m_currentNonFuelList[m_indexWH+m_distX];
                            glVertex3f(m_posWH.m_x, m_posWH.m_y-0.05, m_posWH.m_z);

                            m_posWH = m_currentNonFuelList[m_indexWH];
                            glVertex3f(m_posWH.m_x, m_posWH.m_y-0.05, m_posWH.m_z);

                        glEnd();
                    }
                }

                // draw side TB
                for(int m_height = 0; m_height<m_distZ; m_height += m_distZ-1)
                {
                    for(int m_width = 0; m_width<m_distX-1; ++m_width)
                    {
                        int m_indexWH = m_width + (m_height*m_distX);
                        ngl::Vector m_posWH = m_currentNonFuelList[m_indexWH];

                        // side
                        glBegin(GL_QUADS);
                            glVertex3f(m_posWH.m_x, m_posWH.m_y+m_objHeight, m_posWH.m_z);

                            m_posWH = m_currentNonFuelList[m_indexWH+1];
                            glVertex3f(m_posWH.m_x, m_posWH.m_y+m_objHeight, m_posWH.m_z);

                            m_posWH = m_currentNonFuelList[m_indexWH+1];
                            glVertex3f(m_posWH.m_x, m_posWH.m_y-0.05, m_posWH.m_z);

                            m_posWH = m_currentNonFuelList[m_indexWH];
                            glVertex3f(m_posWH.m_x, m_posWH.m_y-0.05, m_posWH.m_z);
                        glEnd();
                    }
                }
            } // end if shape = cube condition
        } // end object list for loop
    } // end stack
    _transformStack.popTransform();

    m_transparency = 1.0;

    // ----- draw sphere object
    _transformStack.pushTransform();
    {
        for(unsigned int u=0; u<m_nonflammableObjectList.size(); ++u)
        {
            FuelObject m_currentObj = m_nonflammableObjectList[u];
            int m_shapeType = m_currentObj.getShape();

            std::vector<ngl::Vector> m_currentNonFuelList;

            float m_objHeight = m_currentObj.getHeight()/3;
            float m_objRad = m_currentObj.getRadius()-0.05;

            if(m_objHeight<=0.001)
                m_objHeight = 0.1;

            ngl::Vector m_colour = m_currentObj.getColour();
            m_colour.m_x -= 0.15;
            m_colour.m_y -= 0.15;
            m_colour.m_z -= 0.2;

            ngl::Vector m_colour2 = ngl::Vector(0.45,0.55,1.0);
            //m_colour = m_colour2;
            m_colour2.m_z = m_colour.m_z;

            for(unsigned int v=0;v<m_currentNonFlammableList.size(); ++v)
            {
                ngl::Vector m_currentPoint = m_currentNonFlammableList[v];
                int m_currentObjIndex = m_currentPoint.m_w;

                if((unsigned)m_currentObjIndex==u)
                {
                    m_currentNonFuelList.push_back(m_currentPoint);
                }
            }

            // find width and height size of each set of obj points
            ngl::Vector m_previousPosition = m_currentNonFuelList[0];
            ngl::Vector m_currentPosition = m_currentNonFuelList[m_currentNonFuelList.size()-1];

            float m_distanceX = (m_previousPosition.m_x - m_currentPosition.m_x)*100;
            float m_distanceZ = (m_previousPosition.m_z - m_currentPosition.m_z)*100;
            m_distanceX = floor(m_distanceX);
            m_distanceZ = floor(m_distanceZ);

            int m_distX = m_distanceX/10;
            int m_distZ = m_distanceZ/10;
            m_distX = abs(m_distX);
            m_distZ = abs(m_distZ);

            // amount of point per column-z and row-x
            m_distX = (m_distX/m_pointRad) + 1;
            m_distZ = (m_distZ/m_pointRad) + 1;

            ngl::Vector m_topRight = m_currentNonFuelList[m_distX-1];
            ngl::Vector m_bottomLeft = m_currentNonFuelList[m_currentNonFuelList.size()-m_distX];

            // sphere
            if(m_shapeType==1)
            {
                float m_diffX = m_currentPosition.m_x - m_previousPosition.m_x;
                float m_diffY = m_currentPosition.m_y - m_previousPosition.m_y;
                float m_diffZ = m_currentPosition.m_z - m_previousPosition.m_z;

                if(m_diffX<0)
                    m_diffX *= -1;
                if(m_diffZ<0)
                    m_diffZ *= -1;

                float m_centreX = m_diffX/2;
                float m_centreY = m_diffY/2;
                float m_centreZ = m_diffZ/2;

                ngl::Vector m_adaptedPosition = m_previousPosition;
                m_adaptedPosition.m_x += m_centreX;
                m_adaptedPosition.m_y += m_centreY;
                m_adaptedPosition.m_z += m_centreZ;

                std::vector<ngl::Vector> m_baseCircleList;
                std::vector<ngl::Vector> m_circleList;
                std::vector<ngl::Vector> m_upperCircleList;
                std::vector<ngl::Vector> m_topCircleList;

                int m_highestY = 0;

                if((m_currentPosition.m_y+0.1<m_previousPosition.m_y)&&(m_currentPosition.m_y+0.1<m_topRight.m_y)&&(m_currentPosition.m_y+0.1<m_bottomLeft.m_y))
                {
                    m_highestY = 1;
                }
                else if((m_currentPosition.m_y>m_previousPosition.m_y+0.1)&&(m_currentPosition.m_y>m_topRight.m_y+0.1)&&(m_currentPosition.m_y>m_bottomLeft.m_y+0.1))
                {
                    m_highestY = -1;
                }
                else if((m_topRight.m_y+0.1<m_previousPosition.m_y)&&(m_topRight.m_y+0.1<m_currentPosition.m_y)&&(m_topRight.m_y+0.1<m_bottomLeft.m_y))
                {
                    m_highestY = 2;
                }
                else if((m_topRight.m_y>m_previousPosition.m_y+0.1)&&(m_topRight.m_y>m_currentPosition.m_y+0.1)&&(m_topRight.m_y>m_bottomLeft.m_y+0.1))
                {
                    m_highestY = -2;
                }
                else if((m_bottomLeft.m_y+0.1<m_previousPosition.m_y)&&(m_bottomLeft.m_y+0.1<m_topRight.m_y)&&(m_bottomLeft.m_y+0.1<m_currentPosition.m_y))
                {
                    m_highestY = 3;
                }
                else if((m_bottomLeft.m_y>m_previousPosition.m_y+0.1)&&(m_bottomLeft.m_y>m_topRight.m_y+0.1)&&(m_bottomLeft.m_y>m_currentPosition.m_y+0.1))
                {
                    m_highestY = -3;
                }
                else
                {
                    m_highestY = 0;
                }

                if(m_highestY!=0)
                {
                    m_colour = m_colour2;
                    m_colour.m_z +=0.4;
                    m_colour.m_x +=0.25;
                    m_colour.m_y +=0.25;
                }

                (*shader)[_shaderName]->use();
                shader->setShaderParamFromMatrix(_shaderName,"ModelMatrix",_transformStack.getCurrAndGlobal().getMatrix());

                // ----- set colour to each point
                shader->setShaderParam4f(_shaderName,_shaderName,m_colour.m_x,m_colour.m_y,m_colour.m_z,m_transparency);

                // draw circle on the plane
                m_baseCircleList.push_back(ngl::Vector(m_adaptedPosition.m_x, m_adaptedPosition.m_y, m_adaptedPosition.m_z));

                float m_togglePoint = 0.0;

                for(int i=0; i<360; ++i)
                {
                    float angle = i* 3.14159/180;
                    float m_xCircle = m_adaptedPosition.m_x + sin(angle)*m_objRad;
                    float m_zCircle = m_adaptedPosition.m_z + cos(angle)*m_objRad;

                    ngl::Vector m_newCirclePos = ngl::Vector(m_xCircle, m_adaptedPosition.m_y, m_zCircle);
                    int m_pickedIndex = 0;
                    float m_minD = 1000.0;

                    for(unsigned int b=0; b<m_currentNonFuelList.size(); ++b)
                    {
                        ngl::Vector m_checkedGridPoint = m_currentNonFuelList[b];
                        ngl::Vector m_newCPos = m_newCirclePos;
                        m_newCPos.m_y = 0.0;
                        m_checkedGridPoint.m_y = 0.0;
                        ngl::Vector m_diff = m_checkedGridPoint - m_newCPos;
                        float m_diffLength = m_diff.length();

                        if(m_diffLength<m_minD)
                        {
                            m_minD = m_diffLength;
                            m_pickedIndex = b;
                        }
                    }
                    m_newCirclePos = m_currentNonFuelList[m_pickedIndex];
                    float m_deltaY = m_newCirclePos.m_y - 0.02;
                    if(i>0)
                    {
                        ngl::Vector m_previousCirclePos = m_baseCircleList[i-1];
                        float m_previousY = m_previousCirclePos.m_y;
                        if(m_previousY!=m_deltaY)
                            m_togglePoint += 1.0;
                    }
                    m_baseCircleList.push_back(ngl::Vector(m_xCircle, m_deltaY, m_zCircle,m_togglePoint));
                }

                // apply base circle to the circle with the terrain height added
                ngl::Vector m_tempPos = m_baseCircleList[0];
                m_tempPos = m_baseCircleList[m_baseCircleList.size()-1];
                int m_maxIterations = m_tempPos.m_w;

                for(int d=0; d<m_maxIterations; ++d)
                {
                    std::vector<ngl::Vector> m_tempList;
                    int m_lastIndex = 0;
                    ngl::Vector m_nextStepPos = m_baseCircleList[0];

                    for(unsigned int c=0; c<m_baseCircleList.size(); ++c)
                    {
                        ngl::Vector m_tempCirclePos = m_baseCircleList[c];
                        int m_iterationsNumber = m_tempCirclePos.m_w;

                        if((m_iterationsNumber==d)||(m_iterationsNumber==d+1))
                        {
                            m_tempList.push_back(m_tempCirclePos);
                            m_lastIndex = c;
                        }
                    }

                    if(d!=m_maxIterations-1)
                    {
                        m_nextStepPos = m_baseCircleList[m_lastIndex+1];
                    }

                    if(m_tempList.size()>0)
                    {
                        ngl::Vector m_dCircle = m_tempList[1];
                        float m_deltaBetStep = m_nextStepPos.m_y - m_dCircle.m_y;
                        float m_distStep = m_deltaBetStep/m_tempList.size();

                        // adjust point
                        for(unsigned int e=0; e<m_tempList.size(); ++e)
                        {
                            ngl::Vector m_tCircle = m_tempList[e];
                            m_tCircle.m_y = m_dCircle.m_y+ (e*m_distStep);
                            m_tempList[e] = m_tCircle;
                        }

                        for(unsigned int f=0; f<m_tempList.size(); ++f)
                        {
                            ngl::Vector m_d = m_tempList[f];
                            m_circleList.push_back(m_d);
                        }
                    } // end if templist > 0 condition
                } // end for loop

                // more steps
                if(m_circleList.size()<m_baseCircleList.size())
                {
                    int m_contIndex = m_maxIterations-1;
                    std::vector<ngl::Vector> m_tempList;

                    ngl::Vector m_nextStepPos = m_baseCircleList[m_baseCircleList.size()-1];

                    for(unsigned int n=0; n<m_baseCircleList.size(); ++n)
                    {
                        ngl::Vector m_moreCirclePos = m_baseCircleList[n];
                        int m_lastIterations = m_moreCirclePos.m_w;

                        if((m_lastIterations==m_contIndex)||(m_lastIterations==m_contIndex+1)||(m_lastIterations==m_contIndex+2))
                        {
                           m_tempList.push_back(m_moreCirclePos);
                        }
                    }

                    // find nearest point on the exist circle list
                    float m_closestPos = 1000.0;
                    int m_closestIn = 0;
                    for(unsigned int j=0; j<m_circleList.size(); ++j)
                    {
                        ngl::Vector m_checkPos = m_circleList[j];

                        m_checkPos.m_y = 0.0;
                        m_nextStepPos.m_y = 0.0;

                        ngl::Vector m_diffPos = m_checkPos-m_nextStepPos;
                        float m_distPos = m_diffPos.length();

                        if(m_distPos<m_closestPos)
                        {
                            m_closestPos = m_distPos;
                            m_closestIn = j;
                        }
                    }
                    ngl::Vector m_closestPoint = m_circleList[m_closestIn];

                    // apply nearest point on the exist circle list
                    ngl::Vector m_dCircle = m_tempList[1];
                    float m_deltaBetStep = m_closestPoint.m_y - m_dCircle.m_y;
                    float m_distStep = m_deltaBetStep/m_tempList.size();

                    // adjust point
                    for(unsigned int e=0; e<m_tempList.size(); ++e)
                    {
                        ngl::Vector m_tCircle = m_tempList[e];
                        m_tCircle.m_y = m_dCircle.m_y+ (e*m_distStep);
                        m_tempList[e] = m_tCircle;
                    }

                    for(unsigned int d=0; d<m_tempList.size(); ++d)
                    {
                        ngl::Vector m_d = m_tempList[d];
                        m_circleList.push_back(m_d);
                    }
                }

                m_objHeight = 0.12;

                // base circle
                glBegin(GL_TRIANGLE_FAN);
                    ngl::Vector m_cPos = m_circleList[0];
                    glVertex3f(m_cPos.m_x, m_cPos.m_y, m_cPos.m_z);

                    for(unsigned int z=1; z<m_circleList.size(); ++z)
                    {
                        m_cPos = m_circleList[z];
                        glVertex3f(m_cPos.m_x, m_cPos.m_y, m_cPos.m_z);
                    }

                    m_cPos = m_circleList[1];
                    glVertex3f(m_cPos.m_x, m_cPos.m_y, m_cPos.m_z);
                glEnd();

                // upper circle
                if(m_highestY==0)
                {
                    glBegin(GL_TRIANGLE_FAN);
                    // glBegin(GL_LINE_LOOP);
                        for(unsigned int p=0; p<m_circleList.size(); ++p)
                        {
                            ngl::Vector m_circlePos = m_circleList[p];

                            if(m_highestY==1)
                            {
                                m_circlePos.m_x += m_objHeight;
                                m_circlePos.m_y += m_objHeight;
                                m_circlePos.m_z += m_objHeight;
                            }
                            else if(m_highestY==-1)
                            {
                                m_circlePos.m_x -= m_objHeight;
                                m_circlePos.m_y += m_objHeight;
                                m_circlePos.m_z -= m_objHeight;
                            }
                            else if(m_highestY==2)
                            {
                                m_circlePos.m_x += m_objHeight;
                                m_circlePos.m_y += m_objHeight;
                                m_circlePos.m_z -= m_objHeight;
                            }
                            else if(m_highestY==-2)
                            {
                                m_circlePos.m_x -= m_objHeight;
                                m_circlePos.m_y += m_objHeight;
                                m_circlePos.m_z += m_objHeight;
                            }
                            else if(m_highestY==3)
                            {
                                m_circlePos.m_x -= m_objHeight;
                                m_circlePos.m_y += m_objHeight;
                                m_circlePos.m_z += m_objHeight;
                            }
                            else if(m_highestY==-3)
                            {
                                m_circlePos.m_x += m_objHeight;
                                m_circlePos.m_y += m_objHeight;
                                m_circlePos.m_z -= m_objHeight;
                            }
                            else
                            {
                                m_circlePos.m_y += m_objHeight;
                            }

                            glVertex3f(m_circlePos.m_x, m_circlePos.m_y, m_circlePos.m_z);

                            m_upperCircleList.push_back(m_circlePos);
                        } // end for loop

                        ngl::Vector m_circle2Init = m_upperCircleList[1];
                        glVertex3f(m_circle2Init.m_x, m_circle2Init.m_y, m_circle2Init.m_z);

                    glEnd();
                }
                else
                {
                    m_upperCircleList = m_circleList;
                }

                // ----- set colour to each point
                if(m_highestY!=0)
                {
                    ngl::Vector m_colour3 = m_colour2;
                    m_colour3.m_z +=0.4;
                    m_colour3.m_x +=0.25;
                    m_colour3.m_y +=0.25;
                    m_colour2 = m_colour3;
                }

                shader->setShaderParam4f(_shaderName,_shaderName,m_colour2.m_x,m_colour2.m_y,m_colour2.m_z,m_transparency);
                m_objHeight = 0.03;

                // ----- lift up the base sphere
                m_topCircleList = m_upperCircleList;
                float m_maxY = -10000.0;
                int m_highestPointIndex = 0;

                // ----- find highest Y pos
                for(unsigned int r=0; r<m_upperCircleList.size(); ++r)
                {
                    ngl::Vector m_highestPoint = m_upperCircleList[r];
                    float m_tempHighestY = m_highestPoint.m_y;

                    if(m_tempHighestY>m_maxY)
                    {
                        m_maxY = m_tempHighestY;
                        m_highestPointIndex = r;
                    }
                }
                ngl::Vector m_highestBase = m_upperCircleList[m_highestPointIndex];

                for(unsigned int q=0; q<m_topCircleList.size(); ++q)
                {
                    ngl::Vector m_liftUpPos = m_topCircleList[q];
                    m_liftUpPos.m_y = m_highestBase.m_y + m_objHeight;
                    m_topCircleList[q] = m_liftUpPos;
                }

                // upper circle (top)
                glBegin(GL_TRIANGLE_FAN);
                    ngl::Vector m_ePos = m_topCircleList[0];
                    glVertex3f(m_ePos.m_x, m_ePos.m_y, m_ePos.m_z);

                    for(unsigned int z=1; z<m_topCircleList.size(); ++z)
                    {
                        m_ePos = m_topCircleList[z];
                        glVertex3f(m_ePos.m_x, m_ePos.m_y, m_ePos.m_z);
                    }

                    m_ePos = m_topCircleList[1];
                    glVertex3f(m_ePos.m_x, m_ePos.m_y, m_ePos.m_z);
                glEnd();

                glBegin(GL_QUADS);
                    for(unsigned int m=0; m<m_upperCircleList.size()-1; ++m)
                    {
                        ngl::Vector m_circlePosG = m_upperCircleList[m];
                        glVertex3f(m_circlePosG.m_x, m_circlePosG.m_y, m_circlePosG.m_z);

                        ngl::Vector m_circlePosT = m_topCircleList[m];
                        glVertex3f(m_circlePosT.m_x, m_circlePosT.m_y, m_circlePosT.m_z);

                        m_circlePosT = m_topCircleList[m+1];
                        glVertex3f(m_circlePosT.m_x, m_circlePosT.m_y, m_circlePosT.m_z);

                        m_circlePosG = m_upperCircleList[m+1];
                        glVertex3f(m_circlePosG.m_x, m_circlePosG.m_y, m_circlePosG.m_z);
                    }
                glEnd();

                // ----- set colour to each point
                shader->setShaderParam4f(_shaderName,_shaderName,m_colour.m_x,m_colour.m_y,m_colour.m_z,m_transparency);

                glBegin(GL_QUADS);
                    for(unsigned int m=0; m<m_circleList.size()-1; ++m)
                    {
                        ngl::Vector m_circlePosG = m_circleList[m];
                        glVertex3f(m_circlePosG.m_x, m_circlePosG.m_y, m_circlePosG.m_z);

                        ngl::Vector m_circlePosT = m_upperCircleList[m];
                        glVertex3f(m_circlePosT.m_x, m_circlePosT.m_y, m_circlePosT.m_z);

                        m_circlePosT = m_upperCircleList[m+1];
                        glVertex3f(m_circlePosT.m_x, m_circlePosT.m_y, m_circlePosT.m_z);

                        m_circlePosG = m_circleList[m+1];
                        glVertex3f(m_circlePosG.m_x, m_circlePosG.m_y, m_circlePosG.m_z);
                    }
                glEnd();

            } // end if object is sphere
        } // end object list for loop

    } // end stack
    _transformStack.popTransform();

    // ------------------------------------------------------- Fuel Object -------------------------------------------------------
    // ----- draw sphere object
    m_transparency = 1.0;

    ngl::VBOPrimitives *prim=ngl::VBOPrimitives::instance();

    std::vector<FuelPoint> m_gridList = m_firePathOne->getCurrentFuelList();

    _transformStack.pushTransform();
    {
        for(unsigned int u=0; u<m_gridList.size(); ++u)
        {
            FuelPoint m_currentPoint = m_gridList[u];
            ngl::Vector m_pointPosition = m_currentPoint.getPosition();

            float m_currentObjHeight = m_currentPoint.getCurrentFuelValue();
            m_currentObjHeight = (m_currentObjHeight*2)/100;

            float m_objRad =  m_pointRadius*3;

            float m_transObj = m_currentPoint.getMoisture();

            if(m_currentPoint.isFuel()==true)
            {
                ngl::Vector m_colourObj = m_currentPoint.getColour();

                ngl::Vector m_colour = m_colourObj;
                m_colour.m_x = m_colourObj.m_x+0.1;
                m_colour.m_y = m_colourObj.m_y+0.5;
                m_colour.m_z = m_colourObj.m_z+0.1;

                // change the colour
                //m_colourObj = ngl::Vector(1.0,0.95,0.0);

                if((m_pauseAnimation==true)&&(m_showPath==false))
                {
                    if(m_objIndex==m_pointPosition.m_w)
                     {
                         m_colourObj = ngl::Vector(1.0,0.95,0.0);
                     }
                }

                _transformStack.getCurrentTransform().setPosition(m_pointPosition);
                _transformStack.getCurrentTransform().setRotation(-90,0,0);
                _transformStack.getCurrentTransform().setScale(m_objRad,m_currentObjHeight,m_objRad);

                (*shader)[_shaderName]->use();
                shader->setShaderParamFromMatrix(_shaderName,"ModelMatrix",_transformStack.getCurrAndGlobal().getMatrix());

                // ----- set colour to each point
                shader->setShaderParam4f(_shaderName,_shaderName,m_colourObj.m_x,m_colourObj.m_y,m_colourObj.m_z,m_transObj);

                prim->draw("cylinder");
                prim->draw("disk");

                float m_thisHeight = m_currentObjHeight * m_objHeight;

                _transformStack.getCurrentTransform().setPosition(m_pointPosition.m_x, m_pointPosition.m_y+m_thisHeight, m_pointPosition.m_z);
                shader->setShaderParamFromMatrix(_shaderName,"ModelMatrix",_transformStack.getCurrAndGlobal().getMatrix());

                // ----- set colour to each point
                shader->setShaderParam4f(_shaderName,_shaderName,m_colourObj.m_x,m_colourObj.m_y,m_colourObj.m_z,m_transparency);
                prim->draw("disk");

            } // end object list for loop
        }

    } // end stack
    _transformStack.popTransform();

    // top
     _transformStack.pushTransform();
     {
         for(unsigned int u=0; u<m_gridList.size(); ++u)
         {
             FuelPoint m_currentPoint = m_gridList[u];
             ngl::Vector m_pointPosition = m_currentPoint.getPosition();

             float m_currentObjHeight = m_currentPoint.getCurrentFuelValue();
             m_currentObjHeight = (m_currentObjHeight*2)/100;

             float m_objRad =  m_pointRadius*3;

             if(m_currentPoint.isFuel()==true)
             {
                 ngl::Vector m_colourObj = m_currentPoint.getColour();

                 ngl::Vector m_colour = m_colourObj;
                 m_colour.m_x = m_colourObj.m_x+0.1;
                 m_colour.m_y = m_colourObj.m_y+0.5;
                 m_colour.m_z = m_colourObj.m_z+0.1;

                 if((m_pauseAnimation==true)&&(m_showPath==false))
                 {
                     if(m_objIndex==m_pointPosition.m_w)
                         m_colourObj = ngl::Vector(1.0,1.0,0.0);
                 }

                // _transformStack.getCurrentTransform().setPosition(m_pointPosition);
                 _transformStack.getCurrentTransform().setRotation(-90,0,0);
                // _transformStack.getCurrentTransform().setScale(m_objRad,m_currentObjHeight,m_objRad);

                 float m_thisHeight = m_currentObjHeight * m_objHeight;

                 _transformStack.getCurrentTransform().setPosition(m_pointPosition.m_x, m_pointPosition.m_y+m_thisHeight, m_pointPosition.m_z);
                 _transformStack.getCurrentTransform().setScale(m_objRad,0.6,m_objRad);

                 // ----- set colour to each point
                 (*shader)[_shaderName]->use();
                 shader->setShaderParamFromMatrix(_shaderName,"ModelMatrix",_transformStack.getCurrAndGlobal().getMatrix());
                 shader->setShaderParam4f(_shaderName,_shaderName,m_colourObj.m_x,m_colourObj.m_y,m_colourObj.m_z,m_transparency);
                 prim->draw("disk");

                 prim->draw("cylinder");

                 _transformStack.getCurrentTransform().setPosition(m_pointPosition.m_x, m_pointPosition.m_y+m_thisHeight+0.1, m_pointPosition.m_z);

                 shader->setShaderParamFromMatrix(_shaderName,"ModelMatrix",_transformStack.getCurrAndGlobal().getMatrix());
                 shader->setShaderParam4f(_shaderName,_shaderName,m_colourObj.m_x,m_colourObj.m_y,m_colourObj.m_z,m_transparency);
                 prim->draw("disk");
             } // end object list for loop
         }

     } // end stack
     _transformStack.popTransform();

}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::generateNewDLA ( )

This method would be called when the new scene is edited and the generate button is clicked for creating the fire path.

Definition at line 2220 of file FireArea.cpp.

References analyzeGridPoint(), FirePath::assignNewMoisture(), FirePath::assignNewObjMoisture(), FirePath::assignNewTemp(), DLAStructure::getDLALine(), DLAStructure::getDLAList(), FuelPoint::getPosition(), m_addWind, m_approxDLASize, m_approxObjMoisture, m_areaHeight, m_areaWidth, m_currentDLALine, m_currentDLAList, m_dlaAmount, m_dlaStructureOne, m_firePathOne, m_gridPointList, m_nonflammableObjectList, m_originList, m_pauseAnimation, m_pointRadius, m_sceneMoisture, m_sceneTemperature, m_showPath, m_timeStep, m_windDirection, m_windSpeed, FirePath::pauseTheAnimation(), FirePath::resetGrid(), FuelPoint::setEmittedHeat(), FirePath::setFirePath(), FirePath::setNewOriginList(), FuelPoint::setPosition(), and FirePath::updateDLAList().

{
    FuelPoint m_firstOrigin = m_originList[0];
    ngl::Vector m_firstOriginPos = m_firstOrigin.getPosition();

    std::vector<FuelPoint> m_emptyList;
    m_currentDLAList = m_emptyList;
    m_currentDLALine = m_emptyList;

    if(m_dlaAmount<=1)
    {
        m_approxDLASize = 3000;

        if(m_addWind==true)
        {
            if(m_windSpeed<5)
                m_approxDLASize = 2200;
            else if((m_windSpeed>=5)&&(m_windSpeed<=7))
                m_approxDLASize = 2000;
            else if((m_windSpeed>7)&&(m_windSpeed<10))
                m_approxDLASize = 1800;
            else if(m_windSpeed==10)
                m_approxDLASize = 1500;
        }

        m_dlaStructureOne = new DLAStructure(m_gridPointList, m_nonflammableObjectList, m_firstOriginPos, m_areaWidth, m_areaHeight, m_pointRadius, m_approxDLASize, m_windDirection, m_windSpeed);

        m_currentDLAList = m_dlaStructureOne->getDLAList();
        m_currentDLALine = m_dlaStructureOne->getDLALine();

        m_firstOrigin.setEmittedHeat(m_currentDLAList.size());
        m_originList[0] = m_firstOrigin;

        m_firePathOne->updateDLAList(m_currentDLAList, m_currentDLALine);
        m_firePathOne->resetGrid(m_gridPointList);
        m_firePathOne->setFirePath();
        m_firePathOne->setNewOriginList(m_originList);
        m_firePathOne->assignNewMoisture(m_sceneMoisture);
        m_firePathOne->assignNewTemp(m_sceneTemperature);
        m_firePathOne->assignNewObjMoisture(m_approxObjMoisture);
    }
    else
    {
        if(m_dlaAmount<3)
            m_approxDLASize = 1500;//1300;
        else if(m_dlaAmount==3)
            m_approxDLASize = 1100;//800;
        else if(m_dlaAmount==4)
            m_approxDLASize = 900;// 600;
        else if(m_dlaAmount==5)
            m_approxDLASize = 700;//450;

        if(m_addWind==true)
            m_approxDLASize -= 200;

        for(unsigned int k=0; k<m_originList.size(); ++k)
        {
            FuelPoint m_originPoint = m_originList[k];
            ngl::Vector m_originPos = m_originPoint.getPosition();

            std::vector<FuelPoint> m_previousGridList;

            if(k>0)
            {
                m_previousGridList = analyzeGridPoint(m_currentDLAList);
            }

            m_dlaStructureOne = new DLAStructure(m_gridPointList, m_nonflammableObjectList, m_originPos, m_areaWidth, m_areaHeight, m_pointRadius, m_previousGridList, m_originList, k, m_approxDLASize, m_windDirection, m_windSpeed);

            std::vector<FuelPoint> m_newDLAPointList = m_dlaStructureOne->getDLAList();
            std::vector<FuelPoint> m_newDLAPointLine = m_dlaStructureOne->getDLALine();

            for(unsigned int h=0; h<m_newDLAPointList.size(); ++h)
            {
                FuelPoint m_newDLAPoint = m_newDLAPointList[h];

                // assign the number of origin to know which origin this form belong to
                ngl::Vector m_newDLAPos = m_newDLAPoint.getPosition();
                m_newDLAPos.m_w = k;

                m_newDLAPoint.setPosition(m_newDLAPos);

                m_currentDLAList.push_back(m_newDLAPoint);
            }

            for(unsigned int g=0; g<m_newDLAPointLine.size(); ++g)
            {
                FuelPoint m_newDLALine = m_newDLAPointLine[g];

                // assign the number of origin to know which origin this form belong to
                ngl::Vector m_newDLALinePos = m_newDLALine.getPosition();
                m_newDLALinePos.m_w = g;

                m_newDLALine.setPosition(m_newDLALinePos);

                m_currentDLALine.push_back(m_newDLALine);
            }

            m_originPoint.setEmittedHeat(m_newDLAPointList.size());
            m_originList[k] = m_originPoint;
        } // end for loop

        m_firePathOne->updateDLAList(m_currentDLAList, m_currentDLALine);
        m_firePathOne->resetGrid(m_gridPointList);
        m_firePathOne->setFirePath();
        m_firePathOne->setNewOriginList(m_originList);
        m_firePathOne->assignNewMoisture(m_sceneMoisture);
        m_firePathOne->assignNewTemp(m_sceneTemperature);
        m_firePathOne->assignNewObjMoisture(m_approxObjMoisture);
    }

    m_pauseAnimation = false;
    m_showPath = true;
    m_timeStep = 0;
    m_firePathOne->pauseTheAnimation(false);
}

Here is the call graph for this function:

Here is the caller graph for this function:

ngl::Vector FireArea::getFuelColourInTheArea ( ngl::Vector  m_checkingArea)

This method would return the colour of point that is located in the fire area.

Parameters:
m_checkingAreais the fire area
Returns:
m_fuelColour is the colour of current fuel object

Definition at line 378 of file FireArea.cpp.

References FuelObject::getColour(), FuelObject::getPosition(), FuelObject::getRadius(), and m_flammableObjectList.

{
    ngl::Vector m_objFuel = ngl::Vector(0.0,1.0,0.0);

    for(unsigned int q=0; q<m_flammableObjectList.size(); ++q)
    {
        FuelObject m_fuelObject = m_flammableObjectList[q];
        ngl::Vector m_fuelObjectPos = m_fuelObject.getPosition();

        ngl::Vector m_distance = m_fuelObjectPos - m_checkingArea;
        float m_distanceLength = m_distance.length();
        float m_fuelObjectRadius = m_fuelObject.getRadius();

        if(m_distanceLength<0)
            m_distanceLength *= -1;

        if((m_fuelObjectPos.m_x>=m_checkingArea.m_x-m_fuelObjectRadius) && (m_fuelObjectPos.m_x<=m_checkingArea.m_x+m_fuelObjectRadius))
        {
            if((m_fuelObjectPos.m_z>=m_checkingArea.m_z-m_fuelObjectRadius) && (m_fuelObjectPos.m_z<=m_checkingArea.m_z+m_fuelObjectRadius))
            {
                m_objFuel = m_fuelObject.getColour();
            }
        }
    }
    return m_objFuel;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int FireArea::identifyArea ( ngl::Vector  m_checkingArea)

This method would find the place on fire area to specify as non-flammable area. Thus, fire path would not go thrugh this part.

Parameters:
m_checkingAreais current point on fire area that wants to be checked

Definition at line 615 of file FireArea.cpp.

References FuelObject::getPosition(), FuelObject::getRadius(), m_currentFlammableList, m_currentNonFlammableList, m_flammableObjectList, and m_nonflammableObjectList.

{
    int m_fuelArea = 1;

    // ----- fuel object
    for(unsigned int k=0; k<m_flammableObjectList.size(); ++k)
    {
        FuelObject m_objectArea = m_flammableObjectList[k];
        ngl::Vector m_area = m_objectArea.getPosition();

        // plus 0.05 for the over range area, thus, the fire path would not go into the object
        float m_objectRadius = m_objectArea.getRadius();

        if((m_area.m_x>=m_checkingArea.m_x-m_objectRadius) && (m_area.m_x<=m_checkingArea.m_x+m_objectRadius))
        {
            if((m_area.m_z>=m_checkingArea.m_z-m_objectRadius) && (m_area.m_z<=m_checkingArea.m_z+m_objectRadius))
            {
                m_fuelArea = k+2;
                m_checkingArea.m_w = k;
                m_currentFlammableList.push_back(m_checkingArea);
            }
        }
    }

    // ----- non-flammable object
    for(unsigned int k=0; k<m_nonflammableObjectList.size(); ++k)
    {
        FuelObject m_objectArea = m_nonflammableObjectList[k];
        ngl::Vector m_area = m_objectArea.getPosition();

        // plus 0.05 for the over range area, thus, the fire path would not go into the object
        float m_objectRadius = m_objectArea.getRadius() + 0.05;

        if((m_area.m_x>=m_checkingArea.m_x-m_objectRadius) && (m_area.m_x<=m_checkingArea.m_x+m_objectRadius))
        {
            if((m_area.m_z>=m_checkingArea.m_z-m_objectRadius) && (m_area.m_z<=m_checkingArea.m_z+m_objectRadius))
            {
                m_fuelArea = 0;
                m_checkingArea.m_w = k;
                m_currentNonFlammableList.push_back(m_checkingArea);
            }
        }
    }

    return m_fuelArea;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::pauseTime ( bool  _pauseStatus,
bool  _editFlag 
)

This method would pause the animation of fire path.

Parameters:
_pauseStatusis the flag of pausing animation. It would toggle between play and pause animation.
_editFlagis the flag of editing mode. If the method is called with editing method, the animation would be paused and animation could not be played again.

Definition at line 2202 of file FireArea.cpp.

References m_firePathOne, m_pauseAnimation, m_showPath, FirePath::pauseTheAnimation(), FirePath::resetFuelListToOriginal(), and FirePath::resetList().

{
    m_pauseAnimation = _pauseStatus;
    m_firePathOne->pauseTheAnimation(m_pauseAnimation);

    if(_editFlag)
    {
        std::cout<<"----------------------------------------------------------------------------------------------------------------------"<<std::endl;
        m_showPath = false;
        m_firePathOne->resetList();
        m_firePathOne->resetFuelListToOriginal();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::pickFlammableObjectPosition ( int  m_amountobject)

This method would randomly assign the fuel object's position.

Parameters:
m_amountObjectis the required amount of fuel

Definition at line 751 of file FireArea.cpp.

References FuelObject::getPosition(), m_areaHeight, m_areaWidth, m_currentFlammableList, m_flammableObjectList, m_nonflammableObjectList, m_objRadius, FuelObject::setFuelAmount(), FuelObject::setHeight(), and FuelObject::setRadius().

{
    std::vector<FuelObject> m_zeroList;
    m_flammableObjectList = m_zeroList;

    std::vector<ngl::Vector> m_zeroPos;
    m_currentFlammableList = m_zeroPos;

    for(int m=0; m<m_amountobject; ++m)
    {
        int m_objR = m_objRadius*10;

        float m_xValue = rand()% (m_areaWidth-(m_objR*2)) + (m_objR);
        float m_yValue = 0.0;
        float m_zValue = rand()% (m_areaHeight-(m_objR*2)) + (m_objR);

        int m_randomXsign = rand()%2 +1;
        int m_randomZsign = rand()%2 +1;

        if(m_randomXsign == 2)
            m_xValue *= -1;

        if(m_randomZsign == 2)
            m_zValue *= -1;

        int m_randomRadiusRatio = rand()%10 + 5;
        float m_randomRadius = (m_randomRadiusRatio*10)*m_objRadius;

        ngl::Vector m_randomPosition = ngl::Vector(m_xValue/10, m_yValue, m_zValue/10, m_randomRadius/75);

        bool m_finePos = false;

        // ----- check collision with other object
        while(m_finePos==false)
        {
            int m_tooCloseCount = 0;

            for(unsigned int n=0; n<m_nonflammableObjectList.size(); ++n)
            {
                FuelObject m_nonFlammableObj = m_nonflammableObjectList[n];
                ngl::Vector m_nonFlammableObjPos = m_nonFlammableObj.getPosition();

                float m_nonFlammableFuel = m_nonFlammableObjPos.m_w;

                ngl::Vector m_distance = m_nonFlammableObjPos - m_randomPosition;
                float m_distanceLength = m_distance.length();

                if(m_distanceLength<0)
                    m_distanceLength *= -1;

                float m_acceptableDistance = m_nonFlammableFuel + m_randomRadius/75 + m_objRadius;

                if(m_distanceLength<m_acceptableDistance)
                    ++m_tooCloseCount;
            }

            for(unsigned int p=0; p<m_flammableObjectList.size(); ++p)
            {
                FuelObject m_flammableObj = m_flammableObjectList[p];
                ngl::Vector m_flammableObjPos = m_flammableObj.getPosition();

                ngl::Vector m_distanceFuel = m_flammableObjPos - m_randomPosition;
                float m_distanceFuelLength = m_distanceFuel.length();

                if(m_distanceFuelLength<0)
                    m_distanceFuelLength *= -1;

                float m_minDistance = m_flammableObjPos.m_w + m_randomPosition.m_w;

                if(m_distanceFuelLength<m_minDistance)
                    ++m_tooCloseCount;
            }

            if(m_tooCloseCount>0)
            {
                m_finePos = false;
                m_xValue = rand()% (m_areaWidth-(m_objR*2)) + (m_objR);
                m_yValue = 0.0;
                m_zValue = rand()% (m_areaHeight-(m_objR*2)) + (m_objR);

                m_randomXsign = rand()%2 +1;
                m_randomZsign = rand()%2 +1;

                if(m_randomXsign == 2)
                    m_xValue *= -1;

                if(m_randomZsign == 2)
                    m_zValue *= -1;

                m_randomPosition = ngl::Vector(m_xValue/10, m_yValue, m_zValue/10, m_randomRadius/75);
            }
            else
            {
                m_finePos = true;
            }
        } // end while loop

        m_flammableObjectList.push_back(FuelObject(m_randomPosition, 1, 1));

    }

    // assign fuel amount, radius, height and colour
    for(unsigned int f=0; f<m_flammableObjectList.size(); ++f)
    {
        FuelObject m_point = m_flammableObjectList[f];

        ngl::Vector m_pointPos = m_point.getPosition();

        int m_randomFuel = rand()%100 + 50;
        m_point.setFuelAmount(m_randomFuel);

        float m_randomHeight = (m_randomFuel*2)/100;

        m_point.setRadius(m_pointPos.m_w);
        m_point.setHeight(m_randomHeight);

        m_flammableObjectList[f] = m_point;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::pickObjectPosition ( int  m_amountobject)

This method would randomly assign the non-flammable object's position and shape.

Parameters:
m_amountObjectis the required amount of fuel

Definition at line 874 of file FireArea.cpp.

References FuelObject::getPosition(), FuelPoint::getPosition(), FuelObject::getShape(), m_areaHeight, m_areaWidth, m_currentNonFlammableList, m_flammableObjectList, m_nonflammableObjectList, m_objRadius, m_originList, FuelObject::setHeight(), and FuelObject::setRadius().

{
    std::vector<FuelObject> m_zeroList;
    m_nonflammableObjectList = m_zeroList;

    std::vector<ngl::Vector> m_zeroPos;
    m_currentNonFlammableList = m_zeroPos;

    for(int a=0; a<m_amountobject; ++a)
    {
        int m_objR = m_objRadius*10;

        float m_xValue = rand()% (m_areaWidth-(m_objR*2)) + (m_objR);
        float m_yValue = 0.0;
        float m_zValue = rand()% (m_areaHeight-(m_objR*2)) + (m_objR);

        int m_randomXsign = rand()%2 +1;
        int m_randomZsign = rand()%2 +1;

        if(m_randomXsign == 2)
            m_xValue *= -1;

        if(m_randomZsign == 2)
            m_zValue *= -1;

        int m_randomRadiusRatio = rand()%10 + 9;
        float m_randomRadius = (m_randomRadiusRatio*10)*m_objRadius;

        ngl::Vector m_randomPosition = ngl::Vector(m_xValue/10, m_yValue, m_zValue/10, m_randomRadius/100);

        // check collision with origin point
        for(unsigned int d=0; d<m_originList.size(); ++d)
        {
            FuelPoint m_checkOrigin = m_originList[d];
            ngl::Vector m_checkingPos = m_checkOrigin.getPosition();
            ngl::Vector m_deltaOrigin = m_randomPosition - m_checkingPos;
            float m_distOrigin = m_deltaOrigin.length();

            while(m_distOrigin<1)
            {
                m_xValue = rand()% (m_areaWidth-(m_objR*2)) + (m_objR);
                m_zValue = rand()% (m_areaHeight-(m_objR*2)) + (m_objR);
                m_randomXsign = rand()%2 +1;
                m_randomZsign = rand()%2 +1;

                if(m_randomXsign == 2)
                    m_xValue *= -1;

                if(m_randomZsign == 2)
                    m_zValue *= -1;

                m_randomPosition = ngl::Vector(m_xValue/10, m_yValue, m_zValue/10, m_objRadius);

                m_deltaOrigin = m_randomPosition - m_checkingPos;
                m_distOrigin = m_deltaOrigin.length();

                d=0;
            }
        }

        // check collision with other object
        if(a>0)
        {
            bool m_putIn = false;

            while(m_putIn==false)
            {
                int m_hitCount = 0;

                for(unsigned int k=1; k<=m_nonflammableObjectList.size(); ++k)
                {
                    FuelObject m_previousObject = m_nonflammableObjectList[k-1];
                    ngl::Vector m_previousPosition = m_previousObject.getPosition();

                    ngl::Vector m_delta = m_previousPosition - m_randomPosition;
                    float m_distance = m_delta.length();

                    float m_previousRadius = m_previousPosition.m_w;
                    float m_radiusPoint = m_previousRadius + m_randomPosition.m_w;

                    // if the distance is less than radius of object, it means it's collision
                    if(m_distance<m_radiusPoint*2 || m_distance<m_objRadius*2)
                    {
                        ++m_hitCount;
                        m_putIn = false;
                    }
                }

                for(unsigned int l=1; l<=m_flammableObjectList.size(); ++l)
                {
                    FuelObject m_previousObject = m_flammableObjectList[l-1];
                    ngl::Vector m_previousPosition = m_previousObject.getPosition();

                    ngl::Vector m_delta = m_previousPosition - m_randomPosition;
                    float m_distance = m_delta.length();

                    float m_previousRadius = m_previousPosition.m_w;
                    float m_radiusPoint = m_previousRadius + m_randomPosition.m_w;

                    // if the distance is less than radius of object, it means it's collision
                    if(m_distance<m_radiusPoint*2 || m_distance<m_objRadius*2)
                    {
                        ++m_hitCount;
                        m_putIn = false;
                    }
                }

                if(m_hitCount>0)
                {
                    m_xValue = rand()% (m_areaWidth-(m_objR*2)) + (m_objR);
                    m_zValue = rand()% (m_areaHeight-(m_objR*2)) + (m_objR);
                    m_randomXsign = rand()%2 +1;
                    m_randomZsign = rand()%2 +1;

                    if(m_randomXsign == 2)
                        m_xValue *= -1;

                    if(m_randomZsign == 2)
                        m_zValue *= -1;

                    m_randomPosition = ngl::Vector(m_xValue/10, m_yValue, m_zValue/10, m_objRadius+0.05);

                    // check collision with origin point
                    for(unsigned int d=0; d<m_originList.size(); ++d)
                    {
                        FuelPoint m_checkOrigin = m_originList[d];
                        ngl::Vector m_checkingPos = m_checkOrigin.getPosition();
                        ngl::Vector m_deltaOrigin = m_randomPosition - m_checkingPos;
                        float m_distOrigin = m_deltaOrigin.length();

                        while(m_distOrigin<1)
                        {
                            m_xValue = rand()% (m_areaWidth-(m_objR*2)) + (m_objR);
                            m_zValue = rand()% (m_areaHeight-(m_objR*2)) + (m_objR);
                            m_randomXsign = rand()%2 +1;
                            m_randomZsign = rand()%2 +1;

                            if(m_randomXsign == 2)
                                m_xValue *= -1;

                            if(m_randomZsign == 2)
                                m_zValue *= -1;

                            m_randomPosition = ngl::Vector(m_xValue/10, m_yValue, m_zValue/10, m_objRadius+0.05);

                            m_deltaOrigin = m_randomPosition - m_checkingPos;
                            m_distOrigin = m_deltaOrigin.length();

                            d=0;
                        }
                    }

                    m_putIn = false;
                }
                else
                    m_putIn = true;
            }
        }

        int m_randShape = rand()%2 + 1;

        m_nonflammableObjectList.push_back(FuelObject(m_randomPosition, 0, m_randShape));
    }

    // assign radius and height
    for(unsigned int f=0; f<m_nonflammableObjectList.size(); ++f)
    {
        FuelObject m_point = m_nonflammableObjectList[f];

        ngl::Vector m_pointPos = m_point.getPosition();

        if(m_point.getShape()==1)
        {
            m_point.setRadius(m_pointPos.m_w);
        }
        else
        {
            m_point.setRadius(m_pointPos.m_w);

            int m_randY = rand()%9+5;
            float m_yHeight = m_pointPos.m_w*m_randY;

            m_point.setHeight(m_yHeight/10);
        }

        m_nonflammableObjectList[f] = m_point;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::seperateList ( )

This method will categorize type of point to flammable and non-flammable list.

Definition at line 665 of file FireArea.cpp.

References FuelPoint::getPosition(), FuelPoint::isFlammable(), m_currentFlammableList, m_currentNonFlammableList, m_flammableList, m_gridPointList, and m_nonflammableList.

{
    std::vector<FuelPoint> m_pointZero;
    m_flammableList = m_pointZero;
    m_nonflammableList = m_pointZero;

    for(unsigned int i=0; i<m_gridPointList.size(); ++i)
    {
        FuelPoint m_point = m_gridPointList[i];

        if(m_point.isFlammable()==true)
        {
            m_flammableList.push_back(m_point);
        }
        else
        {
            m_nonflammableList.push_back(m_point);
        }
    }

    // ----- non-flammable object
    for(unsigned int j=0; j<m_currentNonFlammableList.size(); ++j)
    {
        ngl::Vector m_initPos = m_currentNonFlammableList[j];
        int m_nearIndex = 0;

        for(unsigned int k=0; k<m_gridPointList.size(); ++k)
        {
            FuelPoint m_point = m_gridPointList[k];
            ngl::Vector m_pointPos = m_point.getPosition();

            m_initPos.m_y = 0.0;
            m_pointPos.m_y = 0.0;

            ngl::Vector m_distVect = m_pointPos - m_initPos;
            float m_distNum = m_distVect.length();

            if(m_distNum==0.0)
            {
                m_nearIndex = k;
            }
        }

        m_initPos = m_currentNonFlammableList[j];

        FuelPoint m_currPoint = m_gridPointList[m_nearIndex];
        ngl::Vector m_currentPos = m_currPoint.getPosition();
        m_initPos.m_y = m_currentPos.m_y;

        m_currentNonFlammableList[j] = m_initPos;
    }

    // ----- Fuel object
    for(unsigned int m=0; m<m_currentFlammableList.size(); ++m)
    {
        ngl::Vector m_initPos = m_currentFlammableList[m];
        int m_nearIndex = 0;

        for(unsigned int k=0; k<m_gridPointList.size(); ++k)
        {
            FuelPoint m_point = m_gridPointList[k];
            ngl::Vector m_pointPos = m_point.getPosition();

            m_initPos.m_y = 0.0;
            m_pointPos.m_y = 0.0;

            ngl::Vector m_distVect = m_pointPos - m_initPos;
            float m_distNum = m_distVect.length();

            if(m_distNum==0.0)
            {
                m_nearIndex = k;
            }
        }

        m_initPos = m_currentFlammableList[m];

        FuelPoint m_currPoint = m_gridPointList[m_nearIndex];
        ngl::Vector m_currentPos = m_currPoint.getPosition();
        m_initPos.m_y = m_currentPos.m_y;

        m_currentFlammableList[m] = m_initPos;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::showLine ( bool  _showingMode)

This method would be called when the showing line only's check box has been toggled.

Parameters:
_showingModeis the flag to show only fire line apart from the burning area

Definition at line 2556 of file FireArea.cpp.

References m_firePathOne, and FirePath::showFireLineOnly().

{
    m_firePathOne->showFireLineOnly(_showingMode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::showMark ( bool  _showingMode)

This method would be called when the mark's check box has been toggled.

Parameters:
_showingModeis the flag to show the mark of origin position

Definition at line 2548 of file FireArea.cpp.

References m_markShowing.

{
    m_markShowing = _showingMode;
}

Here is the caller graph for this function:

void FireArea::timestep ( const std::string &  _shaderName,
ngl::TransformStack &  _transformStack 
)

This method updates the point to current state.

Parameters:
&_shaderNamerefers to the shader of fire path's appearance,
&_transformStackrefers to the transform stack of fire path

Definition at line 2185 of file FireArea.cpp.

References FirePath::drawDLAPath(), m_firePathOne, m_pauseAnimation, m_showPath, m_timeStep, and FirePath::timeUpdate().

{
    // draw fire path
    if(m_showPath==true)
        m_firePathOne->drawDLAPath(_shaderName, _transformStack);

    if(m_pauseAnimation==false)
    {
        m_firePathOne->timeUpdate(m_timeStep);
        ++m_timeStep;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::toggleMountainDraw ( bool  _mountainDraw,
int  _iterations 
)

This method would toggle the drawing or generating the mountain or terrain.

Parameters:
_mountainDrawis the flag that would enable or disable the terrain generating,
_iterationsis the number of iterations that would generate terrain

Definition at line 215 of file FireArea.cpp.

References buildMountain(), m_drawMountain, m_gridPointList, m_initPointList, and m_mountainNumber.

{
    m_mountainNumber = _iterations;

    if(_mountainDraw==true)
    {
        m_drawMountain = true;
        buildMountain();
    }
    else
    {
        m_drawMountain = false;
        m_gridPointList = m_initPointList;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void FireArea::updateGridPoint ( )

This method would update the new grid point after the new amount of obstacle is created.

Definition at line 406 of file FireArea.cpp.

References FuelPoint::changeColour(), FuelPoint::getCurrentFuelValue(), getFuelColourInTheArea(), FuelPoint::getPosition(), identifyArea(), m_currentNonFlammableList, m_firePathOne, m_gridPointList, m_initPointList, FuelPoint::makeToBeflammable(), FuelPoint::makeToBeNonflammable(), FuelPoint::setPosition(), FuelPoint::setToBeBigFuel(), FuelPoint::setToBeNonBigFuel(), and FirePath::updateFuelOnGrid().

{
    // update initList
    for(unsigned int j=0; j<m_initPointList.size(); ++j)
    {
        FuelPoint m_initPoint = m_initPointList[j];
        ngl::Vector m_initPos = m_initPoint.getPosition();

        int m_fuelArea = identifyArea(m_initPos);

        if(m_fuelArea==0)
        {
            m_initPoint.makeToBeNonflammable();
            m_initPoint.setToBeNonBigFuel();
        }
        else if(m_fuelArea==1)
        {
            FuelPoint m_gridPoint = m_gridPointList[j];
            int m_randomFuel = m_gridPoint.getCurrentFuelValue();
            m_initPoint.makeToBeflammable(m_randomFuel);
            m_initPoint.setToBeNonBigFuel();
        }
        else
        {
            ngl::Vector m_fuelAmount = getFuelColourInTheArea(m_initPos);
            m_initPoint.makeToBeflammable(m_fuelAmount.m_x*100);
            m_initPoint.changeColour(m_fuelAmount);
            m_initPoint.setToBeBigFuel(m_fuelAmount.m_x*100);

            // assign index of obj that would identify this point
            ngl::Vector m_currentPos = m_initPoint.getPosition();
            m_currentPos.m_w = m_fuelArea-2;
            m_initPoint.setPosition(m_currentPos);
        }

        m_initPointList[j] = m_initPoint;
        m_initPoint = m_initPointList[j];
    }

    std::vector<ngl::Vector> m_posZero;
    m_currentNonFlammableList = m_posZero;

    // update gridList
    for(unsigned int i=0; i<=m_gridPointList.size(); ++i)
    {
        FuelPoint m_currentGridPoint = m_gridPointList[i];
        ngl::Vector m_currentPoint = m_currentGridPoint.getPosition();

        int m_fuelArea = identifyArea(m_currentPoint);

        if(m_fuelArea==0)
        {
            m_currentGridPoint.makeToBeNonflammable();
            m_currentGridPoint.setToBeNonBigFuel();
        }
        else if(m_fuelArea==1)
        {
            int m_randomFuel = m_currentGridPoint.getCurrentFuelValue();
            if(m_randomFuel==0)
                m_randomFuel = rand()%100 + 50;
            m_currentGridPoint.makeToBeflammable(m_randomFuel);
            m_currentGridPoint.setToBeNonBigFuel();
        }
        else
        {
            ngl::Vector m_fuelAmount = getFuelColourInTheArea(m_currentPoint);
            m_currentGridPoint.makeToBeflammable(m_fuelAmount.m_x*100);
            m_currentGridPoint.changeColour(m_fuelAmount);
            m_currentGridPoint.setToBeBigFuel(m_fuelAmount.m_x*100);

            // assign index of obj that would identify this point
            ngl::Vector m_currentPos = m_currentGridPoint.getPosition();
            m_currentPos.m_w = m_fuelArea-2;
            m_currentGridPoint.setPosition(m_currentPos);
        }

        m_gridPointList[i] = m_currentGridPoint;

        m_currentGridPoint = m_gridPointList[i];
    }

    m_firePathOne->updateFuelOnGrid(m_gridPointList);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

bool FireArea::m_addWind [private]

the flag of wind enable

Definition at line 459 of file FireArea.h.

the size of DLA that is assigned by users and calculated the approximate value (with the scene) by the program

Definition at line 436 of file FireArea.h.

the moisture of the fuel object

Definition at line 471 of file FireArea.h.

int FireArea::m_areaHeight [private]

height size of fire area

Definition at line 315 of file FireArea.h.

int FireArea::m_areaWidth [private]

width size of fire area

Definition at line 311 of file FireArea.h.

std::vector<FuelPoint> FireArea::m_currentDLALine [private]

list of current built DLA seed point

Definition at line 423 of file FireArea.h.

std::vector<FuelPoint> FireArea::m_currentDLAList [private]

list of current built DLA point

Definition at line 419 of file FireArea.h.

std::vector<ngl::Vector> FireArea::m_currentFlammableList [private]

the list of current non-flammable object's position

Definition at line 441 of file FireArea.h.

std::vector<ngl::Vector> FireArea::m_currentNonFlammableList [private]

the list of current non-flammable object's position

Definition at line 431 of file FireArea.h.

float FireArea::m_displacement [private]

displacement for building mountain (height of mountain)

Definition at line 373 of file FireArea.h.

int FireArea::m_dlaAmount [private]

the amount of dla stucture of the entire scene

Definition at line 427 of file FireArea.h.

create DLA object

Definition at line 320 of file FireArea.h.

bool FireArea::m_drawMountain [private]

the flag of drawing or generating terrain

Definition at line 386 of file FireArea.h.

create firePath object

Definition at line 325 of file FireArea.h.

std::vector<FuelPoint> FireArea::m_flammableList [private]

the list contains flammable point

Definition at line 338 of file FireArea.h.

the list contains non-flammable object

Definition at line 446 of file FireArea.h.

std::vector<FuelPoint> FireArea::m_gridPointList [private]

the list contains every point on the fire area

Definition at line 330 of file FireArea.h.

the index of origin point, according to grid point list

Definition at line 382 of file FireArea.h.

std::vector<FuelPoint> FireArea::m_initPointList [private]

the list contains initial point on the fire area

Definition at line 334 of file FireArea.h.

bool FireArea::m_markShowing [private]

the flag of showing mark of origin point

Definition at line 415 of file FireArea.h.

number of mountain that would generate on the scene

Definition at line 369 of file FireArea.h.

std::vector<FuelPoint> FireArea::m_nonflammableList [private]

the list contains non-flammable point

Definition at line 342 of file FireArea.h.

the list contains non-flammable object

Definition at line 346 of file FireArea.h.

the amount of origin number of the entire scene

Definition at line 403 of file FireArea.h.

float FireArea::m_objHeight [private]

height of fuel object

Definition at line 364 of file FireArea.h.

int FireArea::m_objIndex [private]

index of fuel object

Definition at line 475 of file FireArea.h.

float FireArea::m_objRadius [private]

radius of fuel object

Definition at line 360 of file FireArea.h.

int FireArea::m_originIndex [private]

the current index of origin number in the origin point list

Definition at line 407 of file FireArea.h.

std::vector<FuelPoint> FireArea::m_originList [private]

the origin point list

Definition at line 411 of file FireArea.h.

ngl::Vector FireArea::m_originPosition [private]

origin point position

Definition at line 398 of file FireArea.h.

the flag of pausing animation

Definition at line 390 of file FireArea.h.

float FireArea::m_pointRadius [private]

radius of the point

Definition at line 355 of file FireArea.h.

double FireArea::m_sceneMoisture [private]

the moisture of the scene

Definition at line 467 of file FireArea.h.

double FireArea::m_sceneTemperature [private]

the temperature of the scene

Definition at line 463 of file FireArea.h.

bool FireArea::m_showPath [private]

the flag of showing DLA form

Definition at line 394 of file FireArea.h.

size of circle represents mountain (sphere radius*2)

Definition at line 377 of file FireArea.h.

int FireArea::m_timeStep [private]

time step number

Definition at line 351 of file FireArea.h.

ngl::Vector FireArea::m_windDirection [private]

the wind direction

Definition at line 451 of file FireArea.h.

int FireArea::m_windSpeed [private]

the wind speed

Definition at line 455 of file FireArea.h.


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