X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FTerrain.cpp;h=ecc8757b7dc953971759fb7a595eff6a1b587cd6;hb=26debbd380c6922e5a0b60d99567c6374a4fef9a;hp=e56f681f8190c9359c5741941855fd4ab1777ebb;hpb=d435148bf0fd538f3b69a8232253618e10249ffa;p=lugaru.git diff --git a/Source/Terrain.cpp b/Source/Terrain.cpp index e56f681..ecc8757 100644 --- a/Source/Terrain.cpp +++ b/Source/Terrain.cpp @@ -24,21 +24,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Objects.h" extern XYZ viewer; extern float viewdistance; -extern float lightambient[3],lightbrightness[3]; extern float fadestart; extern int environment; extern float texscale; extern Light light; extern float multiplier; extern FRUSTUM frustum; -extern float texdetail,terraindetail; +extern float texdetail; extern int detail; extern bool decals; extern float blurness; extern float targetblurness; extern Objects objects; extern TGAImageRec texture; -extern Game * pgame; extern bool visibleloading; extern bool skyboxtexture; extern int tutoriallevel; @@ -371,17 +369,20 @@ void Terrain::UpdateVertexArray(int whichx, int whichy){ } -bool Terrain::load(char *fileName) +bool Terrain::load(const char *fileName) { static long i,j; static long x,y; static float patch_size; float temptexdetail=texdetail; - texdetail=terraindetail; //LoadTGA( fileName ); + + // Fixing filename so that it works with its own os + char * FixedFN = ConvertFileName(fileName); + unsigned char fileNamep[256]; - CopyCStringToPascal(fileName,fileNamep); + CopyCStringToPascal(FixedFN, fileNamep); //Load Image upload_image( fileNamep ,0); @@ -398,7 +399,7 @@ bool Terrain::load(char *fileName) } } texture.bpp=24; - if(visibleloading)pgame->LoadingScreen(); + if(visibleloading) Game::LoadingScreen(); texdetail=temptexdetail; @@ -425,12 +426,12 @@ bool Terrain::load(char *fileName) for(i=0;iLoadingScreen(); + if(visibleloading) Game::LoadingScreen(); float slopeness; @@ -439,7 +440,7 @@ bool Terrain::load(char *fileName) textureness[i][j]=-1; } } - if(visibleloading)pgame->LoadingScreen(); + if(visibleloading) Game::LoadingScreen(); for(i=0;iLoadingScreen(); + if(visibleloading) Game::LoadingScreen(); for(i=0;iLoadingScreen(); + if(visibleloading) Game::LoadingScreen(); /*float total; int todivide; @@ -595,7 +596,7 @@ bool Terrain::load(char *fileName) } } } - if(visibleloading)pgame->LoadingScreen(); + if(visibleloading) Game::LoadingScreen(); patch_size=size/subdivision; patch_elements=(patch_size)*(patch_size)*54; @@ -975,7 +976,7 @@ void Terrain::draw(int layer) endz=(viewer.z+viewdistance)/(patch_size)+1; if(endz>subdivision)endz=subdivision; - if(!layer) + if(!layer) { for(i=beginx;iviewdistsquared*fadestart-viewdistsquared)opacity=0; - if(opacity==1&&i!=subdivision)if(distance[i+1][j]>viewdistsquared*fadestart-viewdistsquared)opacity=0; - if(opacity==1&&j!=subdivision)if(distance[i][j+1]>viewdistsquared*fadestart-viewdistsquared)opacity=0; - if(opacity==1&&j!=subdivision&&i!=subdivision)if(distance[i+1][j+1]>viewdistsquared*fadestart-viewdistsquared)opacity=0; - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPushMatrix(); - if(frustum.CubeInFrustum(i*patch_size+patch_size*.5,avgypatch[i][j],j*patch_size+patch_size*.5,heightypatch[i][j]/2)) - { - if(environment==desertenvironment&&distance[i][j]>viewdistsquared/4)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness); - else if(environment==desertenvironment)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0 ); - if(!layer&&textureness[i][j]!=allsecond)drawpatch(i,j,opacity); - if(layer==1&&textureness[i][j]!=allfirst)drawpatchother(i,j,opacity); - if(layer==2&&textureness[i][j]!=allfirst)drawpatchotherother(i,j,opacity); - } - glPopMatrix(); - } + } + for(i=beginx;iviewdistsquared*fadestart-viewdistsquared) + opacity=0; + if(opacity==1&&i!=subdivision) + if(distance[i+1][j]>viewdistsquared*fadestart-viewdistsquared) + opacity=0; + if(opacity==1&&j!=subdivision) + if(distance[i][j+1]>viewdistsquared*fadestart-viewdistsquared) + opacity=0; + if(opacity==1&&j!=subdivision&&i!=subdivision) + if(distance[i+1][j+1]>viewdistsquared*fadestart-viewdistsquared) + opacity=0; + glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix + glPushMatrix(); + if(frustum.CubeInFrustum(i*patch_size+patch_size*.5,avgypatch[i][j],j*patch_size+patch_size*.5,heightypatch[i][j]/2)) + { + if(environment==desertenvironment&&distance[i][j]>viewdistsquared/4) + glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness); + else if(environment==desertenvironment) + glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0 ); + if(!layer&&textureness[i][j]!=allsecond) + drawpatch(i,j,opacity); + if(layer==1&&textureness[i][j]!=allfirst) + drawpatchother(i,j,opacity); + if(layer==2&&textureness[i][j]!=allfirst) + drawpatchotherother(i,j,opacity); + } + glPopMatrix(); } } - if(environment==desertenvironment)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0 ); + } + if(environment==desertenvironment) + glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0 ); } void Terrain::drawdecals() { - if(decals){ + if(decals) { static int i,j; static float distancemult; static int lasttype; @@ -1033,7 +1047,7 @@ void Terrain::drawdecals() for(i=0;ipoints[0].x&&where.x-radiuspoints[0].z&&where.z-radius0&&size>0){ + if(decals) { + if(opacity>0&&size>0) { static int patchx[4]; static int patchy[4]; @@ -1234,11 +1248,9 @@ void Terrain::MakeDecalLock(int type, XYZ where,int whichx, int whichy, float si decalbrightness[numdecals]=(rot.x+rot.y+rot.z)/3; if(decalbrightness[numdecals]<.4)decalbrightness[numdecals]=.4; - //if(type==blooddecal||type==blooddecalfast||type==blooddecalslow){ if(environment==grassyenvironment){ decalbrightness[numdecals]*=.6; } - //} if(decalbrightness[numdecals]>1)decalbrightness[numdecals]=1; decalbright=decalbrightness[numdecals]; @@ -1446,12 +1458,12 @@ void Terrain::DoShadows() if(objects.type[l]!=treetrunktype){ testpoint=terrainpoint; testpoint2=terrainpoint+lightloc*50*(1-shadowed); - if(objects.model[l].LineCheck(&testpoint,&testpoint2,&col,&objects.position[l],&objects.rotation[l])!=-1){ + if(objects.model[l].LineCheck(&testpoint,&testpoint2,&col,&objects.position[l],&objects.yaw[l])!=-1){ shadowed=1-(findDistance(&terrainpoint,&col)/50); } } } - if(visibleloading)pgame->LoadingScreen(); + if(visibleloading) Game::LoadingScreen(); } brightness=dotproduct(&lightloc,&normals[i][j]); if(shadowed)brightness*=1-shadowed; @@ -1472,7 +1484,7 @@ void Terrain::DoShadows() } } - if(visibleloading)pgame->LoadingScreen(); + if(visibleloading) Game::LoadingScreen(); //Smooth shadows for(i=0;i