Skip to content

Commit

Permalink
Added support for Timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonm-unity committed Mar 13, 2017
1 parent afe2674 commit 1587c56
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ internal static GameObject Import(AlembicImportMode importMode, AlembicImportSet
dynStream.m_PlaybackSettings = new AlembicPlaybackSettings()
{
m_startTime = abcStream.AbcStartTime,
m_endTime = abcStream.AbcEndTime
m_endTime = abcStream.AbcEndTime,
m_duration = abcStream.AbcEndTime
};
dynStream.m_StreamDescriptor = streamDescr;
dynStream.enabled = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public class AlembicImportSettings

}


[System.Serializable]
public class AlembicPlaybackSettings
{
Expand All @@ -50,6 +49,8 @@ public enum CycleType
Reverse,
Bounce
};

[HideInInspector][SerializeField] public float m_duration = 0.0f;

[Tooltip("Specifies the lower time bound to use in the stream")]
[SerializeField] public float m_startTime = 0.0f;
Expand All @@ -69,6 +70,8 @@ public enum CycleType
[Tooltip("Controls how playback cycles throught the stream.")]
[SerializeField] public CycleType m_cycle = CycleType.Hold;

[SerializeField] public float m_Time = 0f;
[SerializeField] public bool m_OverrideTime = false;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,13 @@ protected override void Dispose(bool disposing)

public void ProcessUpdateEvent()
{
if (Application.isPlaying)
if (Application.isPlaying && !m_playbackSettings.m_OverrideTime)
{
AbcUpdateBegin(Time.time);
}
else
{
AbcUpdateBegin(m_time);
AbcUpdateBegin(m_playbackSettings.m_Time);
}
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#if ENABLE_TIMELINE

using System;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;

namespace UTJ.Alembic
{
public class AlembicShotAsset : PlayableAsset, ITimelineClipAsset
{
AlembicStreamPlayer m_Stream;

[Tooltip("Alambic asset to play")]
public ExposedReference<AlembicStreamPlayer> m_StreamPlayer;

[Tooltip("Amount of time to clip off the start of the alembic asset from playback.")]
[SerializeField] public float m_StartOffset;

[Tooltip("Amount of time to clip off the end of the alembic asset from playback.")]
[SerializeField] public float m_EndOffset;

[Tooltip("Use to compress/dilute time play back.")]
[SerializeField] public float m_TimeScale = 1f;

[Tooltip("Controls how playback cycles throught the stream.")]
[SerializeField] public AlembicPlaybackSettings.CycleType m_Cycle = AlembicPlaybackSettings.CycleType.Hold;

[Tooltip("Portion, in seconds, of the alembic stream used by the shot.")]
[ReadOnly] public float m_AlembicLength = 0;

public ClipCaps clipCaps { get { return ClipCaps.None; } }

public override PlayableHandle CreatePlayable(PlayableGraph graph, GameObject owner)
{
var handle = graph.CreateScriptPlayable<AlembicShotPlayable>();

var playable = handle.GetObject<AlembicShotPlayable>();
m_Stream = m_StreamPlayer.Resolve(graph.resolver);
playable.streamPlayer = m_Stream;
playable.m_StartTimeOffset = m_StartOffset;
playable.m_EndTimeClipOff = m_EndOffset;
playable.m_TimeScale = m_TimeScale;
playable.m_Cycle = m_Cycle;
return handle;
}

public override double duration
{
get
{
var t = m_Stream == null ? 0 : m_Stream.m_PlaybackSettings.m_duration;
m_AlembicLength = t;
if (m_Cycle == AlembicPlaybackSettings.CycleType.Hold || m_Cycle == AlembicPlaybackSettings.CycleType.Reverse)
return (t - m_StartOffset - m_EndOffset) * m_TimeScale;
else
{
return base.duration;
}
}
}

}
}

#endif

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#if ENABLE_TIMELINE
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;

namespace UTJ.Alembic
{
[System.Serializable]
[TrackClipType(typeof(AlembicShotAsset))]
[TrackMediaType(TimelineAsset.MediaType.Script)]
[TrackColor(0.53f, 0.0f, 0.08f)]
public class AlembicTrack : TrackAsset
{
}
}

#endif

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1587c56

Please sign in to comment.