Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <math.h>
- #include <GL/glut.h>
- #include "RgbImage.h"
- #include "materiais.h"
- //--------------------------------- Definir cores
- #define BLUE 0.0, 0.0, 1.0, 1.0
- #define RED 1.0, 0.0, 0.0, 1.0
- #define YELLOW 1.0, 1.0, 0.0, 1.0
- #define GREEN 0.0, 1.0, 0.0, 1.0
- #define WHITE 1.0, 1.0, 1.0, 1.0
- #define BLACK 0.0, 0.0, 0.0, 1.0
- #define PI 3.14159
- #define SIZE 156
- #define SIZEMINI 96
- #define frand() ((float)rand()/RAND_MAX)
- #define MAX_PARTICULAS 1500
- #define RandomFactor 2.0 //cannot be variable, because it is only use in InitFountain(),
- //zero for perfect physical
- GLint ListNum; //The number of the diplay list
- GLfloat OuterRadius = 1.2;
- GLfloat InnerRadius = 1.0;
- GLint NumOfVerticesStone = 32; //only a quarter of the finally used vertices
- GLfloat StoneHeight = 0.5;
- GLfloat WaterHeight = 0.45;
- GLint Turned = 0;
- bool DoTurn = true;
- bool DoMoveUp = true;
- bool DoUpdateScene = true;
- GLfloat MoveUp = 0.8;
- GLfloat ChangeMoveUp = 0.01;
- //---------------------------------------- Particle attributes
- typedef struct {
- float size; // tamanho
- float life; // vida
- float fade; // fade
- float r, g, b; // color
- GLfloat x, y, z; // posicao
- GLfloat vx, vy, vz; // velocidade
- GLfloat ax, ay, az; // aceleracao
- } Particle;
- //---------------------------------------- fonte agua
- /*struct Svertex{ //posicao
- GLfloat x,y,z;
- };*/
- struct SVertex
- {
- GLfloat x,y,z;
- };
- //It's not the best style to put classes into the main file,
- //but here it is easier for you and me!
- class CDrop
- {
- private:
- GLfloat time; //How many steps the drop was "outside", when it falls into the water, time is set back to 0
- SVertex Speed; //See the doc for explanation of the physics
- GLfloat AccFactor;
- public:
- void SetTime(GLfloat NewTime);
- void SetConstantSpeed (SVertex NewSpeed);
- void SetAccFactor(GLfloat NewAccFactor);
- void ComputeNewPosition(SVertex *PositionVertex); //increments time, gets the new position
- };
- void CDrop::SetConstantSpeed(SVertex NewSpeed)
- {
- Speed = NewSpeed;
- }
- void CDrop::SetAccFactor (GLfloat NewAccFactor)
- {
- AccFactor = NewAccFactor;
- }
- void CDrop::SetTime(GLfloat NewTime)
- {
- time = NewTime;
- }
- void CDrop::ComputeNewPosition(SVertex * PositionVertex)
- {
- SVertex Position;
- time = time+ 1.0;
- //--------------------------------------- Posicao
- Position.x = Speed.x * time;
- Position.y = Speed.y * time - AccFactor * time * time;
- Position.z = Speed.z * time;
- PositionVertex->x = Position.x;
- PositionVertex->y = Position.y;// + WaterHeight;
- PositionVertex->z = Position.z;
- //---------------------------------------- Bate no chao
- if (Position.y < 0.0)
- {
- /*the drop has fallen into the water. The problem is now, that we cannot
- set time to 0.0, because if there are more "DropsPerRay" than "TimeNeeded" (See InitFountain())
- several drops would be seen as one. Check it out.
- */
- time = time - int(time);
- if (time > 0.0) time -= 1.0;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- CDrop * FountainDrops;
- SVertex * FountainVertices;
- GLint Steps = 3; //a fountain has several steps, each with its own height
- GLint RaysPerStep = 8;
- GLint DropsPerRay = 50;
- GLfloat DropsTotal = Steps * RaysPerStep * DropsPerRay;
- GLfloat AngleOfDeepestStep = 80;
- GLfloat AccFactor = 0.011;
- GLfloat GetRandomFloat(GLfloat range)
- {
- return (GLfloat)rand() / (GLfloat)RAND_MAX * range * RandomFactor;
- }
- void InitFountain(void)
- {
- //This function needn't be and isn't speed optimized
- FountainDrops = new CDrop [ 3*8*50 ];//DropsComplete ];
- FountainVertices = new SVertex [ 3*8*50];//DropsComplete ];
- SVertex NewSpeed;
- GLfloat DropAccFactor; //different from AccFactor because of the random change
- GLfloat TimeNeeded;
- GLfloat StepAngle; //Angle, which the ray gets out of the fountain with
- GLfloat RayAngle; //Angle you see when you look down on the fountain
- GLint i,j,k;
- for (k = 0; k <Steps; k++)
- {
- for (j = 0; j < RaysPerStep; j++)
- {
- for (i = 0; i < DropsPerRay; i++)
- {
- //------------------------------------------------- Aceleracao - random
- DropAccFactor = AccFactor + GetRandomFloat(0.0005);
- StepAngle = AngleOfDeepestStep + (90.0-AngleOfDeepestStep)
- * GLfloat(k) / (Steps-1) + GetRandomFloat(0.2+0.8*(Steps-k-1)/(Steps-1));
- RayAngle = (GLfloat)j / (GLfloat)RaysPerStep * 360.0;
- //------------------------------------------------- velocidade - - random
- //This is the speed caused by the step:
- NewSpeed.x = cos ( StepAngle * PI / 180.0) * (0.2+0.04*k);
- NewSpeed.y = sin ( StepAngle * PI / 180.0) * (0.2+0.04*k);
- //This is the speed caused by the ray:
- //for the next computations "NewSpeed.x" is the radius. Care! Dont swap the two
- //lines, because the second one changes NewSpeed.x!
- NewSpeed.z = NewSpeed.x * sin ( RayAngle * PI /180.0);
- NewSpeed.x = NewSpeed.x * cos ( RayAngle * PI /180.0);
- //Calculate how many steps are required, that a drop comes out and falls down again
- //--------------------------------------------------- Tempo de vida util
- TimeNeeded = NewSpeed.y/ DropAccFactor;
- //--------------------------------------------------- Vertex Array
- FountainDrops[i+j*DropsPerRay+k*DropsPerRay*RaysPerStep].SetConstantSpeed ( NewSpeed );
- FountainDrops[i+j*DropsPerRay+k*DropsPerRay*RaysPerStep].SetAccFactor (DropAccFactor);
- FountainDrops[i+j*DropsPerRay+k*DropsPerRay*RaysPerStep].SetTime(TimeNeeded * i / DropsPerRay);
- }
- }
- }
- //Tell OGL that we'll use the vertex array function
- glEnableClientState(GL_VERTEX_ARRAY);
- //Pass the date position
- glVertexPointer( 3, //x,y,z-components
- GL_FLOAT, //data type of SVertex
- 0, //the vertices are tightly packed
- FountainVertices);
- }
- void Reshape(int x, int y)
- {
- if (y == 0 || x == 0) return; //Nothing is visible then, so return
- //Set a new projection matrix
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- //Angle of view:40 degrees
- //Near clipping plane distance: 0.5
- //Far clipping plane distance: 20.0
- gluPerspective(40.0,(GLdouble)x/(GLdouble)y,0.5,20.0);
- glMatrixMode(GL_MODELVIEW);
- glViewport(0,0,x,y); //Use the whole window for rendering
- //Adjust point size to window size
- glPointSize(GLfloat(x)/200.0);
- }
- //================================================================================
- //===========================================================Variaveis e constantes
- //------------------------------------------------------------ Sistema Coordenadas + objectos
- GLint wScreen=1000, hScreen=800; //.. janela (pixeis)
- GLfloat xC=1000.0, yC=1000.0, zC=1000.0; //.. Mundo (unidades mundo)
- //------------------------------------------------------------ Observador
- GLfloat rVisao=-300, aVisao=1*PI, incVisao=0.05;
- GLfloat obsP[] ={rVisao*cos(aVisao), 50, rVisao*sin(aVisao)};
- GLfloat angZoom=90;
- GLfloat incZoom=3;
- GLdouble tx=obsP[0];
- GLdouble ty=0;
- GLdouble tz=obsP[2];
- GLdouble Upx=0;
- GLdouble Upy=1;
- GLdouble Upz=0;
- GLint temp[24];
- //para subir e descer
- GLint flagSED = 0; //1->sobe, 0->inativa, -1 -> desce
- GLdouble sobeEdesce= 0;
- //controlo do fogo de artificio
- GLint flagFA = 0; //1->fogo ativo, 0->inativo
- //controlo colunas
- GLint flagColunas = 0; //1->colunas ativas, 0->inativas
- //auxiliar de camera
- float movementSpeed = 0.05;
- GLfloat forwardVector[3] = {tx - obsP[0],ty - obsP[1], tz - obsP[2]};
- //forwardVector.normalise(); //lol
- //particulas
- Particle particula1[MAX_PARTICULAS];
- //texturas
- GLuint texture[6];
- RgbImage imag;
- static GLfloat arrayTexture[]={
- 0,0, 1,0, 1,1, 0,1, 0,0, 1,0, 1,1, 0,1, 0,0, 1,0, 1,1, 0,1, 0,0, 1,0, 1,1, 0,1, 0,0, 1,0, 1,1, 0,1, 0,0, 1,0, 1,1, 0,1, 0,0, 1,0, 1,1, 0,1, 0,0, 1,0, 1,1, 0,1, 0,0, 1,0, 1,1, 0,1, 0,0, 1,0, 1,1, 0,1, 0,0, 1,0, 1,1, 0,1, 0,0, 1,0, 1,1, 0,1, 0,0, 1,0, 1,1, 0,1
- };
- //=========================================================== FACES DA MESA
- GLboolean frenteVisivel=1;
- static GLuint **ordem = new GLuint*[SIZE/4]();
- static GLuint **ordemMini = new GLuint*[SIZEMINI/4]();
- GLfloat tam=2.0;
- static GLfloat vertices[]={
- -30.000000, -0.000000, 96.000000, 30.000000, -0.000000, 96.000000, 30.000000, 0.000000, 0.000000, -30.000000, 0.000000, 0.000000, -30.000000, 0.000000, 96.000000, 30.000000, 0.000000, 96.000000, 30.000000, 16.000000, 96.000000, -30.000000, 16.000000, 96.000000, -30.000000, 16.000000, 128.000000, 30.000000, 16.000000, 128.000000, 30.000000, 16.000000, 96.000000, -30.000000, 16.000000, 96.000000, -30.000000, 16.000000, 128.000000, 30.000000, 16.000000, 128.000000, 30.000000, 32.000000, 128.000000, -30.000000, 32.000000, 128.000000, -30.000000, 32.000000, 160.000000, 30.000000, 32.000000, 160.000000, 30.000000, 32.000000, 128.000000, -30.000000, 32.000000, 128.000000, -30.000000, 32.000000, 160.000000, 30.000000, 32.000000, 160.000000, 30.000000, 48.000000, 160.000000, -30.000000, 48.000000, 160.000000, -30.000000, 48.000000, 192.000000, 30.000000, 48.000000, 192.000000, 30.000000, 48.000000, 160.000000, -30.000000, 48.000000, 160.000000, -30.000000, 48.000000, 192.000000, 30.000000, 48.000000, 192.000000, 30.000000, 64.000000, 192.000000, -30.000000, 64.000000, 192.000000, -30.000000, 64.000000, 224.000000, 30.000000, 64.000000, 224.000000, 30.000000, 64.000000, 192.000000, -30.000000, 64.000000, 192.000000, -30.000000, 64.000000, 224.000000, 30.000000, 64.000000, 224.000000, 30.000000, 80.000000, 224.000000, -30.000000, 80.000000, 224.000000, -30.000000, 80.000000, 256.000000, 30.000000, 80.000000, 256.000000, 30.000000, 80.000000, 224.000000, -30.000000, 80.000000, 224.000000, -30.000000, 80.000000, 256.000000, 30.000000, 80.000000, 256.000000, 30.000000, 96.000000, 256.000000, -30.000000, 96.000000, 256.000000, -30.000000, 96.000000, 352.000000, 30.000000, 96.000000, 352.000000, 30.000000, 96.000000, 256.000000, -30.000000, 96.000000, 256.000000
- };
- static GLfloat normais[] = {
- 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000
- };
- //------------------------------------------------------------ Cores
- static GLfloat cores[]={
- 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000
- };
- static GLfloat verticesMini[]={
- -30.000000, 0.000000, 0.000000, 30.000000, 0.000000, 0.000000, 30.000000, 16.000000, 0.000000, -30.000000, 16.000000, 0.000000, -30.000000, 16.000000, 32.000000, 30.000000, 16.000000, 32.000000, 30.000000, 16.000000, 0.000000, -30.000000, 16.000000, 0.000000, -30.000000, 16.000000, 32.000000, 30.000000, 16.000000, 32.000000, 30.000000, 32.000000, 32.000000, -30.000000, 32.000000, 32.000000, -30.000000, 32.000000, 64.000000, 30.000000, 32.000000, 64.000000, 30.000000, 32.000000, 32.000000, -30.000000, 32.000000, 32.000000, -30.000000, 32.000000, 64.000000, 30.000000, 32.000000, 64.000000, 30.000000, 48.000000, 64.000000, -30.000000, 48.000000, 64.000000, -30.000000, 48.000000, 96.000000, 30.000000, 48.000000, 96.000000, 30.000000, 48.000000, 64.000000, -30.000000, 48.000000, 64.000000, -30.000000, 48.000000, 96.000000, 30.000000, 48.000000, 96.000000, 30.000000, 64.000000, 96.000000, -30.000000, 64.000000, 96.000000, -30.000000, 64.000000, 192.000000, 30.000000, 64.000000, 192.000000, 30.000000, 64.000000, 96.000000, -30.000000, 64.000000, 96.000000
- };
- static GLfloat normaisMini[] = {
- 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000
- };
- static GLfloat coresMini[]={
- 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000
- };
- //================================================================================
- //=========================================================================== INIT
- void inicializa(int escada)
- {
- glClearColor(BLACK); //………………………………………………………………………………Apagar
- glEnable(GL_DEPTH_TEST); //………………………………………………………………………………Profundidade
- glShadeModel(GL_SMOOTH); //………………………………………………………………………………Interpolacao de cores
- if(escada==1){
- glVertexPointer(3, GL_FLOAT, 0, vertices); //………………………………………Vertex arrays
- glEnableClientState(GL_VERTEX_ARRAY);
- glNormalPointer(GL_FLOAT, 0, normais);// normais
- glEnableClientState(GL_NORMAL_ARRAY);
- glColorPointer(3, GL_FLOAT, 0, cores);
- glEnableClientState(GL_COLOR_ARRAY);
- } if(escada==0) {
- glVertexPointer(3, GL_FLOAT, 0, verticesMini); //………………………………………Vertex arrays
- glEnableClientState(GL_VERTEX_ARRAY);
- glNormalPointer(GL_FLOAT, 0, normaisMini);// normais
- glEnableClientState(GL_NORMAL_ARRAY);
- glColorPointer(3, GL_FLOAT, 0, coresMini);
- glEnableClientState(GL_COLOR_ARRAY);
- } if(escada == 2) { //paredes em volta
- }
- }
- void initTexturas()
- {
- //----------------------------------------- paredes
- glGenTextures(1, &texture[0]);
- glBindTexture(GL_TEXTURE_2D, texture[0]);
- //imag.LoadBmpFile("pedra.bmp");
- RgbImage pedra("pedra.bmp");
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- /*glTexImage2D(GL_TEXTURE_2D, 0, 3,
- imag.GetNumCols(),
- imag.GetNumRows(), 0, GL_RGB, GL_UNSIGNED_BYTE,
- imag.ImageData()); */
- gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB,
- pedra.GetNumCols(),
- pedra.GetNumRows(), GL_RGB, GL_UNSIGNED_BYTE,
- pedra.ImageData());
- //----------------------------------------- tubos
- glGenTextures(1, &texture[1]);
- glBindTexture(GL_TEXTURE_2D, texture[1]);
- //imag.LoadBmpFile("blackMetal.bmp");
- RgbImage blackMetal("blackMetal.bmp");
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- /*glTexImage2D(GL_TEXTURE_2D, 0, 3,
- imag.GetNumCols(),
- imag.GetNumRows(), 0, GL_RGB, GL_UNSIGNED_BYTE,
- imag.ImageData()); */
- gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB,
- blackMetal.GetNumCols(),
- blackMetal.GetNumRows(), GL_RGB, GL_UNSIGNED_BYTE,
- blackMetal.ImageData());
- //----------------------------------------- escadas
- glGenTextures(1, &texture[2]);
- glBindTexture(GL_TEXTURE_2D, texture[2]);
- //imag.LoadBmpFile("gucciGang.bmp");
- RgbImage gucciGang("gucciGang.bmp");
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- /*glTexImage2D(GL_TEXTURE_2D, 0, 3,
- imag.GetNumCols(),
- imag.GetNumRows(), 0, GL_RGB, GL_UNSIGNED_BYTE,
- imag.ImageData());*/
- gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB,
- gucciGang.GetNumCols(),
- gucciGang.GetNumRows(), GL_RGB, GL_UNSIGNED_BYTE,
- gucciGang.ImageData());
- //----------------------------------------- escadasv2
- glGenTextures(1, &texture[3]);
- glBindTexture(GL_TEXTURE_2D, texture[3]);
- //imag.LoadBmpFile("wood.bmp");
- RgbImage wood("wood.bmp");
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- /*glTexImage2D(GL_TEXTURE_2D, 0, 3,
- imag.GetNumCols(),
- imag.GetNumRows(), 0, GL_RGB, GL_UNSIGNED_BYTE,
- imag.ImageData());*/
- gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB,
- wood.GetNumCols(),
- wood.GetNumRows(), GL_RGB, GL_UNSIGNED_BYTE,
- wood.ImageData());
- //-------------------------------------------------fogo artificio
- glGenTextures(1, &texture[4]);
- glBindTexture(GL_TEXTURE_2D, texture[4]);
- //imag.LoadBmpFile("brilho0.bmp");
- RgbImage brilho("fogo.bmp");
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
- /*glTexImage2D(GL_TEXTURE_2D, 0, 3,
- imag.GetNumCols(),
- imag.GetNumRows(), 0, GL_RGB, GL_UNSIGNED_BYTE,
- imag.ImageData()); */
- gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB,
- brilho.GetNumCols(),
- brilho.GetNumRows(), GL_RGB, GL_UNSIGNED_BYTE,
- brilho.ImageData());
- //-------------------------------------------------agua
- glGenTextures(1, &texture[5]);
- glBindTexture(GL_TEXTURE_2D, texture[5]);
- //imag.LoadBmpFile("brilho0.bmp");
- RgbImage water("water.bmp");
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
- /*glTexImage2D(GL_TEXTURE_2D, 0, 3,
- imag.GetNumCols(),
- imag.GetNumRows(), 0, GL_RGB, GL_UNSIGNED_BYTE,
- imag.ImageData()); */
- gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB,
- water.GetNumCols(),
- water.GetNumRows(), GL_RGB, GL_UNSIGNED_BYTE,
- water.ImageData());
- }
- //==========================================================
- void iniParticulas(Particle *particula, int tipo)
- {
- GLfloat v, theta, phi;
- int i;
- GLfloat px, py, pz;
- GLfloat ps;
- /*px = 175.0;
- py = 290.0;
- pz = 200.0;*/
- if(tipo == 1){
- px = 175.0+0.5*frand()*175;
- py = 290.0;//+0.25*frand()*290;
- pz = 200.0+0.5*frand()*200;
- ps = 1.5;
- for(i=0; i<MAX_PARTICULAS; i++) {
- //---------------------------------
- v = 3*frand()+0.02;
- theta = 2.0*frand()*M_PI; // [0..2pi]
- phi = frand()*M_PI; // [0.. pi]
- particula[i].size = ps ; // tamanh de cada particula
- particula[i].x = px ;//+ 0.1*frand()*px; // [-200 200]
- particula[i].y = py ;//+ 0.1*frand()*py; // [-200 200]
- particula[i].z = pz ;//+ 0.1*frand()*pz; // [-200 200]
- particula[i].vx = v * cos(theta) * sin(phi); // esferico
- particula[i].vy = v * cos(phi);
- particula[i].vz = v * sin(theta) * sin(phi);
- particula[i].ax = 0.01f;
- particula[i].ay = -0.01f;
- particula[i].az = 0.015f;
- particula[i].r = 0.1f;
- particula[i].g = 0.1f;
- particula[i].b = 0.1f;
- particula[i].life = 1.0f;
- particula[i].fade = 0.001f; // Em 100=1/0.01 iteracoes desaparece
- }
- }
- else if(tipo == 2){
- px = 20.0;//175.0+0.5*frand()*175;
- py = 10.0;//290.0;//+0.25*frand()*290;
- pz = 0.0;//200.0+0.5*frand()*200;
- ps = 4.5;
- for(i=0; i<MAX_PARTICULAS; i++) {
- //---------------------------------
- v = 3*frand()+0.02;
- theta = 2.0*frand()*M_PI; // [0..2pi]
- phi = frand()*M_PI; // [0.. pi]
- particula[i].size = ps ; // tamanh de cada particula
- particula[i].x = px ;//+ 0.1*frand()*px; // [-200 200]
- particula[i].y = py ;//+ 0.1*frand()*py; // [-200 200]
- particula[i].z = pz ;//+ 0.1*frand()*pz; // [-200 200]
- particula[i].vx = 0;//v ;//* cos(theta) * sin(phi); // esferico
- particula[i].vy = v;
- particula[i].vz = 0;//v ;//* sin(theta) * sin(phi);
- particula[i].ax = 0;//0.01f;
- particula[i].ay = 0;//-0.01f;
- particula[i].az = 0;//0.015f;
- particula[i].r = 0.1f;
- particula[i].g = 0.1f;
- particula[i].b = 0.1f;
- particula[i].life = 1.0f;
- particula[i].fade = 0.001f; // Em 100=1/0.01 iteracoes desaparece
- }
- }
- }
- void showParticulas(Particle *particula, int sistema) {
- int i;
- int numero;
- numero=(int) (frand()*10.0);
- for (i=0; i<MAX_PARTICULAS; i++){
- glColor4f(1,1,1, particula[i].life);
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D,texture[5]);
- glBegin(GL_POINTS);
- glTexCoord2d(0,0); glVertex3f(particula[i].x -particula[i].size, particula[i].y -particula[i].size, particula[i].z);
- glTexCoord2d(1,0); glVertex3f(particula[i].x +particula[i].size+40, particula[i].y -particula[i].size, particula[i].z);
- /*glTexCoord2d(1,1); glVertex3f(particula[i].x +particula[i].size, particula[i].y +particula[i].size, particula[i].z);
- glTexCoord2d(0,1); glVertex3f(particula[i].x -particula[i].size, particula[i].y +particula[i].size, particula[i].z);*/
- glEnd();
- glDisable(GL_TEXTURE_2D);
- particula[i].x += particula[i].vx;
- particula[i].y += particula[i].vy;
- particula[i].z += particula[i].vz;
- particula[i].vx += particula[i].ax;
- particula[i].vy += particula[i].ay;
- particula[i].vz += particula[i].az;
- particula[i].life -= particula[i].fade;
- }
- }
- void DrawFountain(void)
- {
- glColor4f(0.8,0.8,0.8,0.8);
- for (int i = 0; i < DropsTotal; i++)
- {
- FountainDrops[i].ComputeNewPosition(&FountainVertices[i]);
- }
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D,texture[5]);
- glDrawArrays(GL_POINTS, 0, DropsTotal); // desenhar pontos
- glDisable(GL_TEXTURE_2D);
- }
- void drawEixos()
- {
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Eixo X
- glColor4f(RED);
- glBegin(GL_LINES);
- glVertex3i( 0, 0, 0);
- glVertex3i(200, 0, 0);
- glEnd();
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Eixo Y
- glColor4f(GREEN);
- glBegin(GL_LINES);
- glVertex3i(0, 0, 0);
- glVertex3i(0, 200, 0);
- glEnd();
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Eixo Z
- glColor4f(BLUE);
- glBegin(GL_LINES);
- glVertex3i( 0, 0, 0);
- glVertex3i( 0, 0, 200);
- glEnd();
- }
- void tubos(){
- glClearColor(BLACK); //………………………………………………………………………………Apagar
- glEnable(GL_DEPTH_TEST); //………………………………………………………………………………Profundidade
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D,texture[1]);
- int acum = 0;
- int i = 0;
- //PARTE FRENTE
- glPushMatrix();
- while(acum<=352){
- glBegin(GL_POLYGON);
- glTexCoord2f ( 0, 0 ); glVertex3f( -30, 0+sobeEdesce, acum );
- acum += temp[i];
- glTexCoord2f ( 1, 0 ); glVertex3f( -30, 0+sobeEdesce, acum );
- glTexCoord2f ( 0, 1 ); glVertex3f( -30, 325, acum);
- glTexCoord2f ( 1, 1 ); glVertex3f( -30, 325, acum-temp[i] );
- glEnd();
- //printf("%d\t", temp);
- acum += temp[i];
- i++;
- //printf("%d\t", temp);
- }
- i=0;
- // printf("parte da frente -> %d\t", aux); aux = 0;
- glPopMatrix();
- //PARTE TRAS
- glPushMatrix();
- acum = -30;
- while(acum<=220 + 30){
- glBegin(GL_POLYGON);
- glTexCoord2f ( 0, 0 ); glVertex3f( acum, 0+sobeEdesce, 352 );
- acum += temp[i];
- glTexCoord2f ( 1, 0 ); glVertex3f( acum, 0+sobeEdesce, 352 );
- glTexCoord2f ( 0, 1 ); glVertex3f( acum, 325, 352);
- glTexCoord2f ( 1, 1 ); glVertex3f( acum-temp[i], 325, 352 );
- glEnd();
- //printf("%d\t", temp);
- acum += temp[i];
- //printf("%d\t", temp);
- i++;
- }
- i=0;
- //printf("parte da lado -> %d\t", aux); aux = 0;
- glPopMatrix();
- //PARTE TRAS2
- glPushMatrix();
- acum = 0;
- while(acum<=352){
- glBegin(GL_POLYGON);
- glTexCoord2f ( 0, 0 ); glVertex3f( 250, 0+sobeEdesce, acum );
- acum += temp[i];
- glTexCoord2f ( 0, 1 ); glVertex3f( 250, 0+sobeEdesce, acum );
- glTexCoord2f ( 1, 0 ); glVertex3f( 250, 325, acum);
- glTexCoord2f ( 1, 1 ); glVertex3f( 250, 325, acum-temp[i] );
- glEnd();
- //printf("%d\t", temp);
- acum += temp[i];
- i++;
- //printf("%d\t", temp);
- }
- i=0;
- glPopMatrix();
- //PARTE FRENTE2 LOL
- glPushMatrix();
- acum = -30;
- while(acum<=220 + 30){
- glBegin(GL_POLYGON);
- glTexCoord2f ( 0, 0 );glVertex3f( acum, 0+sobeEdesce, 0 );
- acum += temp[i];
- glTexCoord2f ( 0, 1 );glVertex3f( acum, 0+sobeEdesce, 0 );
- glTexCoord2f ( 1, 0 );glVertex3f( acum, 325, 0);
- glTexCoord2f ( 1, 1 ); glVertex3f( acum-temp[i], 325, 0 );
- glEnd();
- //printf("%d\t", temp);
- acum += temp[i];
- i++;
- //printf("%d\t", temp);
- }
- i=0;
- glDisable(GL_TEXTURE_2D);
- glPopMatrix();
- }
- void cenario(){
- glClearColor(WHITE); //………………………………………………………………………………Apagar
- glEnable(GL_DEPTH_TEST); //………………………………………………………………………………Profundidade
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D,texture[0]);
- glPushMatrix();
- glTranslatef(0,162.5,100); //nivelar
- glScalef( 650.0, 650.0/2, 650.0 );
- glBegin(GL_POLYGON);
- glTexCoord2f ( 0, 0 ); glVertex3f( 0.5, -0.5, -0.5 );
- glTexCoord2f ( 1, 0 ); glVertex3f( 0.5, 0.5, -0.5 );
- glTexCoord2f ( 0, 1 ); glVertex3f( -0.5, 0.5, -0.5 );
- glTexCoord2f ( 1, 1 ); glVertex3f( -0.5, -0.5, -0.5 );
- glEnd();
- glBegin(GL_POLYGON);
- glTexCoord2f ( 0, 0 ); glVertex3f( 0.5, -0.5, 0.5 );
- glTexCoord2f ( 1, 0 ); glVertex3f( 0.5, 0.5, 0.5 );
- glTexCoord2f ( 0, 1 ); glVertex3f( -0.5, 0.5, 0.5 );
- glTexCoord2f ( 1, 1 ); glVertex3f( -0.5, -0.5, 0.5 );
- glEnd();
- glBegin(GL_POLYGON);
- glTexCoord2f ( 0, 0 ); glVertex3f( 0.5, -0.5, -0.5 );
- glTexCoord2f ( 1, 0 ); glVertex3f( 0.5, 0.5, -0.5 );
- glTexCoord2f ( 0, 1 ); glVertex3f( 0.5, 0.5, 0.5 );
- glTexCoord2f ( 1, 1 ); glVertex3f( 0.5, -0.5, 0.5 );
- glEnd();
- glBegin(GL_POLYGON);
- glTexCoord2f ( 0, 0 ); glVertex3f( -0.5, -0.5, 0.5 );
- glTexCoord2f ( 1, 0 ); glVertex3f( -0.5, 0.5, 0.5 );
- glTexCoord2f ( 0, 1 ); glVertex3f( -0.5, 0.5, -0.5 );
- glTexCoord2f ( 1, 1 ); glVertex3f( -0.5, -0.5, -0.5 );
- glEnd();
- glBegin(GL_POLYGON);
- glTexCoord2f ( 0, 0 ); glVertex3f( 0.5, 0.5, 0.5 );
- glTexCoord2f ( 1, 0 ); glVertex3f( 0.5, 0.5, -0.5 );
- glTexCoord2f ( 0, 1 ); glVertex3f( -0.5, 0.5, -0.5 );
- glTexCoord2f ( 1, 1 );glVertex3f( -0.5, 0.5, 0.5 );
- glEnd();
- glBegin(GL_POLYGON);
- glTexCoord2f ( 0, 0 ); glVertex3f( 0.5, -0.5, -0.5 );
- glTexCoord2f ( 1, 0 ); glVertex3f( 0.5, -0.5, 0.5 );
- glTexCoord2f ( 0, 1 ); glVertex3f( -0.5, -0.5, 0.5 );
- glTexCoord2f ( 1, 1 ); glVertex3f( -0.5, -0.5, -0.5 );
- glEnd();
- glPopMatrix();
- glDisable(GL_TEXTURE_2D);
- //tubos
- tubos();
- }
- void drawScene(){
- //subir e descer os tubos que nao sao tubos
- //cenario
- cenario();
- inicializa(1);
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D,texture[2]);
- //em frente
- glPushMatrix();
- //glTranslatef(40, 0, 0);
- for(int i=0; i<SIZE/4; i++) {
- if(i%2==0)
- glBindTexture(GL_TEXTURE_2D,texture[2]);
- else
- glBindTexture(GL_TEXTURE_2D,texture[3]);
- glDrawElements(GL_POLYGON, 4, GL_UNSIGNED_INT, ordem[i]);
- }
- glPopMatrix();
- //para tras
- glPushMatrix();
- glTranslatef(222, 160, 351);
- glRotatef(180,0,1,0);
- for(int i=0; i<SIZE/4; i++) {
- if(i%2==0)
- glBindTexture(GL_TEXTURE_2D,texture[2]);
- else
- glBindTexture(GL_TEXTURE_2D,texture[3]);
- glDrawElements(GL_POLYGON, 4, GL_UNSIGNED_INT, ordem[i]);
- }
- glPopMatrix();
- //para o lado
- inicializa(0);
- glPushMatrix();
- glTranslatef(30, 96, 322);
- glRotatef(90,0,1,0);
- for(int i=0; i<SIZEMINI/4; i++) {
- if(i%2==0)
- glBindTexture(GL_TEXTURE_2D,texture[2]);
- else
- glBindTexture(GL_TEXTURE_2D,texture[3]);
- glDrawElements(GL_POLYGON, 4, GL_UNSIGNED_INT, ordem[i]);
- }
- glPopMatrix();
- }
- void display(void){
- //================================================================= APaga ecran/profundidade
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
- //3D
- //glViewport (0, 0, wScreen, hScreen); // ESQUECER PoR AGORA
- glMatrixMode(GL_PROJECTION); // ESQUECER PoR AGORA
- glLoadIdentity(); // ESQUECER PoR AGORA
- //glOrtho( -20, 20, -20, 20, -20, 20);
- gluPerspective(angZoom, (float)wScreen/hScreen, 0.1, 3*zC); // ESQUECER PoR AGORA
- glMatrixMode(GL_MODELVIEW); // ESQUECER PoR AGORA
- glLoadIdentity();
- //-------------------------------------------------------------- observador
- gluLookAt(obsP[0], obsP[1], obsP[2], tx,ty,tz, Upx, Upy, Upz);
- //drawEixos();
- drawScene();
- showParticulas(particula1, 1);
- DrawFountain();
- glFlush();
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Actualizacao
- glutSwapBuffers();
- }
- void keyboard(unsigned char key, int x, int y){
- forwardVector[0] = tx - obsP[0];
- forwardVector[1] = ty - obsP[1];
- forwardVector[2] = tz - obsP[2];
- switch (key) {
- case 'W':
- case 'w':
- //moving forward :
- obsP[0] += forwardVector[0] * movementSpeed;
- obsP[1] += forwardVector[1] * movementSpeed;
- obsP[2] += forwardVector[2] * movementSpeed;
- tx += forwardVector[0] * movementSpeed;
- ty += forwardVector[1] * movementSpeed;
- tz += forwardVector[2] * movementSpeed;
- glutPostRedisplay();
- break;
- case 'S':
- case 's':
- //moving backward :
- obsP[0] -= forwardVector[0] * movementSpeed;
- obsP[1] -= forwardVector[1] * movementSpeed;
- obsP[2] -= forwardVector[2] * movementSpeed;
- tx -= forwardVector[0] * movementSpeed;
- ty -= forwardVector[1] * movementSpeed;
- tz -= forwardVector[2] * movementSpeed;
- glutPostRedisplay();
- break;
- case 'U':
- case 'u':
- if(flagSED == 1) {
- flagSED = 0;
- } else {
- flagSED = 1;
- }
- glutPostRedisplay();
- break;
- case 'D':
- case 'd':
- if(flagSED == -1) {
- flagSED = 0;
- } else {
- flagSED = -1;
- }
- glutPostRedisplay();
- break;
- case 'F':
- case 'f':
- if(flagFA == 1) {
- flagFA = 0;
- } else {
- flagFA = 1;
- }
- case 'E':
- case 'e':
- if(flagColunas == 1) {
- flagColunas = 0;
- } else {
- flagColunas = 1;
- }
- break;
- //--------------------------- Escape
- case 27:
- exit(0);
- break;
- }
- }
- void teclasNotAscii(int key, int x, int y){
- if(key == GLUT_KEY_UP){
- //aVisaoAux = (aVisaoAux + 0.1) ;
- //printf("antes -> %f\n", ty);
- ty = ty + rVisao*sin(-0.1);
- //printf("depois -> %f\n", ty);
- }
- if(key == GLUT_KEY_DOWN){
- //aVisaoAux = (aVisaoAux - 0.1) ;
- ty = ty + rVisao*sin(0.1);
- }
- if(key == GLUT_KEY_LEFT) {
- aVisao = (aVisao - 0.1) ;
- //printf("antes -> %f\n", tx);
- tx = obsP[0] + rVisao*cos(aVisao);
- tz = obsP[2] + rVisao*sin(aVisao);
- //printf("depois -> %f\n", tx);
- }
- if(key == GLUT_KEY_RIGHT){
- aVisao = (aVisao + 0.1) ;
- tx =obsP[0] + rVisao*cos(aVisao);
- tz =obsP[2] + rVisao*sin(aVisao);
- }
- glutPostRedisplay();
- }
- void Timer(int value) {
- if(flagSED == 1) { //vai subir
- if(sobeEdesce<315) {
- sobeEdesce += 8;
- }
- else {
- flagSED = 0;
- }
- }
- if(flagSED == -1) { //vai descer
- if(sobeEdesce>0) {
- sobeEdesce -= 8;
- }
- else {
- flagSED = 0;
- }
- }
- glutPostRedisplay();
- glutTimerFunc(100, Timer, 1);
- }
- //loop do fogo de artificio
- void TimerFogo(int value)
- {
- if(flagFA == 1) { //vai comecar o fogo
- iniParticulas(particula1, 1);
- }
- else {
- flagFA = 0;
- }
- glutPostRedisplay();
- glutTimerFunc(3500 ,TimerFogo, 1); //.. Espera msecDelay milisegundos
- }
- //loop do fogo de artificio
- void TimerColunas(int value)
- {
- if(flagColunas == 1) { //vai comecar o fogo
- iniParticulas(particula1, 2);
- }
- else {
- flagColunas = 0;
- }
- glutPostRedisplay();
- glutTimerFunc(3500 ,TimerColunas, 1); //.. Espera msecDelay milisegundos
- }
- //======================================================= MAIN
- //======================================================= MAIN
- int main(int argc, char** argv){
- glutInit(&argc, argv);
- glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
- glutInitWindowSize (wScreen, hScreen);
- glutInitWindowPosition (300, 100);
- glutCreateWindow ("|Fogo-artificio:'f'| |Observador:'SETAS'| |Andar-'w/s'| |Colunas-'e'| |Barras -'u/d'| ");
- glTexCoordPointer(2, GL_FLOAT, 0, arrayTexture);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnable(GL_DEPTH_TEST);
- glClearColor(0.1,0.1,0.1,0.0);
- glEnable(GL_POINT_SMOOTH);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- //escadas grandes
- int acum = 0;
- for(int i = 0; i < SIZE/4; i++){
- ordem[i] = new GLuint[4];
- }
- for(int i = 0; i<SIZE/4; i++) {
- for(int j=0; j<4; j++){
- ordem[i][j] = acum;
- acum++;
- }
- }
- //escadas pequenas
- acum = 0;
- for(int i = 0; i < SIZEMINI/4; i++){
- ordemMini[i] = new GLuint[4];
- }
- for(int i = 0; i<SIZEMINI/4; i++) {
- for(int j=0; j<4; j++){
- ordemMini[i][j] = acum;
- acum++;
- }
- }
- //aleatorios para tubos
- for(int i=0; i<24; i++){
- temp[i]= rand() %10 + 8;
- }
- initTexturas();
- InitFountain();
- glutSpecialFunc(teclasNotAscii);
- glutDisplayFunc(display);
- glutReshapeFunc(Reshape);
- glutKeyboardFunc(keyboard);
- //motor
- glutTimerFunc(100, Timer, 1);
- glutTimerFunc(3500, TimerFogo, 1);
- glutTimerFunc(3500, TimerColunas, 1);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement