back to the text
/*----------------------------------------------------
 * 
 * FIRE.c - app variables and draw functions
 * 
 *--------------------------------------------------*/

#include "INCLUDES.h"

static int fireA, fireC;
static float fireB=1, fireD=4;
static int eye = 0;
static int fireCNT=0, fireE=40;
int firestrobe=1, firemist_move=-15;

void atmosphere();
void firewall();
void pyramid();
void strobe_lines();
void greenmist();

/*--------------------------------------------------*/
/*--------------------------------------------------*/
/*--------------------------------------------------*/
/*--------------------------------------------------*/
/*----------------------------------------------------
 * 
 * DRAW functions
 * 
 *--------------------------------------------------*/

void draw_FIRE()
{
	float dummy[1] = {0.0};							
	float fog[5] = {10.0, 40.0, 1.0, 0.2, 0.0};
	/* controls  - {start,thickest,R,G,B    }*/		
	fogvertex(FG_VTX_LIN, fog);
	cpack(0xff000080); clear(); zclear();

	rotate(-200,'x');
	translate(0.0, .75, -4.0); 
	scale(0.65, 0.65, 0.65);
	
	fogvertex(FG_ON,dummy); /* turns fog function ON */
	
	/*----------------------------*/
		
	atmosphere();

	/*----------------------------*/
	
		texbind(TX_TEXTURE_0, img_list[fireA]);												
	firewall();
		texbind(0, 0);
		fogvertex(FG_OFF,dummy); 
	/*----------------------------*/
		
		blendfunction(BF_SA, BF_MSA);      
		texbind(TX_TEXTURE_0, img_list[fireC]);
	pyramid();
		texbind(0, 0);
		blendfunction(BF_ONE, BF_ZERO);

	/*----------------------------*/
		
	strobe_lines();
	
	/*----------------------------*/
		
		blendfunction(BF_SA, BF_MSA);
		texbind(TX_TEXTURE_0, img_list[fireE]);
	greenmist();
		texbind(0, 0);
		blendfunction(BF_ONE, BF_ZERO);					
		
	/*----------------------------*/
		
	if(eye)
	{
		firestrobe = firestrobe + 1;
		if (firestrobe==5) firestrobe = 1;
			
		firemist_move = firemist_move + 1;
		if (firemist_move==15) firemist_move =-15;

		fireB = fireB + .4;									
		if (fireB < 2 && fireB > 1) fireA = 34;
			else if (fireB < 3 && fireB > 2) fireA = 35;
			else if (fireB < 4 && fireB > 3) fireA = 36;
			else if (fireB >= 4)
			{
				fireA = 34;
				fireB = 1;
			}
			
		fireD = fireD + .4;									
		if (fireD < 5 && fireD > 4) fireC = 37;
			else if (fireD < 6 && fireD > 5) fireC = 38;
			else if (fireD < 7 && fireD > 6) fireC = 39;
			else if (fireD >= 7)
			{
				fireC = 37;
				fireD = 4;
			}
			
	}
	eye=!eye;
	fireCNT = fireCNT + 4;
	if (fireCNT >3500) fireCNT = 0;
}

/*--------------------------------------------------*/

void atmosphere()
{
	pushmatrix();							
		translate(0.0, -50.0, 00.0);
		scale(100.0, 100.0, 100.0);
		callobj(GLobjCubeIndex);
	popmatrix();
}

/*--------------------------------------------------*/

void firewall()
{											
cpack(0xffffffff);
pushmatrix();
	rotate(-450,'y');
	pushmatrix(); /* frontwall - middle */
		translate(0.0, 5.0, -10.0);		
		scale(20.0, 20.0, 0.0);
		callobj(GLobjSqrIndex);
	popmatrix();
	
	pushmatrix(); /* sidewall - middle */
		translate(-10.0, 5.0, 0.0);		
		rotate(900,'y');				
		scale(-20.0, 20.0, 0.0);
		callobj(GLobjSqrIndex);
	popmatrix();
	
	pushmatrix(); /* frontwall - top */
		translate(0.0, 35, -5.0);
		rotate(200,'x');		
		scale(20.0, -20.0, 0.0);
		callobj(GLobjSqrIndex);
	popmatrix();
	
	pushmatrix(); /* sidewall - top */
		translate(-5.0, 35, 0.0);		
		rotate(-200,'z');
		rotate(900,'y');				
		scale(-20.0, -20.0, 0.0);
		callobj(GLobjSqrIndex);
	popmatrix();
	
	pushmatrix(); /* frontwall - bottom */
		translate(0.0, -25, -5.0);
		rotate(-200,'x');		
		scale(20.0, -20.0, 0.0);
		callobj(GLobjSqrIndex);
	popmatrix();
	
	pushmatrix(); /* sidewall - bottom */
		translate(-5.0, -25, 0.0);		
		rotate(200,'z');
		rotate(900,'y');				
		scale(-20.0, -20.0, 0.0);
		callobj(GLobjSqrIndex);
	popmatrix();
	
popmatrix();
}

/*--------------------------------------------------*/
	
void pyramid()
{
pushmatrix();
	pushmatrix();
		translate(0.0, -3.0, -4.5);
		rotate(-fireCNT,'y');
		scale(2.0, 1.0, 2.0);
		callobj(GLobjPyrIndex);
	popmatrix();
	
	pushmatrix();
		translate(0.0, 13.0, -4.5);
		rotate(fireCNT,'y');
		scale(2.0, -1.0, 2.0);
		callobj(GLobjPyrIndex);
	popmatrix();
popmatrix();

}

/*--------------------------------------------------*/

void strobe_lines()
{  
	if (firestrobe==1)cpack(0xffffff);
	else cpack(0x000000);
	pushmatrix();
		translate(7.0, 5.0, -5.0);
		scale(5.0, .1, 0.0);
		callobj(GLobjSqrIndex);
	popmatrix();
	
	pushmatrix();
		translate(-7.0, 5.0, -5.0);
		scale(5.0, .1, 0.0);
		callobj(GLobjSqrIndex);
	popmatrix();
}

/*--------------------------------------------------*/
	
void greenmist()
{		
	cpack(0xa0ffffff);
	pushmatrix();
		translate(0.0, 0.0, firemist_move);
		translate(0.0, 5.0, 0.0);
		scale(7.0, 2.0, 0.0);
		
		callobj(GLobjSqrIndex);
	popmatrix();	
}   

/*--------------------------------------------------*/