Main.h

The bulk of the useful program code
//Main.h where it all happens
//Written by: Chris Morrison and Nick Kutac
//Not perfected version
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
#include <gl\gl.h> //gl libraries
#include <gl\glu.h>
#include <math.h>
#include<vector.h>
#include<iomanip.h>
#include "Load.h"
#include "Data.h"
#include "Wind.h"

void DrawForest(double ypers, double xpers,double sf, int selected[3]);
void DrawHeat (double ypers, double xpers,double sf, int selected[3]);
void DrawFire (double ypers, double xpers,double sf, int selected[3]);
void DrawBurnt (double ypers, double xpers,double sf, int selected[3]);
void MakeFire();
void Continue(int sf);
void disContinue();
void Record();

double increment=.1; //fire step length
double MSR=1; //interval*fuela legnth per step
double s=0; //current interval*fuela

int degrees=18; //number of extensionsor radii on fire arc
int boundaries;
//-----------------------------------------------------------------
class Enviornment //forest environment
{
public:
double WindSpeed; //global env factors
double WindAngle;
double AmbientTemperature;

class Patches
{ public: //specific to patch env factors
int type;
float DryFuelHum;
float WetFuelHum;
float oxygen;
double CrownWetFuel;
double CrownDryFuel;
double FloorWetFuel;
double FloorDryFuel;
long double CelsiusTemperature;
double WetFlashPoint;
double DryFlashPoint;
double InstantaneousFlashPoint;
double ProducedHeat;
double CrownHeight;
double emmisivity;
bool active[10][10]; //minipatches

void Ignite(int x,int y) //ignite mini-patches
{
active[x][y]=true;
}

bool PreviousFire(int x,int y)//check if a fire has previously been
{ //in the patch
return active[x][y];
}

bool Sustainable() //if the conditions in the patch are
{ //able to sustain fire
if((CelsiusTemperature>DryFlashPoint&&FloorDryFuel>0)||(CelsiusTemperature>WetFlashPoint&&FloorWetFuel>0))
{return true;}
return false;
}

}Heat[500][500][2]; //500x500 patches supportable x2 for heat records
//
void Rationalize(int sf) //rationalize temperatures
{ for(int x=0;x<=sf;x++)
{for(int y=0;y<=sf;y++)
{Heat[x][y][0].CelsiusTemperature+=Heat[x][y][1].CelsiusTemperature;}
}
}
//
void HeatFlow(int x,int y) //heat flow algorithm
{ double k=-.25; //Newton's Law of Cooling Varible
double e=2.718281828; //e
double K=1; //Fouriers Law of Conductivity
double joulesToCelsius=.5;
//Joules required to raise

Heat[x][y][0].CelsiusTemperature=AmbientTemperature+(Heat[x][y][0].CelsiusTemperature-AmbientTemperature)*pow(e,k);
//Newton's Law of Cooling
if(Heat[x-1][y][0].CelsiusTemperature<Heat[x][y][0].CelsiusTemperature)
{Heat[x-1][y][1].CelsiusTemperature=+K*(((Heat[x][y][0].CelsiusTemperature-Heat[x-1][y][0].CelsiusTemperature))/4);}
if(Heat[x+1][y][0].CelsiusTemperature<Heat[x][y][0].CelsiusTemperature)
{Heat[x+1][y][1].CelsiusTemperature=+K*(((Heat[x][y][0].CelsiusTemperature-Heat[x+1][y][0].CelsiusTemperature))/4);}
if(Heat[x][y-1][0].CelsiusTemperature<Heat[x][y][0].CelsiusTemperature)
{Heat[x][y-1][1].CelsiusTemperature=+K*(((Heat[x][y][0].CelsiusTemperature-Heat[x][y-1][0].CelsiusTemperature))/4);}
if(Heat[x][y+1][0].CelsiusTemperature<Heat[x][y][0].CelsiusTemperature)
{Heat[x][y+1][1].CelsiusTemperature=+K*(((Heat[x][y][0].CelsiusTemperature-Heat[x][y+1][0].CelsiusTemperature))/4);}
//Fourier's Law of conductivity
Heat[x-1][y][1].CelsiusTemperature=+.0000000567*Heat[x][y][1].emmisivity*pow(Heat[x][y][1].CelsiusTemperature+273,4)*joulesToCelsius/8;
Heat[x+1][y][1].CelsiusTemperature=+.0000000567*Heat[x][y][1].emmisivity*pow(Heat[x][y][1].CelsiusTemperature+273,4)*joulesToCelsius/8;
Heat[x][y-1][1].CelsiusTemperature=+.0000000567*Heat[x][y][1].emmisivity*pow(Heat[x][y][1].CelsiusTemperature+273,4)*joulesToCelsius/8;
Heat[x][y+1][1].CelsiusTemperature=+.0000000567*Heat[x][y][1].emmisivity*pow(Heat[x][y][1].CelsiusTemperature+273,4)*joulesToCelsius/8;
Heat[x-1][y+1][1].CelsiusTemperature=+.0000000567*Heat[x][y][1].emmisivity*pow(Heat[x][y][1].CelsiusTemperature+273,4)*joulesToCelsius/16;
Heat[x+1][y+1][1].CelsiusTemperature=+.0000000567*Heat[x][y][1].emmisivity*pow(Heat[x][y][1].CelsiusTemperature+273,4)*joulesToCelsius/16;
Heat[x-1][y-1][1].CelsiusTemperature=+.0000000567*Heat[x][y][1].emmisivity*pow(Heat[x][y][1].CelsiusTemperature+273,4)*joulesToCelsius/16;
Heat[x+1][y+1][1].CelsiusTemperature=+.0000000567*Heat[x][y][1].emmisivity*pow(Heat[x][y][1].CelsiusTemperature+273,4)*joulesToCelsius/16;
//Stefan Boltzmann Law of Radiation
double total=0;
for(int xa=0;xa<=9;xa++)
{ for(int ya=0; ya<=9;ya++)
{ if(Heat[x][y][0].active[xa][ya])
{total+=.01;}
}
}
Heat[x][y][0].CelsiusTemperature+=Heat[x][y][0].ProducedHeat*total;

//Burn loop
}
//
void LoadForest(int sf) //initializes forest and its values
{ AmbientTemperature=getAmbient();
WindSpeed=getWind();
WindAngle=getWindAngle();
//Load for environment class
for(int x=0; x<=sf-1;x++)
{for(int y=0; y<=sf-1;y++)
{Heat[x][y][0].CelsiusTemperature=AmbientTemperature;
Heat[x][y][0].ProducedHeat=Produced(Heat[x][y][0].type)*3;
Heat[x][y][0].FloorWetFuel=WetFuel(Heat[x][y][0].type);
Heat[x][y][0].FloorDryFuel=DryFuel(Heat[x][y][0].type);
Heat[x][y][0].WetFlashPoint=wetBasicFlash(Heat[x][y][0].type);
Heat[x][y][0].DryFlashPoint=dryBasicFlash(Heat[x][y][0].type);
Heat[x][y][0].InstantaneousFlashPoint=instantFlash(Heat[x][y][0].type);
Heat[x][y][0].emmisivity=Emmisivity(Heat[x][y][0].type);
//load values for patch class
for(int xa=0; xa<=9;xa++)
{for(int ya=0; ya<=9;ya++)
{Heat[x][y][0].active[xa][ya]=false;
}}}//set mini-patches unburned
}
//Heat[10][10][0].CelsiusTemperature=150000;
}

}FOREST;
//-------------------------------------------------------------------
class FirePerimeter //keep track of all points to arc next iteration
{public:
vector<double> xloc;
vector<double> yloc;
vector<double> zloc;
}Perimeter;
//----------------------------------------------------------------------
class Draw //records last iteration to display it with less processing
{public:
double xstart;
double ystart;
double zstart;
vector <double> xloc;
vector <double> yloc;
vector <double> zloc;

Draw(int num,vector <double> aloc,vector <double> bloc,vector <double> cloc,double xs,double ys,double zs)
{//constructor
xloc=aloc;
yloc=bloc;
zloc=cloc;
xstart=xs;
ystart=ys;
zstart=0;
}

void Display() //function to display the past step
{ glBegin(GL_LINES);
if(xloc.size()!=0)
{for(int x=0; x<=xloc.size()-1; x++)
{
glVertex3f(xloc[x],yloc[x],0);
glVertex3f(xstart,ystart,0);
}
glEnd();
}
}
};
vector<Draw> DRAWING;//make it dynamic
//----------------------------------------------------------------------
class Fire //handles fire procreation
{public:
double xstart;
double ystart;
double zstart;

Fire(double x,double y, double z)
{ xstart=x;ystart=y; zstart=z;}
//constructor
void FireFlow()
{ bool done;
vector<double> xloc,yloc,zloc;
for(int x=0;x<=180;x+=(360/degrees))
{ //increments the degree of the radii
double spread=0;s=0;
do
{
//double b=ystart-tan(convert(x))*xstart;
//double xa=xstart+(s/sqrt(1+pow(tan(convert(x)),2)));
//double ya=(xstart+(s/sqrt(1+pow(tan(convert(x)),2))))*tan(convert(x))+b;
//before and after polar corrections
double xa= xstart + s*(cos(convert(x) + pi/2));
double ya= ystart + s*(sin(convert(x) + pi/2));
//keeps track of exact coordinates
double za=0;
if(xa<1){xa=1;}if(ya<1){ya=1;}
if(xa>30){xa=30;}if(ya>30){ya=30;}
//keeps flow within boundaries
int aa=floor(xa);
int ba=floor(ya);
//casts as ints to ignite flow

spread=spread+(increment*Geta(FOREST.Heat[aa][ba][0].type));
//adds spread until reaxhes maximum
if(spread>=MSR)
{done=true;
//if it has reached the maximum time flow
double newxa=xa,newya=ya,newza=0;
if(FOREST.WindSpeed!=0)
{ newxa=WindVectoring('x',xa,ya,za,xstart,ystart,zstart,FOREST.WindAngle,2,x);
newya=WindVectoring('y',xa,ya,za,xstart,ystart,zstart,FOREST.WindAngle,2,x);
newza=WindVectoring('z',xa,ya,za,xstart,ystart,zstart,FOREST.WindAngle,2,x);
} //computes wind vectoring
if(newxa<1){newxa=1;}if(newya<1){newya=1;}
bool record=firepath(newxa,newya,x);
if(record)
{Perimeter.xloc.push_back(newxa);
Perimeter.yloc.push_back(newya);
//keep track of fire end points and perimeter
xloc.push_back(newxa);
yloc.push_back(newya);
zloc.push_back(0);
}

}
else
{done=false; }

if(!FOREST.Heat[aa][ba][0].Sustainable())
{done=true; //if conditions aren't suitable for fire
double newxa=xa,newya=ya,newza=0;
if(FOREST.WindSpeed!=0)
{ newxa=WindVectoring('x',xa,ya,za,xstart,ystart,zstart,FOREST.WindAngle,2,x);
newya=WindVectoring('y',xa,ya,za,xstart,ystart,zstart,FOREST.WindAngle,2,x);
newza=WindVectoring('z',xa,ya,za,xstart,ystart,zstart,FOREST.WindAngle,2,x);
}
if(newxa<1){newxa=1;}if(newya<1){newya=1;}
bool record=firepath(newxa,newya,x);
if(record)
{Perimeter.xloc.push_back(newxa);
Perimeter.yloc.push_back(newya);
//keep track of spread in vectors
xloc.push_back(newxa);
yloc.push_back(newya);
zloc.push_back(0);

}}

s=s+(increment*heatFactor(FOREST.Heat[aa][ba][0].CelsiusTemperature));
}while(!done);
spread=0; s=0;
do
{ //computes the same just for the opposite quadrant
//double b=ystart-tan(convert(x))*xstart;
//double xa=xstart-(s/sqrt(1+pow(tan(convert(x)),2)));
//double ya=(xstart-(s/sqrt(1+pow(tan(convert(x)),2))))*tan(convert(x))+b;
double xa = xstart - s * (cos(convert(x) + pi/2));
double ya = ystart - s * (sin(convert(x) + pi/2));
double za=0;
if(xa<1){xa=1;}if(ya<1){ya=1;}

int aa=floor(xa);
int ba=floor(ya);

spread=spread+(increment*Geta(FOREST.Heat[aa][ba][0].type));

if(spread>=MSR)
{done=true;
double newxa=xa,newya=ya,newza=0;
if(FOREST.WindSpeed!=0)
{ newxa=WindVectoring('x',xa,ya,za,xstart,ystart,zstart,FOREST.WindAngle,FOREST.WindSpeed,x+180);
newya=WindVectoring('y',xa,ya,za,xstart,ystart,zstart,FOREST.WindAngle,FOREST.WindSpeed,x+180);
newza=WindVectoring('z',xa,ya,za,xstart,ystart,zstart,FOREST.WindAngle,FOREST.WindSpeed,x+180);
}
if(newxa<1){newxa=1;}if(newya<1){newya=1;}
bool record=firepath(newxa,newya,x+180);
if(record)
{Perimeter.xloc.push_back(newxa);
Perimeter.yloc.push_back(newya);
xloc.push_back(newxa);
yloc.push_back(newya);
zloc.push_back(0);
}
}
else
{done=false;
}

if(!FOREST.Heat[aa][ba][0].Sustainable())
{done=true; double newxa=xa,newya=ya,newza=0;
if(FOREST.WindSpeed!=0)
{ newxa=WindVectoring('x',xa,ya,za,xstart,ystart,zstart,FOREST.WindAngle,2,x);
newya=WindVectoring('y',xa,ya,za,xstart,ystart,zstart,FOREST.WindAngle,2,x);
newza=WindVectoring('z',xa,ya,za,xstart,ystart,zstart,FOREST.WindAngle,2,x);
}
if(newxa<1){newxa=1;}if(newya<1){newya=1;}
bool record=firepath(newxa,newya,x);
if(record)
{Perimeter.xloc.push_back(newxa);
Perimeter.yloc.push_back(newya);

xloc.push_back(newxa);
yloc.push_back(newya);
zloc.push_back(0); }}
s=s+(increment*heatFactor(FOREST.Heat[aa][ba][0].CelsiusTemperature));
}while(!done);
}

Draw tmp(degrees,xloc,yloc,zloc,xstart,ystart,zstart);
DRAWING.push_back(tmp);

}
bool firepath(double xa,double ya,int degslope)//keeps track of the fire path
{ double legnth=sqrt(pow(xstart-xa,2)+pow(ystart-ya,2));
int aa=0,ba=0,ca=0,da=0;
for(double x=0; x<=legnth; x+=.09)
{ //tells the computer to burn the minipatches in the way of the fire
double feta;
if((degslope>=90&&degslope<=180)||(degslope>=270&&degslope<=360))
{feta=90-(degslope%90);}
if((degslope<90)||(degslope>180&&degslope<270))
{feta=degslope%90;}

if(degslope<=90)
{aa=floor(xstart+x*cos(convert(feta)));
ca=floor(10*(xstart+x*cos(convert(feta))));
ba=floor(ystart+x*sin(convert(feta)));
da=floor(10*(ystart+x*sin(convert(feta))));
}

if(degslope>90&&degslope<180)
{aa=floor(xstart-x*cos(convert(feta)));
ca=floor(10*(xstart-x*cos(convert(feta))));
ba=floor(ystart+x*sin(convert(feta)));
da=floor(10*(ystart+x*sin(convert(feta))));
}
if(degslope>=180&&degslope<=270)
{aa=floor(xstart-(x*cos(convert(feta))));
ca=floor(10*(xstart-(x*cos(convert(feta)))));
ba=floor(ystart-(x*sin(convert(feta))));
da=floor(10*(ystart-(x*sin(convert(feta)))));
}
if(degslope>270&&degslope<=360)
{aa=floor(xstart+x*cos(convert(feta)));
ca=floor(10*(xstart+x*cos(convert(feta))));
ba=floor(ystart-x*sin(convert(feta)));
da=floor(10*(ystart-x*sin(convert(feta))));
}
if(!FOREST.Heat[aa][ba][0].PreviousFire(ca%10,da%10)&&x<legnth-sqrt(.02))
{FOREST.Heat[aa][ba][0].Ignite(ca%10,da%10);}
}
if(!FOREST.Heat[aa][ba][0].PreviousFire(ca%10,da%10))
{return true;}
return false;
}
}fire(14,16,0),fIre(5,5,0);

vector<Fire> FIRE;
//**************************************************************
bool Main(double ypers, double xpers,const double sf,int selected[3],int status,long timer,int TimeChange)
{ //initializes
if(timer==0)
{boundaries=sf+1;
for(int x=0;x<=sf;x++)
{for(int y=0; y<=sf; y++)
{ FOREST.Heat[x][y][0].type=getType(x,y);}
}
FOREST.LoadForest(sf);
}
switch(TimeChange)
{//if there is a time step or not
case 0:
{ disContinue();
if(status==1){ DrawForest(ypers,xpers,sf,selected);}
if(status==2){ DrawHeat(ypers,xpers,sf,selected);}
if(status==3){ DrawFire(ypers,xpers,sf,selected);}
if(status==4){ DrawBurnt(ypers,xpers,sf,selected);}
break;//which screen to display
}

case 1:
{ //if there is a time change
if(status==1){ DrawForest(ypers,xpers,sf,selected);}
if(status==2){ DrawHeat(ypers,xpers,sf,selected);}
if(status==3){ DrawFire(ypers,xpers,sf,selected);}
if(status==4){ DrawBurnt(ypers,xpers,sf,selected);}
//which screen to display
DRAWING.clear();
fire.FireFlow();
//fIre.FireFlow();
if(FIRE.size()!=0)
{for(int x=1; x<=FIRE.size()-1;x++)
{
FIRE[x].FireFlow();
}
}
//compute the fire flow
Continue(sf);
Record();
//record valid data to a text file
break;
}

default:{break;}
}
return true;
}

//**************************************************************
void DrawForest(double ypers, double xpers,double sf,int selected[3])
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glTranslatef(xpers,ypers,-25.0f);
glBegin(GL_QUADS);
{ glColor3f(0,.75,.5);
glVertex3d(1,1,0);
glVertex3d(1,sf,0);
glVertex3d(sf,sf,0);
glVertex3d(sf,1,0);



}glEnd();

for(int x=1; x<=sf; x++)
{ for(int y=1; y<=sf; y++)
{ glBegin(GL_QUADS);
glColor3f( blue(FOREST.Heat[x][y][0].type) ,yellow(FOREST.Heat[x][y][0].type),red(FOREST.Heat[x][y][0].type));
glVertex3d(x,y,0);
glVertex3d(x+1,y,0);
glVertex3d(x+1,y+1,0);
glVertex3d(x,y+1,0);
glEnd();
}}
//draw the fuel types

glBegin(GL_QUADS);
{ glColor3f(1.0f,1.0f,1.0f);
glVertex3d(selected[0],selected[1],0);//selected[3]);
glVertex3d(selected[0]+1,selected[1],0);//selected[3]);
glVertex3d(selected[0]+1,selected[1]+1,0);//,selected[3]);
glVertex3d(selected[0],selected[1]+1,0);//selected[3]);
}glEnd();
glBegin(GL_LINES);
for(int x=1; x<=sf; x++)
{ glColor3f(0.0f,1.0f,1.0f);
glVertex3d(1,x,0); // Left Center Of Player
glVertex3d(sf,x,0);
glVertex3d(x,1,0); // Left Center Of Player
glVertex3d(x,sf,0);
}
glEnd();

for(int x=1; x<=sf; x++)
{ for(int y=1; y<=sf; y++)
{
glBegin(GL_QUADS);
glColor3f( blue(FOREST.Heat[x][y][0].type) ,yellow(FOREST.Heat[x][y][0].type),red(FOREST.Heat[x][y][0].type));
glVertex3d(((6/sf)*x)-xpers-11-2,((6/sf)*y)-ypers-11+12,0);
glVertex3d(((6/sf)*x)-xpers-11-2+6/sf,((6/sf)*y)-ypers-11+12,0);
glVertex3d(((6/sf)*x)-xpers-11-2+6/sf,((6/sf)*y)-ypers-11+12+6/sf,0);
glVertex3d(((6/sf)*x)-xpers-11-2,((6/sf)*y)-ypers-11+12+6/sf,0);
}
}
//draw the minimap // Done Drawing The Quad
glEnd();


}
//*************************************************************
void DrawHeat(double ypers, double xpers,double sf, int selected[3])
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(xpers,ypers,-25.0f);

for(int x=1; x<=sf; x++)
{ for(int y=1; y<=sf; y++)
{ glBegin(GL_QUADS);
glColor3f( BLUE(FOREST.Heat[x][y][0].CelsiusTemperature) ,GREEN(FOREST.Heat[x][y][0].CelsiusTemperature),RED(FOREST.Heat[x][y][0].CelsiusTemperature));
glVertex3d(x,y,0);
glVertex3d(x+1,y,0);
glVertex3d(x+1,y+1,0);
glVertex3d(x,y+1,0);
}}
glEnd();

glBegin(GL_QUADS);
{ glColor3f(1.0f,1.0f,1.0f);
glVertex3d(selected[0],selected[1],0);//selected[3]);
glVertex3d(selected[0]+1,selected[1],0);//selected[3]);
glVertex3d(selected[0]+1,selected[1]+1,0);//selected[3]);
glVertex3d(selected[0],selected[1]+1,0);//selected[3]);
} glEnd();
glBegin(GL_LINES);
for(int x=1; x<=sf; x++)
{ glColor3f(0.0f,1.0f,1.0f);
glVertex3d(1,x,0); // Left Center Of Player
glVertex3d(sf,x,0);
glVertex3d(x,1,0); // Left Center Of Player
glVertex3d(x,sf,0);
}
glEnd();
DrawNum(1,FOREST.Heat[selected[0]][selected[1]][0].CelsiusTemperature,ypers+12,xpers+12);

}
//*************************************************************
void DrawFire(double ypers, double xpers,double sf, int selected[3])
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(xpers,ypers,-25.0f);
glBegin(GL_LINES);
for(int x=1; x<=sf; x++)
{ glColor3f(0.0f,1.0f,1.0f);
glVertex3d(1,x,0); // Left Center Of Player
glVertex3d(sf,x,0);
glVertex3d(x,1,0); // Left Center Of Player
glVertex3d(x,sf,0);
}
glEnd();


//DRAWING.clear();
if(DRAWING.size()!=0)
{for(int x=0; x<=DRAWING.size()-1;x++)
{
DRAWING[x].Display();
}
} //displays all saved fire arcs
}
//**************************************************************
void DrawBurnt (double ypers, double xpers,double sf, int selected[3])
{ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(xpers,ypers,-25.0f);
for(int x=1; x<=sf; x++)
{ for(int y=1; y<=sf; y++)
{ for(int xa=0; xa<=9; xa++)
{ for(int ya=0; ya<=9; ya++)
{
double a=xa,b=ya;
glBegin(GL_QUADS);
if(FOREST.Heat[x][y][0].active[xa][ya]){glColor3f(1,1,0);}
if(!FOREST.Heat[x][y][0].active[xa][ya]){glColor3f(0,0,1);}
glVertex3d(x+(a/10),y+(b/10),0);
glVertex3d(x+.1+(a/10),y+(b/10),0);
glVertex3d(x+.1+(a/10),y+.1+(b/10),0);
glVertex3d(x+(a/10),y+.1+(b/10),0);
glEnd();
}}}}


glBegin(GL_LINES);
for(int x=1; x<=sf; x++)
{ glColor3f(0.0f,1.0f,1.0f);
glVertex3d(1,x,0); // Left Center Of Player
glVertex3d(sf,x,0);
glVertex3d(x,1,0); // Left Center Of Player
glVertex3d(x,sf,0);
}
glEnd();

}
//**************************************************************
void MakeFire()
{if(Perimeter.xloc.size())
{ for(int x=0; x<=Perimeter.xloc.size()-1; x++)
{ Fire Temporary(Perimeter.xloc[x-1],Perimeter.yloc[x-1],0);
FIRE.push_back(Temporary);
}
} //add fires to vectors
Perimeter.xloc.clear();
Perimeter.yloc.clear();
Perimeter.zloc.clear();
}
//**************************************************************
void Continue(int sf)
{
for(int x=1; x<=sf-1; x++)
{ for(int y=1; y<=sf-1; y++)
{FOREST.HeatFlow(x,y);}
}
FOREST.Rationalize(sf);
//create new fires
FIRE.clear();
MakeFire();
}
//***************************************************************
void disContinue()
{
Perimeter.xloc.clear();
Perimeter.yloc.clear();
Perimeter.zloc.clear();
}//crear extra vectors
//****************************************************************
void Record()
{ int num=0;
for(int w=0; w<=30-1;w++)
{for(int x=0; x<=30-1;x++)
{for(int y=0; y<=9;y++)
{for(int z=0; z<=9;z++)
{if(FOREST.Heat[w][x][0].PreviousFire(y,z))
{num++;}}}}}
PutOut(num,num);
}

Data.h
Data Storehouse
//Data.h Where data is stored for patches mainly
//based on fuel type values

#include<math.h>
#define pi 3.141592654

double inline convert(double con)
{ return con*pi/180;}

float red(int ft)
{
if(ft==0){return 0;}
if(ft==1){return 0;}
if(ft==2){return 0.5;}
if(ft==3){return 1;}
if(ft==4){return 0;}
if(ft==5){return 0;}
if(ft==6){return 0;}
if(ft==7){return 1;}
if(ft==8){return 0;}
if(ft==9){return 1;}
if(ft==10){return 0;}
return 0;
}
float yellow(int ft)
{
if(ft==0){return 0;}
if(ft==1){return 0;}
if(ft==2){return 0;}
if(ft==3){return 0;}
if(ft==4){return 0.5;}
if(ft==5){return 1;}
if(ft==6){return 0;}
if(ft==7){return 0;}
if(ft==8){return 0.5;}
if(ft==9){return 1;}
if(ft==10){return 0;}
return 0;
}
float blue(int ft)
{
if(ft==0){return 0;}
if(ft==1){return 0;}
if(ft==2){return 0.5;}
if(ft==3){return 1;}
if(ft==4){return 0;}
if(ft==5){return 0;}
if(ft==6){return 0.5;}
if(ft==7){return 0;}
if(ft==8){return 1;}
if(ft==9){return 0;}
if(ft==10){return 1;}
return 0;
}
//spread values based on fuel type
float Geta(int ft)
{
if(ft==0){return 1.5;}
if(ft==1){return 1;}
if(ft==2){return .5;}
if(ft==3){return 3;}
if(ft==4){return 2;}
if(ft==5){return 1;}
if(ft==6){return .5;}
if(ft==7){return 2;}
if(ft==8){return 1;}
if(ft==9){return 2.5;}
if(ft==10){return 1;}
return 0;
}
//RGB heat colors
float RED(double Heat)
{ if(Heat<0)
{return 1;}
if(Heat<=1500&&Heat>=0)
{return 1-Heat/1500;}
else {return (Heat-1500)/1500;}
}

float BLUE(double Heat)
{ if(Heat<0)
{return 0;}
if(Heat<=1500&&Heat>=0)
{return Heat/1500;}
else {return 1;}
}
float GREEN(double Heat)
{ if(Heat>1500)
{return (Heat-1500)/1500;}
else
{return 0;}
}
float Produced(int ft)
{ if(ft==0){return 100;}
if(ft==1){return 100;}
if(ft==2){return 100;}
if(ft==3){return 100;}
if(ft==4){return 100;}
if(ft==5){return 100;}
if(ft==6){return 100;}
if(ft==7){return 100;}
if(ft==8){return 100;}
if(ft==9){return 100;}
if(ft==10){return 100;}
return 0;
}
int WetFuel(int ft)
{ if(ft==0){return 1;}
if(ft==1){return 1;}
if(ft==2){return 1;}
if(ft==3){return 1;}
if(ft==4){return 1;}
if(ft==5){return 1;}
if(ft==6){return 1;}
if(ft==7){return 1;}
if(ft==8){return 1;}
if(ft==9){return 1;}
if(ft==10){return 1;}
return 0;
}
int DryFuel(int ft)
{ if(ft==0){return 1;}
if(ft==1){return 1;}
if(ft==2){return 1;}
if(ft==3){return 1;}
if(ft==4){return 1;}
if(ft==5){return 1;}
if(ft==6){return 1;}
if(ft==7){return 1;}
if(ft==8){return 1;}
if(ft==9){return 1;}
if(ft==10){return 1;}
return 0;
}
double wetBasicFlash(int ft)
{ if(ft==0){return 200;}
if(ft==1){return 200;}
if(ft==2){return 200;}
if(ft==3){return 200;}
if(ft==4){return 200;}
if(ft==5){return 200;}
if(ft==6){return 200;}
if(ft==7){return 200;}
if(ft==8){return 200;}
if(ft==9){return 200;}
if(ft==10){return 200;}
return 0;

}
double dryBasicFlash(int ft)
{ if(ft==0){return 0;}
if(ft==1){return 0;}
if(ft==2){return 0;}
if(ft==3){return 0;}
if(ft==4){return 0;}
if(ft==5){return 0;}
if(ft==6){return 0;}
if(ft==7){return 0;}
if(ft==8){return 0;}
if(ft==9){return 0;}
if(ft==10){return 0;}
return 0;
}
double instantFlash(int ft)
{ if(ft==0){return 500;}
if(ft==1){return 500;}
if(ft==2){return 500;}
if(ft==3){return 500;}
if(ft==4){return 500;}
if(ft==5){return 500;}
if(ft==6){return 500;}
if(ft==7){return 500;}
if(ft==8){return 500;}
if(ft==9){return 500;}
if(ft==10){return 500;}
return 0;
}
//MONITERS HEATS EFFECT UPON FIRE FLOW
float heatFactor(int temp)
{
return 1;
}
float Emmisivity(int ft)
{
if(ft==0){return .5;}
if(ft==1){return .5;}
if(ft==2){return .5;}
if(ft==3){return .5;}
if(ft==4){return .5;}
if(ft==5){return .5;}
if(ft==6){return .5;}
if(ft==7){return .5;}
if(ft==8){return .5;}
if(ft==9){return .5;}
if(ft==10){return .5;}
return 0;
}
//draws numbers to the screen (incomplete)
void DrawNum(double size,double temp,double xl,double yl)
{ glBegin(GL_QUADS);
int ones=floor(temp);
for(int x=0;x<=7;x++)
{
for(int y=0; y<=7;y++)
{/*if(getNum(ones%10-1,x,y)==1)
//{
glColor3f(1.0f,1.0f,1.0f);
glVertex3d(10+x/8, 10+y/8 ,0);
glVertex3d(10+x/8+1/8,10+y/8 ,0);
glVertex3d(10+x/8+1/8,10+y/8+1/8,0);
glVertex3d(10+x/8,10+y/8+1/8 ,0);
// glVertex3d(10,10+1,0);
//glVertex3d(10,10,0);
//glVertex3d(10+1,10,0);
//glVertex3d(10+1,10+1,0);

}*/}
}

glEnd();
}
Fire.cpp
Initializatione Code borrowed and edited from nehe.gamedev.net
You don’t want to reinvent the wheel
//Chris Morrison
//Initialization Source borrowed and edited from nehe.gamedev.net
//2.5d fire flow program
//******************************************************************
#include <windows.h> // Header File For Windows
#include <gl\gl.h> // Header File For The OpenGL32 Library
#include <gl\glu.h> // Header File For The GLu32 Library
#include "Main.h"
#include<iostream.h>
#include<fstream.h>
#define sf size4feet

HDC hDC=NULL; // Private GDI Device Context
HGLRC hRC=NULL; // Permanent Rendering Context
HWND hWnd=NULL; // Holds Our Window Handle
HINSTANCE hInstance; // Holds The Instance Of The Application

bool keys[256]; // Array Used For The Keyboard Routine
bool active=TRUE; // Window Active Flag Set To TRUE By Default
bool fullscreen=TRUE; // Fullscreen Flag Set To Fullscreen Mode By Default
bool Return=false;
int status=1;
int selected[3]={0,0,0};

double xpers=-11;
double ypers=-10;
double size4feet=30;

unsigned long timer=0;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
// Declaration For WndProc
//*****************************************************************
GLvoid ReSizeGLScene(GLsizei width, GLsizei height)
// Resize And Initialize The GL Window
{
if (height==0) // Prevent A Divide By Zero By
{
height=1; // Making Height Equal One
}

glViewport(0,0,width,height); // Reset The Current Viewport

glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix

// Calculate The Aspect Ratio Of The Window
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,35.0f);

glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
}
//********************************************************************
int InitGL(GLvoid) // All Setup For OpenGL Goes Here
{
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
// Really Nice Perspective Calculations
return TRUE; // Initialization Went OK
}
//*********************************************************************
GLvoid KillGLWindow(GLvoid) // Properly Kill The Window
{
if (fullscreen) // Are We In Fullscreen Mode?
{
ChangeDisplaySettings(NULL,0); // If So Switch Back To The Desktop
ShowCursor(TRUE); // Show Mouse Pointer
}

if (hRC) // Do We Have A Rendering Context?
{
if (!wglMakeCurrent(NULL,NULL))
// Are We Able To Release The DC And RC Contexts?
{
MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}

if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC?
{
MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}
hRC=NULL; // Set RC To NULL
}

if (hDC && !ReleaseDC(hWnd,hDC)) // Are We Able To Release The DC
{
MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hDC=NULL; // Set DC To NULL
}

if (hWnd && !DestroyWindow(hWnd))// Are We Able To Destroy The Window?
{
MessageBox(NULL,"Could Not Release hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hWnd=NULL; // Set hWnd To NULL
}

if (!UnregisterClass("OpenGL",hInstance)) // Are We Able To Unregister Class
{
MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hInstance=NULL; // Set hInstance To NULL
}
}

/*This Code Creates Our OpenGL Window. Parameters Are: *
*title - Title To Appear At The Top Of The Window *
* width - Width Of The GL Window Or Fullscreen Mode *
* height - Height Of The GL Window Or Fullscreen Mode *
* bits - Number Of Bits To Use For Color (8/16/24/32) *
* fullscreenflag - Use Fullscreen Mode (TRUE) Or Windowed Mode (FALSE) */
//**********************************************************************
BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag)
{
GLuint PixelFormat; // Holds The Results After Searching For A Match
WNDCLASS wc; // Windows Class Structure
DWORD dwExStyle; // Window Extended Style
DWORD dwStyle; // Window Style
RECT WindowRect; // Grabs Rectangle Upper Left / Lower Right Values
WindowRect.left=(long)0; // Set Left Value To 0
WindowRect.right=(long)width; // Set Right Value To Requested Width
WindowRect.top=(long)0; // Set Top Value To 0
WindowRect.bottom=(long)height; // Set Bottom Value To Requested Height
fullscreen=fullscreenflag; // Set The Global Fullscreen Flag

hInstance= GetModuleHandle(NULL); // Grab An Instance For Our Window
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
// Redraw On Size, And Own DC For Window.
wc.lpfnWndProc= (WNDPROC) WndProc; // WndProc Handles Messages
wc.cbClsExtra = 0; // No Extra Window Data
wc.cbWndExtra= 0; // No Extra Window Data
wc.hInstance= hInstance; // Set The Instance
wc.hIcon= LoadIcon(NULL, IDI_WINLOGO); // Load The Default Icon
wc.hCursor= LoadCursor(NULL, IDC_ARROW); // Load The Arrow Pointer
wc.hbrBackground= NULL; // No Background Required For GL
wc.lpszMenuName= NULL; // We Don't Want A Menu
wc.lpszClassName= "OpenGL"; // Set The Class Name

if (!RegisterClass(&wc)) // Attempt To Register The Window Class
{
MessageBox(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}

if (fullscreen) // Attempt Fullscreen Mode?
{
DEVMODE dmScreenSettings; // Device Mode
memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
// Makes Sure Memory's Cleared
dmScreenSettings.dmSize=sizeof(dmScreenSettings);
// Size Of The Devmode Structure
dmScreenSettings.dmPelsWidth= width; // Selected Screen Width
dmScreenSettings.dmPelsHeight= height; // Selected Screen Height
dmScreenSettings.dmBitsPerPel= bits; // Selected Bits Per Pixel

dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
if(ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CH ANGE_SUCCESSFUL)
{// If The Mode Fails, Offer Two Options. Quit Or Use Windowed Mode.
if (MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
{
fullscreen=FALSE; // Windowed Mode Selected. Fullscreen = FALSE
}
else
{
// Pop Up A Message Box Letting User Know The Program Is Closing.
MessageBox(NULL,"Program Will Now Close.","ERROR",MB_OK|MB_ICONSTOP);
return FALSE; // Return FALSE
}
}
}

if (fullscreen) // Are We Still In Fullscreen Mode?
{
dwExStyle=WS_EX_APPWINDOW; // Window Extended Style
dwStyle=WS_POPUP; // Windows Style
ShowCursor(FALSE); // Hide Mouse Pointer
}
else
{
dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style
dwStyle=WS_OVERLAPPEDWINDOW; // Windows Style
}

AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requested Size

// Create The Window
if (!(hWnd=CreateWindowEx(
dwExStyle, // Extended Style For The Window
"OpenGL", // Class Name
title, // Window Title
dwStyle | // Defined Window Style
WS_CLIPSIBLINGS | // Required Window Style
WS_CLIPCHILDREN, // Required Window Style
0, 0, // Window Position WindowRect.right-WindowRect.left, // Calculate Window Width
WindowRect.bottom-WindowRect.top,// Calculate Window Height
NULL, // No Parent Window
NULL, // No Menu
hInstance, // Instance NULL))) // Dont Pass Anything To WM_CREATE
{
KillGLWindow(); // Reset The Display
MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}

static PIXELFORMATDESCRIPTOR pfd=
// pfd Tells Windows How We Want Things To Be
{
sizeof(PIXELFORMATDESCRIPTOR),
// Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
bits, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // No Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
16, // 16Bit Z-Buffer (Depth Buffer)
0, // No Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};

if (!(hDC=GetDC(hWnd))) // Did We Get A Device Context?
{
KillGLWindow(); // Reset The Display
MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}

if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd))) // Did Windows Find A Matching Pixel Format?
{
KillGLWindow(); // Reset The Display
MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE
}

if(!SetPixelFormat(hDC,PixelFormat,&pfd))
// Are We Able To Set The Pixel Format?
{
KillGLWindow(); // Reset The Display
MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}

if (!(hRC=wglCreateContext(hDC)))
// Are We Able To Get A Rendering Context?
{
KillGLWindow(); // Reset The Display
MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}

if(!wglMakeCurrent(hDC,hRC)) // Try To Activate The Rendering Context
{
KillGLWindow(); // Reset The Display
MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}

ShowWindow(hWnd,SW_SHOW); // Show The Window
SetForegroundWindow(hWnd); // Slightly Higher Priority
SetFocus(hWnd); // Sets Keyboard Focus To The Window
ReSizeGLScene(width, height); // Set Up Our Perspective GL Screen

if (!InitGL()) // Initialize Our Newly Created GL Window
{
KillGLWindow(); // Reset The Display
MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}

return TRUE; // Success
}
//**********************************************************************
LRESULT CALLBACK WndProc( HWND
hWnd, // Handle For This Window
UINT uMsg, // Message For This Window
WPARAM wParam, // Additional Message Information
LPARAM lParam) // Additional Message Information
{
switch (uMsg) // Check For Windows Messages
{
case WM_ACTIVATE: // Watch For Window Activate Message
{
if (!HIWORD(wParam)) // Check Minimization State
{
active=TRUE; // Program Is Active
}
else
{
active=FALSE; // Program Is No Longer Active
}

return 0; // Return To The Message Loop
}

case WM_SYSCOMMAND: // Intercept System Commands
{
switch (wParam) // Check System Calls
{
case SC_SCREENSAVE: // Screensaver Trying To Start?
case SC_MONITORPOWER: // Monitor Trying To Enter Powersave?
return 0; // Prevent From Happening
}
break; // Exit
}

case WM_CLOSE: // Did We Receive A Close Message?
{
PostQuitMessage(0); // Send A Quit Message
return 0; // Jump Back
}

case WM_KEYDOWN: // Is A Key Being Held Down?
{
keys[wParam] = TRUE;// If So, Mark It As TRUE
return 0; // Jump Back
}

case WM_KEYUP: // Has A Key Been Released?
{
keys[wParam] = FALSE;
Return=true; // If So, Mark It As FALSE
return 0; // Jump Back
}

case WM_SIZE: // Resize The OpenGL Window
{
ReSizeGLScene(LOWORD(lParam),HIWORD(lParam)); // LoWord=Width, HiWord=Height
return 0; // Jump Back
}
}// Pass All Unhandled Messages To DefWindowProc
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
//**********************************************************************
int WINAPI WinMain(
HINSTANCE hInstance, // Instance
HINSTANCE hPrevInstance, // Previous Instance
LPSTR lpCmdLine, // Command Line Parameters
int nCmdShow) // Window Show State
{
MSG msg; // Windows Message Structure
BOOL done=FALSE; // Bool Variable To Exit Loop
// Ask The User Which Screen Mode They Prefer
if (MessageBox(NULL,"Are you cool?", "Coolness",MB_YESNO|MB_ICONQUESTION)==IDNO)
{
fullscreen=FALSE; // Windowed Mode
}

// Create Our OpenGL Window
if (!CreateGLWindow("Fire!",640,480,16,fullscreen))
{
return 0; // Quit If Window Was Not Created
}
Load();
while(!done) // Loop That Runs While done=FALSE
{
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting?
{
if (msg.message==WM_QUIT)
// Have We Received A Quit Message?
{
done=TRUE; // If So done=TRUE
}
else // If Not, Deal With Window Messages
{
TranslateMessage(&msg); // Translate The Message
DispatchMessage(&msg); // Dispatch The Message
}
}
else // If There Are No Messages
{
if ((active && !Main( ypers, xpers, sf,selected,status,timer,0)) || keys[VK_ESCAPE]) // Active? Was There A Quit Received?
{
done=TRUE;
}
else // Not Time To Quit, Update Screen
{
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
}
if(keys[VK_SHIFT]&&keys[VK_UP])
{ypers--;}
if(keys[VK_SHIFT]&&keys[VK_DOWN])
{ypers++;}
if(keys[VK_SHIFT]&&keys[VK_LEFT])
{xpers++;}
if(keys[VK_SHIFT]&&keys[VK_RIGHT])
{xpers--;}
if(keys[VK_UP])
{selected[1]++;}
if(keys[VK_DOWN])
{selected[1]--;}
if(keys[VK_LEFT])
{selected[0]--;}
if(keys[VK_RIGHT])
{selected[0]++;}
if(keys[VK_RETURN]&&Return)
{timer++;
Main(ypers, xpers, sf,selected,status,timer,1);
Return=false;
}
if(selected[0]<1)
{selected[0]=1;}
if(selected[1]<1)
{selected[1]=1;}
if(selected[0]>sf-1)
{selected[0]=sf-1;}
if(selected[1]>sf-1)
{selected[1]=sf-1;}
if (keys[VK_F1])
{status=1;
Main(ypers, xpers, sf,selected,status,timer,2);
}
if(keys[VK_F2])
{status=2;
// Main(ypers, xpers, sf,selected,status,timer,2);
}
if(keys[VK_F3])
{status=3;
// Main(ypers, xpers, sf,selected,status,timer,2);
}
if(keys[VK_F4])
{status=4;
// Main(ypers, xpers, sf,selected,status,timer,2);
}
}
}

// Shutdown
KillGLWindow(); // Kill The Window
return (msg.wParam); // Exit The Program
}

Load.h
//loads basis of patches and such
//from text Files
#include<iostream.h>
#include<fstream.h>

vector<int> record;
struct Factors
{ double AmbientTemp;
double WindSpeed;
double WindAngle;
}Forest;

int level[300][300];
int num[10][8][8];
//****************************************************
void Load()
{ ifstream coolestfile;
ifstream coolfile;
ifstream Numbers;
coolfile.open("forest.txt");
for(int x=0; x<=29; x++)
{for(int y=0; y<=29; y++)
{
coolfile>>level[x][y];
}
}

coolestfile.open("Factors.txt");

coolestfile>>Forest.AmbientTemp>>Forest.WindSpeed>>Forest.WindAngle;

Numbers.open("numbers.txt"); //the following loads the text 0 and 1 renderings of numbers for this program
for(int n=0;n<=9; n++) //0-9
{
for(int y=0; y<=7; y++) //8x8
{
for(int x=0; x<=7;x++)
{
Numbers>>num[n][x][y];
}
}
}
coolestfile.close();
coolfile.close();
Numbers.close();
}
//*******************************************************
int getType(int x,int y)
{
return level[x][y];
}
//********************************************************
int getNum(int x,int y,int z)
{
return num[x][y][z];
}
//********************************************************
inline double getAmbient()
{return Forest.AmbientTemp;}
//*********************************************************
inline double getWind()
{return Forest.WindSpeed;}
//********************************************************
inline double getWindAngle()
{ return Forest.WindAngle;}
//********************************************************
void PutOut(int minifires, int totalfires)
{ record.push_back(minifires);
ofstream coolerfile;
coolerfile.open("record.txt",ios::out);
for(int x=0; x<=record.size()-1; x++)
{
coolerfile<<record[x]<<'\n';
}
//coolerfile<<totalfires;
coolerfile.close();
}
//**********************************************************

double WindVectoring(char Component,double xa,double ya,double za,double xstart,double ystart,double zstart,int WindAngle,double WindSpeed,int xb)
{ WindSpeed=15;//3;

WindAngle=120;
double WindtoFireRatio=.8;
double newxa=xa,newya=ya,newza=za;
double legnth=sqrt(pow(xstart-xa,2)+pow(ystart-ya,2));
double feta=abs(xb-WindAngle);
double newLength=legnth+WindtoFireRatio*WindSpeed*cos(convert(feta));
newxa=xstart+newLength*cos(convert(xb));
newya=ystart+newLength*sin(convert(xb));
newza=0;
if(Component=='x')
{return newxa;}
if(Component=='y')
{return newya;}
if(Component=='z')
{return newza;}
}