public override void AddGraphSetupComponent(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { var walkShortLeftClip = WalkShortLeftClip.ToDenseClip(); var walkLongLeftClip = WalkLongLeftClip.ToDenseClip(); var walkStraightClip = WalkStraightClip.ToDenseClip(); var walkLongRightClip = WalkLongRightClip.ToDenseClip(); var walkShortRightClip = WalkShortRightClip.ToDenseClip(); var jogShortLeftClip = JogShortLeftClip.ToDenseClip(); var jogLongLeftClip = JogLongLeftClip.ToDenseClip(); var jogStraightClip = JogStraightClip.ToDenseClip(); var jogLongRightClip = JogLongRightClip.ToDenseClip(); var jogShortRightClip = JogShortRightClip.ToDenseClip(); var clipConfiguration = new ClipConfiguration(); clipConfiguration.Mask = ClipConfigurationMask.LoopTime | ClipConfigurationMask.CycleRootMotion | ClipConfigurationMask.DeltaRootMotion; clipConfiguration.Mask |= LoopValues ? ClipConfigurationMask.LoopValues : 0; clipConfiguration.Mask |= BankPivot ? ClipConfigurationMask.BankPivot : 0; clipConfiguration.MotionID = m_MotionId; var graphSetup = new AnimationControllerSetup { WalkShortLeftClip = walkShortLeftClip, WalkLongLeftClip = walkLongLeftClip, WalkStraightClip = walkStraightClip, WalkLongRightClip = walkLongRightClip, WalkShortRightClip = walkShortRightClip, JogShortLeftClip = jogShortLeftClip, JogLongLeftClip = jogLongLeftClip, JogStraightClip = jogStraightClip, JogLongRightClip = jogLongRightClip, JogShortRightClip = jogShortRightClip, }; if (Bake) { var rigDefinition = dstManager.GetComponentData <Rig>(entity); graphSetup.WalkShortLeftClip = UberClipNode.Bake(rigDefinition.Value, walkShortLeftClip, clipConfiguration, SampleRate); graphSetup.WalkLongLeftClip = UberClipNode.Bake(rigDefinition.Value, walkLongLeftClip, clipConfiguration, SampleRate); graphSetup.WalkStraightClip = UberClipNode.Bake(rigDefinition.Value, walkStraightClip, clipConfiguration, SampleRate); graphSetup.WalkLongRightClip = UberClipNode.Bake(rigDefinition.Value, walkLongRightClip, clipConfiguration, SampleRate); graphSetup.WalkShortRightClip = UberClipNode.Bake(rigDefinition.Value, walkShortRightClip, clipConfiguration, SampleRate); graphSetup.JogShortLeftClip = UberClipNode.Bake(rigDefinition.Value, jogShortLeftClip, clipConfiguration, SampleRate); graphSetup.JogLongLeftClip = UberClipNode.Bake(rigDefinition.Value, jogLongLeftClip, clipConfiguration, SampleRate); graphSetup.JogStraightClip = UberClipNode.Bake(rigDefinition.Value, jogStraightClip, clipConfiguration, SampleRate); graphSetup.JogLongRightClip = UberClipNode.Bake(rigDefinition.Value, jogLongRightClip, clipConfiguration, SampleRate); graphSetup.JogShortRightClip = UberClipNode.Bake(rigDefinition.Value, jogShortRightClip, clipConfiguration, SampleRate); clipConfiguration.Mask = ClipConfigurationMask.NormalizedTime | ClipConfigurationMask.LoopTime | ClipConfigurationMask.RootMotionFromVelocity; clipConfiguration.MotionID = 0; } else { clipConfiguration.Mask |= ClipConfigurationMask.NormalizedTime; } graphSetup.Configuration = clipConfiguration; dstManager.AddComponentData(entity, graphSetup); dstManager.AddComponent <ProcessDefaultAnimationGraph.AnimatedRootMotion>(entity); dstManager.AddComponent <DeltaTime>(entity); }
public override void AddGraphSetupComponent(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { var walkShortLeftClip = ClipBuilder.AnimationClipToDenseClip(WalkShortLeftClip); var walkLongLeftClip = ClipBuilder.AnimationClipToDenseClip(WalkLongLeftClip); var walkStraightClip = ClipBuilder.AnimationClipToDenseClip(WalkStraightClip); var walkLongRightClip = ClipBuilder.AnimationClipToDenseClip(WalkLongRightClip); var walkShortRightClip = ClipBuilder.AnimationClipToDenseClip(WalkShortRightClip); var jogShortLeftClip = ClipBuilder.AnimationClipToDenseClip(JogShortLeftClip); var jogLongLeftClip = ClipBuilder.AnimationClipToDenseClip(JogLongLeftClip); var jogStraightClip = ClipBuilder.AnimationClipToDenseClip(JogStraightClip); var jogLongRightClip = ClipBuilder.AnimationClipToDenseClip(JogLongRightClip); var jogShortRightClip = ClipBuilder.AnimationClipToDenseClip(JogShortRightClip); var clipConfiguration = new ClipConfiguration(); clipConfiguration.Mask = 0; clipConfiguration.Mask |= (int)ClipConfigurationMask.LoopTime; clipConfiguration.Mask |= LoopValues ? (int)ClipConfigurationMask.LoopValues : 0; clipConfiguration.Mask |= (int)ClipConfigurationMask.CycleRootMotion; clipConfiguration.Mask |= (int)ClipConfigurationMask.DeltaRootMotion; clipConfiguration.Mask |= BankPivot ? (int)ClipConfigurationMask.BankPivot : 0; clipConfiguration.MotionID = m_MotionId; var graphSetup = new AnimationControllerSetup { WalkShortLeftClip = walkShortLeftClip, WalkLongLeftClip = walkLongLeftClip, WalkStraightClip = walkStraightClip, WalkLongRightClip = walkLongRightClip, WalkShortRightClip = walkShortRightClip, JogShortLeftClip = jogShortLeftClip, JogLongLeftClip = jogLongLeftClip, JogStraightClip = jogStraightClip, JogLongRightClip = jogLongRightClip, JogShortRightClip = jogShortRightClip, }; if (Bake) { var rigDefinition = dstManager.GetComponentData <RigDefinitionSetup>(entity); var walkShortLeftClipInstance = ClipInstance.Create(rigDefinition.Value, walkShortLeftClip); var walkLongLeftClipInstance = ClipInstance.Create(rigDefinition.Value, walkLongLeftClip); var walkStraightClipInstance = ClipInstance.Create(rigDefinition.Value, walkStraightClip); var walkLongRightClipInstance = ClipInstance.Create(rigDefinition.Value, walkLongRightClip); var walkShortRightClipInstance = ClipInstance.Create(rigDefinition.Value, walkShortRightClip); var jogShortLeftClipInstance = ClipInstance.Create(rigDefinition.Value, jogShortLeftClip); var jogLongLeftClipInstance = ClipInstance.Create(rigDefinition.Value, jogLongLeftClip); var jogStraightClipInstance = ClipInstance.Create(rigDefinition.Value, jogStraightClip); var jogLongRightClipInstance = ClipInstance.Create(rigDefinition.Value, jogLongRightClip); var jogShortRightClipInstance = ClipInstance.Create(rigDefinition.Value, jogShortRightClip); graphSetup.WalkShortLeftClip = UberClipNode.Bake(walkShortLeftClipInstance, clipConfiguration, SampleRate); graphSetup.WalkLongLeftClip = UberClipNode.Bake(walkLongLeftClipInstance, clipConfiguration, SampleRate); graphSetup.WalkStraightClip = UberClipNode.Bake(walkStraightClipInstance, clipConfiguration, SampleRate); graphSetup.WalkLongRightClip = UberClipNode.Bake(walkLongRightClipInstance, clipConfiguration, SampleRate); graphSetup.WalkShortRightClip = UberClipNode.Bake(walkShortRightClipInstance, clipConfiguration, SampleRate); graphSetup.JogShortLeftClip = UberClipNode.Bake(jogShortLeftClipInstance, clipConfiguration, SampleRate); graphSetup.JogLongLeftClip = UberClipNode.Bake(jogLongLeftClipInstance, clipConfiguration, SampleRate); graphSetup.JogStraightClip = UberClipNode.Bake(jogStraightClipInstance, clipConfiguration, SampleRate); graphSetup.JogLongRightClip = UberClipNode.Bake(jogLongRightClipInstance, clipConfiguration, SampleRate); graphSetup.JogShortRightClip = UberClipNode.Bake(jogShortRightClipInstance, clipConfiguration, SampleRate); walkShortLeftClipInstance.Dispose(); walkLongLeftClipInstance.Dispose(); walkStraightClipInstance.Dispose(); walkLongRightClipInstance.Dispose(); walkShortRightClipInstance.Dispose(); jogShortLeftClipInstance.Dispose(); jogLongLeftClipInstance.Dispose(); jogStraightClipInstance.Dispose(); jogLongRightClipInstance.Dispose(); jogShortRightClipInstance.Dispose(); clipConfiguration.Mask = 0; clipConfiguration.Mask |= (int)ClipConfigurationMask.NormalizedTime; clipConfiguration.Mask |= (int)ClipConfigurationMask.LoopTime; clipConfiguration.Mask |= (int)ClipConfigurationMask.RootMotionFromVelocity; clipConfiguration.MotionID = 0; } else { clipConfiguration.Mask |= (int)ClipConfigurationMask.NormalizedTime; } graphSetup.Configuration = clipConfiguration; dstManager.AddComponentData(entity, graphSetup); }