static mesh finish
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
------------ Tyra's v2.0 roadmap to publish on GitHub ------------
|
||||
|
||||
--- H4570
|
||||
- [Renderer] Mesh, StaticMesh, AnimMesh
|
||||
- [Renderer] dynamicRenderer, dbufferring during mesh unrolling, simple clip
|
||||
- [Renderer] staticRenderer -> remove animation, dbufferring during mesh unrolling, full plane clip
|
||||
- [Renderer] Add possibility to on/off frustum check in all pipelines (renderOptions?)
|
||||
|
||||
@@ -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;
|
||||
+5
-5
@@ -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,
|
||||
explicit MeshMaterialFrame(const MeshBuilderData& data, const u32& frameIndex,
|
||||
const u32& materialIndex);
|
||||
explicit DynamicMeshMaterialFrame(const DynamicMeshMaterialFrame& frame);
|
||||
~DynamicMeshMaterialFrame();
|
||||
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
|
||||
@@ -39,24 +39,19 @@ class Stapipeline : public Renderer3DPipeline {
|
||||
RendererCore* rendererCore;
|
||||
Vec4* colorsCache;
|
||||
|
||||
void addVertices(DynamicMesh* mesh, DynamicMeshMaterial* material,
|
||||
StapipBag* bag, DynamicMeshFrame* frameFrom,
|
||||
DynamicMeshFrame* frameTo) const;
|
||||
void addVertices(DynamicMesh* mesh, MeshMaterial* material, StapipBag* bag,
|
||||
MeshFrame* frameFrom, MeshFrame* frameTo) const;
|
||||
StapipInfoBag* getInfoBag(DynamicMesh* mesh, const StapipOptions* options,
|
||||
M4x4* model) const;
|
||||
StapipColorBag* getColorBag(DynamicMesh* mesh, DynamicMeshMaterial* material,
|
||||
DynamicMeshFrame* frameFrom,
|
||||
DynamicMeshFrame* frameTo) const;
|
||||
StapipTextureBag* getTextureBag(DynamicMesh* mesh,
|
||||
DynamicMeshMaterial* material,
|
||||
DynamicMeshFrame* frameFrom,
|
||||
DynamicMeshFrame* frameTo);
|
||||
StapipLightingBag* getLightingBag(DynamicMesh* mesh,
|
||||
DynamicMeshMaterial* material, M4x4* model,
|
||||
DynamicMeshFrame* frameFrom,
|
||||
DynamicMeshFrame* frameTo,
|
||||
StapipColorBag* getColorBag(DynamicMesh* mesh, MeshMaterial* material,
|
||||
MeshFrame* frameFrom, MeshFrame* frameTo) const;
|
||||
StapipTextureBag* getTextureBag(DynamicMesh* mesh, MeshMaterial* material,
|
||||
MeshFrame* frameFrom, MeshFrame* frameTo);
|
||||
StapipLightingBag* getLightingBag(DynamicMesh* mesh, MeshMaterial* material,
|
||||
M4x4* model, MeshFrame* frameFrom,
|
||||
MeshFrame* frameTo,
|
||||
const StapipOptions* options) const;
|
||||
void deallocDrawBags(StapipBag* bag, DynamicMeshMaterial* material) const;
|
||||
void deallocDrawBags(StapipBag* bag, MeshMaterial* material) const;
|
||||
|
||||
void setLightingColorsCache(StapipLightingOptions* lightingOptions);
|
||||
};
|
||||
|
||||
@@ -15,41 +15,28 @@
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
DynamicMesh::DynamicMesh(const MeshBuilderData& data) : Mesh(true) {
|
||||
DynamicMesh::DynamicMesh(const MeshBuilderData& data) : Mesh(data) {
|
||||
TYRA_ASSERT(framesCount > 1, "Frames count must be greater than 1");
|
||||
|
||||
framesCount = data.framesCount;
|
||||
TYRA_ASSERT(framesCount > 0, "Frames count must be greater than 0");
|
||||
|
||||
materialsCount = data.materialsCount;
|
||||
TYRA_ASSERT(materialsCount > 0, "Materials count must be greater than 0");
|
||||
|
||||
frames = new DynamicMeshFrame*[framesCount];
|
||||
frames = new MeshFrame*[framesCount];
|
||||
for (u32 i = 0; i < framesCount; i++) {
|
||||
frames[i] = new DynamicMeshFrame(data, i);
|
||||
frames[i] = new MeshFrame(data, i);
|
||||
}
|
||||
|
||||
materials = new DynamicMeshMaterial*[materialsCount];
|
||||
for (u32 i = 0; i < materialsCount; i++) {
|
||||
materials[i] = new DynamicMeshMaterial(data, i);
|
||||
}
|
||||
|
||||
initMesh();
|
||||
initAnimation();
|
||||
}
|
||||
|
||||
DynamicMesh::DynamicMesh(const DynamicMesh& mesh) : Mesh(false) {
|
||||
DynamicMesh::DynamicMesh(const DynamicMesh& mesh) : Mesh(mesh) {
|
||||
framesCount = mesh.framesCount;
|
||||
materialsCount = mesh.materialsCount;
|
||||
|
||||
frames = new DynamicMeshFrame*[framesCount];
|
||||
frames = new MeshFrame*[framesCount];
|
||||
for (u32 i = 0; i < framesCount; i++) {
|
||||
frames[i] = new DynamicMeshFrame(*mesh.frames[i]);
|
||||
frames[i] = new MeshFrame(*mesh.frames[i]);
|
||||
}
|
||||
|
||||
materials = new DynamicMeshMaterial*[materialsCount];
|
||||
for (u32 i = 0; i < materialsCount; i++) {
|
||||
materials[i] = new DynamicMeshMaterial(*mesh.materials[i]);
|
||||
}
|
||||
|
||||
initMesh();
|
||||
initAnimation();
|
||||
}
|
||||
|
||||
DynamicMesh::~DynamicMesh() {
|
||||
@@ -57,15 +44,9 @@ DynamicMesh::~DynamicMesh() {
|
||||
delete frames[i];
|
||||
}
|
||||
delete[] frames;
|
||||
|
||||
for (u32 i = 0; i < materialsCount; i++) {
|
||||
delete materials[i];
|
||||
|
||||
delete[] materials;
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicMesh::initMesh() {
|
||||
void DynamicMesh::initAnimation() {
|
||||
animState.startFrame = 0;
|
||||
animState.endFrame = 0;
|
||||
animState.interpolation = 0.0F;
|
||||
|
||||
@@ -13,14 +13,53 @@
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
Mesh::Mesh(const u8& isMother) {
|
||||
id = rand() % 1000000;
|
||||
_isMother = isMother;
|
||||
translation.translate(Vec4(0.0F, 0.0F, 0.0F, 1.0F));
|
||||
Mesh::Mesh(const MeshBuilderData& data) {
|
||||
init();
|
||||
|
||||
TYRA_ASSERT(data.materialsCount > 0,
|
||||
"Materials count must be greater than 0");
|
||||
|
||||
materialsCount = data.materialsCount;
|
||||
materials = new MeshMaterial*[materialsCount];
|
||||
|
||||
for (u32 i = 0; i < materialsCount; i++) {
|
||||
materials[i] = new MeshMaterial(data, i);
|
||||
}
|
||||
|
||||
_isMother = true;
|
||||
}
|
||||
|
||||
Mesh::Mesh(const Mesh& mesh) {
|
||||
init();
|
||||
|
||||
materialsCount = mesh.materialsCount;
|
||||
materials = new MeshMaterial*[materialsCount];
|
||||
|
||||
for (u32 i = 0; i < materialsCount; i++) {
|
||||
materials[i] = new MeshMaterial(*mesh.materials[i]);
|
||||
}
|
||||
|
||||
_isMother = false;
|
||||
}
|
||||
|
||||
M4x4 Mesh::getModelMatrix() const { return translation * rotation * scale; }
|
||||
|
||||
Mesh::~Mesh() {}
|
||||
Mesh::~Mesh() {
|
||||
for (u32 i = 0; i < materialsCount; i++) {
|
||||
delete materials[i];
|
||||
}
|
||||
delete[] materials;
|
||||
}
|
||||
|
||||
void Mesh::init() {
|
||||
id = rand() % 1000000;
|
||||
materialsCount = 0;
|
||||
translation.translate(Vec4(0.0F, 0.0F, 0.0F, 1.0F));
|
||||
}
|
||||
|
||||
void Mesh::setPosition(const Vec4& v) {
|
||||
TYRA_ASSERT(v.w == 1.0F, "Vec4 must be homogeneous");
|
||||
reinterpret_cast<Vec4*>(&translation.data[3 * 4])->set(v);
|
||||
}
|
||||
|
||||
} // namespace Tyra
|
||||
|
||||
+7
-8
@@ -15,12 +15,11 @@
|
||||
#include <string>
|
||||
#include "math/vec4.hpp"
|
||||
#include "renderer/models/color.hpp"
|
||||
#include "renderer/3d/mesh/dynamic/dynamic_mesh_frame.hpp"
|
||||
#include "renderer/3d/mesh/mesh_frame.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
DynamicMeshFrame::DynamicMeshFrame(const MeshBuilderData& data,
|
||||
const u32& index) {
|
||||
MeshFrame::MeshFrame(const MeshBuilderData& data, const u32& index) {
|
||||
TYRA_ASSERT(index < data.framesCount && index >= 0, "Provided index \"",
|
||||
index, "\" is out of range");
|
||||
|
||||
@@ -64,7 +63,7 @@ DynamicMeshFrame::DynamicMeshFrame(const MeshBuilderData& data,
|
||||
_isMother = true;
|
||||
}
|
||||
|
||||
DynamicMeshFrame::DynamicMeshFrame(const DynamicMeshFrame& frame) {
|
||||
MeshFrame::MeshFrame(const MeshFrame& frame) {
|
||||
id = rand() % 1000000;
|
||||
|
||||
vertices = frame.vertices;
|
||||
@@ -82,7 +81,7 @@ DynamicMeshFrame::DynamicMeshFrame(const DynamicMeshFrame& frame) {
|
||||
_isMother = false;
|
||||
}
|
||||
|
||||
DynamicMeshFrame::~DynamicMeshFrame() {
|
||||
MeshFrame::~MeshFrame() {
|
||||
if (_isMother) {
|
||||
delete[] vertices;
|
||||
if (normals) delete[] normals;
|
||||
@@ -92,17 +91,17 @@ DynamicMeshFrame::~DynamicMeshFrame() {
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicMeshFrame::print() const {
|
||||
void MeshFrame::print() const {
|
||||
auto text = getPrint(nullptr);
|
||||
printf("%s\n", text.c_str());
|
||||
}
|
||||
|
||||
void DynamicMeshFrame::print(const char* name) const {
|
||||
void MeshFrame::print(const char* name) const {
|
||||
auto text = getPrint(name);
|
||||
printf("%s\n", text.c_str());
|
||||
}
|
||||
|
||||
std::string DynamicMeshFrame::getPrint(const char* name) const {
|
||||
std::string MeshFrame::getPrint(const char* name) const {
|
||||
std::stringstream res;
|
||||
if (name) {
|
||||
res << name << "(";
|
||||
+15
-15
@@ -13,11 +13,11 @@
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
#include <iomanip>
|
||||
#include "renderer/3d/mesh/dynamic/dynamic_mesh_material.hpp"
|
||||
#include "renderer/3d/mesh/mesh_material.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
DynamicMeshMaterial::DynamicMeshMaterial(const MeshBuilderData& data,
|
||||
MeshMaterial::MeshMaterial(const MeshBuilderData& data,
|
||||
const u32& materialIndex)
|
||||
: singleColor(false) {
|
||||
TYRA_ASSERT(materialIndex < data.materialsCount && materialIndex >= 0,
|
||||
@@ -58,18 +58,18 @@ DynamicMeshMaterial::DynamicMeshMaterial(const MeshBuilderData& data,
|
||||
TYRA_ASSERT(facesCount > 0, "Faces count must be greater than 0");
|
||||
|
||||
_name = data.materials[materialIndex]->name;
|
||||
TYRA_ASSERT(_name.length() > 0, "DynamicMeshMaterial name cannot be empty");
|
||||
TYRA_ASSERT(_name.length() > 0, "MeshMaterial name cannot be empty");
|
||||
|
||||
framesCount = data.framesCount;
|
||||
frames = new DynamicMeshMaterialFrame*[framesCount];
|
||||
frames = new MeshMaterialFrame*[framesCount];
|
||||
for (u32 i = 0; i < framesCount; i++) {
|
||||
frames[i] = new DynamicMeshMaterialFrame(data, i, materialIndex);
|
||||
frames[i] = new MeshMaterialFrame(data, i, materialIndex);
|
||||
}
|
||||
|
||||
_isMother = true;
|
||||
}
|
||||
|
||||
DynamicMeshMaterial::DynamicMeshMaterial(const DynamicMeshMaterial& mesh) {
|
||||
MeshMaterial::MeshMaterial(const MeshMaterial& mesh) {
|
||||
id = rand() % 1000000;
|
||||
|
||||
vertexFaces = mesh.vertexFaces;
|
||||
@@ -83,15 +83,15 @@ DynamicMeshMaterial::DynamicMeshMaterial(const DynamicMeshMaterial& mesh) {
|
||||
|
||||
singleColor.set(128.0F, 128.0F, 128.0F, 128.0F);
|
||||
|
||||
frames = new DynamicMeshMaterialFrame*[framesCount];
|
||||
frames = new MeshMaterialFrame*[framesCount];
|
||||
for (u32 i = 0; i < framesCount; i++) {
|
||||
frames[i] = new DynamicMeshMaterialFrame(*mesh.frames[i]);
|
||||
frames[i] = new MeshMaterialFrame(*mesh.frames[i]);
|
||||
}
|
||||
|
||||
_isMother = false;
|
||||
}
|
||||
|
||||
DynamicMeshMaterial::~DynamicMeshMaterial() {
|
||||
MeshMaterial::~MeshMaterial() {
|
||||
if (_isMother) {
|
||||
delete[] vertexFaces;
|
||||
if (textureCoordFaces) delete[] textureCoordFaces;
|
||||
@@ -105,11 +105,11 @@ DynamicMeshMaterial::~DynamicMeshMaterial() {
|
||||
delete[] frames;
|
||||
}
|
||||
|
||||
const BBox& DynamicMeshMaterial::getBBox(const u32& frame) const {
|
||||
const BBox& MeshMaterial::getBBox(const u32& frame) const {
|
||||
return frames[frame]->getBBox();
|
||||
}
|
||||
|
||||
void DynamicMeshMaterial::setSingleColorFlag(const u8& flag) {
|
||||
void MeshMaterial::setSingleColorFlag(const u8& flag) {
|
||||
TYRA_ASSERT(
|
||||
colorFaces != nullptr,
|
||||
"Colors and color faces are required to use color-per-vertex mode");
|
||||
@@ -117,22 +117,22 @@ void DynamicMeshMaterial::setSingleColorFlag(const u8& flag) {
|
||||
singleColorFlag = flag;
|
||||
}
|
||||
|
||||
void DynamicMeshMaterial::print() const {
|
||||
void MeshMaterial::print() const {
|
||||
auto text = getPrint(nullptr);
|
||||
printf("%s\n", text.c_str());
|
||||
}
|
||||
|
||||
void DynamicMeshMaterial::print(const char* name) const {
|
||||
void MeshMaterial::print(const char* name) const {
|
||||
auto text = getPrint(name);
|
||||
printf("%s\n", text.c_str());
|
||||
}
|
||||
|
||||
std::string DynamicMeshMaterial::getPrint(const char* name) const {
|
||||
std::string MeshMaterial::getPrint(const char* name) const {
|
||||
std::stringstream res;
|
||||
if (name) {
|
||||
res << name << "(";
|
||||
} else {
|
||||
res << "DynamicMeshMaterial(";
|
||||
res << "MeshMaterial(";
|
||||
}
|
||||
|
||||
res << std::endl;
|
||||
+4
-5
@@ -13,11 +13,11 @@
|
||||
#include <tamtypes.h>
|
||||
#include "renderer/models/color.hpp"
|
||||
#include "loaders/3d/builder/mesh_builder_data.hpp"
|
||||
#include "renderer/3d/mesh/dynamic/dynamic_mesh_material_frame.hpp"
|
||||
#include "renderer/3d/mesh/mesh_material_frame.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
DynamicMeshMaterialFrame::DynamicMeshMaterialFrame(const MeshBuilderData& data,
|
||||
MeshMaterialFrame::MeshMaterialFrame(const MeshBuilderData& data,
|
||||
const u32& frameIndex,
|
||||
const u32& materialIndex) {
|
||||
TYRA_ASSERT(frameIndex < data.framesCount && frameIndex >= 0,
|
||||
@@ -34,8 +34,7 @@ DynamicMeshMaterialFrame::DynamicMeshMaterialFrame(const MeshBuilderData& data,
|
||||
_isMother = true;
|
||||
}
|
||||
|
||||
DynamicMeshMaterialFrame::DynamicMeshMaterialFrame(
|
||||
const DynamicMeshMaterialFrame& frame) {
|
||||
MeshMaterialFrame::MeshMaterialFrame(const MeshMaterialFrame& frame) {
|
||||
id = rand() % 1000000;
|
||||
|
||||
bbox = frame.bbox;
|
||||
@@ -43,7 +42,7 @@ DynamicMeshMaterialFrame::DynamicMeshMaterialFrame(
|
||||
_isMother = false;
|
||||
}
|
||||
|
||||
DynamicMeshMaterialFrame::~DynamicMeshMaterialFrame() {
|
||||
MeshMaterialFrame::~MeshMaterialFrame() {
|
||||
if (_isMother) {
|
||||
delete bbox;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#include "renderer/3d/mesh/static/static_mesh.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
StaticMesh::StaticMesh(const MeshBuilderData& data) : Mesh(data) {
|
||||
TYRA_ASSERT(data.framesCount == 1, "Static meshes must have only one frame");
|
||||
frame = new MeshFrame(data, 0);
|
||||
}
|
||||
|
||||
StaticMesh::StaticMesh(const StaticMesh& mesh) : Mesh(mesh) {
|
||||
frame = new MeshFrame(*mesh.frame);
|
||||
}
|
||||
|
||||
StaticMesh::~StaticMesh() { delete frame; }
|
||||
|
||||
} // namespace Tyra
|
||||
@@ -26,13 +26,12 @@ void Stapipeline::onUse() { core.reinitStandardVU1Programs(); }
|
||||
void Stapipeline::render(DynamicMesh* mesh, const StapipOptions* options) {
|
||||
auto model = mesh->getModelMatrix();
|
||||
|
||||
DynamicMeshFrame* frameFrom =
|
||||
mesh->getFramesCount() > 0
|
||||
MeshFrame* frameFrom = mesh->getFramesCount() > 0
|
||||
? mesh->getFrame(mesh->getCurrentAnimationFrame())
|
||||
: mesh->getFrame(0);
|
||||
|
||||
DynamicMeshFrame* frameTo =
|
||||
mesh->getFramesCount() > 0 ? mesh->getFrame(mesh->getNextAnimationFrame())
|
||||
MeshFrame* frameTo = mesh->getFramesCount() > 0
|
||||
? mesh->getFrame(mesh->getNextAnimationFrame())
|
||||
: nullptr;
|
||||
|
||||
auto* infoBag = getInfoBag(mesh, options, &model);
|
||||
@@ -66,9 +65,9 @@ void Stapipeline::render(DynamicMesh* mesh, const StapipOptions* options) {
|
||||
delete infoBag;
|
||||
}
|
||||
|
||||
void Stapipeline::addVertices(DynamicMesh* mesh, DynamicMeshMaterial* material,
|
||||
StapipBag* bag, DynamicMeshFrame* frameFrom,
|
||||
DynamicMeshFrame* frameTo) const {
|
||||
void Stapipeline::addVertices(DynamicMesh* mesh, MeshMaterial* material,
|
||||
StapipBag* bag, MeshFrame* frameFrom,
|
||||
MeshFrame* frameTo) const {
|
||||
bag->count = material->getFacesCount();
|
||||
bag->vertices = new Vec4[bag->count];
|
||||
|
||||
@@ -107,9 +106,9 @@ StapipInfoBag* Stapipeline::getInfoBag(DynamicMesh* mesh,
|
||||
}
|
||||
|
||||
StapipColorBag* Stapipeline::getColorBag(DynamicMesh* mesh,
|
||||
DynamicMeshMaterial* material,
|
||||
DynamicMeshFrame* frameFrom,
|
||||
DynamicMeshFrame* frameTo) const {
|
||||
MeshMaterial* material,
|
||||
MeshFrame* frameFrom,
|
||||
MeshFrame* frameTo) const {
|
||||
auto* result = new StapipColorBag();
|
||||
|
||||
if (material->isSingleColorActivated()) {
|
||||
@@ -135,9 +134,9 @@ StapipColorBag* Stapipeline::getColorBag(DynamicMesh* mesh,
|
||||
}
|
||||
|
||||
StapipTextureBag* Stapipeline::getTextureBag(DynamicMesh* mesh,
|
||||
DynamicMeshMaterial* material,
|
||||
DynamicMeshFrame* frameFrom,
|
||||
DynamicMeshFrame* frameTo) {
|
||||
MeshMaterial* material,
|
||||
MeshFrame* frameFrom,
|
||||
MeshFrame* frameTo) {
|
||||
if (!material->getTextureCoordFaces()) return nullptr;
|
||||
|
||||
auto* result = new StapipTextureBag();
|
||||
@@ -165,8 +164,8 @@ StapipTextureBag* Stapipeline::getTextureBag(DynamicMesh* mesh,
|
||||
}
|
||||
|
||||
StapipLightingBag* Stapipeline::getLightingBag(
|
||||
DynamicMesh* mesh, DynamicMeshMaterial* material, M4x4* model,
|
||||
DynamicMeshFrame* frameFrom, DynamicMeshFrame* frameTo,
|
||||
DynamicMesh* mesh, MeshMaterial* material, M4x4* model,
|
||||
MeshFrame* frameFrom, MeshFrame* frameTo,
|
||||
const StapipOptions* options) const {
|
||||
if (!material->getNormalFaces() || options == nullptr ||
|
||||
options->lighting == nullptr)
|
||||
@@ -204,7 +203,7 @@ void Stapipeline::setLightingColorsCache(
|
||||
}
|
||||
|
||||
void Stapipeline::deallocDrawBags(StapipBag* bag,
|
||||
DynamicMeshMaterial* material) const {
|
||||
MeshMaterial* material) const {
|
||||
if (bag->color->many) {
|
||||
delete[] bag->color->many;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user