Jim’esque Simulation Details

 

 

Field Dynamics

Initial Birkeland Current Implementation 2017

Argos GPU VR Field Explorer – Interactive

 

Dynamic Symmetry

Planet Orbit Solver – Runge-Kutta

using UnityEngine;
using System.Collections;

public class PlanetaryOrbit : MonoBehaviour
{
	public float[] Par { get; set; } 		//eccentricity , r_pericenter,  orbital period,  radius, axial tilt, rot pediod longtitude of ascending node

	private float[] CosSinOmega = new float[2];

	public float OP { get; private set; }		//orbital period
	public float RP { get; private set; }		// rotation period

	public float GetVelMagnitude ()
	{
		return ParametricVelocity ().magnitude * Scales.velmu2kms;
	}

	private const int N = 300;
	private float[] angleArray = new float[N];
	private float surface;
	private float k;
	private float orbitDt;
    private HMD_Ctrl_Tracking hmd_Ctrl_Tracking;
    public GameObject myNavSphere;
    public int myIdx = 0;
    public string planet_Name;

    public bool bThis_is_The_Sun = false;

	public float Theta
    {
		get { return Theta_Time(time); }
	}

	public float time;

    Solar_System_Base solar_System_Base;

	void Start ()
	{
        solar_System_Base = Solar_System_Base.instance;
        hmd_Ctrl_Tracking = HMD_Ctrl_Tracking.Instance;
    }

    public void Set_MyNav_Sphere(GameObject navSphere)
    {
        myNavSphere = navSphere;
    }

    public void Init(int idx)
    {
        if (!bThis_is_The_Sun)
        {
            myIdx = idx;

            OP = Par[2] * Scales.y2tmu;
            RP = Par[5] * Scales.y2tmu;

            //float rSemiMajor = transform.localPosition.x;

            //Par[1] = rSemiMajor - Par[0] * rSemiMajor;

            surface = Mathf.Sqrt(-(1 + Par[0]) / Mathf.Pow(-1 + Par[0], 3)) * Mathf.PI * Par[1] * Par[1];
            k = 2 * surface / (Mathf.Pow(1 + Par[0], 2) * OP * Par[1] * Par[1]);
            orbitDt = OP / (2 * (N - 1));

            ThetaRunge();
            time = 0;// Random.Range(0, OP);

            CosSinOmega[0] = Mathf.Cos(Par[6]);
            CosSinOmega[1] = Mathf.Sin(Par[6]);

            GetComponent<PlanetRotation>().Init(this);
            GetComponentInParent<Plane_of_Inclination>().Set_Plane_of_Inclination(Par[7], Par[6]);
        }
    }

    public void Reset_Time()
    {
        if (!bThis_is_The_Sun)
        {
            time = 0;
            transform.localPosition = ParametricOrbit(Theta_Time(time)) * solar_System_Base.scale_Solar_System_0_to_5;
            myNavSphere.transform.position = transform.position;
        }
    }

    void FixedUpdate ()
	{
        if (!bThis_is_The_Sun)
        {
            if (solar_System_Base.bRunning)
            {
                time += Time.deltaTime * solar_System_Base.years_Per_Second_SS;
                transform.localPosition = ParametricOrbit(Theta_Time(time)) * solar_System_Base.scale_Solar_System_0_to_5;
                myNavSphere.transform.position = transform.position;
            }
        }
	}

    public Vector3 Planetary_Parametric(float arg)
    {
        return ParametricOrbit(Theta_Time(arg));
    }

    public void Update_Planet_Position()
    {
        solar_System_Base = Solar_System_Base.instance;
        if (!bThis_is_The_Sun)
        {
            transform.localPosition = ParametricOrbit(Theta_Time(time)) * solar_System_Base.scale_Solar_System_0_to_5;
            myNavSphere.transform.position = transform.position;
        }
    }

	public Vector3 GetPositionAfterTime (float t)
	{
		return ParametricOrbit (Theta_Time(time + t));
	}

	public Vector3 ParametricOrbit (float th)
	{
		float Cost = Mathf.Cos (th);
		float Sint = Mathf.Sin (th);

		float x = (Par [1] * (1 + Par [0])) / (1 + Par [0] * Cost) * Cost;
		float z = (Par [1] * (1 + Par [0])) / (1 + Par [0] * Cost) * Sint;

		float xp = CosSinOmega [0] * x - CosSinOmega [1] * z;
		float yp = CosSinOmega [1] * x + CosSinOmega [0] * z;

		return new Vector3 (xp, 0f, yp);
	}

	private float dthdt (float th)
	{
		return k * Mathf.Pow ((1 + Par [0] * Mathf.Cos (th)), 2);
	}

	private void ThetaRecurrence ()
	{
		angleArray [0] = 0;  //Initial conditionL theta(0) = 0

		for (int i = 0; i < N - 2; i++)
			angleArray [i + 1] = orbitDt * dthdt (angleArray [i]) + angleArray [i];

		angleArray [N - 1] = Mathf.PI;
	}

	private void ThetaRunge ()
	{
		float w = 0, k1, k2, k3, k4;
		for (int i = 0; i < N - 2; i++)
        {
			k1 = orbitDt * dthdt (w);
			k2 = orbitDt * dthdt (w + k1 / 2);
			k3 = orbitDt * dthdt (w + k2 / 2);
			k4 = orbitDt * dthdt (w + k3);
			w = w + (k1 + 2 * k2 + 2 * k3 + k4) / 6;
			angleArray [i + 1] = w;
		}
		angleArray [N - 1] = Mathf.PI;
	}

	public float Theta_Time (float t)
	{
		float theta0 = 0;
		t = t % OP;//Orbital Period

		if (t <= OP / 2)
        {
			float d = t / orbitDt;
			float d0 = Mathf.Clamp (Mathf.Floor (d), 0, N - 1);
			float d1 = Mathf.Clamp (Mathf.Ceil (d), 0, N - 1);

			if (d0 == d1)
				theta0 = angleArray [(int)d0];
			else
            {
				theta0 = (angleArray [(int)d0] - angleArray [(int)d1]) / (d0 - d1) * d + (d0 * angleArray [(int)d1] - angleArray [(int)d0] * d1) / (d0 - d1);
			}
			return theta0;
		}
        else
        {
			t = -t + OP;
			float d = t / orbitDt;
			float d0 = Mathf.Clamp (Mathf.Floor (d), 0, N - 1);
			float d1 = Mathf.Clamp (Mathf.Ceil (d), 0, N - 1);

			if (d0 == d1)
				theta0 = -angleArray [(int)d0] + 2 * Mathf.PI;
			else
            {
				theta0 = -((angleArray [(int)d0] - angleArray [(int)d1]) / (d0 - d1) * d + (d0 * angleArray [(int)d1] - angleArray [(int)d0] * d1) / (d0 - d1)) + 2 * Mathf.PI;
			}
			return theta0;
		}
	}

	public Vector3 ParametricVelocity ()
	{
		float myfixedDt = 2 * orbitDt;
		Vector3 pos2 = ParametricOrbit (Theta_Time(time + myfixedDt));
		Vector3 pos1 = ParametricOrbit (Theta_Time(time - myfixedDt));

		return new Vector3 ((pos2.x - pos1.x) / (2 * myfixedDt), 0.0f, (pos2.z - pos1.z) / (2 * myfixedDt));
	}
}

Helical Path Calculation

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

public class Helical_Plot : MonoBehaviour
{
    //[SerializeField]
    // Material _material;
    public enum PLANET
    {
        hp_Mercury,
        hp_Venus,
        hp_Earth,
        hp_Mars,
        hp_Jupiter,
        hp_Saturn,
        hp_Uranus,
        hp_Neptune,
        hp_Pluto,
    }

    public int[] hp_AUX_cnt = new int[] { 700, 500, 500, 400, 88, 70, 5, 3, 2,1};

    Mesh myMesh;

    public float tweek_Rota = 0.0f;

    //MaterialPropertyBlock _block;

    private Solar_System_Base solar_System_Base;
    private ArgosMeshDraft amd;
    private ArgosMeshDraft amd_Aux;
    public GameObject myPlane;
    private PlanetaryOrbit myOrbit;
    public float width = 1f;
    private Color orbitColor;

    public int myIdx = 0;

    public GameObject aux_Helical_PREFAB;
    private GameObject[] aux_Helical_Extensions;
    private Extension_AMD_Handler ext_AMD_Handler;

    void Start()
    {
        amd = new ArgosMeshDraft();
        amd_Aux = new ArgosMeshDraft();
        myOrbit = myPlane.GetComponentInChildren<PlanetaryOrbit>();
        solar_System_Base = Solar_System_Base.instance;
        orbitColor = myPlane.GetComponent<Orbit_VU>().orbitColor;
        setColor(orbitColor);

        GetComponent<Plane_of_Inclination>().Set_Plane_of_Inclination(myOrbit.Par[7], myOrbit.Par[6]);
        myMesh = GetComponent<MeshFilter>().mesh;
    }

    public void Set_My_Idx_Add_Extensions(int idx)
    {
        myIdx = idx;

        if (aux_Helical_Extensions == null)
        {
            aux_Helical_Extensions = new GameObject[hp_AUX_cnt[myIdx]];
            for (int i = 0; i < hp_AUX_cnt[myIdx]; i++)
            {
                aux_Helical_Extensions[i] = Instantiate(aux_Helical_PREFAB, transform);
                ext_AMD_Handler = aux_Helical_Extensions[i].GetComponent<Extension_AMD_Handler>();
                ext_AMD_Handler.Init_Aux();
                ext_AMD_Handler.Set_Color(orbitColor);
                aux_Helical_Extensions[i].GetComponent<MeshRenderer>().enabled = false;
            }
        }
    }

    public void Generate_Helix(int divisions, float time_Frame, float linear_velocity, float helical_Period, float helix_Radius, float line_width, bool bPluto_Exclusive)
    {
        if (amd != null)
        {
            amd.Clear();
        }

        if (amd_Aux != null)
        {
            amd_Aux.Clear();
        }

        //if(myIdx == 8)//Pluto - better angular resolution
        //{
        //    divisions *= 3;
        //}

        if (!bPluto_Exclusive)
        {
            GetComponent<MeshRenderer>().enabled = true;
            MeshRenderer[] mr = GetComponentsInChildren<MeshRenderer>();
            foreach (MeshRenderer MR in mr)
            {
                MR.enabled = true;
            }
        }
        else
        {
            if (myIdx != 8) return;
        }
        Vector3 vUP_trans = transform.InverseTransformDirection(Vector3.up);
        Vector3 vHelix_Origin_Trans = transform.InverseTransformDirection(Vector3.right) * helix_Radius;

        List<Vector3> vInner = new List<Vector3>();
        List<Vector3> vOuter = new List<Vector3>();

        List<Vector3> vInner_Aux = new List<Vector3>();
        List<Vector3> vOuter_Aux = new List<Vector3>();

        float cycles = time_Frame / myOrbit.OP;
        float quadDivs = divisions * cycles;//180 * cycles;

        int totalQuads = (int)quadDivs;
        float totDistance = time_Frame * linear_velocity;
        float deltaDIST = totDistance / totalQuads;
        float accDIST = 0;

        int useQuads = totalQuads;

        bool bFlipper = false;

        int ext_COUNT = 0;

        if (totalQuads > 70 * divisions)
        {
            useQuads = 70 * divisions;

            ext_COUNT = (int)Mathf.Floor(((float)totalQuads / (float)useQuads))-1;

            if (ext_COUNT > hp_AUX_cnt[myIdx]) ext_COUNT = hp_AUX_cnt[myIdx];

            if(myIdx == 0)
            {
                ARGOS_TRACE.Instance.Mark("MERCURY ext_Count = " + ext_COUNT.ToString());
                print("MERCURY ext_Count = " + ext_COUNT.ToString());
            }

            for (int i = 0; i < ext_COUNT; i++)
            {
                aux_Helical_Extensions[i].GetComponent<MeshRenderer>().enabled = true;
                aux_Helical_Extensions[i].GetComponent<Extension_AMD_Handler>().Set_Color(orbitColor);
            }
            for(int j = ext_COUNT; j<hp_AUX_cnt[myIdx]; j++)
            {
                aux_Helical_Extensions[j].GetComponent<MeshRenderer>().enabled = false;
            }
        }
        else
        {
            for (int i = 0; i < hp_AUX_cnt[myIdx]; i++)
            {
                aux_Helical_Extensions[i].GetComponent<MeshRenderer>().enabled = false;
            }
        }

        float delt_OP_ANGLE = 360 / divisions;
        float acc_OP_ANGLE = 0;
        float delt_Time_OP = myOrbit.OP / divisions;
        float acc_Time_OP = 0;

        float hp = helical_Period;
        float delt_HP_ANGLE = delt_OP_ANGLE * myOrbit.OP / helical_Period;
        float acc_HP_ANGLE = 0;

        float delta_Theta_Helical = delt_HP_ANGLE * (useQuads-1);
        float delta_Dist_Helical = deltaDIST * (useQuads-1);

        Vector3 vNorm;
        float w_by_2 = line_width / 2;
        Vector3 vPathWay;
        Vector3 vAxis = Vector3.zero;

        //print("Total Slices" + totalSlices.ToString("F2"));

        float deg_to_rad = Mathf.PI / 180;
        int total_AUX_Quads = 0;

        Vector3 vRight_H_Start;
        Vector3 vRight_H_Trans_Start;
        Vector3 vOrbit_Center_Start;
        float vAccDist_Start = 0;
        float acc_HP_Ang_Start = 0;

        Vector3 vRight_H_End;
        Vector3 vRight_H_Trans_End;
        Vector3 vOrbit_Center_End;
        float vAccDist_End = 0;
        float acc_HP_Ang_End = 0;

        for (int i = 0; i < useQuads; i++)
        {
            Vector3 vRight_H = new Vector3(Mathf.Cos(acc_HP_ANGLE * deg_to_rad), 0, Mathf.Sin(acc_HP_ANGLE * deg_to_rad));
            Vector3 vRight_H_Trans = transform.InverseTransformDirection(vRight_H);

            //Vector3 vForward_O = new Vector3(-Mathf.Sin(acc_OP_ANGLE * deg_to_rad), 0, Mathf.Cos(acc_OP_ANGLE * deg_to_rad));

            Vector3 vOrbit_Center = vHelix_Origin_Trans - vRight_H_Trans * helix_Radius;//CHECK THIS
            //Vector3 vOrbit        = myOrbit.ParametricOrbit(acc_OP_ANGLE * deg_to_rad) * solar_System_Base.scale_Solar_System_0_to_5;
            Vector3 vOrbit = myOrbit.ParametricOrbit(myOrbit.Theta_Time(acc_Time_OP)) * solar_System_Base.scale_Solar_System_0_to_5;

            float theta_0         = Mathf.Atan2(vOrbit.z, vOrbit.x);
            float theta_full      = theta_0 + acc_HP_ANGLE * deg_to_rad;
            float vOrbitMag       = vOrbit.magnitude;

            Vector3 vOrbitTrans = new Vector3(Mathf.Cos(theta_full), 0, Mathf.Sin(theta_full));
            Vector3 orbit_v = vOrbitMag * vOrbitTrans + vOrbit_Center;

            vPathWay = orbit_v + accDIST * vUP_trans;
            vOrbit_Center += accDIST * vUP_trans;
            vNorm = (vPathWay - vOrbit_Center).normalized;

            if(i==0)
            {
                vRight_H_Start = vRight_H;
                vRight_H_Trans_Start = vRight_H_Trans;
                vOrbit_Center_Start = vOrbit_Center;
                vAccDist_Start = accDIST;
                acc_HP_Ang_Start = acc_HP_ANGLE;
            }
            if (i == (useQuads-1))
            {
                vRight_H_End = vRight_H;
                vRight_H_Trans_End = vRight_H_Trans;
                vOrbit_Center_End = vOrbit_Center;
                vAccDist_End = accDIST;
                acc_HP_Ang_End = acc_HP_ANGLE;
            }

            vInner.Add(vPathWay - w_by_2 * vNorm);
            vOuter.Add(vPathWay + w_by_2 * vNorm);

            bFlipper = !bFlipper;
            if (bFlipper)
            {
                vInner_Aux.Add(vPathWay - w_by_2 * vNorm);
                vOuter_Aux.Add(vPathWay + w_by_2 * vNorm);
                total_AUX_Quads++;
            }

            acc_OP_ANGLE += delt_OP_ANGLE;
            acc_HP_ANGLE += delt_HP_ANGLE;

            acc_Time_OP += delt_Time_OP;

            //float delt_Time_OP = myOrbit.OP / divisions;
            //float acc_Time_OP = 0;

            accDIST += deltaDIST;
        }
        if (totalQuads > 2)
        {
            amd.Add(MeshDraft.Band_Arc(vInner, vOuter));
            GetComponent<MeshFilter>().mesh = amd.ToMeshInternal();

            if (total_AUX_Quads > 2)
            {
                amd_Aux.Add(MeshDraft.Band_Arc(vInner_Aux, vOuter_Aux));
            }
        }

        //EXTENSIONS
        Vector3 v = new Vector3(10, 0, 0);

        delta_Theta_Helical = acc_HP_Ang_End - acc_HP_Ang_Start;
        delta_Dist_Helical  = vAccDist_End - vAccDist_Start; 
        acc_HP_ANGLE        = delta_Theta_Helical;
        accDIST             = delta_Dist_Helical;

        GameObject go;
        for (int i = 0; i < ext_COUNT; i++)
        {
            Vector3 vRight_H        = new Vector3(Mathf.Cos(acc_HP_ANGLE * deg_to_rad), 0, Mathf.Sin(acc_HP_ANGLE * deg_to_rad));
            Vector3 vRight_H_Trans  = transform.InverseTransformDirection(vRight_H);
            //Vector3 v_Helix_Origin = vHelix_Origin_Trans - vRight_H_Trans * helix_Radius;

            float dTrans_Right      = Vector3.Dot(vRight_H, vRight_H_Trans);
            Vector3 vCross          = Vector3.Cross(vRight_H, vRight_H_Trans).normalized;
            Vector3 vCross_Trans    = transform.TransformDirection(vCross);

            Vector3 vOrbit_Center   = vHelix_Origin_Trans - vRight_H_Trans * helix_Radius;

            go = aux_Helical_Extensions[i];

            Quaternion q = transform.parent.localRotation;
            if (!float.IsNaN(q.x) && !float.IsNaN(q.y) && !float.IsNaN(q.z) && !float.IsNaN(q.w))
            {
                go.transform.localRotation = transform.parent.localRotation;
                go.transform.localRotation *= Quaternion.AngleAxis(dTrans_Right, vCross);
                go.transform.localRotation *= Quaternion.AngleAxis(-acc_HP_ANGLE + tweek_Rota, vUP_trans);
                
                //go.transform.localRotation *= Quaternion.AngleAxis(-acc_HP_ANGLE + tweek_Rota, vUP_trans);
                
                Vector3 vlp = vUP_trans * accDIST + vOrbit_Center;
                if (!float.IsNaN(vlp.x) && !float.IsNaN(vlp.y) && !float.IsNaN(vlp.z))
                {
                    go.transform.localPosition = vUP_trans * accDIST + vOrbit_Center;

                    ext_AMD_Handler = aux_Helical_Extensions[i].GetComponent<Extension_AMD_Handler>();

                    ext_AMD_Handler.Clear_AMD();
                    ext_AMD_Handler.Add(amd_Aux);
                    ext_AMD_Handler.To_Mesh_Internal();
                }
            }
            acc_HP_ANGLE += delta_Theta_Helical;
            accDIST += delta_Dist_Helical;
        }              
    }
        //if (bDraw_Aux)
        //{
        //    List<Vector3> vLower_Out = new List<Vector3>();
        //    List<Vector3> vUpper_Out = new List<Vector3>();
        //    //List<Vector3> vUpper_In  = new List<Vector3>();
        //    //List<Vector3> vLower_In  = new List<Vector3>();

        //    Vector3 vBottom = accDIST * Vector3.up;
        //    Vector3 vTop = vBottom + remaining_dist * Vector3.up;
        //    Vector3 vRide = vBottom;

        //    float remaining_helical_Cycles = remaining_time / helical_Period;
        //    float oc_to_hc = helical_Period / myOrbit.OP;
        //    float helical_slices = remaining_helical_Cycles * 36; // 36 cylinders around one circle of Helix
        //    float oc_per_slice = oc_to_hc / 36;

        //    float uv_Adjust;
        //    if (oc_per_slice > 256) uv_Adjust = 1;
        //    else uv_Adjust = oc_per_slice / 256;

        //    print("orbital rings per slice = " + oc_per_slice.ToString());

        //    float sliceDistance = (remaining_dist / helical_slices);
        //    float delt_AUX_HP_ANGLE = 10f;
        //    Vector3 vDeltaRide = sliceDistance * Vector3.up;

        //    print("Helical Slices = " + helical_slices.ToString());

        //    if (helical_slices > 360) helical_slices = 360;//10 cycles

        //    for (int i = 0; i < helical_slices; i++)
        //    {
        //        vLower_Out.Clear();
        //        vUpper_Out.Clear();

        //        Vector3 vRight_H0 = new Vector3(Mathf.Cos(acc_HP_ANGLE * deg_to_rad), 0, Mathf.Sin(acc_HP_ANGLE * deg_to_rad));
        //        Vector3 vRight_H1 = new Vector3(Mathf.Cos((acc_HP_ANGLE + delt_AUX_HP_ANGLE) * deg_to_rad),
        //                                          0, Mathf.Sin((acc_HP_ANGLE + delt_AUX_HP_ANGLE) * deg_to_rad));
        //        //Vector3 vForward_O = new Vector3(-Mathf.Sin(acc_OP_ANGLE * deg_to_rad), 0, Mathf.Cos(acc_OP_ANGLE * deg_to_rad));

        //        Vector3 vOrbit_Org = helical_Radius * vRight_H0;
        //        Vector3 vLowerRing_Center = vRide + vOrbit_Org;
        //        Vector3 vOrbit_Org_Next = helical_Radius * vRight_H1;
        //        Vector3 vUpperRing_Center = vRide + vDeltaRide + vOrbit_Org_Next;
        //        Vector3 vForward_O;
        //        Vector3 vPointPos_Low;
        //        Vector3 vPointPos_High;

        //        for (int k = 0; k < 36; k++)
        //        {
        //            float arg = k * 10 * deg_to_rad;
        //            vForward_O = new Vector3(-Mathf.Sin(arg), 0, Mathf.Cos(arg));
        //            vPointPos_Low = vLowerRing_Center + vForward_O * (myOrbit.transform.localPosition.x
        //                 + w_by_2);
        //            vLower_Out.Add(vPointPos_Low);
        //            vPointPos_High = vUpperRing_Center + vForward_O * (myOrbit.transform.localPosition.x + w_by_2);
        //            vUpper_Out.Add(vPointPos_High);
        //        }

        //        if (helical_slices > 0)
        //        {
        //            ext_AMD_Handler.Add(MeshDraft.Band_V_adj(vLower_Out, vUpper_Out, uv_Adjust));
        //            ext_AMD_Handler.Add(MeshDraft.Band_V_adj(vUpper_Out, vLower_Out, uv_Adjust));

        //        }

        //        //vPos = myOrbit.ParametricOrbit(myOrbit.ThetaInt(accANGLE)) * solar_System_Base.scale_Solar_System_0_to_5;

        //        vRide += vDeltaRide;
        //        acc_HP_ANGLE += delt_AUX_HP_ANGLE;
        //    }
        //    ext_AMD_Handler.To_Mesh_Internal();
        //}
    public void Hide_Helix()
    {
        GetComponent<MeshRenderer>().enabled = false;
        MeshRenderer[] mr = GetComponentsInChildren<MeshRenderer>();
        foreach (MeshRenderer MR in mr)
        {
            MR.enabled = false;
        }
    }

    public void setColor(Color c)
    {
        GetComponent<Renderer>().material.SetColor("_TintColor", c);
    }

    void Update()
    {

    }
}

 

Planet Data / Manager

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class PlanetManager : MonoBehaviour
{
	private static PlanetManager _instance;		//much better with singletons
	public static PlanetManager instance {
		get {
			if (_instance == null)		//This will only happen the first time this reference is used.
				_instance = GameObject.FindObjectOfType<PlanetManager> ();
			return _instance;
		}
	}

    public PlanetaryOrbit mercury;
    public PlanetaryOrbit venus;
    public PlanetaryOrbit earth;
    public PlanetaryOrbit mars;
    public PlanetaryOrbit jupiter;
    public PlanetaryOrbit saturn;
    public PlanetaryOrbit uranus;
    public PlanetaryOrbit neptune;
    public PlanetaryOrbit pluto;

    public Orbit_VU[] orbit_VUs;

    public GameObject[] teleporters = new GameObject[10];

    private HMD_Ctrl_Tracking hmd_Ctrl_tracking;

    private const string meshChildPrefix = "Mesh";
	private static string[] planetNames = {
		"Mercury",
		"Venus",
		"Earth",
		"Mars",
		"Jupiter",
		"Saturn",
		"Uranus",
		"Neptune",
        "Pluto"
	};
	private static string[] planetMaterials = {
		"Materials/MercuryMaterial",
		"Materials/VenusMaterial",
		"Materials/EarthMaterial", 
		"Materials/MarsMaterial",
		"Materials/JupiterMaterial",
		"Materials/SaturnMaterial",
		"Materials/UranusMaterial",
		"NeptuneMaterial"
	};
	private static string[] moonNames = { "Moon" };
	private static string[] moonParentNames = { "Earth" };
	private static string[] moonMaterials = { "Materials/MoonMaterial" };
	private GameObject rings;
	private float[][] planetParameters = new float[planetNames.Length][];
	private float[][] moonParameters = new float[moonNames.Length][];

    public enum USER_EXPLORE_ZONE
    {
        INNER,
        MID,
        OUTER,
    }

    public class Planet_EXPLORE_Params
    {
        public USER_EXPLORE_ZONE zoom_Zone;
        public float        rMin;
        public float        rMax;
        public float        rTeleEnd;
        public Vector3      vTeleRel_Pos; //Relative to Planet Transform
    }

    public Planet_EXPLORE_Params[] teleport_Params = new Planet_EXPLORE_Params[10];

	void Awake ()
	{
		_instance = this;

        float scale_VU = Scales.au_2_VU;
		//eccentricity, r_pericenter, orbital period, radius, axial tilt, rot period, longitude of ascending node, INCLINATION 
		const int numOfPlanetParams = 8;
        //Mercury
        planetParameters [0] = new float[numOfPlanetParams] {
			0.2056f,                //eccentricity
			0.3075f * scale_VU,     //r_pericenter
			0.241f,                 //orbital period
			0.38f,                  //radius
			0.01f,                  //axial tilt
			-0.16f,                 //rot period
			48.3f,                  //longitude of ascending node
			7.005f                  //INCLINATION
		};

        teleport_Params[0] = new Planet_EXPLORE_Params();
        teleport_Params[0].rMin = 0.321f;
        teleport_Params[0].rMax = 12.575f;
        teleport_Params[0].rTeleEnd = 1.661f;
        teleport_Params[0].vTeleRel_Pos = new Vector3(1.039f, -0.580f, -1.087f);
        teleport_Params[0].zoom_Zone = USER_EXPLORE_ZONE.INNER;

        //Venus
        planetParameters [1] = new float[numOfPlanetParams] {
			0.0067f,                //eccentricity
			0.718f * scale_VU,      //r_pericenter
			0.615f,                 //orbital period
			0.95f,                  //radius
			177.4f,                 //axial tilt 
			-0.67f  ,               //rot period
			76.7f,                  //longitude of ascending node
			3.3947f                 //INCLINATION
		};

        teleport_Params[1] = new Planet_EXPLORE_Params();
        teleport_Params[1].rMin = 0.611f;
        teleport_Params[1].rMax = 19.343f;
        teleport_Params[1].rTeleEnd = 1.290f;
        teleport_Params[1].vTeleRel_Pos = new Vector3(1.002f, -0.542f, -0.635f);
        teleport_Params[1].zoom_Zone = USER_EXPLORE_ZONE.INNER;

        //Earth
        planetParameters [2] = new float[numOfPlanetParams] {
			0.0167f,                //eccentricity
			0.9833f * scale_VU,     //r_pericenter
			1f,                     //orbital period
			1f,                     //radius
			23.45f,                 //axial tilt
			-0.0027f,               //rot period
			349f,                   //longitude of ascending node
			0                       //INCLINATION
		};

        teleport_Params[2] = new Planet_EXPLORE_Params();
        teleport_Params[2].rMin = 0.631f;
        teleport_Params[2].rMax = 23.326f;
        teleport_Params[2].rTeleEnd = 1.641f;
        teleport_Params[2].vTeleRel_Pos = new Vector3(0.890f, -1.281f, -0.509f);
        teleport_Params[2].zoom_Zone = USER_EXPLORE_ZONE.INNER;

        //Mars
        planetParameters [3] = new float[numOfPlanetParams] {
			0.0934f,                //eccentricity
			1.3814f * scale_VU,     //r_pericenter
			1.882f,                 //orbital period
			0.53f,                  //radius
			25.19f,                 //axial tilt
			-0.0029f,               //rot period
			49.6f,                  //longitude of ascending node
			1.851f                  //INCLINATION
		};

        teleport_Params[3] = new Planet_EXPLORE_Params();
        teleport_Params[3].rMin = 0.424f;
        teleport_Params[3].rMax = 16.071f;
        teleport_Params[3].rTeleEnd = 1.026f;
        teleport_Params[3].vTeleRel_Pos = new Vector3(0.406f, -0.858f, -0.371f);
        teleport_Params[3].zoom_Zone = USER_EXPLORE_ZONE.INNER;

        //Jupiter
        planetParameters [4] = new float[numOfPlanetParams] {
			0.0488f,                //eccentricity
			4.950f * scale_VU,      //r_pericenter
			11.86f ,                //orbital period
			11f,                    //radius
			3.13f,                  //axial tilt
			-0.0011f ,              //rot period
			101f,                   //longitude of ascending node
			1.305f                  //INCLINATION
		};
        teleport_Params[4] = new Planet_EXPLORE_Params();
        teleport_Params[4].rMin = 3.878f;
        teleport_Params[4].rMax = 43.822f;
        teleport_Params[4].rTeleEnd = 7.290f;
        teleport_Params[4].vTeleRel_Pos = new Vector3(0.708f, 2.126f, -6.915f);
        teleport_Params[4].zoom_Zone = USER_EXPLORE_ZONE.MID;

        //Saturn
        planetParameters [5] = new float[numOfPlanetParams] {
			0.0542f,                //eccentricity
			9.021f * scale_VU,      //r_pericenter
			29.457f ,               //orbital period
			9.14f,                  //radius
			26.73f,                 //axial tilt
			-0.0012f,               //rot period
			114f,                   //longitude of ascending node
			2.484f                  //INCLINATION
		};

        teleport_Params[5] = new Planet_EXPLORE_Params();
        teleport_Params[5].rMin = 3.411f;
        teleport_Params[5].rMax = 47.274f;
        teleport_Params[5].rTeleEnd = 9.222f;
        teleport_Params[5].vTeleRel_Pos = new Vector3(3.980f, 0.852f, -8.241f);
        teleport_Params[5].zoom_Zone = USER_EXPLORE_ZONE.MID;

        //Uranus
        planetParameters [6] = new float[numOfPlanetParams] {
			0.0472f,                //eccentricity
			18.286f * scale_VU,     //r_pericenter
			84.016f ,               //orbital period
			4f,                     //radius
			97.77f,                 //axial tilt
			0.0019f,                //rot period
			74.2f,                  //longitude of ascending node
			0.770f                  //INCLINATION
		};

        teleport_Params[6] = new Planet_EXPLORE_Params();
        teleport_Params[6].rMin = 0.699f;
        teleport_Params[6].rMax = 19.871f;
        teleport_Params[6].rTeleEnd = 1.203f;
        teleport_Params[6].vTeleRel_Pos = new Vector3(0.106f, -0.875f, -0.807f);
        teleport_Params[6].zoom_Zone = USER_EXPLORE_ZONE.OUTER;

        //Neptune
        planetParameters [7] = new float[numOfPlanetParams] {
			0.0086f,                //eccentricity
			29.81f * scale_VU,      //r_pericenter
			164.791f,               //orbital period
			3.9f,                   //radius
			28.32f,                 //axial tilt
			-0.0018f,               //rot period
			131f,                   //longitude of ascending node
			1.679f                  //INCLINATION
		};

        teleport_Params[7] = new Planet_EXPLORE_Params();
        teleport_Params[7].rMin = 0.582f;
        teleport_Params[7].rMax = 19.772f;
        teleport_Params[7].rTeleEnd = 1.930f;
        teleport_Params[7].vTeleRel_Pos = new Vector3(-0.185f, -0.445f, -1.858f);
        teleport_Params[7].zoom_Zone = USER_EXPLORE_ZONE.OUTER;

        //Pluto
        planetParameters[8] = new float[numOfPlanetParams] {
            0.2488f,                //eccentricity
            29.659f * scale_VU,     //r_pericenter
            247.68f,                //orbital period
            3.9f,                   //radius
            122.53f,                //axial tilt
            -0.0018f,               //rot period
            110.303f,               //longitude of ascending node
            17.142f                 //INCLINATION
        };

        teleport_Params[8] = new Planet_EXPLORE_Params();
        teleport_Params[8].rMin = 0.135f;
        teleport_Params[8].rMax = 4.334f;
        teleport_Params[8].rTeleEnd = 1.140f;
        teleport_Params[8].vTeleRel_Pos = new Vector3(-0.745f, -0.858f, -0.012f);
        teleport_Params[8].zoom_Zone = USER_EXPLORE_ZONE.OUTER;

        //THE MOON !
        const int numOfMoonParams = 8;
		moonParameters [0] = new float[numOfMoonParams] {
			0.055f,
			2.44f,
			0.074f,
			0.273f,
			6.69f,
			-29 / 365f,
			0.0f,
			0.012f
		};

        orbit_VUs[0].Set_Orbit(mercury);
        mercury.Par = planetParameters[0];
        mercury.planet_Name = planetNames[0];

        orbit_VUs[1].Set_Orbit(venus);
        venus.Par = planetParameters[1];
        venus.planet_Name = planetNames[1];

        orbit_VUs[2].Set_Orbit(earth);
        earth.Par = planetParameters[2];
        earth.planet_Name = planetNames[2];

        orbit_VUs[3].Set_Orbit(mars);
        mars.Par = planetParameters[3];
        mars.planet_Name = planetNames[3];

        orbit_VUs[4].Set_Orbit(jupiter);
        jupiter.Par = planetParameters[4];
        jupiter.planet_Name = planetNames[4];

        orbit_VUs[5].Set_Orbit(saturn);
        saturn.Par = planetParameters[5];
        saturn.planet_Name = planetNames[5];

        orbit_VUs[6].Set_Orbit(uranus);
        uranus.Par = planetParameters[6];
        uranus.planet_Name = planetNames[6];

        orbit_VUs[7].Set_Orbit(neptune);
        neptune.Par = planetParameters[7];
        neptune.planet_Name = planetNames[7];

        orbit_VUs[8].Set_Orbit(pluto);
        pluto.Par = planetParameters[8];
        pluto.planet_Name = planetNames[8];
    }

    public void Init_PlanetManager()
    {
        mercury.Init(1);
        venus.Init(2);
        earth.Init(3);
        mars.Init(4);
        jupiter.Init(5);
        saturn.Init(6);
        uranus.Init(7);
        neptune.Init(8);
        pluto.Init(9);

        hmd_Ctrl_tracking = HMD_Ctrl_Tracking.Instance;

        for(int i = 0; i<9; i++)
        {
            teleporters[i] = hmd_Ctrl_tracking.ptp_GOs[i+1];
        }
    }
}