Pose
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
ท่าโพสถือ CFrame ที่ใช้กับ Motor6D ที่เชื่อมโยงกับ BasePart ที่เกี่ยวข้องส่วนที่ควบคุมขึ้นอยู่กับชื่อของท่า
โพสเป็นบล็อกก่อสร้างพื้นฐานของแอนิเมชั่นและ, ด้วย Keyframes , ทำให้เสร็จ KeyframeSequences .
ท่าทาง ข้อต่อ และลําดับชั้น
แม้ว่าท่าจะถูกกำหนดให้กับ BasePart โดยชื่อ แต่วัตถุที่ถูกจัดการระหว่างการเล่นแอนิเมชั่นจริงๆ คือ Motor6D ที่เชื่อมต่อกับส่วนนี้สาขาแอนิเมชั่นแยกออกจากส่วนรากของโมเดลผ่านจุดเชื่อมต่อดังกล่าว
ในตัวละคร R15 ส่วนรากคือส่วนรากมนุษย์ส่วนลําตัวล่างเชื่อมต่อกับส่วนรากมนุษย์ด้วยมอเตอร์ชื่อ 'ราก'ดังนั้น CFrame ของท่าทางที่ชื่อว่า 'LowerTorso' ใน 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
เพิ่ม sub 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
ส่งคืนคอลเลกชันที่มีทั้งหมด sub Poses ที่ถูกเพิ่มลงใน Poseนี่คือฟังก์ชันเดียวกับการใช้ฟังก์ชัน Instance:GetChildren() บน Pose
หมายเหตุ: ฟังก์ชันนี้ส่งคืนลูกทั้งหมดของ Pose รวมถึงไม่ Class.Pose``Class.Instance|Instances ถ้ามีใด ๆ ปรากฏ
ส่งค่ากลับ
ชุดของ sub 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