X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FObjects.cpp;h=de603c1655d52fe58c341943efd904d81a0da6b6;hb=263a338c0c3648cfa2388d4a21584a09294ffd9e;hp=e5d26898ad07f01bad09545d65f1d0d5aaeb2ba6;hpb=36cc3af3e5074215817ddee16defde754e2ad67f;p=lugaru.git diff --git a/Source/Objects.cpp b/Source/Objects.cpp index e5d2689..de603c1 100644 --- a/Source/Objects.cpp +++ b/Source/Objects.cpp @@ -1,7 +1,27 @@ +/* +Copyright (C) 2003, 2010 - Wolfire Games + +This file is part of Lugaru. + +Lugaru is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +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; @@ -10,14 +30,12 @@ extern float multiplier; extern float gravity; extern FRUSTUM frustum; extern Terrain terrain; -extern float terraindetail; extern bool foliage; extern int detail; extern float blurness; extern float windvar; extern float playerdist; extern bool skyboxtexture; -extern Sprites sprites; //Functions @@ -34,7 +52,7 @@ bool Objects::checkcollide(XYZ startpoint,XYZ endpoint,int which){ if(type[i]!=treeleavestype&&type[i]!=treetrunktype&&type[i]!=bushtype&&type[i]!=firetype&&i!=which){ colviewer=startpoint; coltarget=endpoint; - if(model[i].LineCheck(&colviewer,&coltarget,&colpoint,&position[i],&rotation[i])!=-1)return 1; + if(model[i].LineCheck(&colviewer,&coltarget,&colpoint,&position[i],&yaw[i])!=-1)return 1; } } @@ -47,15 +65,15 @@ void Objects::SphereCheckPossible(XYZ *p1,float radius) static int whichpatchx; static int whichpatchz; - whichpatchx=p1->x/(terrain.size/subdivision*terrain.scale*terraindetail); - whichpatchz=p1->z/(terrain.size/subdivision*terrain.scale*terraindetail); + whichpatchx=p1->x/(terrain.size/subdivision*terrain.scale); + whichpatchz=p1->z/(terrain.size/subdivision*terrain.scale); if(whichpatchx>=0&&whichpatchz>=0&&whichpatchx0&&terrain.patchobjectnum[whichpatchx][whichpatchz]<500) for(j=0;j1)distance=1; if(distance>0){ - /*if(checkcollide(viewer,DoRotation(model[i].vertex[model[i].vertexNum],0,rotation[i],0)*scale[i]+position[i],i)){ + /*if(checkcollide(viewer,DoRotation(model[i].vertex[model[i].vertexNum],0,yaw[i],0)*scale[i]+position[i],i)){ occluded[i]+=1; } else occluded[i]=0;*/ @@ -97,26 +115,26 @@ void Objects::Draw() if(type[i]==bushtype){ messedwith[i]-=multiplier; if(rotxvel[i]||rotx[i]){ - if(rotx[i]>0)rotxvel[i]-=multiplier*8*abs(rotx[i]); - if(rotx[i]<0)rotxvel[i]+=multiplier*8*abs(rotx[i]); + if(rotx[i]>0)rotxvel[i]-=multiplier*8*fabs(rotx[i]); + if(rotx[i]<0)rotxvel[i]+=multiplier*8*fabs(rotx[i]); if(rotx[i]>0)rotxvel[i]-=multiplier*4; if(rotx[i]<0)rotxvel[i]+=multiplier*4; if(rotxvel[i]>0)rotxvel[i]-=multiplier*4; if(rotxvel[i]<0)rotxvel[i]+=multiplier*4; - if(abs(rotx[i])0)rotyvel[i]-=multiplier*8*abs(roty[i]); - if(roty[i]<0)rotyvel[i]+=multiplier*8*abs(roty[i]); + if(roty[i]>0)rotyvel[i]-=multiplier*8*fabs(roty[i]); + if(roty[i]<0)rotyvel[i]+=multiplier*8*fabs(roty[i]); if(roty[i]>0)rotyvel[i]-=multiplier*4; if(roty[i]<0)rotyvel[i]+=multiplier*4; if(rotyvel[i]>0)rotyvel[i]-=multiplier*4; if(rotyvel[i]<0)rotyvel[i]+=multiplier*4; - if(abs(roty[i])0)rotxvel[i]-=multiplier*8*abs(rotx[i]); - if(rotx[i]<0)rotxvel[i]+=multiplier*8*abs(rotx[i]); + if(rotx[i]>0)rotxvel[i]-=multiplier*8*fabs(rotx[i]); + if(rotx[i]<0)rotxvel[i]+=multiplier*8*fabs(rotx[i]); if(rotx[i]>0)rotxvel[i]-=multiplier*4; if(rotx[i]<0)rotxvel[i]+=multiplier*4; if(rotxvel[i]>0)rotxvel[i]-=multiplier*4; if(rotxvel[i]<0)rotxvel[i]+=multiplier*4; - if(abs(rotx[i])0)rotyvel[i]-=multiplier*8*abs(roty[i]); - if(roty[i]<0)rotyvel[i]+=multiplier*8*abs(roty[i]); + if(roty[i]>0)rotyvel[i]-=multiplier*8*fabs(roty[i]); + if(roty[i]<0)rotyvel[i]+=multiplier*8*fabs(roty[i]); if(roty[i]>0)rotyvel[i]-=multiplier*4; if(roty[i]<0)rotyvel[i]+=multiplier*4; if(rotyvel[i]>0)rotyvel[i]-=multiplier*4; if(rotyvel[i]<0)rotyvel[i]+=multiplier*4; - if(abs(roty[i])0)rotxvel[i]-=multiplier*8*abs(rotx[i]); - if(rotx[i]<0)rotxvel[i]+=multiplier*8*abs(rotx[i]); + if(rotx[i]>0)rotxvel[i]-=multiplier*8*fabs(rotx[i]); + if(rotx[i]<0)rotxvel[i]+=multiplier*8*fabs(rotx[i]); if(rotx[i]>0)rotxvel[i]-=multiplier*4; if(rotx[i]<0)rotxvel[i]+=multiplier*4; if(rotxvel[i]>0)rotxvel[i]-=multiplier*4; if(rotxvel[i]<0)rotxvel[i]+=multiplier*4; - if(abs(rotx[i])0)rotyvel[i]-=multiplier*8*abs(roty[i]); - if(roty[i]<0)rotyvel[i]+=multiplier*8*abs(roty[i]); + if(roty[i]>0)rotyvel[i]-=multiplier*8*fabs(roty[i]); + if(roty[i]<0)rotyvel[i]+=multiplier*8*fabs(roty[i]); if(roty[i]>0)rotyvel[i]-=multiplier*4; if(roty[i]<0)rotyvel[i]+=multiplier*4; if(rotyvel[i]>0)rotyvel[i]-=multiplier*4; if(rotyvel[i]<0)rotyvel[i]+=multiplier*4; - if(abs(roty[i])1)distance=1; glColor4f((1-shadowed[i])/2+.5,(1-shadowed[i])/2+.5,(1-shadowed[i])/2+.5,distance); if(distance>=1){ @@ -309,7 +327,7 @@ void Objects::Draw() glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0 ); for(i=0;i