From 5a01eca7807fe362bbcdfe5b73efcaa3ddcebad2 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 24 Jun 2024 20:57:19 +0300 Subject: [PATCH] add entity models rigging draft --- src/logic/PlayerController.cpp | 2 +- src/objects/Entities.cpp | 3 ++- src/objects/Entities.hpp | 1 + src/objects/rigging.hpp | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 src/objects/rigging.hpp diff --git a/src/logic/PlayerController.cpp b/src/logic/PlayerController.cpp index 5885b728..f7b3b85b 100644 --- a/src/logic/PlayerController.cpp +++ b/src/logic/PlayerController.cpp @@ -248,7 +248,7 @@ void PlayerController::update(float delta, bool input, bool pause) { if (input) { updateInteraction(); if (Events::jactive("player.drop")) { - level->entities->drop(player->camera->position, player->camera->front*10.0f+player->hitbox->velocity); + level->entities->drop(player->camera->position, player->camera->front*8.0f+glm::vec3(0, 2, 0)+player->hitbox->velocity); } } else { player->selection.vox.id = BLOCK_VOID; diff --git a/src/objects/Entities.cpp b/src/objects/Entities.cpp index 56f52318..fd4fe76c 100644 --- a/src/objects/Entities.cpp +++ b/src/objects/Entities.cpp @@ -25,7 +25,8 @@ void Entities::drop(glm::vec3 pos, glm::vec3 vel) { glm::vec3 size(1); registry.emplace(entity, static_cast(1)); registry.emplace(entity, pos, size/4.0f, glm::mat3(1.0f)); - registry.emplace(entity, pos, size/2.0f); + registry.emplace(entity, pos, + glm::vec3(size.x*0.2f, size.y*0.5f, size.z*0.2f)); auto& hitbox = registry.get(entity); hitbox.velocity = vel; diff --git a/src/objects/Entities.hpp b/src/objects/Entities.hpp index 0a05bfba..8efc7197 100644 --- a/src/objects/Entities.hpp +++ b/src/objects/Entities.hpp @@ -24,6 +24,7 @@ class Level; class Assets; class ModelBatch; class Frustum; +class Rig; class Entity { entt::registry& registry; diff --git a/src/objects/rigging.hpp b/src/objects/rigging.hpp new file mode 100644 index 00000000..a509533b --- /dev/null +++ b/src/objects/rigging.hpp @@ -0,0 +1,34 @@ +#ifndef OBJECTS_SKELETON_HPP_ +#define OBJECTS_SKELETON_HPP_ + +#include "../typedefs.hpp" + +#include +#include +#include + +namespace rigging { + struct Rig; + + struct Pose { + std::vector matrices; + }; + + class RigNode { + uint index; + std::vector> subnodes; + public: + RigNode(uint index); + }; + + class RigConfig { + std::unique_ptr root; + }; + + struct Rig { + RigConfig* config; + Pose pose; + }; +}; + +#endif // OBJECTS_SKELETON_HPP_