forked from Mirrors/openclonk
Added BoundingBox to StdMesh
parent
16bd81ffad
commit
8c15d08a18
|
@ -163,6 +163,12 @@ private:
|
||||||
std::vector<StdMeshTrack*> Tracks; // bone-indexed
|
std::vector<StdMeshTrack*> Tracks; // bone-indexed
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct StdMeshBox
|
||||||
|
{
|
||||||
|
float x1, y1, z1;
|
||||||
|
float x2, y2, z2;
|
||||||
|
};
|
||||||
|
|
||||||
class StdMesh
|
class StdMesh
|
||||||
{
|
{
|
||||||
friend class StdMeshInstance;
|
friend class StdMeshInstance;
|
||||||
|
@ -187,6 +193,8 @@ public:
|
||||||
const StdMeshAnimation* GetAnimationByName(const StdStrBuf& name) const;
|
const StdMeshAnimation* GetAnimationByName(const StdStrBuf& name) const;
|
||||||
const StdMeshMaterial& GetMaterial() const { return *Material; }
|
const StdMeshMaterial& GetMaterial() const { return *Material; }
|
||||||
|
|
||||||
|
const StdMeshBox& GetBoundingBox() const { return BoundingBox; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void AddMasterBone(StdMeshBone* bone);
|
void AddMasterBone(StdMeshBone* bone);
|
||||||
|
|
||||||
|
@ -206,6 +214,7 @@ private:
|
||||||
|
|
||||||
std::map<StdStrBuf, StdMeshAnimation> Animations;
|
std::map<StdStrBuf, StdMeshAnimation> Animations;
|
||||||
|
|
||||||
|
StdMeshBox BoundingBox;
|
||||||
const StdMeshMaterial* Material;
|
const StdMeshMaterial* Material;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -318,6 +318,8 @@ StdMeshAnimation& StdMeshAnimation::operator=(const StdMeshAnimation& other)
|
||||||
StdMesh::StdMesh():
|
StdMesh::StdMesh():
|
||||||
Material(NULL)
|
Material(NULL)
|
||||||
{
|
{
|
||||||
|
BoundingBox.x1 = BoundingBox.y1 = BoundingBox.z1 = 0.0f;
|
||||||
|
BoundingBox.x2 = BoundingBox.y2 = BoundingBox.z2 = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
StdMesh::~StdMesh()
|
StdMesh::~StdMesh()
|
||||||
|
@ -356,6 +358,23 @@ void StdMesh::InitXML(const char* filename, const char* xml_data, StdMeshSkeleto
|
||||||
Vertices[i].nz = mesh.RequireFloatAttribute(normal_elem, "z");
|
Vertices[i].nz = mesh.RequireFloatAttribute(normal_elem, "z");
|
||||||
Vertices[i].u = mesh.RequireFloatAttribute(texcoord_elem, "u");
|
Vertices[i].u = mesh.RequireFloatAttribute(texcoord_elem, "u");
|
||||||
Vertices[i].v = mesh.RequireFloatAttribute(texcoord_elem, "v");
|
Vertices[i].v = mesh.RequireFloatAttribute(texcoord_elem, "v");
|
||||||
|
|
||||||
|
// Construct BoundingBox
|
||||||
|
if(i == 0)
|
||||||
|
{
|
||||||
|
BoundingBox.x1 = BoundingBox.x2 = Vertices[i].x;
|
||||||
|
BoundingBox.y1 = BoundingBox.y2 = Vertices[i].y;
|
||||||
|
BoundingBox.z1 = BoundingBox.z2 = Vertices[i].z;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BoundingBox.x1 = Min(Vertices[i].x, BoundingBox.x1);
|
||||||
|
BoundingBox.x2 = Max(Vertices[i].x, BoundingBox.x2);
|
||||||
|
BoundingBox.y1 = Min(Vertices[i].y, BoundingBox.y1);
|
||||||
|
BoundingBox.y2 = Max(Vertices[i].y, BoundingBox.y2);
|
||||||
|
BoundingBox.z1 = Min(Vertices[i].z, BoundingBox.z1);
|
||||||
|
BoundingBox.z2 = Max(Vertices[i].z, BoundingBox.z2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TiXmlElement* faces_elem = mesh.RequireFirstChild(submesh_elem, "faces");
|
TiXmlElement* faces_elem = mesh.RequireFirstChild(submesh_elem, "faces");
|
||||||
|
|
Loading…
Reference in New Issue