Skip to content

Commit

Permalink
um bonequinho. (e algumas mudancas pequenas)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlight committed Jul 21, 2011
1 parent 034048d commit e8048b1
Show file tree
Hide file tree
Showing 7 changed files with 19,751 additions and 37 deletions.
18 changes: 4 additions & 14 deletions event.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

#define KM_H (1000.f / 3600.f)

float vel = 60 * KM_H; /* velocidade linear, km/h */
float vel = 6 * KM_H; /* velocidade linear, km/h */
float ang_vel = 0.2 ; /* velocidade angular */

float theta = 0; /* orientacao no plano xz */
Expand All @@ -66,13 +66,13 @@ float light[4] = /* posicao da luz 0 */
char stop_light = 0; /* luz 0 esta parada? */

float light_color[4] = /* cor da luz 1 */
{ 0.5, 0.5, 0.5, 0 };
{ 3, 3, 3, 0 };

float shininess = 0; /* brilho do material */
float diffuse[4]= /* reflectancia difusa */
{ 5, 5, 5, 1 };
{ 1, 1, 1, 1 };
float ambient[4]=
{ 2, 2, 2, 1 };
{ 1, 1, 1, 1 };
float specular[4]= /* reflectancia especular */
{ 0, 0, 0, 1 };

Expand Down Expand Up @@ -120,16 +120,6 @@ int idx()
return ruinas_map[(map_len_v - iv) * map_len_v + iu].r;
}

int m(a, b)
{
return a > b ? a : b;
}

int mmax(int a, int b, int c, int d, int e, int f, int g, int h, int i)
{
return m(a, m(b, m(c, m(d, m(e, m(f, m(g, m(h, i))))))));
}

void update_map_pos()
{
// z (blender x) 100m
Expand Down
2 changes: 0 additions & 2 deletions event.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ extern unsigned map_len_v;

extern unsigned screen_map_len;

extern void (*desenhar_terreno)(void);

extern rgba* ruinas_map;

extern float minha_altura;
Expand Down
58 changes: 39 additions & 19 deletions gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ GLuint ruinas_minimap, ruinas_textura, sky_textura;

int res_x = 800, res_y = 600; /* resolucao padrao */

void (*desenhar_terreno)(void) = ruinasDraw;

// ----- ----------------- ----- //
// | | //
// | MUNDO 3D | //
Expand Down Expand Up @@ -101,7 +99,7 @@ void posicionar_luzes()

void fog() {
if (use_fog) {
glClearColor (0.3, 0.3, 0.3, 0);
glClearColor (0.2, 0.2, 0.2, 0);
glEnable(GL_FOG);
}
else {
Expand All @@ -116,8 +114,8 @@ void sky()
if (use_texture)
glEnable(GL_TEXTURE_2D);

glColor4f(1, 1, 1, 1);
skyDraw();
glColor4f(0.3, 0.3, 0.3, 1);
draw_mesh(MESH_SKY);

glDisable(GL_TEXTURE_2D);
}
Expand All @@ -128,7 +126,7 @@ void terreno()
if (use_texture)
glEnable(GL_TEXTURE_2D);

desenhar_terreno();
draw_mesh(MESH_RUINAS);

glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
Expand Down Expand Up @@ -168,18 +166,40 @@ void draw_light_point()
glEnd();
}

void draw_char()
{
glEnable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);

float shininessq = 100;
float specularq[4]=
{ 2, 2, 2, 1 };

glMaterialfv(GL_FRONT, GL_SHININESS, &shininessq);
glMaterialfv(GL_FRONT, GL_SPECULAR, specularq);

draw_mesh(MESH_CHAR);
glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
}

void desenhar_mundo_3d()
{
glEnable(GL_DEPTH_TEST);

fog();

draw_light_point();

linhas();

glColor3f(0, 0, 100);

terreno();
draw_light_point();
glDisable(GL_FOG);
sky();
draw_char();
glDisable(GL_FOG);

sky();

glDisable(GL_DEPTH_TEST);
}
Expand Down Expand Up @@ -212,15 +232,15 @@ void direcao()

glBegin(GL_TRIANGLES);

glColor4f(0, 1, 0, 0.1);
glColor4f(0, 1, 0, 0.0);

glVertex2f(-5, 15);
glVertex2f(-10, 20);

glColor4f(0, 1, 0, 0.4);
glColor4f(0, 1, 0, 0.2);
glVertex2f(0, 0);

glColor4f(0, 1, 0, 0.1);
glVertex2f(5, 15);
glColor4f(0, 1, 0, 0.0);
glVertex2f(10, 20);

glEnd();

Expand All @@ -238,7 +258,7 @@ void draw_map()
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glColor4f (0.5, 0.8, 1, 0.6);
glColor4f (0.9, 0.8, 1, 0.4);

int m = 5;

Expand Down Expand Up @@ -339,7 +359,6 @@ void initdraw()
glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse);

glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0);
}

void draw()
Expand Down Expand Up @@ -385,19 +404,20 @@ void initgl()
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient);

glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.001);
glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.0001);
glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.1);

glEnable(GL_LIGHT1);

glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.1);
//glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 1);
glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 0.1);

float luz0[]={ 10, 10, 10, 1 };

glLightfv(GL_LIGHT0, GL_DIFFUSE, luz0);
glLightfv(GL_LIGHT0, GL_SPECULAR, luz0);


GLfloat fogColor[4]= {0.3, 0.3, 0.3, 1};
GLfloat fogColor[4]= {0.2, 0.2, 0.2, 1};


glFogi(GL_FOG_MODE, GL_EXP);
Expand Down
Binary file added mesh/char.blend
Binary file not shown.
Loading

0 comments on commit e8048b1

Please sign in to comment.