devNotes 5-15-16 particles, instantiation, fibRider and tweening

using UnityEngine;
using System.Collections;
using ProceduralToolkit;
using System.Collections.Generic;
using System.IO;


public class Fibo_Rider : MonoBehaviour
{
    StreamWriter sWrite;

    public ArgosMeshDraft_Fibonacci AMD_Base;

    GameObject goMyPivot;
    GameObject goTweenFollower;

    Quaternion qStart;
    Quaternion qEnd;

    int m_startLoc;
    int m_toLoc;
    int m_deltLoc;
    int m_numPoints;
    float m_pathTime;

    public void initFromSpawner(int FibLoc, int delt, int numPoints, float pathTime )
    {
        //sWrite = new StreamWriter("Fibo_Rider4.csv");
        m_startLoc = FibLoc;
        m_deltLoc = delt;
        m_toLoc = FibLoc + delt;
        m_pathTime = pathTime;
        m_numPoints = numPoints;

        GameObject gFibSphere = GameObject.Find("Fibonacci_Sphere");
        ArgosFibonacci aF = gFibSphere.GetComponent<ArgosFibonacci>();
        AMD_Base = aF.aMF_Base;

        Quaternion q0, q1;

        q0 = Quaternion.LookRotation(AMD_Base.funcVerts[m_startLoc].vPos.normalized);
        q1 = Quaternion.LookRotation(AMD_Base.funcVerts[m_toLoc].vPos.normalized);
        transform.rotation = q0;
        transform.position = AMD_Base.funcVerts[FibLoc].vPos;

        goTweenFollower = transform.Find("TweenFollower").gameObject;

        goMyPivot = new GameObject();
        goMyPivot.transform.position = new Vector3(0, 0, 0);
        goMyPivot.transform.rotation = Quaternion.identity;

        transform.SetParent(goMyPivot.transform);
        goTweenFollower.transform.SetParent(transform);//this
        goTweenFollower.transform.position = Vector3.zero;

        qEnd = q1 * Quaternion.Inverse(q0);
        qStart = Quaternion.identity;

        //iTween.MoveTo(goTweenFollower, iTween.Hash("x", 1, "time", m_pathTime, "easetype", "easeInOutBack", "onstart", "fibTweenStarted", "onstartparams", "FIB Rider Started...", "onupdate", "fibTweenUpdate", "onupdateparams", FibLoc.ToString(), "oncomplete", "fibTweenComplete", "oncompleteparams", "fib Tween DONE", "onCompleteTarget", gameObject, "onStartTarget", gameObject, "onUpdateTarget", gameObject));

        m_numPoints--;
    }

    public void initFromEventSytem(int FibLoc, int delt, ArgosMeshDraft_Fibonacci amd_F, float pathTime)
    {
        //sWrite = new StreamWriter("Fibo_Rider4.csv");
        m_startLoc = FibLoc;
        m_deltLoc = delt;
        m_toLoc = FibLoc + delt;
        m_pathTime = pathTime;
        AMD_Base = amd_F;

        Quaternion q0, q1;

        q0 = Quaternion.LookRotation(AMD_Base.funcVerts[m_startLoc].vPos.normalized);
        q1 = Quaternion.LookRotation(AMD_Base.funcVerts[m_toLoc].vPos.normalized);
        transform.rotation = q0;
        transform.position = AMD_Base.funcVerts[FibLoc].vPos;

        goTweenFollower = transform.Find("TweenFollower").gameObject;

        goMyPivot = new GameObject();
        goMyPivot.transform.position = new Vector3(0, 0, 0);
        goMyPivot.transform.rotation = Quaternion.identity;

        transform.SetParent(goMyPivot.transform);
        goTweenFollower.transform.SetParent(transform);//this
        goTweenFollower.transform.position = Vector3.zero;

        qEnd = q1 * Quaternion.Inverse(q0);
        qStart = Quaternion.identity;
    }

    public void onEventTween()
    {
        iTween.MoveTo(goTweenFollower, iTween.Hash("x", 1, "time", m_pathTime, "easetype", "easeOutCubic", "onstart", "SODTweenStarted", "onupdate", "SODTweenUpdate", "oncomplete", "SODTweenComplete", "onCompleteTarget", gameObject, "onStartTarget", gameObject, "onUpdateTarget", gameObject));
    }

    void SODTweenStarted()
    {

    }

    void SODTweenUpdate()
    {
 
        float sTime = goTweenFollower.transform.position.x;
        goMyPivot.transform.rotation = Quaternion.LerpUnclamped(qStart, qEnd, sTime);

        float envSc = 4.0f - sTime * 1.8f;

        transform.localScale = new Vector3(envSc, envSc, envSc);

    }

    void SODTweenComplete()
    {
        Quaternion q0, q1;

        goMyPivot.transform.rotation = Quaternion.LerpUnclamped(qStart, qEnd, 1.0f);

        q0 = Quaternion.LookRotation(AMD_Base.funcVerts[m_toLoc].vPos.normalized);
        m_toLoc += m_deltLoc;

        if (m_toLoc > 2000) m_toLoc = m_startLoc;
        q1 = Quaternion.LookRotation(AMD_Base.funcVerts[m_toLoc].vPos.normalized);

        qEnd = q1 * Quaternion.Inverse(q0) * goMyPivot.transform.rotation;
        qStart = goMyPivot.transform.rotation;

        goTweenFollower.transform.position = Vector3.zero;
        
    }


    int CBcount = 0;
    //float fAccumTime = 0.0f;
    void fibTweenUpdate(string textToDisplay)
    {
        //print("fibTweenUpdate " + textToDisplay + " call count = " + CBcount.ToString() + " pos = " + goTweenFollower.transform.position.x.ToString("F3") + " deltaTime = " + Time.deltaTime.ToString("F3"));

        float sTime = goTweenFollower.transform.position.x;
        goMyPivot.transform.rotation = Quaternion.LerpUnclamped(qStart, qEnd, sTime);



        CBcount++;
    }

    void fibTweenComplete(string textToDisplay)
    {
        Quaternion q0, q1;

        goMyPivot.transform.rotation = Quaternion.LerpUnclamped(qStart, qEnd, 1.0f);

        if (--m_numPoints > 0)
        {
            q0 = Quaternion.LookRotation(AMD_Base.funcVerts[m_toLoc].vPos.normalized); 
            m_toLoc += m_deltLoc;
            q1 = Quaternion.LookRotation(AMD_Base.funcVerts[m_toLoc].vPos.normalized);

            qEnd = q1 * Quaternion.Inverse(q0) * goMyPivot.transform.rotation;
            qStart = goMyPivot.transform.rotation;

            goTweenFollower.transform.position = Vector3.zero;

            iTween.MoveTo(goTweenFollower, iTween.Hash("x", 1, "time", m_pathTime, "easetype", "easeOutCubic", "onstart", "fibTweenStarted", "onstartparams", "FIB Rider Started...", "onupdate", "fibTweenUpdate", "onupdateparams", m_toLoc.ToString(), "oncomplete", "fibTweenComplete", "oncompleteparams", "fib Tween DONE", "onCompleteTarget", gameObject, "onStartTarget", gameObject, "onUpdateTarget", gameObject));
        }
    }

	void Update ()
    {
	
	}
}

//public enum EaseType
//{
//    easeInQuad,
//    easeOutQuad,
//    easeInOutQuad,
//    easeInCubic,
//    easeOutCubic,
//    easeInOutCubic,
//    easeInQuart,
//    easeOutQuart,
//    easeInOutQuart,
//    easeInQuint,
//    easeOutQuint,
//    easeInOutQuint,
//    easeInSine,
//    easeOutSine,
//    easeInOutSine,
//    easeInExpo,
//    easeOutExpo,
//    easeInOutExpo,
//    easeInCirc,
//    easeOutCirc,
//    easeInOutCirc,
//    linear,
//    spring,
//    /* GFX47 MOD START */
//    //bounce,
//    easeInBounce,
//    easeOutBounce,
//    easeInOutBounce,
//    /* GFX47 MOD END */
//    easeInBack,
//    easeOutBack,
//    easeInOutBack,
//    /* GFX47 MOD START */
//    //elastic,
//    easeInElastic,
//    easeOutElastic,
//    easeInOutElastic,
//    /* GFX47 MOD END */
//    punch
//}

http://argos.vu/wp-content/uploads/2016/05/Deadmau5_Strobe.mp3

 

 

TILE

BrickRound0103_1_S