feat: experimenting with desired mood

This commit is contained in:
Sara 2024-11-27 00:41:39 +01:00
parent ceba03ec36
commit 4940f67c21
58 changed files with 4826 additions and 28 deletions

22
src/player.cpp Normal file
View file

@ -0,0 +1,22 @@
#include "player.hpp"
#include "utils/godot_macros.hpp"
void Player::_bind_methods() {
}
void Player::_ready() {
this->anim_tree = this->get_node<gd::AnimationTree>("%AnimationTree");
this->model_node = this->get_node<gd::Node3D>("%CharacterModel");
}
void Player::_physics_process(double delta [[maybe_unused]]) {
gd::Basis const &model_basis{this->model_node->get_global_basis()};
gd::Vector3 const local_motion{this->anim_tree->get_root_motion_position()};
gd::Vector3 const motion {
local_motion.x * model_basis.get_column(0) +
local_motion.y * model_basis.get_column(1) +
local_motion.z * model_basis.get_column(2)
};
this->set_velocity(motion / delta);
this->move_and_slide();
}

21
src/player.hpp Normal file
View file

@ -0,0 +1,21 @@
#ifndef TR_PLAYER_HPP
#define TR_PLAYER_HPP
#include "utils/player_input.hpp"
#include <godot_cpp/classes/animation_tree.hpp>
#include <godot_cpp/classes/character_body3d.hpp>
namespace gd = godot;
class Player : public gd::CharacterBody3D {
GDCLASS(Player, gd::CharacterBody3D);
static void _bind_methods();
public:
virtual void _ready() override;
virtual void _physics_process(double delta) override;
private:
gd::AnimationTree *anim_tree{nullptr};
utils::PlayerInput *input{nullptr};
gd::Node3D *model_node{nullptr};
};
#endif // !TR_PLAYER_HPP

View file

@ -5,6 +5,8 @@
#include <godot_cpp/core/defs.hpp>
#include <godot_cpp/godot.hpp>
#include "player.hpp"
using namespace godot;
void initialize_gdextension_types(ModuleInitializationLevel p_level)
@ -13,12 +15,13 @@ void initialize_gdextension_types(ModuleInitializationLevel p_level)
return;
}
utils::godot_cpp_utils_register_types();
GDREGISTER_RUNTIME_CLASS(Player);
}
extern "C"
{
// Initialization
GDExtensionBool GDE_EXPORT EXAMPLE_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization)
GDExtensionBool GDE_EXPORT trenches_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization)
{
GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);
init_obj.register_initializer(initialize_gdextension_types);

@ -1 +1 @@
Subproject commit 79c37a3cccfcc24759fe5893705b1030cec5f3df
Subproject commit efaeb16fe57b4f2cebbc382ed09268ba13a28191