dynamic mesh functions

This commit is contained in:
h4570
2022-07-18 20:32:30 +02:00
parent c56c3d76db
commit f249936981
4 changed files with 30 additions and 43 deletions
@@ -24,30 +24,22 @@ class DynamicMesh : public Mesh {
explicit DynamicMesh(const DynamicMesh& mesh);
~DynamicMesh();
const u8& isMother() const { return _isMother; }
/** Get position from translation matrix */
Vec4* getPosition() {
return reinterpret_cast<Vec4*>(&translation.data[3 * 4]);
}
void setPosition(const Vec4& v) {
TYRA_ASSERT(v.w == 1.0F, "Vec4 must be homogeneous");
reinterpret_cast<Vec4*>(&translation.data[3 * 4])->set(v);
}
/** Returns material, which is a mesh "subgroup". */
DynamicMeshMaterial* getMaterial(const u32& i) const { return materials[i]; }
DynamicMeshMaterial** getMaterials() { return materials; }
const u32& getMaterialsCount() const { return materialsCount; }
const DynamicMeshAnimState& getAnimState() const { return animState; }
/** Count of all vertices. */
u32 getVertexCount() { return frames[0]->getVertexCount(); }
inline u32 getVertexCount() { return frames[0]->getVertexCount(); }
/** Returns single frame. */
DynamicMeshFrame* getFrame(const u32& i) const { return frames[i]; }
DynamicMeshFrame* getFrame(const u32& i) { return frames[i]; }
DynamicMeshFrame** getFrames() { return frames; }
/** Count of frames. Static object (not animated) will have only 1 frame. */
const u32& getFramesCount() const { return framesCount; }
@@ -62,22 +54,11 @@ class DynamicMesh : public Mesh {
const u32& getStayAnimationFrame() const { return animState.stayFrame; }
M4x4 getModelMatrix() const;
// /**
// * Returns material, which is a mesh "subgroup".
// * NULL if not found.
// */
// DynamicMeshMaterial* getMaterialById(const u32& t_id) const;
/** @returns bounding box object of current frame. */
const BBox& getCurrentBoundingBox() const {
return frames[animState.currentFrame]->getBBox();
}
/** Check if are there any frames */
u8 isDataLoaded() const { return framesCount > 0; }
/** Loop in one frame */
void playAnimation(const u32& t_frame) { playAnimation(t_frame, t_frame); }
@@ -102,7 +83,6 @@ class DynamicMesh : public Mesh {
private:
void initMesh();
DynamicMeshAnimState animState;
u8 _isMother;
u32 framesCount, materialsCount;
DynamicMeshFrame** frames;
DynamicMeshMaterial** materials;
+15 -2
View File
@@ -17,7 +17,7 @@ namespace Tyra {
class Mesh {
public:
explicit Mesh();
Mesh(const u8& isMother);
~Mesh();
/** Translation matrix */
@@ -29,9 +29,22 @@ class Mesh {
/** Scale matrix */
M4x4 scale;
const u32& getId() const { return id; }
inline const u32& getId() const { return id; }
inline const u8& isMother() const { return _isMother; }
M4x4 getModelMatrix() const;
/** Get position from translation matrix */
inline Vec4* getPosition() {
return reinterpret_cast<Vec4*>(&translation.data[3 * 4]);
}
inline void setPosition(const Vec4& v) {
TYRA_ASSERT(v.w == 1.0F, "Vec4 must be homogeneous");
reinterpret_cast<Vec4*>(&translation.data[3 * 4])->set(v);
}
protected:
u8 _isMother;
u32 id;
};