Pose 持有 CFrame 应用于 Motor6D 连接到其附属的 BasePart 。 受控的部分取决于 Pose 的名称。
位置是动画的基础构建块,通过 Keyframes 组成 KeyframeSequences。
位置、关节和层次
虽然 Pose 被分配到 BasePart 按名,但在动画播放中操作的对象实际上是 Motor6D 连接到此部分。动画装备从模型的根部分通过这些关节分支到此部分。
在 R15 角色骨架中,根部是人形根部。 下半身是由名为“根”的电机连接到人形根部。 因此, Pose 的 CFrame 的 Keyframe 中的“Datatype.CFrame”将被应用到电机上,而不是根本。
体位是按照共同层级排列在 Keyframe 中。这意味着,体位的 CFrame 适用于与该体位相关的部分,并且该部分与该体位的父元素部分连接。见下面的视觉示例来说明结构上的位置。
CFrame 姿势
Roblox 动画系统将 Pose.CFrame 应用到相应的 Motor6D 通过操作引擎的相对变形来操作 Motor6D.Transform 属性。原始 2>Class.JointInstance.C1|C02> 和
代码示例
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
属性
方法
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
返回一个包含所有子 Pose 的阵列,该添加到一个 Instance:GetChildren() 。这是与使用 1> Class.Instance:GetChildren()1> 函数在 4> Class.Pose4> 上的功能上的功能相同。
注意:此函数将返回 Pose 中所有的子 Pose ,包括非 Instances Class.Instance|Instances 如果存在。
返回
一个子阵列 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 相同。
注意:如果 Pose 其他的 Pose 用作 1> Class.Pose1> 参数,此函数将此4> Class.Instance4> 移除,并且不提供错误。
参数
返回
代码示例
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