mirror of
https://github.com/Kbz-8/42_vox.git
synced 2026-01-13 07:33:35 +00:00
world generation
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <Maths/Quaternions.h>
|
||||
#include <Core/Script.h>
|
||||
#include <Graphics/Model.h>
|
||||
#include <Core/UUID.h>
|
||||
|
||||
namespace Scop
|
||||
{
|
||||
@@ -30,6 +31,7 @@ namespace Scop
|
||||
[[nodiscard]] inline const Quatf& GetOrientation() const noexcept { return m_orientation; }
|
||||
[[nodiscard]] inline const Model& GetModel() const noexcept { return m_model; }
|
||||
[[nodiscard]] inline Model& GetModelRef() noexcept { return m_model; }
|
||||
[[nodiscard]] inline std::uint32_t GetUUID() const noexcept { return m_uuid; }
|
||||
|
||||
~Actor();
|
||||
|
||||
@@ -43,6 +45,7 @@ namespace Scop
|
||||
Vec3f m_position = Vec3f{ 0.0f, 0.0f, 0.0f };
|
||||
Vec3f m_scale = Vec3f{ 1.0f, 1.0f, 1.0f };
|
||||
std::shared_ptr<ActorScript> p_script;
|
||||
std::uint64_t m_uuid;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -16,23 +16,18 @@ namespace Scop
|
||||
public:
|
||||
struct SubMesh
|
||||
{
|
||||
VertexBuffer vbo;
|
||||
IndexBuffer ibo;
|
||||
MeshBuffer buffer;
|
||||
std::size_t index_size;
|
||||
std::size_t triangle_count = 0;
|
||||
|
||||
inline SubMesh(const std::vector<Vertex>& vertices, const std::vector<std::uint32_t>& indices)
|
||||
{
|
||||
CPUBuffer vb(vertices.size() * sizeof(Vertex));
|
||||
std::memcpy(vb.GetData(), vertices.data(), vb.GetSize());
|
||||
vbo.Init(vb.GetSize());
|
||||
vbo.SetData(std::move(vb));
|
||||
|
||||
CPUBuffer ib(indices.size() * sizeof(std::uint32_t));
|
||||
std::memcpy(ib.GetData(), indices.data(), ib.GetSize());
|
||||
ibo.Init(ib.GetSize());
|
||||
ibo.SetData(std::move(ib));
|
||||
|
||||
CPUBuffer data(vertices.size() * sizeof(Vertex) + indices.size() * sizeof(std::uint32_t));
|
||||
std::memcpy(data.GetData(), vertices.data(), vertices.size() * sizeof(Vertex));
|
||||
std::memcpy(data.GetData() + vertices.size() * sizeof(Vertex), indices.data(), indices.size() * sizeof(std::uint32_t));
|
||||
buffer.Init(vertices.size() * sizeof(Vertex), indices.size() * sizeof(std::uint32_t), 0, std::move(data));
|
||||
triangle_count = vertices.size() / 3;
|
||||
index_size = indices.size();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <Maths/Quaternions.h>
|
||||
#include <Core/Script.h>
|
||||
#include <Graphics/Model.h>
|
||||
#include <Core/UUID.h>
|
||||
|
||||
namespace Scop
|
||||
{
|
||||
@@ -14,8 +15,9 @@ namespace Scop
|
||||
friend Scene;
|
||||
|
||||
public:
|
||||
Narrator() = default;
|
||||
Narrator() : m_uuid(UUID()) {}
|
||||
inline void AttachScript(std::shared_ptr<NarratorScript> script) { p_script = script; }
|
||||
[[nodiscard]] inline std::uint32_t GetUUID() const noexcept { return m_uuid; }
|
||||
inline ~Narrator()
|
||||
{
|
||||
if(p_script)
|
||||
@@ -31,6 +33,7 @@ namespace Scop
|
||||
|
||||
private:
|
||||
std::shared_ptr<NarratorScript> p_script;
|
||||
std::uint64_t m_uuid;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,10 @@ namespace Scop
|
||||
Sprite& CreateSprite(std::shared_ptr<Texture> texture) noexcept;
|
||||
Sprite& CreateSprite(std::string_view name, std::shared_ptr<Texture> texture);
|
||||
|
||||
void RemoveActor(Actor& actor) noexcept;
|
||||
void RemoveNarrator(Narrator& narrator) noexcept;
|
||||
void RemoveSprite(Sprite& sprite) noexcept;
|
||||
|
||||
[[nodiscard]] inline Scene& AddChildScene(std::string_view name, SceneDescriptor desc) { return m_scene_children.emplace_back(name, std::move(desc), this); }
|
||||
inline void AddSkybox(std::shared_ptr<CubeTexture> cubemap) { p_skybox = cubemap; }
|
||||
void SwitchToChild(std::string_view name) const noexcept;
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Scop
|
||||
[[nodiscard]] inline const Vec2f& GetScale() const noexcept { return m_scale; }
|
||||
[[nodiscard]] inline std::shared_ptr<Mesh> GetMesh() const { return p_mesh; }
|
||||
[[nodiscard]] inline std::shared_ptr<Texture> GetTexture() const { return p_texture; }
|
||||
[[nodiscard]] inline std::uint32_t GetUUID() const noexcept { return m_uuid; }
|
||||
|
||||
~Sprite();
|
||||
|
||||
@@ -57,6 +58,7 @@ namespace Scop
|
||||
Vec4f m_color = Vec4f{ 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
Vec2ui m_position = Vec2ui{ 0, 0 };
|
||||
Vec2f m_scale = Vec2f{ 1.0f, 1.0f };
|
||||
std::uint64_t m_uuid;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user