资讯 社区 文档
技术能力
语音技术
文字识别
人脸与人体
图像技术
语言与知识
视频技术

动画

ARAnimationController

动画播放控制器类, 用于创建/管理所有动画播放会ARAnimationController话。

Public methods
ARAnimationController create_animation_session
创建一个动画播放会话

create_animation_session

API起始版本:190

ARAnimationSession * create_animation_session (string type, LUA_TABLE configs);

创建一个动画播放会话

Parameters

  • string | type : 动画播放会话的类型,目前支持三种"model"-模型(pod/gltf)动画、"rigid"-刚体动画
  • LUA_TABLE | configs : key-value的方式存储的配置信息。可用的配置项如下
  • ARAnimationSession : 返回一个动画播放会话类的对象

模型动画config配置项:

key type value-tip defult-value meaning
repeat_count int 取值为非负整数 默认值为1, 0为无限循环 重复次数
speed float 取值为正数 默认为1.0 播放速度(多少倍速)
start_frame int 整数,未设置则从头播放,负数为无效值 -1(未设置) 起始帧
end_frame int 整数,未设置则播放到动画末尾,负数为无效值 -1(未设置) 结束帧
animation_chip string 此字段和(start_frame/end_frame)互斥使用,若都设置,以animation_chip的设置优先 场景配置文件中AnimationList中定义的动画片段的名称
forward_conflict_solving_strategy string wait_forward 当同一个结点上出现多个相同AnimationType的session时,相对前面的session的冲突处理的策略。取值:wait_forward、cancel_forward、cancel_all_forward、cancel_self、wait_all_forward、 force_cancel_forward
backward_conflict_solving_strategy string can_be_canceled 当同一个结点上出现多个相同AnimationType的session时,相对后面的session的冲突处理的策略。取值:can_be_canceled、cannot_be_canceled、cancel_backward
sample:
local config = {}
config["repeat_count"] = 1
config["speed"] = 0.5
config["start_frame"] = 0
config["end_frame"] = 100
config["forward_conflict_solving_strategy"] = "cancel_forward"

local node_name = scene:get_node_by_name("node_name")
local anim_controller = node_name:get_animation_controller()
local model_anim_session = anim_controller:create_animation_session("model", config)
model_anim_session:play()

刚体动画config配置项:

key type meaning defult-value
duration int 动画时长(ms) 默认值为1000
delay int 延迟开始时间(ms) 0
repeat_count int 重复次数 默认值为1; 0为无限循环
repeat_mode string 重复模式:"restart"/"reverse" "restart"
interp_type string 插值方式:"linear"/"bounce" "linear"
rigid_anim_type string 动画类型:"translate"/"rotate"/"scale"
translate_from ARVec3 位移动画起始位置 (0,0,0)无效
translate_to ARVec3 位移动画结束位置 (0,0,0)
start_offset int translate起始位置偏移量 毫秒
forward_direction int 是否从正向开始 0:是 1:否 1
bezier_ctrl_0 ARVec3 (translate)贝塞尔曲线第1个控制点 (0, 0, 0)
bezier_ctrl_1 ARVec3 (translate)贝塞尔曲线第2个控制点 (0, 0, 0)
bezier_ctrl_2 ARVec3 (translate)贝塞尔曲线第3个控制点 (0, 0, 0)
bezier_ctrl_3 ARVec3 (translate)贝塞尔曲线第4个控制点 (0, 0, 0)
rotate_to float 旋转结束角度 0
rotate_axis ARVec3 旋转轴 (0, 0, 0)
scale_to ARVec3 缩放结束Scale (0,0,0)
sample:
local rotate_config = {}
rotate_config["rigid_anim_type"] = "rotate"
rotate_config["duration"] = 3000 
rotate_config["delay"] = 1000
rotate_config["repeat_count"] = 5
rotate_config["repeat_mode"] = "reverse"
rotate_config["interp_type"] = "bounce"
rotate_config["rotate_to"] = 90
rotate_config["rotate_axis"] = ae.ARVec3:new_local(0, 1, 0)

local node_name = scene:get_node_by_name("node_name")
local anim_controller = node_name:get_animation_controller()
local rigid_anim_session = anim_controller:create_animation_session("rigid", rotate_config)
rigid_anim_session:play()

ARAnimationSession

动画播放会话类,用于管理一次动画(模型动画、刚体动画)播放过程。

Public methods
ARAnimationController set_state_handler
设置ARAnimationSession的状态回调
ARAnimationController Key-Value Coding support
KVC支持

set_state_handler

API起始版本:190

void set_state_handler(ARLuaFunction handler)

设置ARAnimationSession的状态回调,当状态发生变化时回调到此方法(目前仅Session结束时会回调: state = "finish")

Parameters

  • handler | ARLuaFunction : 一个原生的Lua Function,带2个参数,session_id和对应的状态state
sample:

function state_handler(session_id, state)
	io.wirte("state of session " + tostring(session_id) + " changed to" + state)
end

local config = {}
config["repeat_count"] = 1
config["speed"] = 0.5

local node_name = scene:get_node_by_name("node_name")
local anim_controller = node_name:get_animation_controller()
local rigid_anim_session = anim_controller:create_animation_session("rigid", rotate_config)
rigid_anim_session:play()
rigid_anim_session:set_state_handler(state_handler)

Key-Value Coding support

API起始版本:190

get_property

void get_property_int(string &key);

void get_property_string(string &key);

key type meaning defult-value ps
session_id int 当前播放会话的id,用于唯一标识一次动画播放过程
animation_type string 动画类型("model"/"rigid"/"alpha")
host_name string 对应节点名字
invalidated bool 当前会话是否失效 false
上一篇
相机控制
下一篇
3D