Esempio n. 1
0
bool CModelConverter::ReadModel(const tstring& sFilename)
{
	tstring sExtension;

	size_t iFileLength = sFilename.length();
	sExtension = sFilename.c_str()+iFileLength-4;
	sExtension.tolower();

	if (sExtension == ".obj")
		return ReadOBJ(sFilename);
	else if (sExtension == ".sia")
		return ReadSIA(sFilename);
	else if (sExtension == ".dae")
		return ReadDAE(sFilename);
	else
		return ReadAssImp(sFilename);
}
Esempio n. 2
0
sreLODModel *sreReadMultiDirectoryLODModelFromFile(const char *filename, const char *base_path,
int model_type, int load_flags) {
    // Read vertex attribute and face information.
    switch (model_type) {
    case SRE_MODEL_FILE_TYPE_OBJ :
        ResetSourceModelData();
        ReadOBJ(filename);
        break;
    default :
        ModelFileReadError("Model file format not supported");
        break;
    }

    sreLODModel *m = sreNewLODModel();

    InitializeModelFromFaceData(m);

    AddFacesToModel(m);

    FreeSourceModelData();

    if (nu_attribute_vertices[SRE_ATTRIBUTE_NORMAL] == 0) {
        // If no normals were specified in the file, calculate them.
        m->CalculateNormals();
    }
    else
        // Vertex normals are already set, calculate just triangle normals.
        m->CalculateTriangleNormals();

    // Because we duplicated every vertex when adding the triangles, there
    // is likely to be potential for optimization, which is handled by
    // this library function.
    m->MergeIdenticalVertices();

    printf("Loaded .obj file %s, %d vertices, %d triangles\n", filename,
        m->nu_vertices, m->nu_triangles);
    return m;
}