Ejemplo n.º 1
0
Node* ReturnElementByName(List* list, char* name)
{
	Node* current_node;
	if (IsListEmpty(list))
	{
		return NULL;
	}
	current_node = list->firstNode;
	if (STRINGS_ARE_EQUAL(current_node->name,name))
	{
		return current_node;
	}

	while (current_node != NULL)
	{
		if (STRINGS_ARE_EQUAL(current_node->name,name))
		{
			return current_node;
		}
		else
		{
			current_node = current_node->next;
		}
	}
	return NULL;
}
Ejemplo n.º 2
0
int ReturnIndexOfElement(List* list, char* name)
{
	Node* current_node = list->firstNode;
	int index_of_element = 0;

	while (current_node != NULL)
	{
		if (STRINGS_ARE_EQUAL(current_node->name,name))
		{
			return index_of_element;
		}
		else
		{
			current_node = current_node->next;
			index_of_element++;
		}
	}
	return -1;
}
Ejemplo n.º 3
0
int getjointvarnum(char string[])
{

   if (STRINGS_ARE_EQUAL(string,"r1"))
      return (0);
   if (STRINGS_ARE_EQUAL(string,"r2"))
      return (1);
   if (STRINGS_ARE_EQUAL(string,"r3"))
      return (2);
   if (STRINGS_ARE_EQUAL(string,"tx"))
      return (3);
   if (STRINGS_ARE_EQUAL(string,"ty"))
      return (4);
   if (STRINGS_ARE_EQUAL(string,"tz"))
      return (5);
   if (STRINGS_ARE_EQUAL(string,"order"))
      return (6);
   if (STRINGS_ARE_EQUAL(string,"axis1"))
      return (7);
   if (STRINGS_ARE_EQUAL(string,"axis2"))
      return (8);
   if (STRINGS_ARE_EQUAL(string,"axis3"))
      return (9);
   if (STRINGS_ARE_EQUAL(string,"segments"))
      return (10);

   return (-1);

}
Ejemplo n.º 4
0
/*
=============
MD5Model::InitMD5ModelWithMesh

	Initializes MD5Model with the mesh at the path.
=============
*/
bool MD5Model::InitMD5ModelWithMesh( const char* path ) {

	if ( !ValidMD5MeshExtension( path ) ) {
		printf( "Not a valid MD5Mesh extension\n" );
		return false;
	}

	char* fileData = FileOperations::ReadFileToCharBuffer( path );

	if ( fileData == NULL ) { //File wasn't opened
		printf( "Mesh at path '%s' could not be opened\n", path );
		return false;
	} else {
		printf( "Beginning load of: %s\n", path );

        modelName       = path;
        unsigned slash  = modelName.find_last_of( "/" ) + 1;
        unsigned dot    = modelName.find_last_of( "." );
        modelName		= modelName.substr( slash, dot - slash );

		char* nextLineToken	= NULL;
		char* currentLine   = strtok_s( fileData, "\n", &nextLineToken );

		while ( currentLine != NULL ) {
			char* nextParam     = NULL;
			char* currentParam  = strtok_s( currentLine, " ", &nextParam );

			if ( STRINGS_ARE_EQUAL( currentParam, "MD5Version" ) ) { //Read the version
				nextParam[2] = '\0'; //Truncate to 2 chars
				 if ( !STRINGS_ARE_EQUAL( nextParam, "10" ) ) {
					printf( "Only MD5Version 10 is supported\n" );
					delete[] fileData;
					return false;                
				 }
			} else if ( STRINGS_ARE_EQUAL( currentParam, "numJoints" ) ) { //Read numjoints
				int numJoints = std::atoi( nextParam );
				joints.resize( numJoints );
				blendSkeleton.joints.resize( numJoints );
                blendSkeleton.jointMatricies.resize( numJoints );                
			} else if ( STRINGS_ARE_EQUAL( currentParam, "numMeshes" ) ) { //Read nummeshes
				int numMeshes = std::atoi( nextParam );
				meshes.reserve( numMeshes );
			} else if ( STRINGS_ARE_EQUAL( currentParam, "joints" ) ) { //Read joints
				if ( joints.size() == 0 ) {
					printf( "numJoints was not specified\n" );
					delete[] fileData;
					return false;    
				}
				nextLineToken = ReadJoints( nextLineToken );
			} else if ( STRINGS_ARE_EQUAL( currentParam, "mesh" ) ) { //Read a mesh
				nextLineToken = ReadMesh( nextLineToken );
			}

			currentLine = strtok_s( NULL, "\n", &nextLineToken );
		}

		GenerateBindPoseMatricies();

		printf( "   MD5Mesh file parsed\n" );
		printf( "      Joint count:\t%i\n", joints.size() );
		printf( "      Mesh count:\t%i\n", meshes.size() );        
		printf( "Successfully Loaded MD5Mesh: %s\n", path );        

	}
    
    delete[] fileData;

	return SetupMatrixTextureBuffer();
}