DLA-Fire-Prediction-Thesis 1.0

FuelObject.cpp

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------------------------------------------------
00004 //----------------------------------------------------------------------------------------------------------------------
00005 
00006 #include "FuelObject.h"
00007 
00008 #include "ngl/Vector.h"
00009 
00010 #include "GLWindow.h"
00011 
00012 //----------------------------------------------------------------------------------------------------------------------
00013 // ctor of point
00014 FuelObject::FuelObject(
00015                       ngl::Vector _objectPosition,
00016                       int _objectStatus,
00017                       int _objectShape
00018                       )
00019 {
00020     m_position = _objectPosition;
00021 
00022     m_objectShape = _objectShape;
00023 
00024     // initial size
00025     m_objectRadius = 0.0;
00026     m_objectHeight = 0.0;
00027 
00028     if(_objectStatus==1)             // flammable point starts with 100 fuel power
00029     {
00030         // ----- flammable point
00031         m_isFlammable = true;
00032         m_isBurning = false;
00033         m_fuel = 100.0;
00034         // set initial colour to green, depends on the fuel amount
00035         float m_fuelColour = m_fuel/100;
00036         m_currentColour = ngl::Vector(m_fuelColour,0.0,0.0);
00037 
00038         m_moisture = 0.1;
00039     }
00040     else                            // non-flammable starts with no fuel
00041     {
00042         // ----- non-flammable point
00043         m_isFlammable = false;
00044         m_isBurning = false;
00045         m_fuel = 0.0;
00046 
00047         // set initial colour
00048         if(m_objectShape==1)
00049             m_currentColour = ngl::Vector(0.7,0.8,1.0);
00050         else if(m_objectShape==2)
00051             m_currentColour = ngl::Vector(0.6,0.7,1.0);
00052         else
00053             m_currentColour = ngl::Vector(0.4,0.5,1.0);
00054 
00055         m_moisture = 0.8;
00056     }
00057 }
00058 
00059 //----------------------------------------------------------------------------------------------------------------------
00060 float FuelObject::getRadius()
00061 {
00062     return m_objectRadius;
00063 }
00064 
00065 //----------------------------------------------------------------------------------------------------------------------
00066 float FuelObject::getHeight()
00067 {
00068     return m_objectHeight;
00069 }
00070 
00071 //----------------------------------------------------------------------------------------------------------------------
00072 void FuelObject::setHeight(
00073                           float _newHeight
00074                           )
00075 {
00076     m_objectHeight = _newHeight;
00077 }
00078 
00079 //----------------------------------------------------------------------------------------------------------------------
00080 void FuelObject::setRadius(
00081                           float _newRadious
00082                           )
00083 {
00084     m_objectRadius = _newRadious;
00085 }
00086 
00087 //----------------------------------------------------------------------------------------------------------------------
00088 int FuelObject::getShape()
00089 {
00090     return m_objectShape;
00091 }
00092 
00093 //----------------------------------------------------------------------------------------------------------------------
00094 ngl::Vector& FuelObject::getPosition()
00095 {
00096     return m_position;
00097 }
00098 
00099 //----------------------------------------------------------------------------------------------------------------------
00100 ngl::Vector& FuelObject::getColour()
00101 {
00102     return m_currentColour;
00103 }
00104 
00105 //----------------------------------------------------------------------------------------------------------------------
00106 void FuelObject::changeColour(
00107                              ngl::Vector _assignedColour
00108                              )
00109 {
00110     m_currentColour = _assignedColour;
00111 }
00112 
00113 //----------------------------------------------------------------------------------------------------------------------
00114 void FuelObject::makeToBeNonflammable()
00115 {
00116     m_isFlammable = false;
00117     m_fuel = 0.0;
00118     // set initial colour to blue
00119     m_currentColour = ngl::Vector(0.0f,0.0f,1.0f);
00120 
00121     m_moisture = 1.0;
00122 }
00123 
00124 //----------------------------------------------------------------------------------------------------------------------
00125 void FuelObject::makeToBeflammable(
00126                                   float _fuel
00127                                   )
00128 {
00129     m_isFlammable = true;
00130     m_fuel = _fuel;
00131     float m_fuelColour = m_fuel/100;
00132     // set initial colour to green, depends on the adding fuel
00133     m_currentColour = ngl::Vector(0.0f,m_fuelColour,0.0f);
00134 }
00135 
00136 //----------------------------------------------------------------------------------------------------------------------
00137 void FuelObject::setFire()
00138 {
00139     if(m_isFlammable==true)
00140     {
00141         m_isBurning = true;
00142         float m_fuelColour = m_fuel/100;
00143         // set colour of the burning point to red, depends on fuel amount
00144         m_currentColour = ngl::Vector(m_fuelColour,0.0f,0.0f);
00145     }
00146     else
00147     {
00148         m_isBurning = false;
00149     }
00150 }
00151 
00152 //----------------------------------------------------------------------------------------------------------------------
00153 void FuelObject::setFuelAmount(
00154                               float _newFuel
00155                               )
00156 {
00157     if(m_isFlammable==true)
00158     {
00159         m_fuel = _newFuel;
00160         float m_fuelColour = m_fuel/100;
00161         // set colour of the burning point to red, depends on fuel amount
00162         m_currentColour = ngl::Vector(m_fuelColour, 0.0f,0.0f);
00163     }
00164     else
00165         m_fuel = 0.0;
00166 }
00167 
00168 //----------------------------------------------------------------------------------------------------------------------
00169 // this function will change the colour if the point is in burning state
00170 void FuelObject::subtractFuel(
00171                              float _decreaseAmount
00172                              )
00173 {
00174     if(m_fuel>0.0)
00175     {
00176         m_fuel = m_fuel-_decreaseAmount;
00177     }
00178     else
00179     {
00180         m_fuel = 0.0;
00181     }
00182 
00183     if(m_isBurning==true)
00184     {
00185         float m_fuelColour = m_fuel/100;
00186         // set colour of the burning point to red, depends on fuel amount
00187         m_currentColour = ngl::Vector(m_fuelColour,0.0f,0.0f);
00188     }
00189 
00190 }
00191 
00192 //----------------------------------------------------------------------------------------------------------------------
00193 bool FuelObject::isFlammable()
00194 {
00195     return m_isFlammable;
00196 }
00197 
00198 //----------------------------------------------------------------------------------------------------------------------
00199 bool FuelObject::isBurning()
00200 {
00201     return m_isBurning;
00202 }
00203 
00204 //----------------------------------------------------------------------------------------------------------------------
00205 float FuelObject::getCurrentFuelValue()
00206 {
00207     return m_fuel;
00208 }
00209 
00210 //----------------------------------------------------------------------------------------------------------------------
00211 float FuelObject::getMoisture()
00212 {
00213     return m_moisture;
00214 }
00215 
00216 //----------------------------------------------------------------------------------------------------------------------
00217 void FuelObject::decreaseMoisture(
00218                                  float _decreasedAmount
00219                                  )
00220 {
00221     m_moisture -= _decreasedAmount;
00222 }
00223 
00224 //----------------------------------------------------------------------------------------------------------------------
00225 void FuelObject::setPosition(
00226                             ngl::Vector _newPos
00227                             )
00228 {
00229     m_position = _newPos;
00230 }
 All Classes Namespaces Files Functions Variables Enumerations Enumerator