Stratos: Punto de Encuentro de Desarrolladores

¡Bienvenido a Stratos!

Acceder

Foros





Un codigo muy tonto muy tonto le dice a otro...

Iniciado por Tei, 02 de Mayo de 2003, 12:51:34 AM

« anterior - próximo »

Tei

                                Esto es un codigo muy tonto para hacer heighfields en un motor de quake. Dibujo el heighfield mediante una displaylist. ¿Deberia checkar algo antes de hacerlo asi?.
Uso dos texturas combinas que crean un paisaje sicodelico muy efectivo.
..aunque igual se os ocurre un hack o un cambio pequeño para hacer mas oscuros los valles y mas claras las montañas (supongo que podria ser facil).

Yo no soy un gran programador asi que casi cualquier sugerencia que me podais hacer vale su peso en oro.

Por si quereis ver algun screenshot de que genera esto, aqui teneis algo:
http://forum.moddb.com/5/2457/


[pre][tt]

#include "quakedef.h"





#ifndef gl_mtextype

#define gl_mtextype GL_TEXTURE0_SGIS

#endif





/* SGIS_multitexture */

#define GL_SELECTED_TEXTURE_SGIS            0x835C

#define GL_MAX_TEXTURES_SGIS                0x835D

#define GL_TEXTURE0_SGIS                    0x835E

#define GL_TEXTURE1_SGIS                    0x835F

#define GL_TEXTURE2_SGIS                    0x8360

#define GL_TEXTURE3_SGIS                    0x8361



#define XMAX 514

#define YMAX XMAX

#define SYZE (YMAX*XMAX)





typedef struct env_s

{

char filename[MAX_QPATH];       //file path

vec3_t mins, maxs;

int width, height;         //Number of x/y coords

byte heightdata[SYZE];         //The actual coordinates.

#define INGROUND 1

byte flags[SYZE];//

vec3_t rotation, origin, scale;



float texres, detailtexres;

int texture, detailtexture;



float waterheight, wavesize, waveheight;   //At wat height should the (sine-wave) water be based, how broad should the waves be, and how big should they be?

float watertexres, waterdetailtexres;

int watertexture, waterdetailtexture;    //Water textures



int numneighbours;

struct env_s *neighbours[1];      //neighbouring terrains

} env_t;



void ENV_Init(void);

void ENV_Load(model_t *mod, byte *buf);

void ENV_ClipMoveToEntity(edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, trace_t *trace);

void ENV_CheckWater(edict_t *ent);

void ENV_SetContentsColor(vec3_t origin);

void ENV_DrawScene(void);





typedef struct

{

vec3_t rotation, origin;

vec3_t scale;



float terraintexres, terraindetailtexres;

float watertexres, waterdetailtexres;

float waterheight;



char heightmaptexture[32];

char terraintexture[32];

char terraindetailtexture[32];

char watertexture[32];

char waterdetailtexture[32];



int numneighbours;

} env0area_t;





//extern qboolean texcombineable;



cvar_t env_dist = {"env_dist", "8", true};

cvar_t env_detaildist = {"env_detaildist", "1", true};



cvar_t env_z = {"env_z", "-4096", true};

cvar_t env_x = {"env_x", "-4096", true};

cvar_t env_y = {"env_y", "-500", true};





cvar_t env_sx = {"env_sx", "20", true};

cvar_t env_sy = {"env_sy", "20", true};

cvar_t env_sz = {"env_sz", "4", true};



cvar_t env_hiddenworld = {"env_hiddenworld", "0", true};



cvar_t env_sdetail = {"env_sdetail", "40", true};





cvar_t env_stex = {"env_stex", "1", true};

cvar_t env_compiled = {"env_compiled", "1", true};//compile mode



env_t terrain;







void R_SetEnvTerrain (char *name)

{

strcpy(terrain.filename, name);



ENV_Load(cl.worldmodel, COM_LoadTempFile(terrain.filename));//Tei: Load the env

}



void LoadEnv_f (void)

{

// int k;//,j,len;



switch (Cmd_Argc())

{

case 1:

 if (terrain.filename[0])

  Con_Printf("Current env: %sn", terrain.filename);

 else

  Con_Printf("Error: No env has been setn");

 break;

case 2:

 R_SetEnvTerrain(Cmd_Argv(1));





 break;

default:

 Con_Printf("Usage: loadenv envnamen");

 break;

}

}





void Env_Print_f (void)

{

Con_Printf("x/y/z: %f %f %fn",env_x.value,env_y.value,env_z.value);

Con_Printf("sx/sy/sz: %f %f %fn",env_sx.value,env_sy.value,env_sz.value);





}





void ENV_Init(void)

{

//CVar initalisations and such

Cvar_RegisterVariable(&env_dist);

Cvar_RegisterVariable(&env_detaildist);



Cvar_RegisterVariable(&env_x);

Cvar_RegisterVariable(&env_y);

Cvar_RegisterVariable(&env_z);



Cvar_RegisterVariable(&env_sx);

Cvar_RegisterVariable(&env_sy);

Cvar_RegisterVariable(&env_sz);



Cvar_RegisterVariable(&env_sdetail);

Cvar_RegisterVariable(&env_stex);

Cvar_RegisterVariable(&env_hiddenworld);//dont use world bmodel

Cvar_RegisterVariable(&env_compiled);





Cmd_AddCommand ("loadenv",LoadEnv_f);

Cmd_AddCommand ("env",Env_Print_f);

}





void ENV_LoadENV(model_t *mod, byte *buf)

{

// int j,k;

int x,y,pc;

vec3_t org;

char hacked[MAX_QPATH];



if(!buf)

 return;



//Init



if(!mod)

{

 Con_Printf("Not env model loaded errorn");

 return;

}





if (mod->environment)

{

 Con_Printf("Model already has enviromentn");

 return;

}



COM_FileBase(mod->name,hacked);

COM_StripExtension(hacked, hacked);

Con_Printf("mod name %sn",hacked);





VectorCopy(vec3_origin, terrain.rotation);

VectorCopy(vec3_origin, terrain.origin);





terrain.width = XMAX;

terrain.height = YMAX;



terrain.texture = loadtextureimage(va("terra/terra_%s",hacked),  true,true);

terrain.detailtexture = loadtextureimage( va("terra/detail_%s",hacked), true,true);



//terrain.watertexture = loadtextureimage( "terra/water.jpg",  true,true);

//terrain.waterdetailtexture = loadtextureimage( "terra/cubemap.tga",   true,true);



terrain.texres = 128;//area->terraintexres;

terrain.detailtexres = 16;//area->terraindetailtexres/10;

terrain.watertexres = 8;//area->watertexres/80;

terrain.waterdetailtexres = 8;// area->waterdetailtexres/20;

terrain.waterheight = 25;//65//area->waterheight;



terrain.scale[0] = 256.0f;

terrain.scale[1] = 256.0f;

terrain.scale[2] = 4;//3.0f



//terrain.origin[0] = terrain.width * terrain.scale[0] * 0.5 * (-1);

//terrain.origin[1] = terrain.height * terrain.scale[1] * 0.5 * (-1);



VectorCopy(vec3_origin, terrain.mins);

terrain.maxs[0] = terrain.origin[0] + terrain.scale[0] * terrain.width;

terrain.maxs[1] = terrain.origin[1] + terrain.scale[1] * terrain.height;

terrain.maxs[2] = terrain.origin[2] + terrain.scale[2] * 256;



/*

for (j=0;j<XMAX;j++)

 {

  for (k=0;k<XMAX;k++) Con_Printf("%d ",buf[j+k*XMAX]);

  Con_Printf("|n");

 }

*/



//Con_Printf("size: %dn",SYZE);

//strncpy(terrain.heightdata,buf,SYZE);



memcpy(terrain.heightdata,buf,SYZE);



/*

for(x=0;x<XMAX;x++)

{

 for(y=0;y<YMAX;y++)

 {

  org[0] = x * env_sx.value + env_x.value;

  org[1] = y * env_sy.value + env_y.value;

  org[2] = buf[x+y*XMAX] * env_sz.value + env_z.value;



  pc = Mod_PointInLeaf(org, cl.worldmodel)->contents;



  if (pc == CONTENTS_SOLID)

  {

   terrain.flags[x+y*XMAX] = INGROUND;

  // Con_Printf("#");

  }

  else

  {

   terrain.flags[x+y*XMAX] = 0; //force 0's

  // Con_Printf("O");

  }





 }

//  Con_Printf("n");

}

*/



mod->environment = &



//TODO: free buf?

}



void ENV_Load(model_t *mod, byte *buf)

{

if(!buf)

{

 Con_Printf("----- NO buff -----n");

 return;

}



ENV_LoadENV(mod, buf);



Con_Printf("----- ENV Environment loaded -----n");

}





void R_ParticleCircle (vec3_t origin);



void ENV_ClipMoveToEntity(edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, trace_t *trace)

{

env_t *env;

int pos[3];

float lh;

static float lastlh=0;

int i, isplayer= false;





if (ent)

{

 lh = ent->v.mins[2];

}

else

 lh = 0;



//if (ent && lh!=lastlh)

//{

// Con_Printf("[%s] -> %fn",ent->v.model + pr_strings, lh);

// lastlh = lh;

//}



//if (ent && *(ent->v.model + pr_strings)=='p')

// Con_Printf("map!n");

//else

//if (ent)

// Con_Printf("car '%c'n",(ent->v.model + pr_strings));

//else

// Con_Printf("no ent!n");



if (lh==-24)

 isplayer = true;



trace->startsolid = false;

trace->fraction = 1;

trace->allsolid = false;

trace->endcontents = CONTENTS_EMPTY;

trace->ent = ent; //????

VectorCopy(end,trace->endpos);



if (!sv.worldmodel)

 return;



if(!(env = sv.worldmodel->environment))

 return;



for(i = 0; i < 3; i++)

 pos[i] = (trace->endpos[i] - env->origin[i])/env->scale[i];//* env_sx.value;

//pos[0] = (trace->endpos[0] - env->origin[0])/env->scale[0] / env_sx.value;

//pos[1] = (trace->endpos[1] - env->origin[1])/env->scale[1] / env_sy.value;

//pos[2] = (trace->endpos[2] - env->origin[2])/env->scale[2] / env_sz.value;



//pos[1] *= env_sx.value;

//pos[0] *= env_sy.value;



//good hack

pos[2] += lh;//break compatibility for env_sz but is smoother



if(pos[0] < 0 || pos[0] > env->width ||

   pos[1] < 0 || pos[1] > env->height)

   return;



if(pos[2] <= env->heightdata[pos[0] * env->height + pos[1]])

{

 trace->endpos[2] = (env->heightdata[pos[0] * env->height + pos[1]] + env->origin[2])*env->scale[2];

 

 if (trace->endpos[2]>start[2])

 {

  trace->startcontents = CONTENTS_SOLID;

  trace->startsolid = true;

  trace->endcontents = CONTENTS_SOLID;

  //trace->allsolid = true; //??

  trace->fraction = 0;  

 }

 else

 //if (trace->endpos[2]>end[2])

 {

  trace->endcontents = CONTENTS_SOLID;

  trace->startcontents = CONTENTS_EMPTY;

 }





 if (trace->fraction)

  trace->fraction *= abs(start[2] - end[2]) * 1.0f / abs(start[2] - trace->endpos[2]);



 trace->plane.normal[0] = 0;

 trace->plane.normal[1] = 0;

 trace->plane.normal[2] = 1;

}



//trace->endpos[2] -= 1;



if(trace->fraction < 1)

 R_ParticleCircle (trace->endpos);



if (trace->fraction>1)

{

 trace->fraction = 1;

 if(ent )

  ent->v.flags = (int)ent->v.flags & ~FL_ONGROUND;

}

else

if (trace->fraction<0.0000001)

{

 trace->fraction = 0;

 //Con_Printf("Strange colliden");

 if (ent)

  ent->v.flags = (int)ent->v.flags | FL_ONGROUND;

}



//if (isplayer)

// Con_Printf("Frac%fn", trace->fraction);



}



void Old2_ENV_ClipMoveToEntity(edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, trace_t *trace)

{

//Yes, this is crap.

env_t *env;

int pos[3], pos2[3];

int i;

//int offset = 42;

int offset = 0;

float hdata1, hdata2;





trace->startsolid = false;

trace->fraction = 1;

trace->allsolid = false;

trace->endcontents = CONTENTS_EMPTY;

trace->ent = ent; //????



VectorCopy(end,trace->endpos);



if(!sv.worldmodel->environment)

 return;



env = sv.worldmodel->environment;





for(i = 0; i < 3; i++)

 pos[i] = (end[i] - env->origin[i]-mins[i])/env->scale[i];





for(i = 0; i < 3; i++)

 pos2[i] = (start[i] - env->origin[i]-mins[i])/env->scale[i];



if(pos[0] < 0 || pos[0] > env->width ||

   pos[1] < 0 || pos[1] > env->height)

   return;



trace->plane.normal[0] = 0;

trace->plane.normal[1] = 0;

trace->plane.normal[2] = 1;





hdata1 = env->heightdata[pos[0] * env->height + pos[1]]; //hend

hdata2 = env->heightdata[pos2[0] * env->height + pos2[1]]; //hstart



//if (hdata1 != hdata2)

// Con_Printf("h1, %f, h2 %f,n",hdata1,hdata2);// sale: h2 > h1





if(pos2[2] < hdata2)

{

 trace->startsolid = true;  

 trace->allsolid = true;

 trace->fraction = 0;

 trace->endcontents = CONTENTS_SOLID;  

 VectorCopy(start,trace->endpos);

}







if(pos[2] < hdata2)

{

 trace->endpos[2] = (hdata1 + env->origin[2] ) * env->scale[2];

 

 if (trace->fraction)

  trace->fraction *= abs(start[2] - end[2]) * 1.0f / abs(start[2] - trace->endpos[2]);

}





}







void Old_ENV_ClipMoveToEntity(edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, trace_t *trace)

{

//Yes, this is crap.

env_t *env;

int pstart[3], pos2[3];

int i;

//int offset = 42;

int offset = 0;

float heigh;





trace->startsolid = false;

trace->fraction = 1;

trace->allsolid = false;

trace->ent = ent; //????

trace->endcontents = CONTENTS_EMPTY;



//Triing to set the correct endpos[2]

VectorCopy(end,trace->endpos);





if(!sv.worldmodel->environment)

 return;



env = sv.worldmodel->environment;



for(i = 0; i < 3; i++)

 pstart[i] = (end[i] - env->origin[i]-mins[i])/env->scale[i];





for(i = 0; i < 3; i++)

 pos2[i] = (start[i] - env->origin[i]-mins[i])/env->scale[i];



if(pstart[0] < 0 || pstart[0] > env->width ||

   pstart[1] < 0 || pstart[1] > env->height)

   return;



heigh = (env->heightdata[pstart[0] * env->height + pstart[1]] + env->origin[2] + offset)*env->scale[2];

heigh = env->heightdata[pstart[0] * env->height + pstart[1]] + offset;



if(pos2[2] < heigh) //env->heightdata[pstart[0] * env->height + pstart[1]]+offset )

{

 trace->endcontents = CONTENTS_SOLID;

 trace->endpos[2] = heigh;



 if(trace->fraction)

  trace->fraction *= abs(start[2] - end[2]) / abs(start[2] - trace->endpos[2]);



 //Fake plane normal

 trace->plane.normal[0] = 0;

 trace->plane.normal[1] = 0;

 trace->plane.normal[2] = 1;

}



if(pstart[2] < heigh  )

{

 trace->startsolid = true;  

 trace->allsolid = true;

 trace->endcontents = CONTENTS_SOLID;

 trace->fraction = 0;

}



}



void ENV_CheckWater(edict_t *ent)

{



}



void ENV_SetContentsColor(vec3_t origin)

{



}





#if 0



extern int gl_mtexable;

void ENV_DrawPart(env_t *env, int xMin, int xMax, int yMin, int yMax, int stepsize)

{

int x, y, dx, dy;

float tex_x, tex_y;

float tex_dx, tex_dy;

float detailtex_x, detailtex_y;

float detailtex_dx, detailtex_dy;

int heightstep, usedetail;

byte *height;







#define lstep(a) {x = a%stepsize; if(x){a+=x;}else{a+=stepsize;}}

#define hstep(a) {x = a%stepsize; if(x){a-=x;}else{a-=stepsize;}}

lstep(xMin);

hstep(xMax);

lstep(yMin);

hstep(yMax);



dx = (xMax - xMin);

dy = (yMax - yMin);

if(dx <= 0 || dy <= 0)

 return;



usedetail = true; //(gl_mtexable && (env_detaildist.value >= stepsize));

heightstep = env->height * stepsize;

height = env->heightdata + xMin*env->height;



//Terrain

tex_x = env->texres / env->width * xMin;

tex_dx = env->texres / env->width * stepsize;

tex_dy = env->texres / env->height * stepsize;

detailtex_x = xMin * env->detailtexres;

detailtex_dx = env->detailtexres * stepsize;

detailtex_dy = env->detailtexres * stepsize;



#define GL_ADD_SIGNED_EXT                   0x8574



glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);

glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD_SIGNED_EXT);



qglSelectTextureSGIS_ARB(TEXTURE0_SGIS_ARB);

glBindTexture (GL_TEXTURE_2D,env->texture);





qglSelectTextureSGIS_ARB(TEXTURE1_SGIS_ARB);//emulated enable multitexture

glBindTexture (GL_TEXTURE_2D,env->detailtexture);





for(x = xMin; x < xMax-stepsize; x+=stepsize, tex_x += tex_dx, detailtex_x += detailtex_dx, height+=heightstep)

{

 tex_y = env->texres / env->height * yMin;

 detailtex_y = yMin * env->detailtexres;

 glBegin(GL_TRIANGLE_STRIP);

 for(y = yMin; y < yMax; y+=stepsize, tex_y += tex_dy, detailtex_y += detailtex_dy)

 {

  qglMTexCoord2fSGIS_ARB(TEXTURE0_SGIS_ARB, tex_y, tex_x+tex_dx);

  qglMTexCoord2fSGIS_ARB(TEXTURE1_SGIS_ARB, detailtex_y, (detailtex_x+detailtex_dx));

  glVertex3f(x+stepsize, y, height[y+heightstep]);

  qglMTexCoord2fSGIS_ARB(TEXTURE0_SGIS_ARB, tex_y, tex_x);

  qglMTexCoord2fSGIS_ARB(TEXTURE1_SGIS_ARB, detailtex_y, detailtex_x);

  glVertex3f(x, y, height[y]);

 }

 glEnd();

}



// glDepthMask(FALSE);



glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);



}



#else

void ENV_DrawPart(env_t *env, int xMin, int xMax, int yMin, int yMax, int stepsize)

{

int x, y, dx, dy;

float tex_x, tex_y;

float tex_dx, tex_dy;

// float detailtex_x, detailtex_y;

// float detailtex_dx, detailtex_dy;

int heightstep;//, usedetail;

byte *height;

int oldxMin,oldxMax,oldyMin,oldyMax;







oldxMin = xMin;

oldxMax = xMax;

oldyMax = yMax;

oldyMin = yMin;





#define lstep(a) {x = a%stepsize; if(x){a+=x;}else{a+=stepsize;}}

#define hstep(a) {x = a%stepsize; if(x){a-=x;}else{a-=stepsize;}}

lstep(xMin);

hstep(xMax);

lstep(yMin);

hstep(yMax);



// if ( env->flags[xMin+yMin*XMAX] == INGROUND && env->flags[xMax+yMax*XMAX] == INGROUND)

// {

//  R_ParticleStatic (org);

///  return;

// }



dx = (xMax - xMin);

dy = (yMax - yMin);

if(dx <= 0 || dy <= 0)

 return;



//heightstep =512 * stepsize;

heightstep = env->height * stepsize;

height = env->heightdata + xMin*env->height;



//Terrain

tex_x = env->texres / env->width * xMin;

tex_dx = env->texres / env->width * stepsize;

tex_dy = env->texres / env->height * stepsize;

//detailtex_x = xMin * env->detailtexres;

//detailtex_dx = env->detailtexres * stepsize;

//detailtex_dy = env->detailtexres * stepsize;



glBindTexture (GL_TEXTURE_2D,env->texture);

for(x = xMin; x < xMax-stepsize; x+=stepsize, tex_x += tex_dx,  height+=heightstep)

{

 tex_y = env->texres / env->height * yMin;

 //detailtex_y = yMin * env->detailtexres;

 glBegin(GL_TRIANGLE_STRIP);

 for(y = yMin; y < yMax; y+=stepsize, tex_y += tex_dy)

 {



//   glColor3f(1,1,1);



/*

  qglMTexCoord2fSGIS(gl_mtextype, tex_y, tex_x+tex_dx);

  qglMTexCoord2fSGIS(gl_mtextype+1, detailtex_y, (detailtex_x+detailtex_dx));

  glVertex3f(x+stepsize, y, height[y+heightstep]);

  qglMTexCoord2fSGIS(gl_mtextype, tex_y, tex_x);

  qglMTexCoord2fSGIS(gl_mtextype+1, detailtex_y, detailtex_x);

  glVertex3f(x, y, height[y]);

*/



  glTexCoord2f( tex_y, tex_x+tex_dx);

  //glTexCoord2f( detailtex_y, (detailtex_x+detailtex_dx));

  glVertex3f(x+stepsize, y, height[y+heightstep]);

  glTexCoord2f( tex_y, tex_x);

  //glTexCoord2f( detailtex_y, detailtex_x);

  glVertex3f(x, y, height[y]);

 }

 glEnd();

}



//return;



//if (stepsize>1)

// return;



xMin = oldxMin;

xMax = oldxMax;

yMax = oldyMax;

yMin = oldyMin;





lstep(xMin);

hstep(xMax);

lstep(yMin);

hstep(yMax);



dx = (xMax - xMin);

dy = (yMax - yMin);





//heightstep =512 * stepsize;

heightstep =env->height * stepsize;

height = env->heightdata + xMin*env->height;







//Terrain

tex_x = env->detailtexres / env->width * xMin;

tex_dx = env->detailtexres / env->width * stepsize;

tex_dy = env->detailtexres / env->height * stepsize;



glColor4f (1,1,1,1);

glBindTexture (GL_TEXTURE_2D,env->detailtexture);

glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR);



for(x = xMin; x < xMax-stepsize; x+=stepsize, tex_x += tex_dx, height+=heightstep)

{

 tex_y = env->detailtexres / env->height * yMin;



 glBegin(GL_TRIANGLE_STRIP);

 for(y = yMin; y < yMax; y+=stepsize, tex_y += tex_dy)

 {



  glTexCoord2f( tex_y, tex_x+tex_dx);

  glVertex3f(x+stepsize, y, height[y+heightstep]);

  glTexCoord2f( tex_y, tex_x);

  glVertex3f(x, y, height[y]);

 }

 glEnd();

}

glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glColor4f (1,1,1,1);





}

#endif



int ENV_Clamp(int x, int xclamp)

{

if(x < 0) x = 0;

if(x > xclamp) x = xclamp;

return x;

}



extern cvar_t r_cloudz,temp1;





void ENV_DrawScene(void)

{

env_t *env;

double time;

static float lastime = 0;

static compiled = false;

extern float   framesmedium;

extern float latestfps;



if(!cl.worldmodel->environment)

 return;



/*

//Experimental profiler

if (lastime < cl.time)

{

 if (framesmedium>60 && latestfps > 40)

 {

  Cvar_Set("env_dist", va("%f",env_dist.value - 1));

 }

 else

 if (framesmedium<40 && latestfps < 60)

 {

  Cvar_Set("env_dist", va("%f",env_dist.value + 1));

 }

 lastime = cl.time + 1;

}

*/





//

// This can be moved inside the callist, but i fear will damage

// compatibility

//



env = cl.worldmodel->environment;



env->origin[0] = env_x.value;

env->origin[1] = env_y.value;

env->origin[2] = env_z.value;



env->scale[0] = env_sx.value;

env->scale[1] = env_sy.value;

env->scale[2] = env_sz.value;





env->detailtexres = env_sdetail.value;

env->texres   = env_stex.value;





glPushMatrix();

glTranslatef(env->origin[0], env->origin[1], env->origin[2]);

glRotatef (env->rotation[1],  0, 0, 1);

glRotatef (env->rotation[0],  0, 1, 0);

glRotatef (env->rotation[2],  1, 0, 0);

glScalef(env->scale[0], env->scale[1], env->scale[2]);

glColor3f(1,1,1);



if (env_compiled.value)

{

 if (!compiled)

 {

  glNewList(1,GL_COMPILE);

  ENV_DrawPart(env, 0, env->width,  0,  env->height,  env_dist.value);//[-1,  1]x[-1,  1]

  glEndList();



  compiled = true;

  //Con_Printf("GenListn");

 }

 else

   glCallList(1); //14x faster

}

else

 ENV_DrawPart(env, 0, env->width,  0,  env->height,  env_dist.value);//[-1,  1]x[-1,  1]



glPopMatrix();

}



[/tt][/pre]
                               

ethernet

Umh, para lo de la claridad y oscuridad podrias poner un color mas claro o mas oscuro en funcion de la altura midiendo la altura en relaccion al punto mas bajo o en funcion del plano z=0 (eso ira en funcion de los datos del heigthmap que cargas)

Tei

                               
CitarUmh, para lo de la claridad y oscuridad podrias poner un color mas claro o mas oscuro en funcion de la altura midiendo la altura en relaccion al punto mas bajo o en funcion del plano z=0 (eso ira en funcion de los datos del heigthmap que cargas)

Y eso como lo hago? hago un glColor3f(brillo, brillo, brillo); antes del primer glTex...? Aun estoy aprendiendo OpenGL, toda la ayuda me que me des le dare buen provecho.                                

ethernet

Si, esa es la idea q tengo yo, aunque tendra q mirarte los modos de combinar el color y las texturas de opengl. No tengo demasiado claro este tema, nunca lo he usado, pero creo q la funcion gltexenv te puede ayudar:

http://www.3dlabs.com/support/developer/GL...es/gltexenv.htm

En la pagina http://www.opengl.org/developers/faqs/tech...cal/texture.htm en la seccion 21.030 Why doesn't lighting work when I turn on texture mapping?
creo a explica mas o menos como va ese tema.

Tb supongo q si usas multitextura habra que mirar si hay nuevas funciones de como combinar los colores.

saludos

Tei

                                gracias ethernet.                                






Stratos es un servicio gratuito, cuyos costes se cubren en parte con la publicidad.
Por favor, desactiva el bloqueador de anuncios en esta web para ayudar a que siga adelante.
Muchísimas gracias.