Anim 0.1
Loading...
Searching...
No Matches
animated_mesh_app.h
1#ifndef _ANIMATED_MESH_APP_H
2#define _ANIMATED_MESH_APP_H
3
4#include <system/application.h>
5#include <maths/vector4.h>
6
7#include "AnimationSystemMesh/AnimationMainSystem.h"
8#include "AnimationSystem/PureResult.h"
9#include "AnimationSystemSprite/Skeletal/SkeletonSprite.h"
10#include "AnimationSystemSprite/SpriteSheet/AtlasAnimationSprite.h"
11#include "graphics/font.h"
12#include <input/input_manager.h>
13
14#include "AnimationSystemMesh/BlendTree/TwoAnimatorsLinearTransitionNode.h"
15#include "GefExtensions/primitive_renderer.h"
16
21
22// FRAMEWORK FORWARD DECLARATIONS
23namespace gef
24{
25 class Platform;
26 class Mesh;
27 class Scene;
28 class Skeleton;
29}
30
31class AnimatedMeshApp final : public gef::Application
32{
33public:
34 explicit AnimatedMeshApp(gef::Platform & platform);
35 void Init() override;
36 void LogError(AnimationSystem::PureResult && result);
37 void CleanUp() override;
38 bool Update(float frameTime) override;
39 void Render() override;
40 void set_ndc_zmin(float value) { ndc_zmin_ = value; }
41private:
42 AnimationSystem::PureResult LoadSpritesAndAnimation();
43 void CreateWalkRunAnimationBlendTransition(AnimationSystem::Mesh::IMeshTreeAnimator const & animator) const;
44 void ResetIKEndEffector();
45 void UpdateUIValues();
46 void UpdateIkParameters(gef::Vector2 const & mousePosition);
47 void UpdateBlendTreeSpeedParameter() const;
48 [[nodiscard]] AnimationSystem::PureResult ConstructBlendTree(AnimationSystem::Mesh::IMeshTreeAnimator const & animator) const;
49 [[nodiscard]] AnimationSystem::PureResult LoadAnimations(AnimationSystem::Mesh::IMeshTreeAnimator & animator) const;
50 void SwapObject();
51 static void SwapAnimation(AnimationSystem::Sprite::ISpriteAnimator & animator);
52 void Render2d() const;
53 void Render3d() const;
54 void SwapAnimation() const;
55 void SetUpViewMatrix() const;
56 void RenderEndEffector() const;
57 void SetPlayerPosition() const;
58 AnimationSystem::PureResult LoadMeshAndAnimation();
59 void InitFont() const;
60 void DrawHUD() const;
61 void SetupLights() const;
62 void SetupCamera();
63
64 std::unique_ptr<gef::SpriteRenderer> sprite_renderer_;
65 std::unique_ptr<gef::Renderer3D> renderer_3d_;
66 std::unique_ptr<gef::InputManager> input_manager_;
67 std::unique_ptr<GefExtensions::PrimitiveRenderer> primitive_renderer_;
68
69 std::unique_ptr<AnimationSystem::AnimationMainSystem> animation_system_;
70
71 std::unique_ptr<gef::Font> font_;
72
73 std::weak_ptr<IAnimatedMesh> mesh_;
74 std::weak_ptr<IAnimatedSprite> skeleton_sprite_;
75 std::weak_ptr<IAnimatedSprite> atlas_sprite_;
76
77 std::weak_ptr<IAnimatedSprite> active_sprite_;
78 std::weak_ptr<IAnimatedMesh> active_mesh_;
79
80 string error_message_;
81
82 gef::Vector4 camera_eye_;
83 gef::Vector4 camera_lookat_;
84 gef::Vector4 camera_up_;
85
86 gef::Vector4 effector_position_;
87
88 float ndc_zmin_{};
89
90 float fps_{};
91 float camera_fov_{};
92 float near_plane_{};
93 float far_plane_{};
94
95 AnimationSystem::BlendLerpValue idleToMovingBlendPercent = 1;
96 string walkingToRunningUIString{}; // walking or running, used for UI
97};
98
99#endif // _ANIMATED_MESH_APP_H
Definition: animated_mesh_app.h:32
A sprite with an animator.
Definition: IAnimatedSprite.h:26
Restricted interface to an animatable mesh object.
Definition: AnimatedMesh.h:14
Interface restricting the blend tree class.
Definition: AnimationBlendTree.h:30
An animated sprite, animated using skeletal animation.
Definition: SkeletonSprite.h:32
An animated sprite, animated using spritesheet animation.
Definition: AtlasAnimationSprite.h:30
An animator for a sprite.
Definition: ISpriteAnimator.h:12
A flot representing the value of a blend.
Definition: BlendLerpValue.h:36
Struct representing the return type of a function performing an operation that may fail....
Definition: PureResult.h:20