private void Start() { _mainMusicSource = GetComponent <AudioSource>(); currentConfiguration = Instantiate(currentConfiguration); _mainMusicSource.clip = currentConfiguration.Clip; _mainMusicSource.Play(); }
private void ReadDuration(ref ClipConfiguration clipConfiguration) { if (formatContext.Duration > TimeSpan.Zero) { clipConfiguration.Duration = formatContext.Duration; } }
private void ReadStreamConfigs(ref ClipConfiguration clipConfiguration) { var configs = new List <StreamConfig>(); ReadAudioConfig(configs); ReadVideoConfig(configs); clipConfiguration.StreamConfigs = configs; }
public override async Task<ClipConfiguration> Open() { Log.Enter(); var config = await _dataSource.Open(); CurrentConfiguration = config; Log.Exit(); return config; }
private ClipConfiguration InitDemuxer(Action initAction) { ffmpegGlue.Initialize(); initAction(); var clipConfiguration = new ClipConfiguration(); FindStreamsInfo(); ReadDuration(ref clipConfiguration); ReadStreamConfigs(ref clipConfiguration); ReadContentProtectionConfigs(ref clipConfiguration); return(clipConfiguration); }
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { if (blendTree == null) { return; } conversionSystem.DeclareAssetDependency(gameObject, blendTree); var rig = dstManager.GetComponentData <Rig>(entity); var clipConfiguration = new ClipConfiguration { Mask = ClipConfigurationMask.LoopValues }; var bakeOptions = new BakeOptions { ClipConfiguration = clipConfiguration, RigDefinition = rig.Value, SampleRate = 60.0f }; var blendTreeIndex = BlendTreeConversion.Convert(blendTree, entity, dstManager, bakeOptions); var blendTree2DResources = dstManager.GetBuffer <BlendTree2DResource>(entity); var blendTreeAsset = BlendTreeBuilder.CreateBlendTree2DFromComponents(blendTree2DResources[blendTreeIndex], dstManager, entity); conversionSystem.BlobAssetStore.AddUniqueBlobAsset(ref blendTreeAsset); var blendTree2DData = new BlendTree2DRuntime { BlendTreeAsset = blendTreeAsset }; dstManager.AddComponentData(entity, blendTree2DData); var blendTree2DParam = new BlendTree2DParamRuntime { InputMapping = float2.zero, StepMapping = paramStep }; dstManager.AddComponentData(entity, blendTree2DParam); dstManager.AddComponent <DeltaTimeRuntime>(entity); dstManager.AddComponent <ProcessDefaultAnimationGraph.AnimatedRootMotion>(entity); }
public override void AddGraphSetupComponent(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { var rigDefinition = dstManager.GetComponentData <Rig>(entity); var clipConfiguration = new ClipConfiguration { Mask = ClipConfigurationMask.LoopValues }; var bakeOptions = new BakeOptions { RigDefinition = rigDefinition.Value, ClipConfiguration = clipConfiguration, SampleRate = 60.0f }; var blendTreeIndex = BlendTreeConversion.Convert(BlendTree, entity, dstManager, bakeOptions); var graphSetup = new BlendTree1DSetup { BlendTreeIndex = blendTreeIndex, }; dstManager.AddComponentData(entity, graphSetup); }
protected override void OnUpdate() { base.OnUpdate(); // Performed on main thread since sending messages from NodeSet and ClipConfiguration changes incur a structural graph change. // It's not recommended to do this at runtime, it's mostly shown here to showcase clip configuration features. Entities.WithAll <ConfigurableClipSetup, ConfigurableClipData>() .ForEach((Entity e, ref ConfigurableClipData data) => { m_GraphSystem.Set.SetData(data.ConfigurableClipNode, ConfigurableClipNode.KernelPorts.Time, data.ClipTime); if (data.UpdateConfiguration) { data.UpdateConfiguration = false; var config = new ClipConfiguration { Mask = 0, MotionID = data.InPlace ? data.MotionID : 0 }; if (data.NormalizedTime) { config.Mask |= ClipConfigurationMask.NormalizedTime; } if (data.LoopTime) { config.Mask |= ClipConfigurationMask.LoopTime; } if (data.LoopValues) { config.Mask |= ClipConfigurationMask.LoopValues; } if (data.CycleRootMotion) { config.Mask |= ClipConfigurationMask.CycleRootMotion; } if (data.BankPivot) { config.Mask |= ClipConfigurationMask.BankPivot; } m_GraphSystem.Set.SendMessage(data.ConfigurableClipNode, ConfigurableClipNode.SimulationPorts.Configuration, config); } }); }
protected override void OnUpdate() { base.OnUpdate(); // Performed on main thread since sending messages from NodeSet and ClipConfiguration changes incur a structural graph change. // It's not recommended to do this at runtime, it's mostly shown here to showcase clip configuration features. Entities.WithAll <ConfigurableClipSetup, ConfigurableClipData>() .ForEach((Entity e, ref ConfigurableClipData data) => { m_AnimationSystem.Set.SetData(data.ConfigurableClipNode, ConfigurableClipNode.KernelPorts.Time, data.ClipTime); if (data.UpdateConfiguration) { var config = new ClipConfiguration { Mask = data.ClipOptions, MotionID = data.InPlace ? data.MotionID : 0 }; m_AnimationSystem.Set.SendMessage(data.ConfigurableClipNode, ConfigurableClipNode.SimulationPorts.Configuration, config); data.UpdateConfiguration = false; } }); }
private static IDemuxer CreateDemuxerStub(ClipConfiguration configuration, StartType startType) { var demuxerStub = Substitute.For <IDemuxer>(); switch (startType) { case StartType.StartForEs: demuxerStub.InitForEs().Returns(configuration); break; case StartType.StartForUrl: demuxerStub.InitForUrl(Arg.Any <string>()) .Returns(configuration); break; default: throw new ArgumentOutOfRangeException(nameof(startType), startType, null); } return(demuxerStub); }
protected override void UpdateGraph(Entity entity, NodeSet set, ref ConfigurableClipData data) { data.RootX = set.GetValueBlocking(data.RootXValue); set.SetData(data.ConfigurableClipNode, (InputPortID)ConfigurableClipNode.KernelPorts.Time, data.ClipTime); if (data.UpdateConfiguration) { data.UpdateConfiguration = false; var mask = 0; if (data.NormalizedTime) { mask |= (int)ClipConfigurationMask.NormalizedTime; } if (data.LoopTime) { mask |= (int)ClipConfigurationMask.LoopTime; } if (data.LoopValues) { mask |= (int)ClipConfigurationMask.LoopValues; } if (data.CycleRootMotion) { mask |= (int)ClipConfigurationMask.CycleRootMotion; } if (data.BankPivot) { mask |= (int)ClipConfigurationMask.BankPivot; } var config = new ClipConfiguration { Mask = mask, MotionID = data.InPlace ? data.MotionID : 0 }; set.SendMessage(data.ConfigurableClipNode, (InputPortID)ConfigurableClipNode.SimulationPorts.Configuration, config); } }
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); }
/// <summary> /// The graph executes in the ProcessDefaultAnimationGraph system, but because we connect an EntityNode to the output of the ClipPlayerNode, /// the AnimatedData buffer gets updated on the entity and can be used in other systems, such as the ProcessLateAnimationGraph system. /// </summary> /// <param name="entity">An entity that has a PlayClipComponent and a Rig.</param> /// <param name="graphSystem">The ProcessDefaultAnimationGraph.</param> /// <param name="rig">The rig that will get animated.</param> /// <param name="playClip">The clip to play.</param> /// <returns>Returns a StateComponent containing the NodeHandles of the graph.</returns> static Socket_PlayClipStateComponent CreateGraph( Entity entity, ProcessDefaultAnimationGraph graphSystem, ref Rig rig, ref Socket_PlayClipComponent playClip) { GraphHandle graph = graphSystem.CreateGraph(); var data = new Socket_PlayClipStateComponent { Graph = graph, ClipPlayerNode = graphSystem.CreateNode <ClipPlayerNode>(graph) }; var deltaTimeNode = graphSystem.CreateNode <ConvertDeltaTimeToFloatNode>(graph); var entityNode = graphSystem.CreateNode(graph, entity); var set = graphSystem.Set; // Connect kernel ports set.Connect(entityNode, deltaTimeNode, ConvertDeltaTimeToFloatNode.KernelPorts.Input); set.Connect(deltaTimeNode, ConvertDeltaTimeToFloatNode.KernelPorts.Output, data.ClipPlayerNode, ClipPlayerNode.KernelPorts.DeltaTime); set.Connect(data.ClipPlayerNode, ClipPlayerNode.KernelPorts.Output, entityNode, NodeSetAPI.ConnectionType.Feedback); // Send messages to set parameters on the ClipPlayerNode set.SetData(data.ClipPlayerNode, ClipPlayerNode.KernelPorts.Speed, 1.0f); var clipconfig = new ClipConfiguration { Mask = ClipConfigurationMask.LoopTime | ClipConfigurationMask.LoopValues }; set.SendMessage(data.ClipPlayerNode, ClipPlayerNode.SimulationPorts.Configuration, clipconfig); set.SendMessage(data.ClipPlayerNode, ClipPlayerNode.SimulationPorts.Rig, rig); set.SendMessage(data.ClipPlayerNode, ClipPlayerNode.SimulationPorts.Clip, playClip.Clip); return(data); }
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { if (Clips == null || BlendThresholds == null) { return; } if (!dstManager.HasComponent <Rig>(entity)) { throw new System.InvalidOperationException("RigComponent must be converted before this component."); } if (Clips.Length != BlendThresholds.Length) { throw new System.InvalidOperationException("You must have the same number of clips and blendthresholds."); } var rigComponent = GetComponent <RigComponent>() as RigComponent; StringHash motionId = ""; for (var boneIter = 0; boneIter < rigComponent.Bones.Length; boneIter++) { if (MotionJointName == rigComponent.Bones[boneIter].name) { motionId = RigGenerator.ComputeRelativePath(rigComponent.Bones[boneIter], rigComponent.transform); } } var rigDefinition = dstManager.GetComponentData <Rig>(entity); var clipConfiguration = new ClipConfiguration(); clipConfiguration.Mask = ClipConfigurationMask.LoopTime | ClipConfigurationMask.LoopValues | ClipConfigurationMask.CycleRootMotion | ClipConfigurationMask.DeltaRootMotion; clipConfiguration.MotionID = motionId; var denseClips = new NativeArray <SampleClip>(Clips.Length, Allocator.Temp); var durations = new NativeArray <SampleClipDuration>(Clips.Length, Allocator.Temp); var thresholds = new NativeArray <SampleClipBlendThreshold>(Clips.Length, Allocator.Temp); for (int i = 0; i < Clips.Length; i++) { conversionSystem.DeclareAssetDependency(gameObject, Clips[i]); denseClips[i] = new SampleClip { Clip = UberClipNode.Bake(rigDefinition.Value, Clips[i].ToDenseClip(), clipConfiguration, 60.0f) }; durations[i] = new SampleClipDuration { Value = denseClips[i].Clip.Value.Duration }; thresholds[i] = new SampleClipBlendThreshold { Value = BlendThresholds[i] }; } var synchronizeMotions = dstManager.AddBuffer <SampleClip>(entity); synchronizeMotions.CopyFrom(denseClips); var synchronizeMotionDurations = dstManager.AddBuffer <SampleClipDuration>(entity); synchronizeMotionDurations.CopyFrom(durations); var synchronizeMotionThresholds = dstManager.AddBuffer <SampleClipBlendThreshold>(entity); synchronizeMotionThresholds.CopyFrom(thresholds); dstManager.AddComponentData(entity, new WeightComponent { Value = 0.0f }); denseClips.Dispose(); durations.Dispose(); thresholds.Dispose(); }
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); }
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); }
private void ReadContentProtectionConfigs(ref ClipConfiguration configuration) { configuration.DrmInitDatas = formatContext.DRMInitData; }