add entity models rigging draft

This commit is contained in:
MihailRis 2024-06-24 20:57:19 +03:00
parent c9fc4a85b8
commit 5a01eca780
4 changed files with 38 additions and 2 deletions

View File

@ -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;

View File

@ -25,7 +25,8 @@ void Entities::drop(glm::vec3 pos, glm::vec3 vel) {
glm::vec3 size(1);
registry.emplace<EntityId>(entity, static_cast<entityid_t>(1));
registry.emplace<Transform>(entity, pos, size/4.0f, glm::mat3(1.0f));
registry.emplace<Hitbox>(entity, pos, size/2.0f);
registry.emplace<Hitbox>(entity, pos,
glm::vec3(size.x*0.2f, size.y*0.5f, size.z*0.2f));
auto& hitbox = registry.get<Hitbox>(entity);
hitbox.velocity = vel;

View File

@ -24,6 +24,7 @@ class Level;
class Assets;
class ModelBatch;
class Frustum;
class Rig;
class Entity {
entt::registry& registry;

34
src/objects/rigging.hpp Normal file
View File

@ -0,0 +1,34 @@
#ifndef OBJECTS_SKELETON_HPP_
#define OBJECTS_SKELETON_HPP_
#include "../typedefs.hpp"
#include <vector>
#include <memory>
#include <glm/glm.hpp>
namespace rigging {
struct Rig;
struct Pose {
std::vector<glm::mat4> matrices;
};
class RigNode {
uint index;
std::vector<std::unique_ptr<RigNode>> subnodes;
public:
RigNode(uint index);
};
class RigConfig {
std::unique_ptr<RigNode> root;
};
struct Rig {
RigConfig* config;
Pose pose;
};
};
#endif // OBJECTS_SKELETON_HPP_