2023-10-29 09:20:23 +01:00
|
|
|
#pragma once
|
2023-11-15 00:06:00 +01:00
|
|
|
#include "Graphics/Command.h"
|
2024-06-09 12:20:04 +02:00
|
|
|
#include "Graphics/Initializer.h"
|
2023-11-05 10:36:01 +01:00
|
|
|
#include "Math/Vector.h"
|
2023-10-07 19:29:53 +02:00
|
|
|
#include "VertexData.h"
|
2024-05-08 10:51:59 +02:00
|
|
|
#include "entt/entt.hpp"
|
2023-10-07 19:29:53 +02:00
|
|
|
|
2024-06-09 12:20:04 +02:00
|
|
|
namespace Seele {
|
|
|
|
|
class StaticMeshVertexData : public VertexData {
|
|
|
|
|
public:
|
2024-12-27 17:06:43 +01:00
|
|
|
using PositionType = Vector;
|
2025-01-29 16:29:58 +01:00
|
|
|
using NormalType = Vector;
|
2025-03-31 11:39:17 +02:00
|
|
|
using TangentType = Vector4;
|
|
|
|
|
//using BiTangentType = Vector;
|
2024-12-27 17:06:43 +01:00
|
|
|
using TexCoordType = U16Vector2;
|
|
|
|
|
using ColorType = U16Vector;
|
|
|
|
|
|
2023-10-31 16:16:23 +01:00
|
|
|
StaticMeshVertexData();
|
2023-10-07 19:29:53 +02:00
|
|
|
virtual ~StaticMeshVertexData();
|
2024-06-09 12:20:04 +02:00
|
|
|
static StaticMeshVertexData* getInstance();
|
2024-12-27 17:06:43 +01:00
|
|
|
void loadPositions(uint64 offset, const Array<PositionType>& data);
|
|
|
|
|
void loadTexCoords(uint64 offset, uint64 index, const Array<TexCoordType>& data);
|
|
|
|
|
void loadNormals(uint64 offset, const Array<NormalType>& data);
|
2025-01-29 16:29:58 +01:00
|
|
|
void loadTangents(uint64 offset, const Array<TangentType>& data);
|
2025-03-31 11:39:17 +02:00
|
|
|
//void loadBitangents(uint64 offset, const Array<BiTangentType>& data);
|
2024-12-27 17:06:43 +01:00
|
|
|
void loadColors(uint64 offset, const Array<ColorType>& data);
|
2025-03-09 22:42:05 +01:00
|
|
|
virtual void serializeMesh(MeshId id, ArchiveBuffer& buffer) override;
|
2024-08-07 21:19:33 +02:00
|
|
|
virtual uint64 deserializeMesh(MeshId id, ArchiveBuffer& buffer) override;
|
2024-06-09 12:20:04 +02:00
|
|
|
virtual void init(Gfx::PGraphics graphics) override;
|
|
|
|
|
virtual void destroy() override;
|
|
|
|
|
virtual void bindBuffers(Gfx::PRenderCommand command) override;
|
|
|
|
|
virtual Gfx::PDescriptorLayout getVertexDataLayout() override;
|
|
|
|
|
virtual Gfx::PDescriptorSet getVertexDataSet() override;
|
|
|
|
|
virtual std::string getTypeName() const override { return "StaticMeshVertexData"; }
|
|
|
|
|
virtual Gfx::PShaderBuffer getPositionBuffer() const override { return positions; }
|
2024-05-08 10:51:59 +02:00
|
|
|
|
2024-06-09 12:20:04 +02:00
|
|
|
private:
|
|
|
|
|
virtual void resizeBuffers() override;
|
|
|
|
|
virtual void updateBuffers() override;
|
|
|
|
|
|
2023-11-01 23:12:30 +01:00
|
|
|
Gfx::OShaderBuffer positions;
|
2025-03-07 21:48:27 +01:00
|
|
|
constexpr static const char* POSITIONS_NAME = "positions";
|
2024-05-06 18:36:16 +02:00
|
|
|
Gfx::OShaderBuffer texCoords[MAX_TEXCOORDS];
|
2025-03-07 21:48:27 +01:00
|
|
|
constexpr static const char* TEXCOORDS_NAME = "texCoords";
|
2023-11-01 23:12:30 +01:00
|
|
|
Gfx::OShaderBuffer normals;
|
2025-03-07 21:48:27 +01:00
|
|
|
constexpr static const char* NORMALS_NAME = "normals";
|
2024-12-27 17:06:43 +01:00
|
|
|
Gfx::OShaderBuffer tangents;
|
2025-03-07 21:48:27 +01:00
|
|
|
constexpr static const char* TANGENTS_NAME = "tangents";
|
2025-03-31 11:39:17 +02:00
|
|
|
//Gfx::OShaderBuffer biTangents;
|
|
|
|
|
//constexpr static const char* BITANGENTS_NAME = "biTangents";
|
2024-06-09 12:20:04 +02:00
|
|
|
Gfx::OShaderBuffer colors;
|
2025-03-07 21:48:27 +01:00
|
|
|
constexpr static const char* COLORS_NAME = "colors";
|
2025-03-26 13:38:48 +01:00
|
|
|
Array<PositionType> posData;
|
2024-12-27 17:06:43 +01:00
|
|
|
Array<TexCoordType> texData[MAX_TEXCOORDS];
|
|
|
|
|
Array<NormalType> norData;
|
2025-01-29 16:29:58 +01:00
|
|
|
Array<TangentType> tanData;
|
2025-03-31 11:39:17 +02:00
|
|
|
//Array<BiTangentType> bitData;
|
2024-12-27 17:06:43 +01:00
|
|
|
Array<ColorType> colData;
|
2024-06-09 12:20:04 +02:00
|
|
|
Gfx::ODescriptorLayout descriptorLayout;
|
|
|
|
|
Gfx::PDescriptorSet descriptorSet;
|
2023-10-07 19:29:53 +02:00
|
|
|
};
|
2024-06-09 12:20:04 +02:00
|
|
|
} // namespace Seele
|