#include "Skeleton.h"
#include "openal_wrapper.h"
#include "Animation.h"
+#include "Utils/Folders.h"
extern float multiplier;
extern float gravity;
-extern Skeleton testskeleton;
extern Terrain terrain;
extern Objects objects;
extern int environment;
extern float camerashake;
extern bool freeze;
extern int detail;
-extern XYZ envsound[30];
-extern float envsoundvol[30];
-extern int numenvsounds;
-extern float envsoundlife[30];
extern int tutoriallevel;
extern int whichjointstartarray[26];
emit_sound_at(breaksound2, joints[i].position * (*scale) + *coords);
- envsound[numenvsounds] = *coords;
- envsoundvol[numenvsounds] = 64;
- envsoundlife[numenvsounds] = .4;
- numenvsounds++;
+ addEnvSound(*coords, 64);
}
if (findLengthfast(&bounceness) > 2500) {
emit_sound_at(breaksound2, joints[i].position * (*scale) + *coords);
- envsound[numenvsounds] = *coords;
- envsoundvol[numenvsounds] = 64;
- envsoundlife[numenvsounds] = .4;
- numenvsounds++;
+ addEnvSound(*coords, 64);
}
if (objects.type[k] == treetrunktype) {
objects.rotx[k] += joints[i].velocity.x * multiplier * .4;
/* EFFECT
* load an animation from file
*/
-void Animation::Load(const char *filename, int aheight, int aattack)
+void Animation::Load(const std::string& filename, int aheight, int aattack)
{
FILE *tfile;
int i, j;
- XYZ startoffset, endoffset;
-
- // path to dir
- const char *anim_prefix = ":Data:Animations:";
-
+ XYZ endoffset;
LOGFUNC;
- // concatenate anim_prefix + 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;
+ std::string filepath = Folders::getResourcePath("Animations/"+filename);
- LOG(std::string("Loading animation...") + fixedFN);
+ LOG(std::string("Loading animation...") + filepath);
// clear existing data
deallocate();
Game::LoadingScreen();
// read file in binary mode
- tfile = fopen( fixedFN, "rb" );
+ tfile = fopen( filepath.c_str(), "rb" );
if (tfile) {
// read numframes, joints to know how much memory to allocate
funpackf(tfile, "Bi Bi", &numframes, &joints);
fclose(tfile);
}
- startoffset = 0;
endoffset = 0;
- // find average position of certain joints on first and last frames
- // and save in startoffset, endoffset
+ // find average position of certain joints on last frames
+ // and save in endoffset
// (not sure what exactly this accomplishes. the y < 1 test confuses me.)
for (j = 0; j < joints; j++) {
- if (position[j][0].y < 1)
- startoffset += position[j][0];
if (position[j][numframes - 1].y < 1)
endoffset += position[j][numframes - 1];
}
- startoffset /= joints;
endoffset /= joints;
offset = endoffset;
offset.y = 0;
// load skeleton
- tfile = fopen( ConvertFileName(filename), "rb" );
+ tfile = fopen( Folders::getResourcePath(filename).c_str(), "rb" );
if (1) { // FIXME: should this be if(tfile) ?
// read num_joints
// load ???
- tfile = fopen( ConvertFileName(lowfilename), "rb" );
+ tfile = fopen( Folders::getResourcePath(lowfilename).c_str(), "rb" );
if (1) { // FIXME: should this be if(tfile) ?
// skip joints section
// load clothes
if (clothes) {
- tfile = fopen( ConvertFileName(clothesfilename), "rb" ); // FIXME: where's the check for valid load
+ tfile = fopen( Folders::getResourcePath(clothesfilename).c_str(), "rb" ); // FIXME: where's the check for valid load
// skip num_joints
lSize = sizeof(num_joints);