X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FSkeleton.cpp;h=2959e8157ab33281b0a96369c0fc8cdff5e67a15;hb=9248d1455aa434112b5ddd771fd69b8df02d44ee;hp=fd44de1cc519e0cad443ba26e135f5c4dffd671c;hpb=8866bcf90dba64f2fd6cecd6839b9b80988e46a6;p=lugaru.git diff --git a/Source/Skeleton.cpp b/Source/Skeleton.cpp index fd44de1..2959e81 100644 --- a/Source/Skeleton.cpp +++ b/Source/Skeleton.cpp @@ -20,16 +20,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /**> HEADER FILES <**/ +#include "Game.h" #include "Skeleton.h" +#include "openal_wrapper.h" +#include "Animation.h" extern float multiplier; extern float gravity; extern Skeleton testskeleton; extern Terrain terrain; -extern FSOUND_SAMPLE *samp[100]; +extern OPENAL_SAMPLE *samp[100]; extern int channels[100]; extern Objects objects; -extern Sprites sprites; extern int environment; extern float terraindetail; extern float camerashake; @@ -46,10 +48,9 @@ extern int tutoriallevel; extern int whichjointstartarray[26]; extern int whichjointendarray[26]; -#include "Game.h" extern Game * pgame; extern bool visibleloading; -extern "C" void PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused); +extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused); void dealloc2(void* param){ free(param); @@ -295,9 +296,9 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) vel[1]=joints[jointlabels[head]].velocity.y; vel[2]=joints[jointlabels[head]].velocity.z; PlaySoundEx( landsound1, samp[landsound1], NULL, true); - FSOUND_3D_SetAttributes(channels[landsound1], gLoc, vel); - FSOUND_SetVolume(channels[landsound1], 128); - FSOUND_SetPaused(channels[landsound1], false); + OPENAL_3D_SetAttributes(channels[landsound1], gLoc, vel); + OPENAL_SetVolume(channels[landsound1], 128); + OPENAL_SetPaused(channels[landsound1], false); breaking=1; } @@ -314,9 +315,9 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) vel[1]=joints[jointlabels[head]].velocity.y; vel[2]=joints[jointlabels[head]].velocity.z; PlaySoundEx( landsound2, samp[landsound2], NULL, true); - FSOUND_3D_SetAttributes(channels[landsound2], gLoc, vel); - FSOUND_SetVolume(channels[landsound2], 128); - FSOUND_SetPaused(channels[landsound2], false); + OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel); + OPENAL_SetVolume(channels[landsound2], 128); + OPENAL_SetPaused(channels[landsound2], false); } terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0)*-1; @@ -328,7 +329,7 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) } if(findLengthfast(&bounceness)>4000&&breaking){ objects.model[k].MakeDecal(breakdecal,DoRotation(temp-objects.position[k],0,-objects.rotation[k],0),.4,.5,Random()%360); - sprites.MakeSprite(cloudsprite, headpos*(*scale)+*coords,joints[jointlabels[head]].velocity*.06, 1,1,1, 4, .2); + Sprite::MakeSprite(cloudsprite, headpos*(*scale)+*coords,joints[jointlabels[head]].velocity*.06, 1,1,1, 4, .2); breaking=0; camerashake+=.6; @@ -341,9 +342,9 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) vel[1]=joints[jointlabels[head]].velocity.y; vel[2]=joints[jointlabels[head]].velocity.z; PlaySoundEx( breaksound2, samp[breaksound2], NULL, true); - FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel); - FSOUND_SetVolume(channels[breaksound2], 300); - FSOUND_SetPaused(channels[breaksound2], false); + OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel); + OPENAL_SetVolume(channels[breaksound2], 300); + OPENAL_SetPaused(channels[breaksound2], false); envsound[numenvsounds]=*coords; envsoundvol[numenvsounds]=64; @@ -374,7 +375,7 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) joints[jointlabels[head]].locked=1; //joints[jointlabels[head]].velocity*=3; } - if(findLengthfast(&bounceness)>500)sprites.MakeSprite(cloudsprite, headpos*(*scale)+*coords,joints[jointlabels[head]].velocity*.06, 1,1,1, .5, .2); + if(findLengthfast(&bounceness)>500)Sprite::MakeSprite(cloudsprite, headpos*(*scale)+*coords,joints[jointlabels[head]].velocity*.06, 1,1,1, .5, .2); joints[jointlabels[head]].position=(temp-*coords)/(*scale)+(startheadpos-headpos)+terrainnormal*.005; if(longdead>100)broken=1; } @@ -426,9 +427,9 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) vel[2]=joints[i].velocity.z; if(tutoriallevel!=1||id==0){ PlaySoundEx( landsound1, samp[landsound1], NULL, true); - FSOUND_3D_SetAttributes(channels[landsound1], gLoc, vel); - FSOUND_SetVolume(channels[landsound1], 128); - FSOUND_SetPaused(channels[landsound1], false); + OPENAL_3D_SetAttributes(channels[landsound1], gLoc, vel); + OPENAL_SetVolume(channels[landsound1], 128); + OPENAL_SetPaused(channels[landsound1], false); } breaking=1; } @@ -446,9 +447,9 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) vel[2]=joints[i].velocity.z; if(tutoriallevel!=1||id==0){ PlaySoundEx( landsound2, samp[landsound2], NULL, true); - FSOUND_3D_SetAttributes(channels[landsound2], gLoc, vel); - FSOUND_SetVolume(channels[landsound2], 128); - FSOUND_SetPaused(channels[landsound2], false); + OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel); + OPENAL_SetVolume(channels[landsound2], 128); + OPENAL_SetPaused(channels[landsound2], false); } } @@ -465,8 +466,8 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) if(tutoriallevel!=1||id==0) if(findLengthfast(&bounceness)>8000&&breaking){ objects.model[k].MakeDecal(breakdecal,DoRotation(temp-objects.position[k],0,-objects.rotation[k],0),.4,.5,Random()%360); - sprites.MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, 1,1,1, 4, .2); - //sprites.MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, 1,1,1, 1, .2); + Sprite::MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, 1,1,1, 4, .2); + //Sprite::MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, 1,1,1, 1, .2); breaking=0; camerashake+=.6; @@ -479,9 +480,9 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) vel[1]=joints[i].velocity.y; vel[2]=joints[i].velocity.z; PlaySoundEx( breaksound2, samp[breaksound2], NULL, true); - FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel); - FSOUND_SetVolume(channels[breaksound2], 300); - FSOUND_SetPaused(channels[breaksound2], false); + OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel); + OPENAL_SetVolume(channels[breaksound2], 300); + OPENAL_SetPaused(channels[breaksound2], false); envsound[numenvsounds]=*coords; envsoundvol[numenvsounds]=64; @@ -507,19 +508,19 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) if(environment==snowyenvironment&&findLengthfast(&bounceness)>500&&terrain.getOpacity(joints[i].position.x*(*scale)+coords->x,joints[i].position.z*(*scale)+coords->z)<.2){ terrainlight=terrain.getLighting(joints[i].position.x*(*scale)+coords->x,joints[i].position.z*(*scale)+coords->z); - sprites.MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7); + Sprite::MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7); if(detail==2)terrain.MakeDecal(bodyprintdecal, joints[i].position*(*scale)+*coords,.4,.4,0); } else if(environment==desertenvironment&&findLengthfast(&bounceness)>500&&terrain.getOpacity(joints[i].position.x*(*scale)+coords->x,joints[i].position.z*(*scale)+coords->z)<.2){ terrainlight=terrain.getLighting(joints[i].position.x*(*scale)+coords->x,joints[i].position.z*(*scale)+coords->z); - sprites.MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, terrainlight.x*190/255,terrainlight.y*170/255,terrainlight.z*108/255, .5, .7); + Sprite::MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, terrainlight.x*190/255,terrainlight.y*170/255,terrainlight.z*108/255, .5, .7); } else if(environment==grassyenvironment&&findLengthfast(&bounceness)>500&&terrain.getOpacity(joints[i].position.x*(*scale)+coords->x,joints[i].position.z*(*scale)+coords->z)<.2){ terrainlight=terrain.getLighting(joints[i].position.x*(*scale)+coords->x,joints[i].position.z*(*scale)+coords->z); - sprites.MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, terrainlight.x*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5); + Sprite::MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, terrainlight.x*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5); } - else if(findLengthfast(&bounceness)>500)sprites.MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, terrainlight.x,terrainlight.y,terrainlight.z, .5, .2); + else if(findLengthfast(&bounceness)>500)Sprite::MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, terrainlight.x,terrainlight.y,terrainlight.z, .5, .2); joints[i].position.y=(terrain.getHeight(joints[i].position.x*(*scale)+coords->x,joints[i].position.z*(*scale)+coords->z)+groundlevel-coords->y)/(*scale); @@ -548,9 +549,9 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) vel[2]=joints[i].velocity.z; if(tutoriallevel!=1||id==0){ PlaySoundEx( landsound1, samp[landsound1], NULL, true); - FSOUND_3D_SetAttributes(channels[landsound1], gLoc, vel); - FSOUND_SetVolume(channels[landsound1], 128); - FSOUND_SetPaused(channels[landsound1], false); + OPENAL_3D_SetAttributes(channels[landsound1], gLoc, vel); + OPENAL_SetVolume(channels[landsound1], 128); + OPENAL_SetPaused(channels[landsound1], false); } breaking=1; } @@ -568,9 +569,9 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) vel[2]=joints[i].velocity.z; if(tutoriallevel!=1||id==0){ PlaySoundEx( landsound2, samp[landsound2], NULL, true); - FSOUND_3D_SetAttributes(channels[landsound2], gLoc, vel); - FSOUND_SetVolume(channels[landsound2], 128); - FSOUND_SetPaused(channels[landsound2], false); + OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel); + OPENAL_SetVolume(channels[landsound2], 128); + OPENAL_SetPaused(channels[landsound2], false); } } @@ -584,7 +585,7 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) if(tutoriallevel!=1||id==0) if(findLengthfast(&bounceness)>4000&&breaking){ objects.model[k].MakeDecal(breakdecal,DoRotation(temp-objects.position[k],0,-objects.rotation[k],0),.4,.5,Random()%360); - sprites.MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, 1,1,1, 4, .2); + Sprite::MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, 1,1,1, 4, .2); breaking=0; camerashake+=.6; @@ -597,9 +598,9 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) vel[1]=joints[i].velocity.y; vel[2]=joints[i].velocity.z; PlaySoundEx( breaksound2, samp[breaksound2], NULL, true); - FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel); - FSOUND_SetVolume(channels[breaksound2], 300); - FSOUND_SetPaused(channels[breaksound2], false); + OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel); + OPENAL_SetVolume(channels[breaksound2], 300); + OPENAL_SetPaused(channels[breaksound2], false); envsound[numenvsounds]=*coords; envsoundvol[numenvsounds]=64; @@ -623,8 +624,8 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) pos.x+=float(abs(Random()%100)-50)/100*objects.scale[k]*5; pos.y+=float(abs(Random()%100)-50)/100*objects.scale[k]*15; pos.z+=float(abs(Random()%100)-50)/100*objects.scale[k]*5; - sprites.MakeSprite(splintersprite, pos,tempvel*.5, 165/255+float(abs(Random()%100)-50)/400,0,0, .2+float(abs(Random()%100)-50)/1300, 1); - sprites.special[sprites.numsprites-1]=1; + Sprite::MakeSprite(splintersprite, pos,tempvel*.5, 165/255+float(abs(Random()%100)-50)/400,0,0, .2+float(abs(Random()%100)-50)/1300, 1); + Sprite::special[Sprite::numsprites-1]=1; }*/ objects.rotx[k]+=joints[i].velocity.x*multiplier*.4; objects.roty[k]+=joints[i].velocity.z*multiplier*.4; @@ -649,7 +650,7 @@ float Skeleton::DoConstraints(XYZ *coords,float *scale) joints[i].locked=1; //joints[i].velocity*=3; } - if(findLengthfast(&bounceness)>500)sprites.MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, 1,1,1, .5, .2); + if(findLengthfast(&bounceness)>500)Sprite::MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, 1,1,1, .5, .2); joints[i].position=(temp-*coords)/(*scale)+terrainnormal*.005; if(longdead>100)broken=1; } @@ -1007,16 +1008,26 @@ void Skeleton::FindRotationMuscle(int which, int animation) if(!isnormal(muscles[which].rotate3))muscles[which].rotate3=0; } -void Animation::Load(char *filename, int aheight, int aattack) +void Animation::Load(const char *filename, int aheight, int aattack) { static FILE *tfile; static int i,j; static XYZ startoffset,endoffset; static int howmany; + static const char *anim_prefix = ":Data:Animations:"; + + LOGFUNC; - LOG(std::string("Loading animation...") + filename); + int len = strlen(anim_prefix) + strlen(filename); + char *buf = new char[len + 1]; + snprintf(buf, len + 1, "%s%s", anim_prefix, filename); + // Changing the filename into something the OS can understand + char *fixedFN = ConvertFileName(buf); + delete[] buf; + + LOG(std::string("Loading animation...") + fixedFN); deallocate(); @@ -1025,7 +1036,7 @@ void Animation::Load(char *filename, int aheight, int aattack) if(visibleloading)pgame->LoadingScreen(); - tfile=fopen( filename, "rb" ); + tfile=fopen( fixedFN, "rb" ); if(tfile){ funpackf(tfile, "Bi Bi", &numframes, &joints); /* @@ -1132,7 +1143,12 @@ void Animation::Move(XYZ how) } } -void Skeleton::Load(char *filename,char *lowfilename,char *clothesfilename, char *modelfilename, char *model2filename, char *model3filename, char *model4filename, char *model5filename, char *model6filename, char *model7filename, char *modellowfilename, char *modelclothesfilename, bool aclothes) +void Skeleton::Load(const char *filename, const char *lowfilename, const char *clothesfilename, + const char *modelfilename, const char *model2filename, + const char *model3filename, const char *model4filename, + const char *model5filename, const char *model6filename, + const char *model7filename, const char *modellowfilename, + const char *modelclothesfilename, bool aclothes) { static GLfloat M[16]; static int parentID; @@ -1144,6 +1160,7 @@ void Skeleton::Load(char *filename,char *lowfilename,char *clothesfilename, char LOGFUNC; + newload=0; num_models=7; @@ -1197,7 +1214,7 @@ void Skeleton::Load(char *filename,char *lowfilename,char *clothesfilename, char drawmodelclothes.CalculateNormals(0); } - tfile=fopen( filename, "rb" ); + tfile=fopen( ConvertFileName(filename), "rb" ); if(1){ funpackf(tfile, "Bi", &num_joints); //joints.resize(num_joints); @@ -1284,7 +1301,7 @@ void Skeleton::Load(char *filename,char *lowfilename,char *clothesfilename, char } fclose(tfile); - tfile=fopen( lowfilename, "rb" ); + tfile=fopen( ConvertFileName(lowfilename), "rb" ); if(1){ lSize=sizeof(num_joints); fseek ( tfile, lSize, SEEK_CUR); @@ -1390,7 +1407,7 @@ void Skeleton::Load(char *filename,char *lowfilename,char *clothesfilename, char } if(clothes){ - tfile=fopen( clothesfilename, "rb" ); + tfile=fopen( ConvertFileName(clothesfilename), "rb" ); lSize=sizeof(num_joints); fseek ( tfile, lSize, SEEK_CUR); //joints = new Joint[num_joints];