moved sts/normals present

This commit is contained in:
h4570
2020-12-28 16:05:48 +01:00
parent 1b6e1e94ee
commit ad43a4bfd3
5 changed files with 30 additions and 16 deletions
-8
View File
@@ -143,9 +143,6 @@ public:
const u8 &areMaterialsAllocated() const { return _areMaterialsAllocated; }; const u8 &areMaterialsAllocated() const { return _areMaterialsAllocated; };
const u8 &isBoundingBoxCalculated() const { return _isBoundingBoxCalculated; }; const u8 &isBoundingBoxCalculated() const { return _isBoundingBoxCalculated; };
const u8 &areSTsPresent() const { return _areSTsPresent; };
const u8 &areNormalsPresent() const { return _areNormalsPresent; };
/** Create reference copy (non-mother) */ /** Create reference copy (non-mother) */
void copyFrom(MeshFrame *t_refCopy); void copyFrom(MeshFrame *t_refCopy);
@@ -161,9 +158,6 @@ public:
/** Set materials count and allocate memory. */ /** Set materials count and allocate memory. */
void allocateMaterials(const u32 &t_val); void allocateMaterials(const u32 &t_val);
void setSTsPresent(const u8 &b) { _areSTsPresent = b; };
void setNormalsPresent(const u8 &b) { _areNormalsPresent = b; };
/** /**
* Calculates bounding box (AABB) for frame and for materiaals. * Calculates bounding box (AABB) for frame and for materiaals.
* Should be called by data loader, * Should be called by data loader,
@@ -178,8 +172,6 @@ private:
_areVerticesAllocated, _areVerticesAllocated,
_areNormalsAllocated, _areNormalsAllocated,
_areMaterialsAllocated, _areMaterialsAllocated,
_areSTsPresent,
_areNormalsPresent,
_isBoundingBoxCalculated; _isBoundingBoxCalculated;
u32 vertexCount, stsCount, normalsCount, materialsCount, id; u32 vertexCount, stsCount, normalsCount, materialsCount, id;
MeshMaterial *materials; MeshMaterial *materials;
+22 -1
View File
@@ -107,10 +107,26 @@ public:
/** Set material name. */ /** Set material name. */
void setName(char *t_val); void setName(char *t_val);
/**
* Do not call this method unless you know what you do.
* Should be called by data loader.
*/
void setSTsPresent(const u8 &b) { _areSTsPresent = b; };
/**
* Do not call this method unless you know what you do.
* Should be called by data loader.
*/
void setNormalsPresent(const u8 &b) { _areNormalsPresent = b; };
// ---- // ----
// Other // Other
// ---- // ----
const u8 &areSTsPresent() const { return _areSTsPresent; };
const u8 &areNormalsPresent() const { return _areNormalsPresent; };
/** Create reference copy (non-mother) */ /** Create reference copy (non-mother) */
void copyFrom(MeshMaterial *t_refCopy); void copyFrom(MeshMaterial *t_refCopy);
@@ -148,7 +164,12 @@ private:
BoundingBox *boundingBoxObj; BoundingBox *boundingBoxObj;
u32 facesCount, id; u32 facesCount, id;
u32 *vertexFaces, *stFaces, *normalFaces; u32 *vertexFaces, *stFaces, *normalFaces;
u8 _isMother, _isNameSet, _areFacesAllocated, _isBoundingBoxCalculated; u8 _isMother,
_isNameSet,
_areFacesAllocated,
_isBoundingBoxCalculated,
_areSTsPresent,
_areNormalsPresent;
char *name; char *name;
}; };
+4 -3
View File
@@ -145,7 +145,7 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
o_result->getMaterial(materialsI).setSTFace(faceI, coordIndex[0] - 1); o_result->getMaterial(materialsI).setSTFace(faceI, coordIndex[0] - 1);
o_result->getMaterial(materialsI).setSTFace(faceI + 1, coordIndex[1] - 1); o_result->getMaterial(materialsI).setSTFace(faceI + 1, coordIndex[1] - 1);
o_result->getMaterial(materialsI).setSTFace(faceI + 2, coordIndex[2] - 1); o_result->getMaterial(materialsI).setSTFace(faceI + 2, coordIndex[2] - 1);
o_result->setSTsPresent(true); o_result->getMaterial(materialsI).setSTsPresent(true);
} }
if (matches == 9) if (matches == 9)
@@ -153,7 +153,7 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
o_result->getMaterial(materialsI).setNormalFace(faceI, normalIndex[0] - 1); o_result->getMaterial(materialsI).setNormalFace(faceI, normalIndex[0] - 1);
o_result->getMaterial(materialsI).setNormalFace(faceI + 1, normalIndex[1] - 1); o_result->getMaterial(materialsI).setNormalFace(faceI + 1, normalIndex[1] - 1);
o_result->getMaterial(materialsI).setNormalFace(faceI + 2, normalIndex[2] - 1); o_result->getMaterial(materialsI).setNormalFace(faceI + 2, normalIndex[2] - 1);
o_result->setNormalsPresent(true); o_result->getMaterial(materialsI).setNormalsPresent(true);
faceI += 3; faceI += 3;
} }
else if (matches == 2) else if (matches == 2)
@@ -171,7 +171,7 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
o_result->getMaterial(materialsI).setNormalFace(faceI, normalIndex[0] - 1); o_result->getMaterial(materialsI).setNormalFace(faceI, normalIndex[0] - 1);
o_result->getMaterial(materialsI).setNormalFace(faceI + 1, normalIndex[1] - 1); o_result->getMaterial(materialsI).setNormalFace(faceI + 1, normalIndex[1] - 1);
o_result->getMaterial(materialsI).setNormalFace(faceI + 2, normalIndex[2] - 1); o_result->getMaterial(materialsI).setNormalFace(faceI + 2, normalIndex[2] - 1);
o_result->setNormalsPresent(true); o_result->getMaterial(materialsI).setNormalsPresent(true);
faceI += 2; faceI += 2;
} }
} }
@@ -180,6 +180,7 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
else else
break; break;
} }
o_result->calculateBoundingBoxes(); o_result->calculateBoundingBoxes();
fclose(file); fclose(file);
delete[] path; delete[] path;
-4
View File
@@ -27,8 +27,6 @@ MeshFrame::MeshFrame()
_areVerticesAllocated = false; _areVerticesAllocated = false;
_areNormalsAllocated = false; _areNormalsAllocated = false;
_areMaterialsAllocated = false; _areMaterialsAllocated = false;
_areSTsPresent = false;
_areNormalsPresent = false;
_isMother = true; _isMother = true;
} }
@@ -160,8 +158,6 @@ void MeshFrame::copyFrom(MeshFrame *t_refCopy)
_areVerticesAllocated = true; _areVerticesAllocated = true;
_areNormalsAllocated = true; _areNormalsAllocated = true;
_areMaterialsAllocated = true; _areMaterialsAllocated = true;
_areSTsPresent = t_refCopy->_areSTsPresent;
_areNormalsPresent = t_refCopy->_areNormalsPresent;
vertices = t_refCopy->vertices; vertices = t_refCopy->vertices;
sts = t_refCopy->sts; sts = t_refCopy->sts;
normals = t_refCopy->normals; normals = t_refCopy->normals;
+4
View File
@@ -25,6 +25,8 @@ MeshMaterial::MeshMaterial()
_isNameSet = false; _isNameSet = false;
_areFacesAllocated = false; _areFacesAllocated = false;
_isBoundingBoxCalculated = false; _isBoundingBoxCalculated = false;
_areSTsPresent = false;
_areNormalsPresent = false;
_isMother = true; _isMother = true;
setDefaultColor(); setDefaultColor();
} }
@@ -158,6 +160,8 @@ void MeshMaterial::copyFrom(MeshMaterial *t_refCopy)
stFaces = t_refCopy->stFaces; stFaces = t_refCopy->stFaces;
normalFaces = t_refCopy->normalFaces; normalFaces = t_refCopy->normalFaces;
facesCount = t_refCopy->facesCount; facesCount = t_refCopy->facesCount;
_areSTsPresent = t_refCopy->_areSTsPresent;
_areNormalsPresent = t_refCopy->_areNormalsPresent;
_areFacesAllocated = true; _areFacesAllocated = true;
_isMother = false; _isMother = false;