void md5Animation::load(const char* animationFile)
{
	// Open file
	string fileToOpen = Import::GetResourcesFolder() + "Res/models/" ;
	fileToOpen += animationFile;

	LOGE("[MD5ANIMATION][Load] Loading %s", fileToOpen.c_str());

	FILE* fp = fopen (fileToOpen.c_str(), "rb");
	if (!fp)
    {
		printf("Error: could not open file '%s'!\n", fileToOpen.c_str());
		return ;
    }


	readVersion(fp);				//CHECK_LOADING_STATUS;
	readCommandline(fp);				//CHECK_LOADING_STATUS;
	readNumFrames(fp);				//CHECK_LOADING_STATUS;
	readNumJoints(fp);				//CHECK_LOADING_STATUS;
	readFrameRate(fp);				//CHECK_LOADING_STATUS;
	readNumAnimatedComponents(fp);			//CHECK_LOADING_STATUS;
	readHierarchy(fp);				//CHECK_LOADING_STATUS;
	readBounds(fp);				///	CHECK_LOADING_STATUS;
	readBaseFrame(fp);				//CHECK_LOADING_STATUS;
	readFrames(fp);					//CHECK_LOADING_STATUS;

	fclose(fp);
	loadingErrors = false;
}
//-*****************************************************************************
HDF5HierarchyReader::HDF5HierarchyReader( hid_t iFile,
                                          HDF5Hierarchy& iH5H,
                                          const bool iCacheHierarchy )
    : m_H5H( iH5H )
{
    int enabled( 0 );
    if (iCacheHierarchy && H5Aexists( iFile, "abc_ref_hierarchy" ))
    {
        H5LTget_attribute_int( iFile, ".", "abc_ref_hierarchy", &enabled );
    }

    m_H5H.clear();
    m_H5H.setEnabled( enabled != 0 );

    if( enabled )
    {
        readHierarchy( iFile );
    }

}
Exemple #3
0
 void Skeleton::readHeading(char* buff, FILE* file) {
 	char* temp = buff;
 	decomment(buff);
 	trim(&temp);

 	char head[50];
 	char rest[200];
 	int num = sscanf(temp, ":%s %s", head, rest);
 	if (num == 0) {
 		printf("Could not get heading name from %s, all is lost\n", temp);
 		exit(EXIT_FAILURE);
 	}
 	if (strcmp(head, "version") == 0) {
		//version string - must be 1.10
 		char* version = rest;
 		if (num != 2) {
 			char *p = { '\0' };
 			while (strlen(p) == 0) {
 				char* p = fgets(buff, buffSize, file);
 				decomment(p);
 				trim(&p);
 				version = p;
 			}
 		}
 		if (strcmp(version, "1.10") != 0) {
 			printf("Invalid version: %s, must be 1.10\n", version);
 			exit(EXIT_FAILURE);
 		}
		//Finished reading version so read the next thing?
 	} else if (strcmp(head, "name") == 0) {
		//This allows the skeleton to be called something
		//other than the file name
		//We don't actually care what the name is, so can
		//ignore this whole section

 	} else if (strcmp(head, "documentation") == 0) {
		//Documentation section has no meaningful information
		//only of use if you want to copy the file. So we skip it
 	} else if (strcmp(head, "units") == 0) {
		//Has factors for the units
		//To be able to model the real person,
		//these must be parsed correctly
		//Only really need to check if deg or rad, but even
		//that is probably not needed for the core or extension
 	} else if (strcmp(head, "root") == 0) {
		//Read in information about root
		//Or be lazy and just assume it is going to be the normal CMU thing!
 	} else if (strcmp(head, "bonedata") == 0) {
		//Description of each bone
		//This does need to actually be read :(
 		char *p;
 		while ((p = fgets(buff, buffSize, file)) != NULL) {
 			decomment(p);
 			trim(&p);
 			if (strlen(p) > 0) {
 				if (p[0] == ':') {
 					return readHeading(buff, file);
 				} else if (strcmp(p, "begin") != 0) {
 					printf("Expected begin for bone data %d, found \"%s\"", numBones, p);
 					exit(EXIT_FAILURE);
 				} else {
 					readBone(buff, file);
 					numBones++;
 				}

 			}
 		}
 	} else if (strcmp(head, "hierarchy") == 0) {
		//Description of how the bones fit together
 		char *p;
 		while ((p = fgets(buff, buffSize, file)) != NULL) {
 			trim(&p);
 			decomment(p);
 			if (strlen(p) > 0) {
 				if (p[0] == ':') {
 					return readHeading(buff, file);
 				} else if (strcmp(p, "begin") != 0) {
 					printf("Expected begin in hierarchy, found %s", p);
 					exit(EXIT_FAILURE);
 				} else {
 					readHierarchy(buff, file);
 				}

 			}
 		}
 	} else {
 		printf("Unknown heading %s\n", head);
 	}

 }