static mesh finish
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "loaders/3d/builder/mesh_builder_data.hpp"
|
||||
#include "./dynamic_mesh_frame.hpp"
|
||||
#include "./dynamic_mesh_material_frame.hpp"
|
||||
#include "../mesh_frame.hpp"
|
||||
#include "../mesh_material_frame.hpp"
|
||||
#include "./dynamic_mesh_anim_state.hpp"
|
||||
#include "../mesh.hpp"
|
||||
|
||||
@@ -24,22 +24,12 @@ class DynamicMesh : public Mesh {
|
||||
explicit DynamicMesh(const DynamicMesh& mesh);
|
||||
~DynamicMesh();
|
||||
|
||||
/** 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. */
|
||||
inline u32 getVertexCount() { return frames[0]->getVertexCount(); }
|
||||
|
||||
/** Returns single frame. */
|
||||
DynamicMeshFrame* getFrame(const u32& i) { return frames[i]; }
|
||||
MeshFrame* getFrame(const u32& i) { return frames[i]; }
|
||||
|
||||
DynamicMeshFrame** getFrames() { return frames; }
|
||||
MeshFrame** getFrames() { return frames; }
|
||||
|
||||
/** Count of frames. Static object (not animated) will have only 1 frame. */
|
||||
const u32& getFramesCount() const { return framesCount; }
|
||||
@@ -81,11 +71,10 @@ class DynamicMesh : public Mesh {
|
||||
const u8& isStayAnimationSet() const { return animState.isStayFrameSet; }
|
||||
|
||||
private:
|
||||
void initMesh();
|
||||
void initAnimation();
|
||||
DynamicMeshAnimState animState;
|
||||
u32 framesCount, materialsCount;
|
||||
DynamicMeshFrame** frames;
|
||||
DynamicMeshMaterial** materials;
|
||||
u32 framesCount;
|
||||
MeshFrame** frames;
|
||||
};
|
||||
|
||||
} // namespace Tyra
|
||||
|
||||
@@ -11,13 +11,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "math/m4x4.hpp"
|
||||
#include "./mesh_material.hpp"
|
||||
#include <tamtypes.h>
|
||||
#include "debug/debug.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
class Mesh {
|
||||
public:
|
||||
Mesh(const u8& isMother);
|
||||
explicit Mesh(const MeshBuilderData& data);
|
||||
explicit Mesh(const Mesh& mesh);
|
||||
~Mesh();
|
||||
|
||||
/** Translation matrix */
|
||||
@@ -38,14 +41,20 @@ class Mesh {
|
||||
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);
|
||||
}
|
||||
void setPosition(const Vec4& v);
|
||||
|
||||
/** Returns material, which is a mesh "subgroup". */
|
||||
MeshMaterial* getMaterial(const u32& i) const { return materials[i]; }
|
||||
|
||||
MeshMaterial** getMaterials() { return materials; }
|
||||
|
||||
const u32& getMaterialsCount() const { return materialsCount; }
|
||||
|
||||
protected:
|
||||
void init();
|
||||
u8 _isMother;
|
||||
u32 id;
|
||||
u32 id, materialsCount;
|
||||
MeshMaterial** materials;
|
||||
};
|
||||
|
||||
} // namespace Tyra
|
||||
|
||||
+5
-5
@@ -10,17 +10,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "./dynamic_mesh_material.hpp"
|
||||
#include "./mesh_material.hpp"
|
||||
#include "loaders/3d/builder/mesh_builder_data.hpp"
|
||||
#include "renderer/3d/bbox/bbox.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
class DynamicMeshFrame {
|
||||
class MeshFrame {
|
||||
public:
|
||||
explicit DynamicMeshFrame(const MeshBuilderData& data, const u32& index);
|
||||
explicit DynamicMeshFrame(const DynamicMeshFrame& frame);
|
||||
~DynamicMeshFrame();
|
||||
explicit MeshFrame(const MeshBuilderData& data, const u32& index);
|
||||
explicit MeshFrame(const MeshFrame& frame);
|
||||
~MeshFrame();
|
||||
|
||||
const u32& getId() const { return id; }
|
||||
const u32& getVertexCount() const { return vertexCount; }
|
||||
+7
-10
@@ -12,16 +12,15 @@
|
||||
|
||||
#include "debug/debug.hpp"
|
||||
#include "loaders/3d/builder/mesh_builder_data.hpp"
|
||||
#include "renderer/3d/mesh/dynamic/dynamic_mesh_material_frame.hpp"
|
||||
#include "./mesh_material_frame.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
class DynamicMeshMaterial {
|
||||
class MeshMaterial {
|
||||
public:
|
||||
explicit DynamicMeshMaterial(const MeshBuilderData& data,
|
||||
const u32& materialIndex);
|
||||
explicit DynamicMeshMaterial(const DynamicMeshMaterial& material);
|
||||
~DynamicMeshMaterial();
|
||||
explicit MeshMaterial(const MeshBuilderData& data, const u32& materialIndex);
|
||||
explicit MeshMaterial(const MeshMaterial& material);
|
||||
~MeshMaterial();
|
||||
|
||||
Color singleColor;
|
||||
|
||||
@@ -30,15 +29,13 @@ class DynamicMeshMaterial {
|
||||
const u32& getFacesCount() const { return facesCount; }
|
||||
const u8& isMother() const { return _isMother; }
|
||||
const u8& isSingleColorActivated() const { return singleColorFlag; }
|
||||
|
||||
u32* getVertexFaces() const { return vertexFaces; }
|
||||
u32* getTextureCoordFaces() const { return textureCoordFaces; }
|
||||
u32* getNormalFaces() const { return normalFaces; }
|
||||
u32* getColorFaces() const { return normalFaces; }
|
||||
DynamicMeshMaterialFrame* getFrames() const { return *frames; }
|
||||
MeshMaterialFrame* getFrames() const { return *frames; }
|
||||
|
||||
const BBox& getBBox(const u32& frame) const;
|
||||
|
||||
void setSingleColorFlag(const u8& flag);
|
||||
|
||||
void print() const;
|
||||
@@ -47,7 +44,7 @@ class DynamicMeshMaterial {
|
||||
std::string getPrint(const char* name = nullptr) const;
|
||||
|
||||
private:
|
||||
DynamicMeshMaterialFrame** frames;
|
||||
MeshMaterialFrame** frames;
|
||||
|
||||
std::string _name;
|
||||
u8 _isMother, singleColorFlag;
|
||||
+6
-6
@@ -10,17 +10,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "loaders/3d/builder/mesh_builder_data.hpp"
|
||||
#include "./renderer/3d/bbox/bbox.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
class DynamicMeshMaterialFrame {
|
||||
class MeshMaterialFrame {
|
||||
public:
|
||||
explicit DynamicMeshMaterialFrame(const MeshBuilderData& data,
|
||||
const u32& frameIndex,
|
||||
const u32& materialIndex);
|
||||
explicit DynamicMeshMaterialFrame(const DynamicMeshMaterialFrame& frame);
|
||||
~DynamicMeshMaterialFrame();
|
||||
explicit MeshMaterialFrame(const MeshBuilderData& data, const u32& frameIndex,
|
||||
const u32& materialIndex);
|
||||
explicit MeshMaterialFrame(const MeshMaterialFrame& frame);
|
||||
~MeshMaterialFrame();
|
||||
|
||||
const u32& getId() const { return id; }
|
||||
const u8& isMother() const { return _isMother; }
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2022, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../mesh.hpp"
|
||||
#include "../mesh_frame.hpp"
|
||||
#include "../mesh_material.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
class StaticMesh : public Mesh {
|
||||
public:
|
||||
StaticMesh(const MeshBuilderData& data);
|
||||
StaticMesh(const StaticMesh& mesh);
|
||||
~StaticMesh();
|
||||
|
||||
MeshFrame* getFrame() { return frame; }
|
||||
|
||||
/** @returns bounding box object of current frame. */
|
||||
const BBox& getBoundingBox() const { return frame->getBBox(); }
|
||||
|
||||
private:
|
||||
MeshFrame* frame;
|
||||
};
|
||||
|
||||
} // namespace Tyra
|
||||
Reference in New Issue
Block a user