Crimson Engine
1.0.0
A high-performance C++20 game engine prototype showcasing a custom ECS, Vulkan renderer, and ImGui editor.
Toggle main menu visibility
Loading...
Searching...
No Matches
IKSolver.hpp
Go to the documentation of this file.
1
#pragma once
2
#include <glm/glm.hpp>
3
#include <string>
4
#include <vector>
5
10
enum class
IKSolverType
{
11
TwoBone
,
// Closed-form analytical solver for elbows/knees
12
FABRIK
// Iterative solver for arbitrary joint chains (e.g. spine, tail)
13
};
14
19
// [ReflectClass]
20
struct
IKSolverComponent
{
21
IKSolverType
solverType
=
IKSolverType::TwoBone
;
22
23
// For 2-Bone Solver
24
// [ReflectField]
25
std::string
startJointName
;
// e.g. "thigh.L"
26
// [ReflectField]
27
std::string
middleJointName
;
// e.g. "shin.L"
28
// [ReflectField]
29
std::string
endJointName
;
// e.g. "foot.L"
30
31
// For FABRIK Solver
32
std::vector<std::string>
jointChainNames
;
// List of joint names from base to tip
33
// [ReflectField]
34
int
maxIterations
= 10;
35
// [ReflectField]
36
float
tolerance
= 0.001f;
37
38
// [ReflectField]
39
glm::vec3
targetPosition
{ 0.0f };
// Target location in world space
40
// [ReflectField]
41
glm::vec3
polePosition
{ 0.0f, 0.0f, 1.0f };
// bend helper vector
42
43
// [ReflectField]
44
float
targetWeight
= 1.0f;
// Blend weight between raw FK (0.0) and IK (1.0)
45
// [ReflectField]
46
bool
enabled
=
false
;
47
};
48
49
50
#include "
meta/ComponentReflection.hpp
"
51
REGISTER_COMPONENT
(
IKSolverComponent
,
"Animation/IK Solver"
);
52
53
ComponentReflection.hpp
REGISTER_COMPONENT
#define REGISTER_COMPONENT(Type, MenuPath)
Definition
ComponentReflection.hpp:156
IKSolverType
IKSolverType
Selects the mathematics used to compute joint alignment.
Definition
IKSolver.hpp:10
IKSolverType::TwoBone
@ TwoBone
Definition
IKSolver.hpp:11
IKSolverType::FABRIK
@ FABRIK
Definition
IKSolver.hpp:12
IKSolverComponent
Specifies target joint chains and goal targets for analytical 2-Bone or iterative FABRIK IK.
Definition
IKSolver.hpp:20
IKSolverComponent::maxIterations
int maxIterations
Definition
IKSolver.hpp:34
IKSolverComponent::tolerance
float tolerance
Definition
IKSolver.hpp:36
IKSolverComponent::endJointName
std::string endJointName
Definition
IKSolver.hpp:29
IKSolverComponent::targetWeight
float targetWeight
Definition
IKSolver.hpp:44
IKSolverComponent::solverType
IKSolverType solverType
Definition
IKSolver.hpp:21
IKSolverComponent::polePosition
glm::vec3 polePosition
Definition
IKSolver.hpp:41
IKSolverComponent::enabled
bool enabled
Definition
IKSolver.hpp:46
IKSolverComponent::targetPosition
glm::vec3 targetPosition
Definition
IKSolver.hpp:39
IKSolverComponent::jointChainNames
std::vector< std::string > jointChainNames
Definition
IKSolver.hpp:32
IKSolverComponent::middleJointName
std::string middleJointName
Definition
IKSolver.hpp:27
IKSolverComponent::startJointName
std::string startJointName
Definition
IKSolver.hpp:25
engine
include
ecs
components
IKSolver.hpp
Generated by
1.17.0