Animation — Aspose.3D FOSS for Python API Reference

Properties

Hệ thống hoạt hình Aspose.3D được tổ chức quanh một cây phân cấp các đối tượng liên kết dữ liệu lấy mẫu theo thời gian với các thuộc tính của cảnh.

  • Properties AnimationClip là một phạm vi phát lại có tên (ví dụ: “Walk”, “Run”) được giữ bởi một Scene.
  • Properties AnimationNode tồn tại bên trong một clip và ràng buộc dữ liệu hoạt hình vào các thuộc tính cụ thể trên các đối tượng trong cảnh.
  • Một BindPoint kết nối một AnimationNode đến một có tên Property trên một A3DObject.
  • Properties AnimationChannel giữ một scalar duy nhất KeyframeSequence trong một bind point.
  • A KeyframeSequence là một danh sách có thứ tự của KeyFrame các mẫu thời gian–giá trị.

Tất cả các lớp hoạt hình nằm trong aspose.threed.animation sub-package, mặc dù chúng cũng có thể truy cập trực tiếp từ aspose.threed.

from aspose.threed.animation import (
    AnimationClip,
    AnimationNode,
    AnimationChannel,
    BindPoint,
    KeyFrame,
    KeyframeSequence,
    Interpolation,
    ExtrapolationType,
)

AnimationClip

Một container có tên cho một phạm vi phát lại. A Scene có thể chứa nhiều clip. Kế thừa từ SceneObject.

Properties

PropertiesProperties
AnimationClip(name=None)Tạo một clip với tên tùy chọn

Properties

PropertiesPropertiesProperties
namestrTên clip (ví dụ. "Walk")
descriptionstrMô tả tùy chọn
startfloatThời gian bắt đầu tính bằng giây
stopfloatThời gian kết thúc tính bằng giây
animationslist[AnimationNode]Danh sách chỉ đọc các nút hoạt hình trong clip này
propertiesPropertyCollectionThuộc tính tùy chỉnh

Properties

PropertiesKiểu trả vềProperties
create_animation_node(node_name)AnimationNodeTạo và đăng ký một mới AnimationNode trong clip này

AnimationNode

Liên kết một AnimationClip với một hoặc nhiều BindPoint đối tượng nhắm tới các thuộc tính của đối tượng cảnh. Kế thừa từ A3DObject.

Properties

PropertiesProperties
AnimationNode(name=None)Tạo một nút hoạt hình với tên tùy chọn

Properties

PropertiesPropertiesProperties
namestrTên nút
bind_pointslist[BindPoint]Danh sách chỉ đọc các điểm ràng buộc
sub_animationslist[AnimationNode]Danh sách chỉ đọc các nút hoạt hình con
propertiesPropertyCollectionThuộc tính tùy chỉnh

Properties

PropertiesKiểu trả vềProperties
find_bind_point(target, name)`BindPointNone`
get_bind_point(target, prop_name, create)`BindPointNone`
create_bind_point(obj, prop_name)`BindPointNone`
get_keyframe_sequence(target, prop_name, channel_name, create)`KeyframeSequenceNone`

BindPoint

Kết nối một AnimationNode đến một Property trên một A3DObject. Mỗi BindPoint có thể chứa nhiều AnimationChannel đối tượng (một cho mỗi thành phần vô hướng). Kế thừa từ A3DObject.

Properties

PropertiesPropertiesProperties
propertyPropertyThuộc tính đối tượng-cảnh mà điểm ràng buộc này nhắm tới
channels_countintSố kênh hoạt hình trong điểm ràng buộc này

Properties

PropertiesKiểu trả vềProperties
add_channel(name, value, type=None)boolThêm một kênh có tên với giá trị mặc định
get_channel(channel_name)`AnimationChannelNone`
get_keyframe_sequence(channel_name)`KeyframeSequenceNone`
create_keyframe_sequence(name)KeyframeSequenceTạo một mới KeyframeSequence cho điểm ràng buộc này
bind_keyframe_sequence(channel_name, sequence)NoneLiên kết một đối tượng hiện có KeyframeSequence với một kênh
reset_channels()NoneXóa tất cả các kênh

AnimationChannel

Chứa một giá trị vô hướng duy nhất KeyframeSequence cho một thành phần được hoạt hình.

Properties

PropertiesPropertiesProperties
namestrTên kênh (ví dụ. "X", "Y", "Z")
default_valueAnyGiá trị được sử dụng khi không có dữ liệu khung hình chính
keyframe_sequence`KeyframeSequenceNone`

KeyframeSequence

Danh sách có thứ tự của KeyFrame mẫu cho một kênh scalar đơn. Kế thừa từ A3DObject.

Properties

PropertiesProperties
KeyframeSequence(name=None)Tạo một chuỗi keyframe trống

Properties

PropertiesPropertiesProperties
namestrTên chuỗi
key_frameslist[KeyFrame]Danh sách keyframe chỉ đọc theo thứ tự thời gian
pre_behaviorExtrapolationHành vi trước keyframe đầu tiên
post_behaviorExtrapolationHành vi sau keyframe cuối cùng
bind_point`BindPointNone`

Properties

PropertiesKiểu trả vềProperties
add(time, value, interpolation=Interpolation.LINEAR)NoneThêm một keyframe tại time (giây) với valueinterpolation chế độ
reset()NoneXóa tất cả các keyframe và đặt lại hành vi pre/post

KeyFrame

Một mẫu thời gian–giá trị duy nhất trong một KeyframeSequence.

Properties

KeyFrame các đối tượng được tạo nội bộ bởi KeyframeSequence.add(); không tạo chúng trực tiếp.

Properties

PropertiesPropertiesProperties
timefloatVị trí thời gian tính bằng giây
valuefloatGiá trị hoạt hình tại thời điểm này
interpolationInterpolationChế độ nội suy được áp dụng giữa keyframe này và keyframe tiếp theo
tangent_weight_modeWeightedModeChế độ trọng lượng tiếp tuyến (đường cong Bezier)
step_modeStepModeHành vi bước (PREVIOUS_VALUE hoặc NEXT_VALUE)
next_in_tangent`Vector2None`
out_tangent`Vector2None`
out_weightfloatTrọng số tiếp tuyến ra
next_in_weightfloatTrọng số tiếp tuyến vào
tensionfloatTham số căng (TCB spline)
continuityfloatTham số độ liên tục (TCB spline)
biasfloatTham số độ lệch (đường cong TCB)
independent_tangentboolProperties True, các tiếp tuyến vào và ra là độc lập
flatboolProperties True, các tiếp tuyến được kẹp phẳng
time_independent_tangentboolProperties True, hướng tiếp tuyến độc lập với việc co dãn thời gian

Properties

Kiểm soát cách các giá trị được nội suy giữa các keyframe liên tiếp.

PropertiesProperties
CONSTANTProperties
LINEARNội suy tuyến tính giữa các giá trị
BEZIERBezier bậc ba sử dụng các tiếp tuyến vào/ra
B_SPLINEB-spline đồng nhất
CARDINAL_SPLINECardinal spline
TCB_SPLINESpline Tension–Continuity–Bias

Properties

Kiểm soát hành vi hoạt ảnh ngoài keyframe đầu tiên và cuối cùng.

PropertiesProperties
CONSTANTGiữ giá trị biên
GRADIENTNgoại suy tại độ dốc tiếp tuyến của keyframe biên
CYCLELặp lại phạm vi keyframe (vòng lặp)
CYCLE_RELATIVELặp lại với độ dịch tích lũy (liên quan đến giá trị cuối)
OSCILLATEPing-pong (lặp lại luân phiên tiến và lùi)

Properties

from aspose.threed import Scene
from aspose.threed.animation import AnimationClip, Interpolation
from aspose.threed.utilities import Vector3

scene = Scene()
node = scene.root_node.create_child_node("animated_box")
node.transform.translation = Vector3(0.0, 0.0, 0.0)

# Create an animation clip
clip = AnimationClip("Move")
clip.start = 0.0
clip.stop  = 2.0

# Create an animation node inside the clip
anim_node = clip.create_animation_node("box_anim")

# Get keyframe sequences for the X and Y translation channels
seq_x = anim_node.get_keyframe_sequence(node.transform, "Translation", "X", True)
seq_y = anim_node.get_keyframe_sequence(node.transform, "Translation", "Y", True)

if seq_x:
    seq_x.add(0.0,  0.0,  Interpolation.LINEAR)
    seq_x.add(1.0, 10.0,  Interpolation.LINEAR)
    seq_x.add(2.0,  0.0,  Interpolation.LINEAR)

if seq_y:
    seq_y.add(0.0,  0.0, Interpolation.BEZIER)
    seq_y.add(1.0,  5.0, Interpolation.BEZIER)
    seq_y.add(2.0,  0.0, Interpolation.BEZIER)

# Export to FBX to preserve animation data
scene.save("animated.fbx")

Xem thêm

 Tiếng Việt