feat: redid all of the textures and some of the lighting

This commit is contained in:
Sara 2024-11-27 20:25:44 +01:00
parent 75ada519b8
commit d2202e960e
56 changed files with 539 additions and 164 deletions

View file

@ -3,10 +3,14 @@
#include <godot_cpp/variant/utility_functions.hpp>
#include <godot_cpp/classes/input_event_joypad_motion.hpp>
void Player::_bind_methods() {}
void Player::_bind_methods() {
#define CLASSNAME Player
GDPROPERTY(input_directions, gd::Variant::VECTOR2);
}
void Player::_ready() {
this->anim_tree = this->get_node<gd::AnimationTree>("%AnimationTree");
this->sfm = gd::Object::cast_to<gd::AnimationNodeStateMachinePlayback>(this->anim_tree->get("parameters/Actions/playback"));
this->input = this->get_node<utils::PlayerInput>("%PlayerInput");
this->input->listen_to(utils::PlayerInput::Listener("dir_left", "dir_right", callable_mp(this, &Player::_on_dir_horizontal)));
this->input->listen_to(utils::PlayerInput::Listener("dir_backward", "dir_forward", callable_mp(this, &Player::_on_dir_vertical)));
@ -17,6 +21,22 @@ void Player::_ready() {
this->model_node = this->get_node<gd::Node3D>("%CharacterModel");
}
void Player::_process(double delta [[maybe_unused]]) {
this->anim_tree->set("parameters/Actions/Walk/Move/blend_position", this->input_directions);
}
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();
}
void Player::_on_dir_horizontal(gd::Ref<gd::InputEvent>, float value) {
this->input_directions.x = value;
}
@ -33,18 +53,8 @@ void Player::_on_look_vertical(gd::Ref<gd::InputEvent>, float value) {
this->input_look.y = value;
}
void Player::_process(double delta [[maybe_unused]]) {
this->anim_tree->set("parameters/Movement/blend_position", this->input_directions);
}
void Player::set_input_directions(gd::Vector2 value [[maybe_unused]]) {}
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();
gd::Vector2 Player::get_input_directions() const {
return this->input_directions;
}

View file

@ -4,6 +4,7 @@
#include "utils/player_input.hpp"
#include <godot_cpp/classes/animation_tree.hpp>
#include <godot_cpp/classes/character_body3d.hpp>
#include <godot_cpp/classes/animation_node_state_machine_playback.hpp>
namespace gd = godot;
class Player : public gd::CharacterBody3D {
@ -18,8 +19,12 @@ public:
void _on_dir_vertical(gd::Ref<gd::InputEvent>, float value);
void _on_look_horizontal(gd::Ref<gd::InputEvent>, float value);
void _on_look_vertical(gd::Ref<gd::InputEvent>, float value);
void set_input_directions(gd::Vector2 value);
gd::Vector2 get_input_directions() const;
private:
gd::AnimationTree *anim_tree{nullptr};
gd::AnimationNodeStateMachinePlayback *sfm{nullptr};
utils::PlayerInput *input{nullptr};
gd::Node3D *model_node{nullptr};
gd::Vector2 input_directions{};