refine GiantSnowflake with logic play dshowplayer

master
hoba 8 years ago
parent b2d1476690
commit 6a094f1034
  1. 7
      Unity_2018_Frozen/Assets/Frozen/Frozen.unity
  2. 4
      Unity_2018_Frozen/Assets/Frozen/Material/GiantSnowflake.mat
  3. 75
      Unity_2018_Frozen/Assets/Frozen/Script/GiantSnowflake.cs
  4. 11
      Unity_2018_Frozen/Assets/KinectOpticalFlow/KinectOpticalFlowMath.cs

@ -809,6 +809,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9126593cba11d9145b83a6ab86efc050, type: 3}
m_Name:
m_EditorClassIdentifier:
kinect: {fileID: 712882417}
triggerRadius: 1
cooldown: 5
breakProgress: 0.1
--- !u!114 &368474582
MonoBehaviour:
m_ObjectHideFlags: 0
@ -820,7 +824,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 03dae28dfe6734f4eb76c922ac72dd34, type: 3}
m_Name:
m_EditorClassIdentifier:
target: 1
target: 2
materials:
- {fileID: 2100000, guid: 3059bdeaeda202b489a491a3025d4843, type: 2}
attributeName: _MainTex
@ -1705,7 +1709,6 @@ MonoBehaviour:
kinect: {fileID: 1848145251}
fps: 15
averagePositinon: {x: 0, y: 0, z: 0}
triggerRadius: 1.5
standardDeviation: -1
debug:
--- !u!43 &725363233

@ -39,7 +39,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 86f3cfc9597a8cb439f8b1a059e766c5, type: 3}
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
@ -72,5 +72,5 @@ Material:
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 0.99999887}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

@ -10,9 +10,23 @@ namespace UltraCombos.Frozen
float alpha = 0.0f;
float smooth = 0.025f;
DShowMoviePlayer player;
[SerializeField]
KinectOpticalFlowMath kinect;
[SerializeField]
float triggerRadius = 1.5f;
[SerializeField]
float cooldown = 2.0f;
private void Start()
{
material = GetComponent<MeshRenderer>().material;
material = GetComponent<MeshRenderer>().sharedMaterial;
player = GetComponent<DShowMoviePlayer>();
StartCoroutine(Flow());
}
private void FixedUpdate()
@ -27,6 +41,65 @@ namespace UltraCombos.Frozen
}
material.color = new Color(1.0f, 1.0f, 1.0f, alpha);
}
private void OnDrawGizmosSelected()
{
var pos = kinect.averagePositinon;
Gizmos.DrawWireSphere(pos, 0.5f);
if (new Vector2(pos.x - transform.position.x, pos.z - transform.position.z).magnitude < triggerRadius)
{
Gizmos.color = Color.red;
}
Gizmos.DrawWireSphere(transform.position, triggerRadius);
Gizmos.color = Color.white;
}
[SerializeField, Range(0, 1)]
float breakProgress = 0.1f;
IEnumerator Flow()
{
float video_stamp = 0.0f;
float progress = 0.0f;
while (true)
{
video_stamp = Time.time;
progress = 0.0f;
player.Pause();
player.Frame = 0;
Debug.Log("Begin");
while (progress < breakProgress)
{
var pos = kinect.averagePositinon;
float dist = new Vector2(pos.x - transform.position.x, pos.z - transform.position.z).magnitude;
if (dist < triggerRadius)
{
//Debug.Log("OK");
progress += 0.001f;
}
else
{
progress = Mathf.Max(progress - 0.001f, 0.0f);
}
player.Frame = (uint)(player.TotalNumFrames * progress);
yield return null;
}
Debug.Log("Play the rest");
player.Play();
while (player.IsFinished == false)
{
yield return null;
}
yield return new WaitForSeconds(cooldown);
Debug.Log("Flow done");
}
}
}

@ -18,7 +18,6 @@ namespace UltraCombos
Vector4[] samples = new Vector4[512 * 424];
public Vector3 averagePositinon = Vector3.zero;
public float triggerRadius = 1.5f;
public float standardDeviation = -1.0f;
[SerializeField]
@ -68,17 +67,7 @@ namespace UltraCombos
}
}
private void OnDrawGizmosSelected()
{
Gizmos.DrawWireSphere(averagePositinon, 0.5f);
if (new Vector2(averagePositinon.x - transform.position.x, averagePositinon.z - transform.position.z).magnitude < triggerRadius)
{
Gizmos.color = Color.red;
}
Gizmos.DrawWireSphere(transform.position, triggerRadius);
Gizmos.color = Color.white;
}
}
}

Loading…
Cancel
Save