一个姿势持有 CFrame 应用于连接到其相关 Motor6D 的 BasePart 。被控制的部分取决于姿势的名称。
姿势是动画的基本积木,并且通过 Keyframes 组成 KeyframeSequences .
姿势、关节和层次
虽然姿势被命名给予 BasePart ,但在动画播放期间操纵的对象实际上是连接到这一部分的 Motor6D 。动画支架从模型的根部通过这些关节分支出来。
在 R15 角色骨架中,根部分是 HumanoidRootPart。下半身通过名为“根”的电机连接到人形根部件。因此,一个名为 "LowerTorso" 的姿势的 CFrame 在 Keyframe 将应用于名为 "Root" 的电机,而不是姿势本身 "LowerTorso"。
姿势是根据共同的等级排列在 Keyframe 中。这意味着,姿势的 CFrame 被应用到连接部件与姿势相关的部件与姿势的父元素部件的电机。请参阅下面的视觉示例,了解 R15 角色上的姿势结构。
姿态 CFrame
Roblox 动画系统将 Pose.CFrame 应用于相应的 Motor6D 通过操纵引擎相对变形、Motor6D.Transform 属性。原始 C0 和 C1 值不会被更改。
代码示例
This sample includes a function that will generate a 'blank' keyframe containing blank poses for all of the model's connected parts in the correct hierarchical order.
local function generateKeyframe(model)
if not model.PrimaryPart then
warn("No primary part set")
return
end
local rootPart = model.PrimaryPart:GetRootPart()
if not rootPart then
warn("Root part not found")
return
end
local partsAdded = {}
partsAdded[rootPart] = true
local function addPoses(part, parentPose)
-- get all of the joints attached to the part
for _, joint in pairs(part:GetJoints()) do
-- we're only interested in Motor6Ds
if joint:IsA("Motor6D") then
-- find the connected part
local connectedPart = nil
if joint.Part0 == part then
connectedPart = joint.Part1
elseif joint.Part1 == part then
connectedPart = joint.Part0
end
if connectedPart then
-- make sure we haven't already added this part
if not partsAdded[connectedPart] then
partsAdded[connectedPart] = true
-- create a pose
local pose = Instance.new("Pose")
pose.Name = connectedPart.Name
parentPose:AddSubPose(pose)
-- recurse
addPoses(connectedPart, pose)
end
end
end
end
end
local keyframe = Instance.new("Keyframe")
-- populate the keyframe
local rootPose = Instance.new("Pose")
rootPose.Name = rootPart.Name
addPoses(rootPart, rootPose)
keyframe:AddPose(rootPose)
return keyframe
end
local character = script.Parent
local keyframe = generateKeyframe(character)
print(keyframe)
This code sample includes a function to reset the CFrame of the Poses in a Keyframe.
local function resetPoses(parent)
-- both functions are equivalent to GetChildren
local poses = parent:IsA("Keyframe") and parent:GetPoses() or parent:IsA("Pose") and parent:GetSubPoses()
for _, pose in pairs(poses) do
if pose:IsA("Pose") then
pose.CFrame = CFrame.new()
-- recurse
resetPoses(pose)
end
end
end
概要
属性
这 CFrame 适用于与 Motor6D 相对应的 Pose 当 Motor6D.Transform 更改时。
用于达到下一个姿势值的放松方向。
用于达到下一个姿势价值的放松风格。
方法
属性
CFrame
这 CFrame 适用于与 Motor6D 相对应的 Pose 当 Motor6D.Transform 更改时。原始 Motor6D.C0 和 Motor6D.C1 值不会被更改。
Pose 对象按照共同的等级排列在一个 Keyframe 中。这意味着,Pose.CFrame 被应用到连接部件与姿势相关的部件与姿势的父元素部件的电机。
方法
AddSubPose
将子 Pose 添加到 Pose 以将其作为父辈。它与设置新姿势的 Instance.Parent 相同功能。
注意,当给予实例其他于 Pose 为姿势参数时,此函数不会出错,并且会成功地将其作为父级。
参数
返回
代码示例
This sample demonstrates quickly the Keyframe.AddPose, Keyframe.RemovePose and Pose.AddSubPose and Pose.RemoveSubPose functions. Note these are functionally equivalent to parenting and un-parenting the poses.
local keyframe = Instance.new("Keyframe")
keyframe.Parent = workspace
local pose = Instance.new("Pose")
pose.EasingStyle = Enum.PoseEasingStyle.Cubic
pose.EasingDirection = Enum.PoseEasingDirection.Out
local pose2 = Instance.new("Pose")
pose2.EasingStyle = Enum.PoseEasingStyle.Cubic
pose2.EasingDirection = Enum.PoseEasingDirection.Out
keyframe:AddPose(pose) -- pose.Parent = keyframe
task.wait(2)
keyframe:RemovePose(pose) -- pose.Parent = nil
task.wait(2)
keyframe:AddPose(pose) -- pose.Parent = keyframe
task.wait(2)
pose:AddSubPose(pose2) -- pose2.Parent = pose
task.wait(2)
pose:RemoveSubPose(pose2) -- pose2.Parent = nil
GetSubPoses
返回包含所有子 Poses 被添加到 Pose 的阵列。这与使用 Instance:GetChildren() 函数在 Pose 上相同。
注意:此函数返回 所有子节点,包括非 如果存在。
返回
一个阵列的子 Poses .
代码示例
This code sample includes a function to reset the CFrame of the Poses in a Keyframe.
local function resetPoses(parent)
-- both functions are equivalent to GetChildren
local poses = parent:IsA("Keyframe") and parent:GetPoses() or parent:IsA("Pose") and parent:GetSubPoses()
for _, pose in pairs(poses) do
if pose:IsA("Pose") then
pose.CFrame = CFrame.new()
-- recurse
resetPoses(pose)
end
end
end
RemoveSubPose
将子 Pose 从 Pose 移除,将其作为父亲将其移至 nil 。这与设置新姿势的 Instance.Parent 到 nil 功能相同。
注意:如果使用了 Instance 其他于 Pose 的参数作为 Pose 参数,该函数将移除该 Instance 并不提供错误。
参数
返回
代码示例
This sample demonstrates quickly the Keyframe.AddPose, Keyframe.RemovePose and Pose.AddSubPose and Pose.RemoveSubPose functions. Note these are functionally equivalent to parenting and un-parenting the poses.
local keyframe = Instance.new("Keyframe")
keyframe.Parent = workspace
local pose = Instance.new("Pose")
pose.EasingStyle = Enum.PoseEasingStyle.Cubic
pose.EasingDirection = Enum.PoseEasingDirection.Out
local pose2 = Instance.new("Pose")
pose2.EasingStyle = Enum.PoseEasingStyle.Cubic
pose2.EasingDirection = Enum.PoseEasingDirection.Out
keyframe:AddPose(pose) -- pose.Parent = keyframe
task.wait(2)
keyframe:RemovePose(pose) -- pose.Parent = nil
task.wait(2)
keyframe:AddPose(pose) -- pose.Parent = keyframe
task.wait(2)
pose:AddSubPose(pose2) -- pose2.Parent = pose
task.wait(2)
pose:RemoveSubPose(pose2) -- pose2.Parent = nil