动画系统

1. 骨骼动画

1.1. 骨骼动画资源

引擎支持导入Max、Maya等三维制作软件中的骨骼动画。具体方法是从Max中导出FBX,在导入引擎时勾选导入动画,即可以生成动画文件,生成的动画文件类型是.seq。

1.2. 骨骼动画使用

详情请参考“动画播放“ 也可参考下面的这段脚本:

function PlayAction(actor, actionPath, isLoop, rate)
local comp = actor:GetRootComponent()
XEAnimController:UnloadAnimation(comp)
   if nil ~= comp:GetAnimController() then
      comp:GetAnimController():Stop()\
  end
XEAnimController:LoadAnimation(actionPath, comp)
if comp and comp.GetAnimController and comp:GetAnimController() then
   comp:GetAnimController():SetLoop(isLoop)
   comp:GetAnimController():Play()
   if rate then
      comp:GetAnimController():SetPlayRate(rate)
      end
  end
end

2. 变形动画

引擎支持导入Max、Maya等三维制作软件中的变形器,即Morph或BlendShape,导出的文件类型是mph。如果有制作morph动画,也可以同步导出,动画的类型同样是seq。

3. 蒙太奇动画

蒙太奇编动画主要用于针对动画的剪接,将多个动画串联成一个复杂的动画。通过添加动画以及粒子效果等,使得表现出一些比较复杂的动画效果。蒙太奇编辑器支持的资源文件格式为*.montage。

蒙太奇动画实例是一棵节点实例树。它的实例基础节点由以下类型的实例节点组成:

  • 基础节点实例XEAnimMonBaseInstance
  • 实例根节点XEAnimMontageInstance
  • 实例动画元素节点XEAnimMonElementInstance
  • 通知节点XEAnimMonNotifyInstance

此外,一个蒙太奇实例有一个动画控制器XEAnimMonController,负责动画的播放、停止等播放逻辑。 蒙太奇动画实例在原来的基础上已经对特定的节点实例支持了脚本绑定,例如通知实例XEAnimMonNotifyInstance,根据需要,可为每个通知实例额外绑定一个自定义的脚本资产,并在脚本对象绑定的代码入口响应函数中组建实现逻辑。 使用节点实例的脚本模板bin/Resources/scriptEntrance/lua/usernode.entrance组建lua的模板代码对象,基本的实例节点入口函数如下:

function code_entity:onHolderEntrance(script_ins, usernode)
  -- this function will be called once when the binding holder is ready to work.
end
function code_entity:onHolderTrigger(usernode, is_trigger)
    -- addition function for usenode trigger in montage, etc.
end
function code_entity:onHolderRelease(usernode)
  -- this function will be called once when the binding holder is ready to release.
end
-- this function will be called each tick after the ticking of the holder.
function code_entity:onHolderTick(usernode, interval)
end
-- this function will be called each tick after the rendering of the holder.
function code_entity:onHolderRender(usernode, viewport)
end

3.1. 蒙太奇动画创建

蒙太奇动画在蒙太奇编辑器中创建,可以在动画轨道上添加粒子消息,声音消息,也可以添加自定义的lua脚本。 可以针对某段动画进行更复杂的操作,如裁剪,循环,缩放等。

3.2. 蒙太奇动画使用

蒙太奇动画的使用方法与骨骼动画相同,可以参考上面的脚本。

4. 过场动画

过场动画编辑器提供了对Actor属性随时间进行动画处理的功能,也提供了创建过场动画序列的功能。基于专用的动画轨道,可以 在轨道上放置关键帧来设置Actor某些属性的值。可以用来添加动画序列、设置Actor基于时间的运动或者变换效果、场景相机变 换、动画融合、指定关键帧处触发某个事件等。

过场动画实例也是一棵节点实例树。它的实例基础节点由以下类型的实例节点组成:

  • 基础节点实例XESeqBaseInstance
  • 实例根节点 XESequencerInstance
  • 可绑定任意Actor的节点实例XESeqBindingActorInstance
  • 事件轨道节点实例XESeqTrackEventInstance
  • 动画速率节点实例XESeqTrackPlayRateInstance
  • 动画轨道节点实例XESeqTrackSectionAnimationInstance 此外,一个过场动画实例有一个动画控制器XESeqAnimController,负责动画的播放、停止等播放逻辑。 事件轨道节点实例现在已经可根据需要额外绑定一个自定义的脚本资产,并可在过场动画编辑器中进行响应函数的编辑并在脚本对象绑定的代码入口响应函数中组建实现逻辑。 使用节点实例的脚本模板bin/Resources/scriptEntrance/lua/event.entrance组建lua的模板代码对象,基本的实例节点入口函数如下:
function code_entity:onEventEntrance(event, world, variant_data)
    -- this function will be called once when the binding event is ready to work.
    local sender = event:GetSender()
    if sender then
      local dispatcher = XECast(sender, "XESequencerInstance::XESequencerInstanceEventDispatcher")
      local sequencer = dispatcher:GetSequencerInstance()
      self._sequencer = sequencer --sequencer ready
    end
end
function code_entity:onEventTrigger(event, world, variant_data)
   -- this function will be called once when the event has been triggered.
end
function code_entity:onEventRelease(event, world, variant_data)
     -- this function will be called once when the binding holder is ready to release.
end
function code_entity:onEventRestore(event, world, variant_data)
    -- this function will be called once when the event has been restored.
end
function code_entity:onEventTick(event, world, interval)
    -- this function will be called each tick.
end
function code_entity:custom_impl_as_you_want(event, world, variant_data)
  -- this function will be called matched to the editor setting...
end

其中, 可在代码对象中实现自定义的方法,例如上述中的custom_impl_as_you_want,并在过场动画编辑器的事件轨道中进行函数调用关键帧设置。

4.1. 过场动画创建

过场动画在过场动画编辑器中创建,支持seq动画,蒙太奇动画,材质动画,坐标变换,灯光参数调节,摄像机参数调节,lua事件等功能。

4.2. 过场动画使用

  • 在世界场景中的过场动画

过场动画可以处理其所在的世界场景中的Actor, 并对Actor的可编辑属性进行基于时间线的K帧编辑。 这种过场动画的Actor类型为SceneSequenceActor。在编辑器中,将过场动画拖动到场景之后,会自动生成一个SceneSequenceActor。 Lua客户端可通过Actor获取RootComponent,再通过以下方法播放过场动画:

local pController = RootCompoennet:GetSequenceInstance():GetSeqAnimController()
pController:Play()
  • 在父Actor中作为过场动画组件存在

过场动画同样可以作为一个父Actor的子组件存在。当作为子组件存在时,只可编辑包含该父Actor的Actor树,Transform节点数据自动以本地空间坐标系储存数据。这种过场动画组件为“Actor的动画器组件”。 要获取"Actor的动画器组件",并播放,可以通过以下方法:

local childComponents = RootComponent:GetChildComponents()
for _, v in pairs(childComponents) do
  if v.XType == "XESceneSequenceComponent" then
    local pController = v:GetSequenceInstance():GetSeqAnimController()
    pController:Play()
    break
  end
end

4.3. 过场动画注意事项

在A场景中编辑的过场动画文件,一般建议只在A场景中使用。如果想拷贝到B场景中使用,前提是场景A和场景B都包含过场动画文 件中使用的Actor等资源,并且Actor名称和属性(尤其是变换属性)要一致,否则,场景B中过场动画效果,可能跟在场景A中的 不一致。 如果场景中添加了多个过场动画文件,并且这些过场动画文件中,在同一时间片段内有针对同一个Actor的编辑操作,而且涉及 到的过场动画文件都设置了“自动播放”,那么,这时在场景预览时,多个过场动画文件同时播放最终效果可能会有重叠现象,可能 不是您想要的结果。建议您在场景中添加过场动画文件时,不要出现上述所说的情况。

@Copyright © cosmos 2019 all right reserved,powered by Gitbook修订时间: 2021-04-12 18:28:15

results matching ""

    No results matching ""