Skip to content

Commit

Permalink
add entity models rigging draft
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailRis committed Jun 24, 2024
1 parent c9fc4a8 commit 5a01eca
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/logic/PlayerController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/objects/Entities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/objects/Entities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Level;
class Assets;
class ModelBatch;
class Frustum;
class Rig;

class Entity {
entt::registry& registry;
Expand Down
34 changes: 34 additions & 0 deletions src/objects/rigging.hpp
Original file line number Diff line number Diff line change
@@ -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_

0 comments on commit 5a01eca

Please sign in to comment.