Skylicht Engine
Loading...
Searching...
No Matches
Skylicht::CIKSolver Class Reference

Simple 2-bone Inverse Kinematics (IK) solver. More...

#include <Animation/IK/CIKSolver.h>

Public Member Functions

void solveIK (const core::vector3df &startJointPos, const core::vector3df &midJointPos, const core::vector3df &endJointPos, const core::vector3df &targetPos, const core::vector3df &poleVector, float twistValue, core::quaternion &qStart, core::quaternion &qMid)
 Solves the Inverse Kinematics (IK) for a 2-bone chain (e.g., limb).

Detailed Description

Simple 2-bone Inverse Kinematics (IK) solver.

Example: Solving IK for an arm

CIKSolver solver;
core::quaternion qStart, qMid;
// poleVector defines the elbow direction
core::vector3df poleVector = elbowPos - shoulderPos;
solver.solveIK(shoulderPos, elbowPos, handPos, targetPos, poleVector, 0.0f, qStart, qMid);
// Apply results to bone rotations
shoulderNode->AnimRotation *= qStart;
elbowNode->AnimRotation *= qMid;
void solveIK(const core::vector3df &startJointPos, const core::vector3df &midJointPos, const core::vector3df &endJointPos, const core::vector3df &targetPos, const core::vector3df &poleVector, float twistValue, core::quaternion &qStart, core::quaternion &qMid)
Solves the Inverse Kinematics (IK) for a 2-bone chain (e.g., limb).

Member Function Documentation

◆ solveIK()

void Skylicht::CIKSolver::solveIK ( const core::vector3df & startJointPos,
const core::vector3df & midJointPos,
const core::vector3df & endJointPos,
const core::vector3df & targetPos,
const core::vector3df & poleVector,
float twistValue,
core::quaternion & qStart,
core::quaternion & qMid )

Solves the Inverse Kinematics (IK) for a 2-bone chain (e.g., limb).

Given the positions of three joints and a target, it calculates the required rotations for the start and middle joints to reach the target.

Parameters
startJointPosCurrent world position of the root joint (e.g., Shoulder).
midJointPosCurrent world position of the middle joint (e.g., Elbow).
endJointPosCurrent world position of the effector joint (e.g., Hand).
targetPosTarget world position for the effector joint.
poleVectorWorld direction defining the plane of rotation (where the knee/elbow points).
twistValueAdditional rotation along the chain direction in degrees.
qStart[out] Output rotation quaternion for the start joint.
qMid[out] Output rotation quaternion for the middle joint.

The documentation for this class was generated from the following file: