]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Objects.cpp
cleanup, renamed rotations to yaw/pitch
[lugaru.git] / Source / Objects.cpp
index cc6008b409cf7389ccc68a5ffc16c9c0f274aaea..353fa6e31f74b8d88215b2aa40928466b447bd74 100644 (file)
@@ -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&&whichpatchx<subdivision&&whichpatchz<subdivision)
                if(terrain.patchobjectnum[whichpatchx][whichpatchz]>0&&terrain.patchobjectnum[whichpatchx][whichpatchz]<500)
                        for(j=0;j<terrain.patchobjectnum[whichpatchx][whichpatchz];j++){
                                i=terrain.patchobjects[whichpatchx][whichpatchz][j];
                                possible[i]=0;
-                               if(model[i].SphereCheckPossible(p1, radius, &position[i], &rotation[i])!=-1){
+                               if(model[i].SphereCheckPossible(p1, radius, &position[i], &yaw[i])!=-1){
                                        possible[i]=1;
                                }
                        }
@@ -70,7 +88,7 @@ void Objects::Draw()
 
        for(i=0;i<numobjects;i++){
                if(type[i]!=firetype){
-                       moved=DoRotation(model[i].boundingspherecenter,0,rotation[i],0);
+                       moved=DoRotation(model[i].boundingspherecenter,0,yaw[i],0);
                        if(type[i]==tunneltype||frustum.SphereInFrustum(position[i].x+moved.x,position[i].y+moved.y,position[i].z+moved.z,model[i].boundingsphereradius)){   
                                distance=findDistancefast(&viewer,&position[i]);
                                distance*=1.2;
@@ -83,7 +101,7 @@ void Objects::Draw()
                                        if(distance>1)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])<multiplier*4)rotx[i]=0;
-                                                                               if(abs(rotxvel[i])<multiplier*4)rotxvel[i]=0;
+                                                                               if(fabs(rotx[i])<multiplier*4)rotx[i]=0;
+                                                                               if(fabs(rotxvel[i])<multiplier*4)rotxvel[i]=0;
 
                                                                                rotx[i]+=rotxvel[i]*multiplier*4;
                                                                        }
                                                                        if(rotyvel[i]||roty[i]){
-                                                                               if(roty[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])<multiplier*4)roty[i]=0;
-                                                                               if(abs(rotyvel[i])<multiplier*4)rotyvel[i]=0;
+                                                                               if(fabs(roty[i])<multiplier*4)roty[i]=0;
+                                                                               if(fabs(rotyvel[i])<multiplier*4)rotyvel[i]=0;
 
                                                                                roty[i]+=rotyvel[i]*multiplier*4;
                                                                        }
@@ -135,26 +153,26 @@ void Objects::Draw()
                                                                        if(type[i]==treetrunktype||environment==2){
                                                                                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])<multiplier*4)rotx[i]=0;
-                                                                                       if(abs(rotxvel[i])<multiplier*4)rotxvel[i]=0;
+                                                                                       if(fabs(rotx[i])<multiplier*4)rotx[i]=0;
+                                                                                       if(fabs(rotxvel[i])<multiplier*4)rotxvel[i]=0;
 
                                                                                        rotx[i]+=rotxvel[i]*multiplier*4;
                                                                                }
                                                                                if(rotyvel[i]||roty[i]){
-                                                                                       if(roty[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])<multiplier*4)roty[i]=0;
-                                                                                       if(abs(rotyvel[i])<multiplier*4)rotyvel[i]=0;
+                                                                                       if(fabs(roty[i])<multiplier*4)roty[i]=0;
+                                                                                       if(fabs(rotyvel[i])<multiplier*4)rotyvel[i]=0;
 
                                                                                        roty[i]+=rotyvel[i]*multiplier*4;
                                                                                }
@@ -173,26 +191,26 @@ void Objects::Draw()
                                                                        {
                                                                                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])<multiplier*4)rotx[i]=0;
-                                                                                       if(abs(rotxvel[i])<multiplier*4)rotxvel[i]=0;
+                                                                                       if(fabs(rotx[i])<multiplier*4)rotx[i]=0;
+                                                                                       if(fabs(rotxvel[i])<multiplier*4)rotxvel[i]=0;
 
                                                                                        rotx[i]+=rotxvel[i]*multiplier*4;
                                                                                }
                                                                                if(rotyvel[i]||roty[i]){
-                                                                                       if(roty[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])<multiplier*4)roty[i]=0;
-                                                                                       if(abs(rotyvel[i])<multiplier*4)rotyvel[i]=0;
+                                                                                       if(fabs(roty[i])<multiplier*4)roty[i]=0;
+                                                                                       if(fabs(rotyvel[i])<multiplier*4)rotyvel[i]=0;
 
                                                                                        roty[i]+=rotyvel[i]*multiplier*4;
                                                                                }
@@ -236,7 +254,7 @@ void Objects::Draw()
                                                                                glRotatef((sin(windvar+position[i].x*.3)+.5)*4*.5*(sin(windvar*2+position[i].x*.3)+1)/2,1,0,0);
                                                                        }
                                                                }
-                                                               glRotatef(rotation[i],0,1,0);
+                                                               glRotatef(yaw[i],0,1,0);
                                                                if(distance>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<numobjects;i++){
                if(type[i]==treeleavestype||type[i]==bushtype){
-                       moved=DoRotation(model[i].boundingspherecenter,0,rotation[i],0);
+                       moved=DoRotation(model[i].boundingspherecenter,0,yaw[i],0);
                        if(frustum.SphereInFrustum(position[i].x+moved.x,position[i].y+moved.y,position[i].z+moved.z,model[i].boundingsphereradius)){   
                                hidden=findDistancefastflat(&viewer,&position[i])<=playerdist+3;
                                if(hidden){
@@ -324,26 +342,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])<multiplier*4)rotx[i]=0;
-                                                                               if(abs(rotxvel[i])<multiplier*4)rotxvel[i]=0;
+                                                                               if(fabs(rotx[i])<multiplier*4)rotx[i]=0;
+                                                                               if(fabs(rotxvel[i])<multiplier*4)rotxvel[i]=0;
 
                                                                                rotx[i]+=rotxvel[i]*multiplier*4;
                                                                        }
                                                                        if(rotyvel[i]||roty[i]){
-                                                                               if(roty[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])<multiplier*4)roty[i]=0;
-                                                                               if(abs(rotyvel[i])<multiplier*4)rotyvel[i]=0;
+                                                                               if(fabs(roty[i])<multiplier*4)roty[i]=0;
+                                                                               if(fabs(rotyvel[i])<multiplier*4)rotyvel[i]=0;
 
                                                                                roty[i]+=rotyvel[i]*multiplier*4;
                                                                        }
@@ -361,26 +379,26 @@ void Objects::Draw()
                                                                if(type[i]==treetrunktype||type[i]==treeleavestype){
                                                                        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])<multiplier*4)rotx[i]=0;
-                                                                               if(abs(rotxvel[i])<multiplier*4)rotxvel[i]=0;
+                                                                               if(fabs(rotx[i])<multiplier*4)rotx[i]=0;
+                                                                               if(fabs(rotxvel[i])<multiplier*4)rotxvel[i]=0;
 
                                                                                rotx[i]+=rotxvel[i]*multiplier*4;
                                                                        }
                                                                        if(rotyvel[i]||roty[i]){
-                                                                               if(roty[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])<multiplier*4)roty[i]=0;
-                                                                               if(abs(rotyvel[i])<multiplier*4)rotyvel[i]=0;
+                                                                               if(fabs(roty[i])<multiplier*4)roty[i]=0;
+                                                                               if(fabs(rotyvel[i])<multiplier*4)rotyvel[i]=0;
 
                                                                                roty[i]+=rotyvel[i]*multiplier*4;
                                                                        }
@@ -417,7 +435,7 @@ void Objects::Draw()
                                                                                glRotatef((sin(windvar+position[i].x*.3)+.5)*4*.5*(sin(windvar*2+position[i].x*.3)+1)/2,1,0,0);
                                                                        }
                                                                }
-                                                               glRotatef(rotation[i],0,1,0);
+                                                               glRotatef(yaw[i],0,1,0);
                                                                glColor4f(1,1,1,distance);
                                                                if(type[i]==treeleavestype){
                                                                        glDisable(GL_CULL_FACE);
@@ -456,7 +474,7 @@ void Objects::Draw()
 void Objects::DeleteObject(int which)
 {
        type[numobjects-1]=0;
-       rotation[numobjects-1]=0;
+       yaw[numobjects-1]=0;
        position[numobjects-1]=0;
        scale[numobjects-1]=0;
        friction[numobjects-1]=0;
@@ -464,10 +482,10 @@ void Objects::DeleteObject(int which)
        numobjects--;
 }
 
-void Objects::MakeObject(int atype, XYZ where, float arotation, float ascale){
+void Objects::MakeObject(int atype, XYZ where, float ayaw, float ascale){
        if((atype!=treeleavestype&&atype!=bushtype)||foliage==1){
                scale[numobjects]=ascale;
-               if(atype==treeleavestype)scale[numobjects]+=abs((float)(Random()%100)/900)*ascale;
+               if(atype==treeleavestype)scale[numobjects]+=fabs((float)(Random()%100)/900)*ascale;
 
                onfire[numobjects]=0;
                flamedelay[numobjects]=0;
@@ -477,7 +495,7 @@ void Objects::MakeObject(int atype, XYZ where, float arotation, float ascale){
 
                position[numobjects]=where;
                if(atype==bushtype)position[numobjects].y=terrain.getHeight(position[numobjects].x,position[numobjects].z)-.3;
-               rotation[numobjects]=arotation;
+               yaw[numobjects]=ayaw;
 
                rotxvel[numobjects]=0;
                rotyvel[numobjects]=0;
@@ -527,7 +545,7 @@ void Objects::MakeObject(int atype, XYZ where, float arotation, float ascale){
                model[numobjects].Scale(.3*scale[numobjects],.3*scale[numobjects],.3*scale[numobjects]);
                model[numobjects].Rotate(90,1,1);
                if(type[numobjects]==rocktype){
-                       model[numobjects].Rotate(arotation*5,1,1);
+                       model[numobjects].Rotate(ayaw*5,1,1);
                }
                model[numobjects].CalculateNormals(1);
                model[numobjects].ScaleNormals(-1,-1,-1);
@@ -541,16 +559,16 @@ void Objects::MakeObject(int atype, XYZ where, float arotation, float ascale){
                }
 
                if(atype!=treeleavestype&&atype!=bushtype&&atype!=firetype)
-                       terrain.AddObject(where+DoRotation(model[numobjects].boundingspherecenter,0,arotation,0),model[numobjects].boundingsphereradius,numobjects);
+                       terrain.AddObject(where+DoRotation(model[numobjects].boundingspherecenter,0,ayaw,0),model[numobjects].boundingsphereradius,numobjects);
 
                numobjects++;
        }       
 }
 
-void Objects::MakeObject(int atype, XYZ where, float arotation, float arotation2, float ascale){
+void Objects::MakeObject(int atype, XYZ where, float ayaw, float apitch, float ascale){
        if((atype!=treeleavestype&&atype!=bushtype)||foliage==1){
                scale[numobjects]=ascale;
-               if(atype==treeleavestype)scale[numobjects]+=abs((float)(Random()%100)/900)*ascale;
+               if(atype==treeleavestype)scale[numobjects]+=fabs((float)(Random()%100)/900)*ascale;
 
                onfire[numobjects]=0;
                flamedelay[numobjects]=0;
@@ -564,8 +582,8 @@ void Objects::MakeObject(int atype, XYZ where, float arotation, float arotation2
                if(position[numobjects].y<terrain.getHeight(position[numobjects].x,position[numobjects].z)-.3)
                position[numobjects].y=terrain.getHeight(position[numobjects].x,position[numobjects].z)-.3;
                }*/
-               rotation[numobjects]=arotation;
-               rotation2[numobjects]=arotation2;
+               yaw[numobjects]=ayaw;
+               pitch[numobjects]=apitch;
 
                rotxvel[numobjects]=0;
                rotyvel[numobjects]=0;
@@ -597,7 +615,7 @@ void Objects::MakeObject(int atype, XYZ where, float arotation, float arotation2
                if(atype==treetrunktype)friction[numobjects]=.4;
                if(atype==treeleavestype)friction[numobjects]=0;
 
-               if(friction[numobjects]==1.5&&abs(arotation2)>5)friction[numobjects]=.5;
+               if(friction[numobjects]==1.5&&fabs(apitch)>5)friction[numobjects]=.5;
 
                if(atype==platformtype){
                        model[numobjects].loaddecal((char *)":Data:Models:Platform.solid",0);
@@ -616,9 +634,9 @@ void Objects::MakeObject(int atype, XYZ where, float arotation, float arotation2
                }
                model[numobjects].Scale(.3*scale[numobjects],.3*scale[numobjects],.3*scale[numobjects]);
                model[numobjects].Rotate(90,1,1);
-               model[numobjects].Rotate(arotation2,0,0);
+               model[numobjects].Rotate(apitch,0,0);
                if(type[numobjects]==rocktype){
-                       model[numobjects].Rotate(arotation*5,0,0);
+                       model[numobjects].Rotate(ayaw*5,0,0);
                }
                model[numobjects].CalculateNormals(1);
                model[numobjects].ScaleNormals(-1,-1,-1);
@@ -632,7 +650,7 @@ void Objects::MakeObject(int atype, XYZ where, float arotation, float arotation2
                }
 
                if(atype!=treeleavestype&&atype!=bushtype&&atype!=firetype)
-                       terrain.AddObject(where+DoRotation(model[numobjects].boundingspherecenter,0,arotation,0),model[numobjects].boundingsphereradius,numobjects);
+                       terrain.AddObject(where+DoRotation(model[numobjects].boundingspherecenter,0,ayaw,0),model[numobjects].boundingsphereradius,numobjects);
 
                numobjects++;
        }       
@@ -643,7 +661,7 @@ void Objects::DoStuff()
        XYZ spawnpoint;
        for(int i=0;i<numobjects;i++){
                /*if(type[i]==firetype){
-               sprites.MakeSprite(weaponshinesprite, position[i],position[i]*0, 1,1,1, 5, 1);
+               Sprite::MakeSprite(weaponshinesprite, position[i],position[i]*0, 1,1,1, 5, 1);
                }*/
 
                if(type[i]==firetype)onfire[i]=1;
@@ -659,7 +677,7 @@ void Objects::DoStuff()
                                        spawnpoint.z=0;
                                        spawnpoint=DoRotation(spawnpoint,0,Random()%360,0);
                                        spawnpoint+=position[i];
-                                       sprites.MakeSprite(flamesprite, spawnpoint,spawnpoint*0, 1,1,1, (.6+(float)abs(Random()%100)/200-.25)*5*scale[i], 1);
+                                       Sprite::MakeSprite(flamesprite, spawnpoint,spawnpoint*0, 1,1,1, (.6+(float)abs(Random()%100)/200-.25)*5*scale[i], 1);
                                }
                                if(type[i]==treeleavestype){
                                        spawnpoint.x=((float)(Random()%100))/80*scale[i];
@@ -667,7 +685,7 @@ void Objects::DoStuff()
                                        spawnpoint.z=0;
                                        spawnpoint=DoRotation(spawnpoint,0,Random()%360,0);
                                        spawnpoint+=position[i];
-                                       sprites.MakeSprite(flamesprite, spawnpoint,spawnpoint*0, 1,1,1, (.6+(float)abs(Random()%100)/200-.25)*6, 1);
+                                       Sprite::MakeSprite(flamesprite, spawnpoint,spawnpoint*0, 1,1,1, (.6+(float)abs(Random()%100)/200-.25)*6, 1);
                                }
                        }
 
@@ -677,8 +695,7 @@ void Objects::DoStuff()
 
 void Objects::DoShadows()
 {
-       int i,j,k,l,todivide;
-       static float brightness, total;
+       int i,j,k,l;
        static XYZ testpoint,testpoint2, terrainpoint,lightloc,col;
        lightloc=light.location;
        if(!skyboxtexture)lightloc=0;
@@ -690,11 +707,11 @@ void Objects::DoShadows()
                for(i=0;i<numobjects;i++){
                        if(type[i]!=treeleavestype&&type[i]!=treetrunktype&&type[i]!=bushtype&&type[i]!=firetype){
                                for(j=0;j<model[i].vertexNum;j++){
-                                       terrainpoint=position[i]+DoRotation(model[i].vertex[j]+model[i].normals[j]*.1,0,rotation[i],0);
+                                       terrainpoint=position[i]+DoRotation(model[i].vertex[j]+model[i].normals[j]*.1,0,yaw[i],0);
                                        //terrainpoint.y+=model[i].boundingsphereradius;
                                        shadowed[i]=0;
-                                       patchx=terrainpoint.x/(terrain.size/subdivision*terrain.scale*terraindetail);
-                                       patchz=terrainpoint.z/(terrain.size/subdivision*terrain.scale*terraindetail);
+                                       patchx=terrainpoint.x/(terrain.size/subdivision*terrain.scale);
+                                       patchz=terrainpoint.z/(terrain.size/subdivision*terrain.scale);
                                        if(patchx>=0&&patchz>=0&&patchx<subdivision&&patchz<subdivision)
                                                if(terrain.patchobjectnum[patchx][patchz])
                                                        for(k=0;k<terrain.patchobjectnum[patchx][patchz];k++){
@@ -702,13 +719,13 @@ void Objects::DoShadows()
                                                                if(type[l]!=treetrunktype/*&&l!=i*/){
                                                                        testpoint=terrainpoint;
                                                                        testpoint2=terrainpoint+lightloc*50*(1-shadowed[i]);
-                                                                       if(model[l].LineCheck(&testpoint,&testpoint2,&col,&position[l],&rotation[l])!=-1){
+                                                                       if(model[l].LineCheck(&testpoint,&testpoint2,&col,&position[l],&yaw[l])!=-1){
                                                                                shadowed[i]=1-(findDistance(&terrainpoint,&col)/50);    
                                                                        }
                                                                }
                                                        }
                                                        if(shadowed[i]>0){
-                                                               col=model[i].normals[j]-DoRotation(lightloc*shadowed[i],0,-rotation[i],0);
+                                                               col=model[i].normals[j]-DoRotation(lightloc*shadowed[i],0,-yaw[i],0);
                                                                Normalise(&col);
                                                                for(k=0;k<model[i].TriangleNum;k++){
                                                                        if(model[i].Triangles[k].vertex[0]==j){
@@ -749,8 +766,8 @@ Objects::Objects()
 
        memset(position, 0, sizeof(position));
        memset(type, 0, sizeof(type));
-       memset(rotation, 0, sizeof(rotation));
-       memset(rotation2, 0, sizeof(rotation2));
+       memset(yaw, 0, sizeof(yaw));
+       memset(pitch, 0, sizeof(pitch));
        memset(rotx, 0, sizeof(rotx));
        memset(rotxvel, 0, sizeof(rotxvel));
        memset(roty, 0, sizeof(roty));