Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Resources/Engine/Lua/Components/SkinnedMeshRenderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,50 @@ function SkinnedMeshRenderer:GetActiveAnimationIndex() end
--- Returns current clip name or nil
---@return string|nil
function SkinnedMeshRenderer:GetActiveAnimationName() end

--- Returns the number of available bones
---@return integer
function SkinnedMeshRenderer:GetBoneCount() end

--- Returns bone name at index or nil
---@param index integer
---@return string|nil
function SkinnedMeshRenderer:GetBoneName(index) end

--- Returns bone index by name or nil
---@param name string
---@return integer|nil
function SkinnedMeshRenderer:GetBoneIndex(name) end

--- Returns local bone position or nil
---@param boneIndex integer
---@return Vector3|nil
function SkinnedMeshRenderer:GetBoneLocalPosition(boneIndex) end

--- Returns local bone rotation or nil
---@param boneIndex integer
---@return Quaternion|nil
function SkinnedMeshRenderer:GetBoneLocalRotation(boneIndex) end

--- Returns local bone scale or nil
---@param boneIndex integer
---@return Vector3|nil
function SkinnedMeshRenderer:GetBoneLocalScale(boneIndex) end

--- Sets local bone position
---@param boneIndex integer
---@param position Vector3
---@return boolean
function SkinnedMeshRenderer:SetBoneLocalPosition(boneIndex, position) end

--- Sets local bone rotation
---@param boneIndex integer
---@param rotation Quaternion
---@return boolean
function SkinnedMeshRenderer:SetBoneLocalRotation(boneIndex, rotation) end

--- Sets local bone scale
---@param boneIndex integer
---@param scale Vector3
---@return boolean
function SkinnedMeshRenderer:SetBoneLocalScale(boneIndex, scale) end
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#include <OvCore/ECS/Components/AComponent.h>
#include <OvMaths/FMatrix4.h>
#include <OvMaths/FQuaternion.h>
#include <OvMaths/FVector3.h>

namespace OvCore::ECS { class Actor; }
namespace OvRendering::Resources { class Model; }
Expand Down Expand Up @@ -150,6 +152,62 @@ namespace OvCore::ECS::Components
*/
std::optional<std::string> GetActiveAnimationName() const;

/**
* Returns the number of available bones
*/
uint32_t GetBoneCount() const;

/**
* Returns the bone name at index (std::nullopt if index is invalid)
* @param p_index
*/
std::optional<std::string> GetBoneName(uint32_t p_index) const;

/**
* Returns the bone index by name (std::nullopt if not found)
* @param p_name
*/
std::optional<uint32_t> GetBoneIndex(const std::string& p_name) const;

/**
* Returns the local bone position (std::nullopt if index is invalid)
* @param p_boneIndex
*/
std::optional<OvMaths::FVector3> GetBoneLocalPosition(uint32_t p_boneIndex) const;

/**
* Returns the local bone rotation (std::nullopt if index is invalid)
* @param p_boneIndex
*/
std::optional<OvMaths::FQuaternion> GetBoneLocalRotation(uint32_t p_boneIndex) const;

/**
* Returns the local bone scale (std::nullopt if index is invalid)
* @param p_boneIndex
*/
std::optional<OvMaths::FVector3> GetBoneLocalScale(uint32_t p_boneIndex) const;

/**
* Sets the local bone position
* @param p_boneIndex
* @param p_position
*/
bool SetBoneLocalPosition(uint32_t p_boneIndex, const OvMaths::FVector3& p_position);

/**
* Sets the local bone rotation
* @param p_boneIndex
* @param p_rotation
*/
bool SetBoneLocalRotation(uint32_t p_boneIndex, const OvMaths::FQuaternion& p_rotation);

/**
* Sets the local bone scale
* @param p_boneIndex
* @param p_scale
*/
bool SetBoneLocalScale(uint32_t p_boneIndex, const OvMaths::FVector3& p_scale);

/**
* Returns the transposed skinning matrix palette ready for GPU upload
*/
Expand Down Expand Up @@ -191,6 +249,8 @@ namespace OvCore::ECS::Components
void SyncWithModel();
void RebuildRuntimeData();
void EvaluatePose();
std::optional<uint32_t> GetNodeIndexFromBoneIndex(uint32_t p_boneIndex) const;
void RecomputeBoneMatricesFromLocalPose();
float GetAnimationDurationSeconds() const;
void UpdatePlayback(float p_deltaTime);

Expand All @@ -209,6 +269,7 @@ namespace OvCore::ECS::Components
std::string m_deserializedAnimationName;

uint64_t m_poseVersion = 0;
bool m_manualPoseOverride = false;

std::vector<std::string> m_animationNames;
std::vector<OvMaths::FMatrix4> m_localPose;
Expand Down
Loading