devNotes 5-14-16 navigation, particles and time tweens

WaveForm Data

using UnityEngine;
using System.Collections;

public class drawWav : MonoBehaviour
{

	int resolution = 60;

	float[] waveForm;
	float[] samples;
	public AudioSource AS;

	// Use this for initialization
	void Start()
	{

		resolution = AS.clip.frequency / resolution;
		
		samples = new float[AS.clip.samples * AS.clip.channels];
		Debug.Log("samples:" + AS.clip.samples + " channels:" + AS.clip.channels + " resolution:"+resolution);
		//huh?  2 channels?  LEFT/RIGHT?		

		//not a get spectrum!  (more core?)
		AS.clip.GetData(samples, 0);

		waveForm = new float[(samples.Length / resolution)];

		for (int i = 0; i < waveForm.Length; i++)
		{
			waveForm[i] = 0;

			for (int ii = 0; ii < resolution; ii++)
			{
				waveForm[i] += Mathf.Abs(samples[(i * resolution) + ii]);
			}

			waveForm[i] /= resolution;
		}

		
	}

	// Update is called once per frame
	void Update()
	{

		//waveForm is same length each update..
		for (int i = 0; i < waveForm.Length - 1; i++)
		{
			Vector3 sv = new Vector3(i * .01f, waveForm[i] * 10, 0);		//sb exactly the same.
			Vector3 ev = new Vector3(i * .01f, -waveForm[i] * 10, 0);		//sb exactly the same.

			//draws the line.
			Debug.DrawLine(sv, ev, Color.yellow);
		}

		//CURRENT position 
		int current = AS.timeSamples / resolution;
		current *= 2;

		Vector3 c = new Vector3(current * .01f, 0, 0);

		//scrubber up line.
		Debug.DrawLine(c, c + Vector3.up * 10, Color.white);
	}
}

Koreographer Event Subscriber

public class KAS_Event_Subscriber : MonoBehaviour
{

    public GameObject[] particlePrefab;
    GameObject effectPrefab;

    //effectPrefab = (GameObject)Instantiate(particlePrefab[particleNum],
    //            new Vector3(hit.point.x, hit.point.y + 0.2f, hit.point.z), Quaternion.Euler(0, 0, 0));


    void Start()
    {
        Koreographer.Instance.RegisterForEvents("VW_Track_Kick", FireEventDebugLog);
    }


    void Update ()
    {
	
	}

    void FireEventDebugLog(KoreographyEvent koreoEvent)
    {
        Debug.Log("KoreographyEventFired");
        effectPrefab = (GameObject)Instantiate(particlePrefab[0],
                new Vector3(0, 0, 0), Quaternion.Euler(0, 0, 0));
    }
}

Transform Quaternion Lock:

    public void onNavSphereLockUnlockButton()
    {
        _isLocked_NavSpheretoCam = !_isLocked_NavSpheretoCam;
        SpriteState st = new SpriteState();

        if (_isLocked_NavSpheretoCam)
        {
            lock_Unlock_Button.image.sprite = locked_sprite;
            st.pressedSprite = unlocked_sprite;            
       
            Quaternion q0 = Argos_Camera.transform.rotation;
            Quaternion q1 = NavSphere_Pivot.transform.rotation;

            Argos_NavSphere.transform.rotation = q1 * Quaternion.Inverse(q0)* Argos_NavSphere.transform.rotation;

            NavSphere_Pivot.transform.rotation = q0;
        }
        else
        {
            lock_Unlock_Button.image.sprite = unlocked_sprite;
            st.pressedSprite = locked_sprite;
        }
        lock_Unlock_Button.spriteState = st;
    }

quaternion snap shot

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class UI_Control : MonoBehaviour
{

    public Canvas UI_Canvas;
    public Sprite locked_sprite;
    public Sprite unlocked_sprite;
    public Button lock_Unlock_Button;

    public Sprite rotate_off_sprite;
    public Sprite rotate_on_sprite;
    public Button rotate_Button;

    public Sprite rotate_OnNavSphere_off_sprite;
    public Sprite rotate_OnNavSphere_on_sprite;
    public Button rotate_OnNavSphere_Button;

    bool isOn = false;
    bool _isLocked_NavSpheretoCam = false;
    bool rotateOn = false;
    bool rotateOnNavSphere = false;

    GameObject Argos_Camera;
    GameObject NavSphere_Pivot;
    GameObject Argos_NavSphere;

    void Start ()
    {
        Argos_Camera    = GameObject.Find("Argos_Camera");
        NavSphere_Pivot = GameObject.Find("NavSphere_Pivot");
        Argos_NavSphere = GameObject.Find("Argos_NavSphere");
    }

    public bool isLocked_NavSpheretoCam
    {
        get { return _isLocked_NavSpheretoCam; }
    }

    public void onRotateButton()
    {
        rotateOn = !rotateOn;
        SpriteState st = new SpriteState();

        if (rotateOn)
        {
            rotate_Button.image.sprite = rotate_on_sprite;
            st.pressedSprite = rotate_off_sprite;
        }
        else
        {
            rotate_Button.image.sprite = rotate_off_sprite;
            st.pressedSprite = rotate_on_sprite;
        }
        rotate_Button.spriteState = st;
    }

    public void onRotateOnNavSphereButton()
    {
        rotateOnNavSphere = !rotateOnNavSphere;
        SpriteState st = new SpriteState();

        if (rotateOnNavSphere)
        {
            rotate_OnNavSphere_Button.image.sprite = rotate_OnNavSphere_on_sprite;
            st.pressedSprite = rotate_OnNavSphere_off_sprite;
        }
        else
        {
            rotate_OnNavSphere_Button.image.sprite = rotate_OnNavSphere_off_sprite;
            st.pressedSprite = rotate_OnNavSphere_on_sprite;
        }
        rotate_OnNavSphere_Button.spriteState = st;
    }


    public void onNavSphereLockUnlockButton()
    {
        _isLocked_NavSpheretoCam = !_isLocked_NavSpheretoCam;
        SpriteState st = new SpriteState();

        if (_isLocked_NavSpheretoCam)
        {
            lock_Unlock_Button.image.sprite = locked_sprite;
            st.pressedSprite = unlocked_sprite;
        }
        else
        {
            //Quaternion q = Argos_NavSphere.transform.rotation;
            //NavSphere_Pivot.transform.rotation = Argos_Camera.transform.rotation;
            //Argos_NavSphere.transform.rotation = q;

            lock_Unlock_Button.image.sprite = unlocked_sprite;
            st.pressedSprite = locked_sprite;
        }
        lock_Unlock_Button.spriteState = st;
    }

    public void onUIButtonDown()
    {
        isOn = !isOn;
        UI_Canvas.gameObject.SetActive(isOn);
    }

    void Update ()
    {
	
    }
}

Dagaz – “Day-gahz” – Literally: “Day” or Dawn – Esoteric: Awakening

dagaz-100x100

Rune of the hyper-consciousness. The process of concept becoming realized.

Rotation

 Sprite newSprite = Resources.Load<Sprite>("sprites/somesprite");
 SpriteState st = new SpriteState();
 st.disabledSprite = newSprite;
 st.highlightedSprite = newSprite;
 st.pressedSprite = newSprite;
 _button.spriteState = st;

fghjghfhff5

concert_hall_pressurewaves