Skip to content

Commit

Permalink
#1 #2 tentative PausableTrailRnderer implementation and test scene th…
Browse files Browse the repository at this point in the history
…at might get thrown away
  • Loading branch information
Yisas committed Feb 10, 2017
1 parent 7056bfd commit 3a62bff
Show file tree
Hide file tree
Showing 10 changed files with 234 additions and 107 deletions.
140 changes: 140 additions & 0 deletions Assets/Prefabs/Shadow Trail Renderer.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1452260926465948}
m_IsPrefabParent: 1
--- !u!1 &1452260926465948
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4552144090377578}
- component: {fileID: 96964719732289224}
m_Layer: 0
m_Name: Shadow Trail Renderer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4552144090377578
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1452260926465948}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 323.86365, y: 0.5478251, z: 122.20422}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!96 &96964719732289224
TrailRenderer:
serializedVersion: 2
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1452260926465948}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 0
m_Materials:
- {fileID: 2100000, guid: 9070154db9d0b5d4c9f02c4b0da14cf8, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingOrder: 0
m_Time: 10000000
m_Parameters:
serializedVersion: 2
widthMultiplier: 1
widthCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
colorGradient:
key0:
serializedVersion: 2
rgba: 4294967295
key1:
serializedVersion: 2
rgba: 4294967295
key2:
serializedVersion: 2
rgba: 0
key3:
serializedVersion: 2
rgba: 0
key4:
serializedVersion: 2
rgba: 0
key5:
serializedVersion: 2
rgba: 0
key6:
serializedVersion: 2
rgba: 0
key7:
serializedVersion: 2
rgba: 0
ctime0: 0
ctime1: 65535
ctime2: 0
ctime3: 0
ctime4: 0
ctime5: 0
ctime6: 0
ctime7: 0
atime0: 0
atime1: 65535
atime2: 0
atime3: 0
atime4: 0
atime5: 0
atime6: 0
atime7: 0
m_Mode: 0
m_NumColorKeys: 2
m_NumAlphaKeys: 2
numCornerVertices: 0
numCapVertices: 0
alignment: 0
textureMode: 0
m_MinVertexDistance: 0.1
m_Autodestruct: 0
8 changes: 8 additions & 0 deletions Assets/Prefabs/Shadow Trail Renderer.prefab.meta

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

102 changes: 8 additions & 94 deletions Assets/Prefabs/Test Shadow Cube.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ GameObject:
- component: {fileID: 65735452598567560}
- component: {fileID: 23834119766803998}
- component: {fileID: 114935342693874920}
- component: {fileID: 96677447906534260}
- component: {fileID: 114480644409964434}
m_Layer: 0
m_Name: Test Shadow Cube
m_TagString: Untagged
Expand Down Expand Up @@ -94,104 +94,18 @@ BoxCollider:
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!96 &96677447906534260
TrailRenderer:
serializedVersion: 2
--- !u!114 &114480644409964434
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1614062590372156}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 0
m_Materials:
- {fileID: 2100000, guid: 9070154db9d0b5d4c9f02c4b0da14cf8, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingOrder: 0
m_Time: 10000000
m_Parameters:
serializedVersion: 2
widthMultiplier: 1
widthCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
colorGradient:
key0:
serializedVersion: 2
rgba: 4294967295
key1:
serializedVersion: 2
rgba: 4294967295
key2:
serializedVersion: 2
rgba: 0
key3:
serializedVersion: 2
rgba: 0
key4:
serializedVersion: 2
rgba: 0
key5:
serializedVersion: 2
rgba: 0
key6:
serializedVersion: 2
rgba: 0
key7:
serializedVersion: 2
rgba: 0
ctime0: 0
ctime1: 65535
ctime2: 0
ctime3: 0
ctime4: 0
ctime5: 0
ctime6: 0
ctime7: 0
atime0: 0
atime1: 65535
atime2: 0
atime3: 0
atime4: 0
atime5: 0
atime6: 0
atime7: 0
m_Mode: 0
m_NumColorKeys: 2
m_NumAlphaKeys: 2
numCornerVertices: 0
numCapVertices: 0
alignment: 0
textureMode: 0
m_MinVertexDistance: 0.1
m_Autodestruct: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 783425d233a54f44ea51f570a7391c62, type: 3}
m_Name:
m_EditorClassIdentifier:
trailRendererObject: {fileID: 0}
--- !u!114 &114935342693874920
MonoBehaviour:
m_ObjectHideFlags: 1
Expand Down
3 changes: 2 additions & 1 deletion Assets/Scene/Test Scenes/Testing Custom Timereset.unity
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
shadowPrefab: {fileID: 1614062590372156, guid: fcf9134591e22d94aa1b0215e54cef7b,
type: 2}
trailRendererPrefab: {fileID: 1452260926465948, guid: 89d696b01c8236c46a0925a288b34308,
type: 2}
--- !u!4 &238929857
Transform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -833,7 +835,6 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
recordedTransform: {fileID: 2053729386}
recordedTrail: {fileID: 0}
--- !u!4 &2053729386 stripped
Transform:
m_PrefabParentObject: {fileID: 400000, guid: 5e9e851c0e142814dac026a256ba2ac0, type: 2}
Expand Down
13 changes: 12 additions & 1 deletion Assets/Scripts/Time Mechanics/Looper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class Looper : MonoBehaviour
Queue<Quaternion> recordedRotations;
Queue<float> recordedTimes;

bool temp = false;

// Use this for initialization
void Start()
{
Expand Down Expand Up @@ -46,7 +48,7 @@ private void FixedUpdate()
}
}

public void StartLooping(Queue<Vector3> recordedPositions, Queue<Quaternion> recordedRotations, Queue<float> recordedTimes, TrailRenderer trailRenderer)
public void StartLooping(Queue<Vector3> recordedPositions, Queue<Quaternion> recordedRotations, Queue<float> recordedTimes)
{
this.recordedPositions = recordedPositions;
this.recordedTimes = recordedTimes;
Expand Down Expand Up @@ -75,12 +77,21 @@ void NextFrameAction()
gameObject.transform.position = tempVector;
gameObject.transform.localRotation = tempQuartenion;
//Debug.Log(originalRecordedTimes.Count);

if (temp)
{
GetComponent<PausableTrailRendererTarget>().ToogleTrailRenderer();
temp = false;
}
}
while (loopingTimer > tempFloat && recordedPositions.Count > 0);
}

private void Reloop()
{
GetComponent<PausableTrailRendererTarget>().ToogleTrailRenderer();
temp = true;

recordedPositions = new Queue<Vector3>(originalRecordedPositions);
recordedRotations = new Queue<Quaternion>(originalRecordedRotations);
recordedTimes = new Queue<float>(originalRecordedTimes);
Expand Down
10 changes: 1 addition & 9 deletions Assets/Scripts/Time Mechanics/Recorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public class Recorder : MonoBehaviour {

// Public references
public Transform recordedTransform; // NOTE TO SELF: GET REFERENCE ON START
public TrailRenderer recordedTrail;

// Private references
private TimelineManager timelineManager;
Expand Down Expand Up @@ -60,15 +59,11 @@ private void StartRecording()
{
recordingTimer = 0;

recordedTrail.enabled = true;

recording = true;
}

private void StopRecording()
{
recordedTrail.enabled = false;

recording = false;
}

Expand All @@ -83,9 +78,6 @@ private void RecordFrame()

private void CreateShadow()
{

recordedTrail.time = 100; // FIX ME TO NOT HARDCODED
timelineManager.CreateShadow(recordedPositions, recordedRotations, recordedTimes, recordedTrail);
recordedTrail.time = 500000000000; // FIX ME TO NOT HARDCODED
timelineManager.CreateShadow(recordedPositions, recordedRotations, recordedTimes);
}
}
13 changes: 11 additions & 2 deletions Assets/Scripts/Time Mechanics/TimelineManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
public class TimelineManager : Singleton<TimelineManager> {

public GameObject shadowPrefab;
public GameObject trailRendererPrefab;

List<GameObject> loopingShadows;

Expand All @@ -18,13 +19,21 @@ void Update () {

}

public void CreateShadow(Queue<Vector3> recordedPositions, Queue<Quaternion> recordedRotations, Queue<float> recordedTimes, TrailRenderer trailRenderer)
public void CreateShadow(Queue<Vector3> recordedPositions, Queue<Quaternion> recordedRotations, Queue<float> recordedTimes)
{
// NOTE TO SELF: CAST CONCERNS?
GameObject shadow = (GameObject) Instantiate(shadowPrefab);

// Create pausable time renderer and attach to shadow
GameObject trail = (GameObject)Instantiate(trailRendererPrefab);

// TODO: some code here to assign the color of this trail

shadow.GetComponent<PausableTrailRendererTarget>().trailRendererObject = trail;
shadow.GetComponent<PausableTrailRendererTarget>().ToogleTrailRenderer();

loopingShadows.Add(shadow);

shadow.GetComponent<Looper>().StartLooping(recordedPositions, recordedRotations, recordedTimes, trailRenderer);
shadow.GetComponent<Looper>().StartLooping(recordedPositions, recordedRotations, recordedTimes);
}
}
Loading

0 comments on commit 3a62bff

Please sign in to comment.