mesh -> dynamicmesh
This commit is contained in:
+14
-14
@@ -11,17 +11,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "loaders/3d/builder/mesh_builder_data.hpp"
|
||||
#include "./mesh_frame.hpp"
|
||||
#include "./mesh_material_frame.hpp"
|
||||
#include "./mesh_anim_state.hpp"
|
||||
#include "./dynamic_mesh_frame.hpp"
|
||||
#include "./dynamic_mesh_material_frame.hpp"
|
||||
#include "./dynamic_mesh_anim_state.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
class Mesh {
|
||||
class DynamicMesh {
|
||||
public:
|
||||
explicit Mesh(const MeshBuilderData& data);
|
||||
explicit Mesh(const Mesh& mesh);
|
||||
~Mesh();
|
||||
explicit DynamicMesh(const MeshBuilderData& data);
|
||||
explicit DynamicMesh(const DynamicMesh& mesh);
|
||||
~DynamicMesh();
|
||||
|
||||
/** Translation matrix */
|
||||
M4x4 translation;
|
||||
@@ -47,17 +47,17 @@ class Mesh {
|
||||
}
|
||||
|
||||
/** Returns material, which is a mesh "subgroup". */
|
||||
MeshMaterial* getMaterial(const u32& i) const { return materials[i]; }
|
||||
DynamicMeshMaterial* getMaterial(const u32& i) const { return materials[i]; }
|
||||
|
||||
const u32& getMaterialsCount() const { return materialsCount; }
|
||||
|
||||
const MeshAnimState& getAnimState() const { return animState; }
|
||||
const DynamicMeshAnimState& getAnimState() const { return animState; }
|
||||
|
||||
/** Count of all vertices. */
|
||||
u32 getVertexCount() { return frames[0]->getVertexCount(); }
|
||||
|
||||
/** Returns single frame. */
|
||||
MeshFrame* getFrame(const u32& i) const { return frames[i]; }
|
||||
DynamicMeshFrame* getFrame(const u32& i) const { return frames[i]; }
|
||||
|
||||
/** Count of frames. Static object (not animated) will have only 1 frame. */
|
||||
const u32& getFramesCount() const { return framesCount; }
|
||||
@@ -78,7 +78,7 @@ class Mesh {
|
||||
// * Returns material, which is a mesh "subgroup".
|
||||
// * NULL if not found.
|
||||
// */
|
||||
// MeshMaterial* getMaterialById(const u32& t_id) const;
|
||||
// DynamicMeshMaterial* getMaterialById(const u32& t_id) const;
|
||||
|
||||
/** @returns bounding box object of current frame. */
|
||||
const BBox& getCurrentBoundingBox() const {
|
||||
@@ -111,11 +111,11 @@ class Mesh {
|
||||
|
||||
private:
|
||||
void initMesh();
|
||||
MeshAnimState animState;
|
||||
DynamicMeshAnimState animState;
|
||||
u8 _isMother;
|
||||
u32 id, framesCount, materialsCount;
|
||||
MeshFrame** frames;
|
||||
MeshMaterial** materials;
|
||||
DynamicMeshFrame** frames;
|
||||
DynamicMeshMaterial** materials;
|
||||
};
|
||||
|
||||
} // namespace Tyra
|
||||
+1
-1
@@ -25,6 +25,6 @@ typedef struct {
|
||||
u32 animType;
|
||||
u32 currentFrame;
|
||||
u32 nextFrame;
|
||||
} MeshAnimState;
|
||||
} DynamicMeshAnimState;
|
||||
|
||||
} // namespace Tyra
|
||||
+5
-5
@@ -10,17 +10,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "renderer/3d/mesh/mesh_material.hpp"
|
||||
#include "./dynamic_mesh_material.hpp"
|
||||
#include "loaders/3d/builder/mesh_builder_data.hpp"
|
||||
#include "renderer/3d/bbox/bbox.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
class MeshFrame {
|
||||
class DynamicMeshFrame {
|
||||
public:
|
||||
explicit MeshFrame(const MeshBuilderData& data, const u32& index);
|
||||
explicit MeshFrame(const MeshFrame& frame);
|
||||
~MeshFrame();
|
||||
explicit DynamicMeshFrame(const MeshBuilderData& data, const u32& index);
|
||||
explicit DynamicMeshFrame(const DynamicMeshFrame& frame);
|
||||
~DynamicMeshFrame();
|
||||
|
||||
const u32& getId() const { return id; }
|
||||
const u32& getVertexCount() const { return vertexCount; }
|
||||
+8
-7
@@ -12,15 +12,16 @@
|
||||
|
||||
#include "debug/debug.hpp"
|
||||
#include "loaders/3d/builder/mesh_builder_data.hpp"
|
||||
#include "renderer/3d/mesh/mesh_material_frame.hpp"
|
||||
#include "renderer/3d/mesh/dynamic/dynamic_mesh_material_frame.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
class MeshMaterial {
|
||||
class DynamicMeshMaterial {
|
||||
public:
|
||||
explicit MeshMaterial(const MeshBuilderData& data, const u32& materialIndex);
|
||||
explicit MeshMaterial(const MeshMaterial& material);
|
||||
~MeshMaterial();
|
||||
explicit DynamicMeshMaterial(const MeshBuilderData& data,
|
||||
const u32& materialIndex);
|
||||
explicit DynamicMeshMaterial(const DynamicMeshMaterial& material);
|
||||
~DynamicMeshMaterial();
|
||||
|
||||
Color singleColor;
|
||||
|
||||
@@ -34,7 +35,7 @@ class MeshMaterial {
|
||||
u32* getTextureCoordFaces() const { return textureCoordFaces; }
|
||||
u32* getNormalFaces() const { return normalFaces; }
|
||||
u32* getColorFaces() const { return normalFaces; }
|
||||
MeshMaterialFrame* getFrames() const { return *frames; }
|
||||
DynamicMeshMaterialFrame* getFrames() const { return *frames; }
|
||||
|
||||
const BBox& getBBox(const u32& frame) const;
|
||||
|
||||
@@ -46,7 +47,7 @@ class MeshMaterial {
|
||||
std::string getPrint(const char* name = nullptr) const;
|
||||
|
||||
private:
|
||||
MeshMaterialFrame** frames;
|
||||
DynamicMeshMaterialFrame** frames;
|
||||
|
||||
std::string _name;
|
||||
u8 _isMother, singleColorFlag;
|
||||
+6
-5
@@ -14,12 +14,13 @@
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
class MeshMaterialFrame {
|
||||
class DynamicMeshMaterialFrame {
|
||||
public:
|
||||
explicit MeshMaterialFrame(const MeshBuilderData& data, const u32& frameIndex,
|
||||
const u32& materialIndex);
|
||||
explicit MeshMaterialFrame(const MeshMaterialFrame& frame);
|
||||
~MeshMaterialFrame();
|
||||
explicit DynamicMeshMaterialFrame(const MeshBuilderData& data,
|
||||
const u32& frameIndex,
|
||||
const u32& materialIndex);
|
||||
explicit DynamicMeshMaterialFrame(const DynamicMeshMaterialFrame& frame);
|
||||
~DynamicMeshMaterialFrame();
|
||||
|
||||
const u32& getId() const { return id; }
|
||||
const u8& isMother() const { return _isMother; }
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "../renderer_3d_pipeline.hpp"
|
||||
#include "./stapip_options.hpp"
|
||||
#include "renderer/core/renderer_core.hpp"
|
||||
#include "renderer/3d/mesh/mesh.hpp"
|
||||
#include "renderer/3d/mesh/dynamic/dynamic_mesh.hpp"
|
||||
#include "./core/static_pipeline_core.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
@@ -32,26 +32,31 @@ class Stapipeline : public Renderer3DPipeline {
|
||||
* Render 3D data via "meshes".
|
||||
* This render() method is a bridge to core.renderer3D.render() method.
|
||||
*/
|
||||
void render(Mesh* mesh, const StapipOptions* options = nullptr);
|
||||
void render(DynamicMesh* mesh, const StapipOptions* options = nullptr);
|
||||
|
||||
private:
|
||||
StapipelineCore core;
|
||||
RendererCore* rendererCore;
|
||||
Vec4* colorsCache;
|
||||
|
||||
void addVertices(Mesh* mesh, MeshMaterial* material, StapipBag* bag,
|
||||
MeshFrame* frameFrom, MeshFrame* frameTo) const;
|
||||
StapipInfoBag* getInfoBag(Mesh* mesh, const StapipOptions* options,
|
||||
void addVertices(DynamicMesh* mesh, DynamicMeshMaterial* material,
|
||||
StapipBag* bag, DynamicMeshFrame* frameFrom,
|
||||
DynamicMeshFrame* frameTo) const;
|
||||
StapipInfoBag* getInfoBag(DynamicMesh* mesh, const StapipOptions* options,
|
||||
M4x4* model) const;
|
||||
StapipColorBag* getColorBag(Mesh* mesh, MeshMaterial* material,
|
||||
MeshFrame* frameFrom, MeshFrame* frameTo) const;
|
||||
StapipTextureBag* getTextureBag(Mesh* mesh, MeshMaterial* material,
|
||||
MeshFrame* frameFrom, MeshFrame* frameTo);
|
||||
StapipLightingBag* getLightingBag(Mesh* mesh, MeshMaterial* material,
|
||||
M4x4* model, MeshFrame* frameFrom,
|
||||
MeshFrame* frameTo,
|
||||
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,
|
||||
const StapipOptions* options) const;
|
||||
void deallocDrawBags(StapipBag* bag, MeshMaterial* material) const;
|
||||
void deallocDrawBags(StapipBag* bag, DynamicMeshMaterial* material) const;
|
||||
|
||||
void setLightingColorsCache(StapipLightingOptions* lightingOptions);
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <draw_buffers.h>
|
||||
#include <vector>
|
||||
#include "./models/texture.hpp"
|
||||
#include "renderer/3d/mesh/mesh.hpp"
|
||||
#include "renderer/3d/mesh/dynamic/dynamic_mesh.hpp"
|
||||
#include "loaders/texture/base/texture_loader_selector.hpp"
|
||||
#include <string>
|
||||
|
||||
@@ -93,12 +93,13 @@ class TextureRepository {
|
||||
/**
|
||||
* Add linked textures in given path for mesh material names.
|
||||
*/
|
||||
void addByMesh(Mesh* mesh, const char* directory, const char* extension);
|
||||
void addByMesh(DynamicMesh* mesh, const char* directory,
|
||||
const char* extension);
|
||||
|
||||
/**
|
||||
* Add linked textures in given path for mesh material names.
|
||||
*/
|
||||
inline void addByMesh(Mesh* mesh, const std::string& directory,
|
||||
inline void addByMesh(DynamicMesh* mesh, const std::string& directory,
|
||||
const char* extension) {
|
||||
addByMesh(mesh, directory.c_str(), extension);
|
||||
}
|
||||
|
||||
+21
-18
@@ -11,11 +11,11 @@
|
||||
|
||||
#include <tamtypes.h>
|
||||
#include "math/m4x4.hpp"
|
||||
#include "renderer/3d/mesh/mesh.hpp"
|
||||
#include "renderer/3d/mesh/dynamic/dynamic_mesh.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
Mesh::Mesh(const MeshBuilderData& data) {
|
||||
DynamicMesh::DynamicMesh(const MeshBuilderData& data) {
|
||||
id = rand() % 1000000;
|
||||
|
||||
framesCount = data.framesCount;
|
||||
@@ -24,14 +24,14 @@ Mesh::Mesh(const MeshBuilderData& data) {
|
||||
materialsCount = data.materialsCount;
|
||||
TYRA_ASSERT(materialsCount > 0, "Materials count must be greater than 0");
|
||||
|
||||
frames = new MeshFrame*[framesCount];
|
||||
frames = new DynamicMeshFrame*[framesCount];
|
||||
for (u32 i = 0; i < framesCount; i++) {
|
||||
frames[i] = new MeshFrame(data, i);
|
||||
frames[i] = new DynamicMeshFrame(data, i);
|
||||
}
|
||||
|
||||
materials = new MeshMaterial*[materialsCount];
|
||||
materials = new DynamicMeshMaterial*[materialsCount];
|
||||
for (u32 i = 0; i < materialsCount; i++) {
|
||||
materials[i] = new MeshMaterial(data, i);
|
||||
materials[i] = new DynamicMeshMaterial(data, i);
|
||||
}
|
||||
|
||||
translation.translate(Vec4(0.0F, 0.0F, 0.0F, 1.0F));
|
||||
@@ -41,20 +41,20 @@ Mesh::Mesh(const MeshBuilderData& data) {
|
||||
_isMother = true;
|
||||
}
|
||||
|
||||
Mesh::Mesh(const Mesh& mesh) {
|
||||
DynamicMesh::DynamicMesh(const DynamicMesh& mesh) {
|
||||
id = rand() % 1000000;
|
||||
|
||||
framesCount = mesh.framesCount;
|
||||
materialsCount = mesh.materialsCount;
|
||||
|
||||
frames = new MeshFrame*[framesCount];
|
||||
frames = new DynamicMeshFrame*[framesCount];
|
||||
for (u32 i = 0; i < framesCount; i++) {
|
||||
frames[i] = new MeshFrame(*mesh.frames[i]);
|
||||
frames[i] = new DynamicMeshFrame(*mesh.frames[i]);
|
||||
}
|
||||
|
||||
materials = new MeshMaterial*[materialsCount];
|
||||
materials = new DynamicMeshMaterial*[materialsCount];
|
||||
for (u32 i = 0; i < materialsCount; i++) {
|
||||
materials[i] = new MeshMaterial(*mesh.materials[i]);
|
||||
materials[i] = new DynamicMeshMaterial(*mesh.materials[i]);
|
||||
}
|
||||
|
||||
translation.translate(Vec4(0.0F, 0.0F, 0.0F, 1.0F));
|
||||
@@ -64,7 +64,7 @@ Mesh::Mesh(const Mesh& mesh) {
|
||||
_isMother = false;
|
||||
}
|
||||
|
||||
Mesh::~Mesh() {
|
||||
DynamicMesh::~DynamicMesh() {
|
||||
for (u32 i = 0; i < framesCount; i++) {
|
||||
delete frames[i];
|
||||
}
|
||||
@@ -77,9 +77,11 @@ Mesh::~Mesh() {
|
||||
}
|
||||
}
|
||||
|
||||
M4x4 Mesh::getModelMatrix() const { return translation * rotation * scale; }
|
||||
M4x4 DynamicMesh::getModelMatrix() const {
|
||||
return translation * rotation * scale;
|
||||
}
|
||||
|
||||
void Mesh::initMesh() {
|
||||
void DynamicMesh::initMesh() {
|
||||
animState.startFrame = 0;
|
||||
animState.endFrame = 0;
|
||||
animState.interpolation = 0.0F;
|
||||
@@ -91,7 +93,8 @@ void Mesh::initMesh() {
|
||||
animState.speed = 0.1F;
|
||||
}
|
||||
|
||||
void Mesh::playAnimation(const u32& t_startFrame, const u32& t_endFrame) {
|
||||
void DynamicMesh::playAnimation(const u32& t_startFrame,
|
||||
const u32& t_endFrame) {
|
||||
TYRA_ASSERT(framesCount > 0,
|
||||
"Cant play animation, because no mesh data was loaded!");
|
||||
TYRA_ASSERT(framesCount != 1,
|
||||
@@ -107,8 +110,8 @@ void Mesh::playAnimation(const u32& t_startFrame, const u32& t_endFrame) {
|
||||
animState.nextFrame = t_startFrame;
|
||||
}
|
||||
|
||||
void Mesh::playAnimation(const u32& t_startFrame, const u32& t_endFrame,
|
||||
const u32& t_stayFrame) {
|
||||
void DynamicMesh::playAnimation(const u32& t_startFrame, const u32& t_endFrame,
|
||||
const u32& t_stayFrame) {
|
||||
TYRA_ASSERT(framesCount > 0,
|
||||
"Cant play animation, because no mesh data was loaded!");
|
||||
TYRA_ASSERT(framesCount != 1,
|
||||
@@ -123,7 +126,7 @@ void Mesh::playAnimation(const u32& t_startFrame, const u32& t_endFrame,
|
||||
animState.nextFrame = t_startFrame;
|
||||
}
|
||||
|
||||
void Mesh::animate() {
|
||||
void DynamicMesh::animate() {
|
||||
animState.interpolation += animState.speed;
|
||||
if (animState.interpolation >= 1.0F) {
|
||||
animState.interpolation = 0.0F;
|
||||
+8
-7
@@ -14,11 +14,12 @@
|
||||
#include <string>
|
||||
#include "math/vec4.hpp"
|
||||
#include "renderer/models/color.hpp"
|
||||
#include "renderer/3d/mesh/mesh_frame.hpp"
|
||||
#include "renderer/3d/mesh/dynamic/dynamic_mesh_frame.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
MeshFrame::MeshFrame(const MeshBuilderData& data, const u32& index) {
|
||||
DynamicMeshFrame::DynamicMeshFrame(const MeshBuilderData& data,
|
||||
const u32& index) {
|
||||
TYRA_ASSERT(index < data.framesCount && index >= 0, "Provided index \"",
|
||||
index, "\" is out of range");
|
||||
|
||||
@@ -62,7 +63,7 @@ MeshFrame::MeshFrame(const MeshBuilderData& data, const u32& index) {
|
||||
_isMother = true;
|
||||
}
|
||||
|
||||
MeshFrame::MeshFrame(const MeshFrame& frame) {
|
||||
DynamicMeshFrame::DynamicMeshFrame(const DynamicMeshFrame& frame) {
|
||||
id = rand() % 1000000;
|
||||
|
||||
vertices = frame.vertices;
|
||||
@@ -80,7 +81,7 @@ MeshFrame::MeshFrame(const MeshFrame& frame) {
|
||||
_isMother = false;
|
||||
}
|
||||
|
||||
MeshFrame::~MeshFrame() {
|
||||
DynamicMeshFrame::~DynamicMeshFrame() {
|
||||
if (_isMother) {
|
||||
delete[] vertices;
|
||||
if (normals) delete[] normals;
|
||||
@@ -90,17 +91,17 @@ MeshFrame::~MeshFrame() {
|
||||
}
|
||||
}
|
||||
|
||||
void MeshFrame::print() const {
|
||||
void DynamicMeshFrame::print() const {
|
||||
auto text = getPrint(nullptr);
|
||||
printf("%s\n", text.c_str());
|
||||
}
|
||||
|
||||
void MeshFrame::print(const char* name) const {
|
||||
void DynamicMeshFrame::print(const char* name) const {
|
||||
auto text = getPrint(name);
|
||||
printf("%s\n", text.c_str());
|
||||
}
|
||||
|
||||
std::string MeshFrame::getPrint(const char* name) const {
|
||||
std::string DynamicMeshFrame::getPrint(const char* name) const {
|
||||
std::stringstream res;
|
||||
if (name) {
|
||||
res << name << "(";
|
||||
+16
-16
@@ -12,12 +12,12 @@
|
||||
#include <tamtypes.h>
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
#include "renderer/3d/mesh/mesh_material.hpp"
|
||||
#include "renderer/3d/mesh/dynamic/dynamic_mesh_material.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
MeshMaterial::MeshMaterial(const MeshBuilderData& data,
|
||||
const u32& materialIndex)
|
||||
DynamicMeshMaterial::DynamicMeshMaterial(const MeshBuilderData& data,
|
||||
const u32& materialIndex)
|
||||
: singleColor(false) {
|
||||
TYRA_ASSERT(materialIndex < data.materialsCount && materialIndex >= 0,
|
||||
"Provided index \"", materialIndex, "\" is out of range");
|
||||
@@ -57,18 +57,18 @@ MeshMaterial::MeshMaterial(const MeshBuilderData& data,
|
||||
TYRA_ASSERT(facesCount > 0, "Faces count must be greater than 0");
|
||||
|
||||
_name = data.materials[materialIndex]->name;
|
||||
TYRA_ASSERT(_name.length() > 0, "MeshMaterial name cannot be empty");
|
||||
TYRA_ASSERT(_name.length() > 0, "DynamicMeshMaterial name cannot be empty");
|
||||
|
||||
framesCount = data.framesCount;
|
||||
frames = new MeshMaterialFrame*[framesCount];
|
||||
frames = new DynamicMeshMaterialFrame*[framesCount];
|
||||
for (u32 i = 0; i < framesCount; i++) {
|
||||
frames[i] = new MeshMaterialFrame(data, i, materialIndex);
|
||||
frames[i] = new DynamicMeshMaterialFrame(data, i, materialIndex);
|
||||
}
|
||||
|
||||
_isMother = true;
|
||||
}
|
||||
|
||||
MeshMaterial::MeshMaterial(const MeshMaterial& mesh) {
|
||||
DynamicMeshMaterial::DynamicMeshMaterial(const DynamicMeshMaterial& mesh) {
|
||||
id = rand() % 1000000;
|
||||
|
||||
vertexFaces = mesh.vertexFaces;
|
||||
@@ -82,15 +82,15 @@ MeshMaterial::MeshMaterial(const MeshMaterial& mesh) {
|
||||
|
||||
singleColor.set(128.0F, 128.0F, 128.0F, 128.0F);
|
||||
|
||||
frames = new MeshMaterialFrame*[framesCount];
|
||||
frames = new DynamicMeshMaterialFrame*[framesCount];
|
||||
for (u32 i = 0; i < framesCount; i++) {
|
||||
frames[i] = new MeshMaterialFrame(*mesh.frames[i]);
|
||||
frames[i] = new DynamicMeshMaterialFrame(*mesh.frames[i]);
|
||||
}
|
||||
|
||||
_isMother = false;
|
||||
}
|
||||
|
||||
MeshMaterial::~MeshMaterial() {
|
||||
DynamicMeshMaterial::~DynamicMeshMaterial() {
|
||||
if (_isMother) {
|
||||
delete[] vertexFaces;
|
||||
if (textureCoordFaces) delete[] textureCoordFaces;
|
||||
@@ -104,11 +104,11 @@ MeshMaterial::~MeshMaterial() {
|
||||
delete[] frames;
|
||||
}
|
||||
|
||||
const BBox& MeshMaterial::getBBox(const u32& frame) const {
|
||||
const BBox& DynamicMeshMaterial::getBBox(const u32& frame) const {
|
||||
return frames[frame]->getBBox();
|
||||
}
|
||||
|
||||
void MeshMaterial::setSingleColorFlag(const u8& flag) {
|
||||
void DynamicMeshMaterial::setSingleColorFlag(const u8& flag) {
|
||||
TYRA_ASSERT(
|
||||
colorFaces != nullptr,
|
||||
"Colors and color faces are required to use color-per-vertex mode");
|
||||
@@ -116,22 +116,22 @@ void MeshMaterial::setSingleColorFlag(const u8& flag) {
|
||||
singleColorFlag = flag;
|
||||
}
|
||||
|
||||
void MeshMaterial::print() const {
|
||||
void DynamicMeshMaterial::print() const {
|
||||
auto text = getPrint(nullptr);
|
||||
printf("%s\n", text.c_str());
|
||||
}
|
||||
|
||||
void MeshMaterial::print(const char* name) const {
|
||||
void DynamicMeshMaterial::print(const char* name) const {
|
||||
auto text = getPrint(name);
|
||||
printf("%s\n", text.c_str());
|
||||
}
|
||||
|
||||
std::string MeshMaterial::getPrint(const char* name) const {
|
||||
std::string DynamicMeshMaterial::getPrint(const char* name) const {
|
||||
std::stringstream res;
|
||||
if (name) {
|
||||
res << name << "(";
|
||||
} else {
|
||||
res << "MeshMaterial(";
|
||||
res << "DynamicMeshMaterial(";
|
||||
}
|
||||
|
||||
res << std::endl;
|
||||
+7
-6
@@ -13,13 +13,13 @@
|
||||
#include <tamtypes.h>
|
||||
#include "renderer/models/color.hpp"
|
||||
#include "loaders/3d/builder/mesh_builder_data.hpp"
|
||||
#include "renderer/3d/mesh/mesh_material_frame.hpp"
|
||||
#include "renderer/3d/mesh/dynamic/dynamic_mesh_material_frame.hpp"
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
MeshMaterialFrame::MeshMaterialFrame(const MeshBuilderData& data,
|
||||
const u32& frameIndex,
|
||||
const u32& materialIndex) {
|
||||
DynamicMeshMaterialFrame::DynamicMeshMaterialFrame(const MeshBuilderData& data,
|
||||
const u32& frameIndex,
|
||||
const u32& materialIndex) {
|
||||
TYRA_ASSERT(frameIndex < data.framesCount && frameIndex >= 0,
|
||||
"Provided index \"", frameIndex, "\" is out of range");
|
||||
TYRA_ASSERT(materialIndex < data.materialsCount && materialIndex >= 0,
|
||||
@@ -34,7 +34,8 @@ MeshMaterialFrame::MeshMaterialFrame(const MeshBuilderData& data,
|
||||
_isMother = true;
|
||||
}
|
||||
|
||||
MeshMaterialFrame::MeshMaterialFrame(const MeshMaterialFrame& frame) {
|
||||
DynamicMeshMaterialFrame::DynamicMeshMaterialFrame(
|
||||
const DynamicMeshMaterialFrame& frame) {
|
||||
id = rand() % 1000000;
|
||||
|
||||
bbox = frame.bbox;
|
||||
@@ -42,7 +43,7 @@ MeshMaterialFrame::MeshMaterialFrame(const MeshMaterialFrame& frame) {
|
||||
_isMother = false;
|
||||
}
|
||||
|
||||
MeshMaterialFrame::~MeshMaterialFrame() {
|
||||
DynamicMeshMaterialFrame::~DynamicMeshMaterialFrame() {
|
||||
if (_isMother) {
|
||||
delete bbox;
|
||||
}
|
||||
@@ -23,16 +23,17 @@ void Stapipeline::init(RendererCore* t_core) {
|
||||
|
||||
void Stapipeline::onUse() { core.reinitStandardVU1Programs(); }
|
||||
|
||||
void Stapipeline::render(Mesh* mesh, const StapipOptions* options) {
|
||||
void Stapipeline::render(DynamicMesh* mesh, const StapipOptions* options) {
|
||||
auto model = mesh->getModelMatrix();
|
||||
|
||||
MeshFrame* frameFrom = mesh->getFramesCount() > 0
|
||||
? mesh->getFrame(mesh->getCurrentAnimationFrame())
|
||||
: mesh->getFrame(0);
|
||||
DynamicMeshFrame* frameFrom =
|
||||
mesh->getFramesCount() > 0
|
||||
? mesh->getFrame(mesh->getCurrentAnimationFrame())
|
||||
: mesh->getFrame(0);
|
||||
|
||||
MeshFrame* frameTo = mesh->getFramesCount() > 0
|
||||
? mesh->getFrame(mesh->getNextAnimationFrame())
|
||||
: nullptr;
|
||||
DynamicMeshFrame* frameTo =
|
||||
mesh->getFramesCount() > 0 ? mesh->getFrame(mesh->getNextAnimationFrame())
|
||||
: nullptr;
|
||||
|
||||
auto* infoBag = getInfoBag(mesh, options, &model);
|
||||
|
||||
@@ -65,9 +66,9 @@ void Stapipeline::render(Mesh* mesh, const StapipOptions* options) {
|
||||
delete infoBag;
|
||||
}
|
||||
|
||||
void Stapipeline::addVertices(Mesh* mesh, MeshMaterial* material,
|
||||
StapipBag* bag, MeshFrame* frameFrom,
|
||||
MeshFrame* frameTo) const {
|
||||
void Stapipeline::addVertices(DynamicMesh* mesh, DynamicMeshMaterial* material,
|
||||
StapipBag* bag, DynamicMeshFrame* frameFrom,
|
||||
DynamicMeshFrame* frameTo) const {
|
||||
bag->count = material->getFacesCount();
|
||||
bag->vertices = new Vec4[bag->count];
|
||||
|
||||
@@ -83,7 +84,8 @@ void Stapipeline::addVertices(Mesh* mesh, MeshMaterial* material,
|
||||
}
|
||||
}
|
||||
|
||||
StapipInfoBag* Stapipeline::getInfoBag(Mesh* mesh, const StapipOptions* options,
|
||||
StapipInfoBag* Stapipeline::getInfoBag(DynamicMesh* mesh,
|
||||
const StapipOptions* options,
|
||||
M4x4* model) const {
|
||||
auto* result = new StapipInfoBag();
|
||||
|
||||
@@ -104,9 +106,10 @@ StapipInfoBag* Stapipeline::getInfoBag(Mesh* mesh, const StapipOptions* options,
|
||||
return result;
|
||||
}
|
||||
|
||||
StapipColorBag* Stapipeline::getColorBag(Mesh* mesh, MeshMaterial* material,
|
||||
MeshFrame* frameFrom,
|
||||
MeshFrame* frameTo) const {
|
||||
StapipColorBag* Stapipeline::getColorBag(DynamicMesh* mesh,
|
||||
DynamicMeshMaterial* material,
|
||||
DynamicMeshFrame* frameFrom,
|
||||
DynamicMeshFrame* frameTo) const {
|
||||
auto* result = new StapipColorBag();
|
||||
|
||||
if (material->isSingleColorActivated()) {
|
||||
@@ -131,9 +134,10 @@ StapipColorBag* Stapipeline::getColorBag(Mesh* mesh, MeshMaterial* material,
|
||||
return result;
|
||||
}
|
||||
|
||||
StapipTextureBag* Stapipeline::getTextureBag(Mesh* mesh, MeshMaterial* material,
|
||||
MeshFrame* frameFrom,
|
||||
MeshFrame* frameTo) {
|
||||
StapipTextureBag* Stapipeline::getTextureBag(DynamicMesh* mesh,
|
||||
DynamicMeshMaterial* material,
|
||||
DynamicMeshFrame* frameFrom,
|
||||
DynamicMeshFrame* frameTo) {
|
||||
if (!material->getTextureCoordFaces()) return nullptr;
|
||||
|
||||
auto* result = new StapipTextureBag();
|
||||
@@ -161,8 +165,9 @@ StapipTextureBag* Stapipeline::getTextureBag(Mesh* mesh, MeshMaterial* material,
|
||||
}
|
||||
|
||||
StapipLightingBag* Stapipeline::getLightingBag(
|
||||
Mesh* mesh, MeshMaterial* material, M4x4* model, MeshFrame* frameFrom,
|
||||
MeshFrame* frameTo, const StapipOptions* options) const {
|
||||
DynamicMesh* mesh, DynamicMeshMaterial* material, M4x4* model,
|
||||
DynamicMeshFrame* frameFrom, DynamicMeshFrame* frameTo,
|
||||
const StapipOptions* options) const {
|
||||
if (!material->getNormalFaces() || options == nullptr ||
|
||||
options->lighting == nullptr)
|
||||
return nullptr;
|
||||
@@ -199,7 +204,7 @@ void Stapipeline::setLightingColorsCache(
|
||||
}
|
||||
|
||||
void Stapipeline::deallocDrawBags(StapipBag* bag,
|
||||
MeshMaterial* material) const {
|
||||
DynamicMeshMaterial* material) const {
|
||||
if (bag->color->many) {
|
||||
delete[] bag->color->many;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ Texture* TextureRepository::add(const char* fullpath) {
|
||||
return texture;
|
||||
}
|
||||
|
||||
void TextureRepository::addByMesh(Mesh* mesh, const char* directory,
|
||||
void TextureRepository::addByMesh(DynamicMesh* mesh, const char* directory,
|
||||
const char* extension) {
|
||||
auto& loader = texLoaderSelector.getLoaderByExtension(extension);
|
||||
|
||||
|
||||
@@ -28,10 +28,10 @@ class H4570 : public Game {
|
||||
private:
|
||||
Engine* engine;
|
||||
|
||||
Mesh* warrior;
|
||||
Mesh* warrior2;
|
||||
Mesh* warrior3;
|
||||
Mesh* warrior4;
|
||||
DynamicMesh* warrior;
|
||||
DynamicMesh* warrior2;
|
||||
DynamicMesh* warrior3;
|
||||
DynamicMesh* warrior4;
|
||||
Sprite* picture;
|
||||
audsrv_adpcm_t* adpcmSample;
|
||||
Timer adpcmTimer;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Tyra {
|
||||
H4570::H4570(Engine* t_engine) { engine = t_engine; }
|
||||
H4570::~H4570() {}
|
||||
|
||||
Mesh* getWarrior(Renderer* renderer);
|
||||
DynamicMesh* getWarrior(Renderer* renderer);
|
||||
StapipOptions* getRenderingOptions();
|
||||
Sprite* get2DPicture(Renderer* renderer);
|
||||
|
||||
@@ -38,19 +38,19 @@ void H4570::init() {
|
||||
auto* warriorTex = engine->renderer.core.texture.repository.getBySpriteOrMesh(
|
||||
warrior->getMaterial(0)->getId());
|
||||
|
||||
warrior2 = new Mesh(*warrior);
|
||||
warrior2 = new DynamicMesh(*warrior);
|
||||
warrior2->translation.translateX(-3.0F);
|
||||
warriorTex->addLink(warrior2->getMaterial(0)->getId());
|
||||
warrior2->playAnimation(0, warrior2->getFramesCount() - 1);
|
||||
warrior2->setAnimSpeed(0.10F);
|
||||
|
||||
warrior3 = new Mesh(*warrior);
|
||||
warrior3 = new DynamicMesh(*warrior);
|
||||
warrior3->translation.translateX(-6.0F);
|
||||
warriorTex->addLink(warrior3->getMaterial(0)->getId());
|
||||
warrior3->playAnimation(0, warrior3->getFramesCount() - 1);
|
||||
warrior3->setAnimSpeed(0.7F);
|
||||
|
||||
warrior4 = new Mesh(*warrior);
|
||||
warrior4 = new DynamicMesh(*warrior);
|
||||
warrior4->translation.translateX(3.0F);
|
||||
warriorTex->addLink(warrior4->getMaterial(0)->getId());
|
||||
warrior4->playAnimation(0, warrior4->getFramesCount() - 1);
|
||||
@@ -151,10 +151,10 @@ void H4570::loop() {
|
||||
engine->renderer.endFrame();
|
||||
}
|
||||
|
||||
Mesh* getWarrior(Renderer* renderer) {
|
||||
DynamicMesh* getWarrior(Renderer* renderer) {
|
||||
MD2Loader loader;
|
||||
auto* data = loader.load(FileUtils::fromCwd("warrior.md2"), .08F, false);
|
||||
auto* result = new Mesh(*data);
|
||||
auto* result = new DynamicMesh(*data);
|
||||
// result->translation.translateZ(-30.0F);
|
||||
delete data;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class Wellinator : public Game {
|
||||
private:
|
||||
Engine* engine;
|
||||
|
||||
Mesh* warrior;
|
||||
DynamicMesh* warrior;
|
||||
Sprite* picture;
|
||||
audsrv_adpcm_t* adpcmSample;
|
||||
Timer adpcmTimer;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Tyra {
|
||||
Wellinator::Wellinator(Engine* t_engine) { engine = t_engine; }
|
||||
Wellinator::~Wellinator() {}
|
||||
|
||||
Mesh* getWarrior(Renderer* renderer);
|
||||
DynamicMesh* getWarrior(Renderer* renderer);
|
||||
StapipOptions* getRenderingOptions();
|
||||
Sprite* get2DPicture(Renderer* renderer);
|
||||
|
||||
@@ -125,10 +125,10 @@ void Wellinator::loop() {
|
||||
engine->renderer.endFrame();
|
||||
}
|
||||
|
||||
Mesh* getWarrior(Renderer* renderer) {
|
||||
DynamicMesh* getWarrior(Renderer* renderer) {
|
||||
MD2Loader loader;
|
||||
auto* data = loader.load(FileUtils::fromCwd("warrior.md2"), .08F, false);
|
||||
auto* result = new Mesh(*data);
|
||||
auto* result = new DynamicMesh(*data);
|
||||
result->translation.translateZ(-30.0F);
|
||||
delete data;
|
||||
renderer->core.texture.repository.addByMesh(result, FileUtils::getCwd(),
|
||||
|
||||
Reference in New Issue
Block a user