removed dff model

This commit is contained in:
Sandro Sobczyński
2020-11-01 14:17:52 +01:00
parent ef7bd425db
commit 200fa3e4d5
14 changed files with 163 additions and 201 deletions
-1
View File
@@ -36,7 +36,6 @@ void BmpLoader::load(MeshTexture &o_texture, char *t_subfolder, char *t_name, ch
char *t_path_part = String::createConcatenated(t_subfolder, t_name);
char *t_path = String::createConcatenated(t_path_part, t_extension);
delete[] t_path_part;
FILE *file = fopen(t_path, "rb");
if (file == NULL)
+56 -2
View File
@@ -34,7 +34,7 @@ DffLoader::~DffLoader() {}
// Methods
// ----
void DffLoader::load(RwClump &o_clump, char *t_filename, float t_scale)
void DffLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_invertT)
{
PRINT_LOG("Loading dff file");
FILE *file = fopen(t_filename, "rb");
@@ -46,11 +46,65 @@ void DffLoader::load(RwClump &o_clump, char *t_filename, float t_scale)
rewind(file);
fread(data, sizeof(u8), fileSize, file);
fclose(file);
serialize(o_clump, data, t_scale);
RwClump *clump = new RwClump();
serialize(*clump, data, t_scale);
delete[] data;
// delete[] clump; // TODO
convert(o_result, *clump, t_invertT);
PRINT_LOG("Dff file loaded!");
}
void DffLoader::convert(MeshFrame *frames, RwClump &t_clump, u8 t_invertT)
{
#define GEOMETRY t_clump.geometryList.geometries[0]
MeshFrame *frame = &frames[0];
u32 vertNormalStCount = GEOMETRY.data.dataHeader.vertexCount;
frame->allocateVertices(vertNormalStCount);
frame->allocateNormals(vertNormalStCount);
frame->allocateSTs(vertNormalStCount);
Vector3 tempVec = Vector3();
Point tempPoint = Point();
for (u32 i = 0; i < vertNormalStCount; i++)
{
tempVec.set(
GEOMETRY.data.vertexInformation[i].x,
GEOMETRY.data.vertexInformation[i].y,
GEOMETRY.data.vertexInformation[i].z);
frame->setVertex(i, tempVec);
tempVec.set(
GEOMETRY.data.normalInformation[i].x,
GEOMETRY.data.normalInformation[i].y,
GEOMETRY.data.normalInformation[i].z);
frame->setNormal(i, tempVec);
tempPoint.set(
GEOMETRY.data.textureMappingInformation[i].u,
GEOMETRY.data.textureMappingInformation[i].v);
if (t_invertT)
tempPoint.y = 1.0F - tempPoint.y;
frame->setST(i, tempPoint);
}
#define CURR_SPLIT GEOMETRY.extension.materialSplit.splitInformation[i]
u32 materialsCount = GEOMETRY.extension.materialSplit.header.splitCount;
frame->allocateMaterials(materialsCount);
for (u32 i = 0; i < materialsCount; i++)
{
u32 facesCount = CURR_SPLIT.faceIndex;
u32 materialIndex = CURR_SPLIT.materialIndex;
frame->getMaterial(i).allocateFaces(facesCount);
char **materialName = &GEOMETRY.materialList.materials[materialIndex].textures[0].textureName.text;
frame->getMaterial(i).setName(*materialName);
for (u32 j = 0; j < facesCount; j++)
{
frame->getMaterial(i).setVertexFace(j, CURR_SPLIT.vertexInformation[j].vertex1);
frame->getMaterial(i).setNormalFace(j, CURR_SPLIT.vertexInformation[j].vertex1);
frame->getMaterial(i).setSTFace(j, CURR_SPLIT.vertexInformation[j].vertex1);
}
}
}
void DffLoader::serialize(RwClump &t_clump, u8 *t_data, float t_scale)
{
u32 ptrPos = 0;
+2 -2
View File
@@ -30,7 +30,7 @@ ObjLoader::~ObjLoader() {}
* Notice: At this moment textures names are MATERIAL names from .obj file!
* Notice 2: Faces MUST be triangulated (check out blender export settings).
*/
void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 invertT)
void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_invertT)
{
FILE *file = fopen(t_filename, "rb");
if (file == NULL)
@@ -55,7 +55,7 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 in
{
Point point = Point();
fscanf(file, "%f %f\n", &point.x, &point.y);
if (invertT)
if (t_invertT)
point.y = 1.0F - point.y;
o_result->setST(cordsI++, point);
}