Exemplo n.º 1
0
GLUSboolean GLUSAPIENTRY glusWavefrontLoad(const GLUSchar* filename, GLUSwavefront* wavefront)
{
	GLUSshape dummyShape;

	GLUSmaterialList* materialWalker;
	GLUSgroupList* groupWalker;

	GLUSuint i;
	GLUSuint counter = 0;

	if (!_glusWavefrontParse(filename, &dummyShape, wavefront))
	{
		glusWavefrontDestroy(wavefront);

		return GLUS_FALSE;
	}

	wavefront->vertices = dummyShape.vertices;
	wavefront->normals = dummyShape.normals;
	wavefront->texCoords = dummyShape.texCoords;
	wavefront->tangents = dummyShape.tangents;
	wavefront->bitangents = dummyShape.bitangents;
	wavefront->numberVertices = dummyShape.numberVertices;

	glusMemoryFree(dummyShape.indices);

	groupWalker = wavefront->groups;
	while (groupWalker)
	{
		groupWalker->group.indices = (GLUSindex*)glusMemoryMalloc(groupWalker->group.numberIndices * sizeof(GLUSindex));

		if (!groupWalker->group.indices)
		{
			glusWavefrontDestroy(wavefront);

			return GLUS_FALSE;
		}

		for (i = 0; i < groupWalker->group.numberIndices; i++)
		{
			groupWalker->group.indices[i] = counter++;
		}

		materialWalker = wavefront->materials;

		while (materialWalker)
		{
			if (strcmp(materialWalker->material.name, groupWalker->group.materialName) == 0)
			{
				groupWalker->group.material = &materialWalker->material;

				break;
			}

			materialWalker = materialWalker->next;
		}

		groupWalker = groupWalker->next;
	}

	return GLUS_TRUE;
}
Exemplo n.º 2
0
GLUSboolean GLUSAPIENTRY glusShapeLoadWavefront(const GLUSchar* filename, GLUSshape* shape)
{
    return _glusWavefrontParse(filename, shape, 0, 0);
}