protected override BlendTree1DData CreateGraph(Entity entity, ref Rig rig, ProcessDefaultAnimationGraph graphSystem, ref BlendTree1DSetup setup) { var set = graphSystem.Set; var blendTreeComponent = EntityManager.GetBuffer <BlendTree1DResource>(entity); var blendTreeAsset = BlendTreeBuilder.CreateBlendTree1DFromComponents(blendTreeComponent[setup.BlendTreeIndex], EntityManager, entity); var data = new BlendTree1DData(); data.BlendTreeNode = set.Create <BlendTree1DNode>(); data.BlendTreeAsset = blendTreeAsset; data.EntityNode = set.CreateComponentNode(entity); data.DeltaTimeNode = set.Create <ConvertDeltaTimeToFloatNode>(); data.TimeCounterNode = set.Create <TimeCounterNode>(); data.TimeLoopNode = set.Create <TimeLoopNode>(); data.FloatRcpNode = set.Create <FloatRcpNode>(); data.BlendTreeInputNode = set.Create <ExtractBlendTree1DParametersNode>(); set.Connect(data.EntityNode, data.DeltaTimeNode, ConvertDeltaTimeToFloatNode.KernelPorts.Input); set.Connect(data.DeltaTimeNode, ConvertDeltaTimeToFloatNode.KernelPorts.Output, data.TimeCounterNode, TimeCounterNode.KernelPorts.DeltaTime); set.Connect(data.TimeCounterNode, TimeCounterNode.KernelPorts.Time, data.TimeLoopNode, TimeLoopNode.KernelPorts.InputTime); set.Connect(data.TimeLoopNode, TimeLoopNode.KernelPorts.OutputTime, data.BlendTreeNode, BlendTree1DNode.KernelPorts.NormalizedTime); set.Connect(data.BlendTreeNode, BlendTree1DNode.KernelPorts.Duration, data.FloatRcpNode, FloatRcpNode.KernelPorts.Input); set.Connect(data.FloatRcpNode, FloatRcpNode.KernelPorts.Output, data.TimeCounterNode, TimeCounterNode.KernelPorts.Speed); set.Connect(data.BlendTreeNode, BlendTree1DNode.KernelPorts.Output, data.EntityNode, NodeSet.ConnectionType.Feedback); set.Connect(data.EntityNode, data.BlendTreeInputNode, ExtractBlendTree1DParametersNode.KernelPorts.Input, NodeSet.ConnectionType.Feedback); set.Connect(data.BlendTreeInputNode, ExtractBlendTree1DParametersNode.KernelPorts.Output, data.BlendTreeNode, BlendTree1DNode.KernelPorts.BlendParameter); set.SendMessage(data.TimeLoopNode, TimeLoopNode.SimulationPorts.Duration, 1.0F); set.SendMessage(data.BlendTreeNode, BlendTree1DNode.SimulationPorts.Rig, rig); set.SendMessage(data.BlendTreeNode, BlendTree1DNode.SimulationPorts.BlendTree, data.BlendTreeAsset); return(data); }
protected override BlendTree1DData CreateGraph(Entity entity, NodeSet set, ref BlendTree1DSetup setup) { if (!EntityManager.HasComponent <SharedRigDefinition>(entity)) { throw new System.NullReferenceException("Entity doesn't have required SharedRigDefinition"); } var rigDefinition = EntityManager.GetSharedComponentData <SharedRigDefinition>(entity); var blendTreeComponent = EntityManager.GetBuffer <BlendTree1DResource>(entity); var blendTreeAsset = BlendTreeBuilder.CreateBlendTree1DFromComponents(blendTreeComponent[setup.BlendTreeIndex], EntityManager, entity); var data = new BlendTree1DData(); var strongHandle = set.Create <BlendTree1DNode>(); data.paramX = 0; data.BlendTree = strongHandle; data.BlendTreeAsset = blendTreeAsset; data.DeltaTimeNode = set.Create <DeltaTimeNode>(); data.TimeCounterNode = set.Create <TimeCounterNode>(); data.TimeLoopNode = set.Create <TimeLoopNode>(); data.FloatRcpSimNode = set.Create <FloatRcpSimNode>(); set.Connect(data.DeltaTimeNode, (OutputPortID)DeltaTimeNode.KernelPorts.DeltaTime, data.TimeCounterNode, (InputPortID)TimeCounterNode.KernelPorts.DeltaTime); set.Connect(data.TimeCounterNode, (OutputPortID)TimeCounterNode.KernelPorts.Time, data.TimeLoopNode, (InputPortID)TimeLoopNode.KernelPorts.InputTime); set.Connect(data.TimeLoopNode, (OutputPortID)TimeLoopNode.KernelPorts.OutputTime, data.BlendTree, (InputPortID)BlendTree1DNode.KernelPorts.NormalizedTime); set.Connect(data.BlendTree, (OutputPortID)BlendTree1DNode.SimulationPorts.Duration, data.FloatRcpSimNode, (InputPortID)FloatRcpSimNode.SimulationPorts.Input); set.Connect(data.FloatRcpSimNode, (OutputPortID)FloatRcpSimNode.SimulationPorts.Output, data.TimeCounterNode, (InputPortID)TimeCounterNode.SimulationPorts.Speed); set.SendMessage(data.TimeLoopNode, (InputPortID)TimeLoopNode.SimulationPorts.Duration, 1.0F); set.SendMessage(data.BlendTree, (InputPortID)BlendTree1DNode.SimulationPorts.RigDefinition, rigDefinition.Value); set.SendMessage(data.BlendTree, (InputPortID)BlendTree1DNode.SimulationPorts.BlendTree, data.BlendTreeAsset); data.Output.Buffer = set.CreateGraphValue(strongHandle, BlendTree1DNode.KernelPorts.Output); PostUpdateCommands.AddComponent(entity, data.Output); return(data); }
public void Convert(Entity entity, EntityManager dstManager, [NotNull] GameObjectConversionSystem conversionSystem) { conversionSystem.DeclareAssetDependency(gameObject, blendTree); var rigComponent = dstManager.GetComponentData <Rig>(entity); var clipConfiguration = new ClipConfiguration { Mask = ClipConfigurationMask.LoopValues }; var bakeOptions = new BakeOptions { RigDefinition = rigComponent.Value, ClipConfiguration = clipConfiguration, SampleRate = 60.0f }; var blendTreeIndex = BlendTreeConversion.Convert(blendTree, entity, dstManager, bakeOptions); var blendTreeComponents = dstManager.GetBuffer <BlendTree1DResource>(entity); var blobBlendTreeRef = BlendTreeBuilder.CreateBlendTree1DFromComponents(blendTreeComponents[blendTreeIndex], dstManager, entity); conversionSystem.BlobAssetStore.AddUniqueBlobAsset(ref blobBlendTreeRef); var blendTreeRuntime = new BlendTree1DRuntime { BlendTree = blobBlendTreeRef }; dstManager.AddComponentData(entity, blendTreeRuntime); var blendTreeParamRuntime = new BlendTree1DParamRuntime { VelocityStep = velocityStep, VelocityX = 0.0f }; dstManager.AddComponentData(entity, blendTreeParamRuntime); dstManager.AddComponent <DeltaTimeRuntime>(entity); }