Exemplo n.º 1
0
    public GameObject loadStarSystem(OrbitalDetails orbitalDetails)
    {
        GameObject centreMass = Instantiate(systemCentreMass, new Vector3(0, 0, 0), Quaternion.identity);

        centreMass.name = "CentreMass";
        CelestialBody centreMassBody = ((CelestialBody)centreMass.GetComponent(typeof(CelestialBody)));

        centreMassBody.loadDetails(orbitalDetails.getRadius(), orbitalDetails.getMass());

        for (int i = 0; i < orbitalDetails.getOrbitingBodies().Count; i++)
        {
            GameObject planet = Instantiate(planetPrefab, centreMass.transform);
            planet.name = "Planet-" + i;
            OrbitingBody planetBody = ((OrbitingBody)planet.GetComponent(typeof(OrbitingBody)));
            planetBody.loadDetails(orbitalDetails.getOrbitingBodies()[i]);

            //moon generation for current planet
            for (int j = 0; j < orbitalDetails.getOrbitingBodies()[i].getOrbitingBodies().Count; j++)
            {
                GameObject moon = Instantiate(moonPrefab, planet.transform);
                moon.name = "Planet-" + i + "-Moon-" + j;
                OrbitingBody moonBody = ((OrbitingBody)moon.GetComponent(typeof(OrbitingBody)));
                moonBody.loadDetails(orbitalDetails.getOrbitingBodies()[i].getOrbitingBodies()[j]);
            }
        }

        return(centreMass);
    }
Exemplo n.º 2
0
    public void loadDetails(OrbitalDetails orbitalDetails)
    {
        base.loadDetails(orbitalDetails.getRadius(), orbitalDetails.getMass());

        semiMinorAxis         = orbitalDetails.getSemiMinorAxis();
        semiMajorAxis         = orbitalDetails.getSemiMajorAxis();
        eccentricity          = orbitalDetails.getEccentricity();
        foci1                 = new Vector3(orbitalDetails.getFoci1()[0], orbitalDetails.getFoci1()[1], orbitalDetails.getFoci1()[2]);
        foci2                 = new Vector3(orbitalDetails.getFoci2()[0], orbitalDetails.getFoci2()[1], orbitalDetails.getFoci2()[2]);
        centre                = new Vector3(orbitalDetails.getCentre()[0], orbitalDetails.getCentre()[1], orbitalDetails.getCentre()[2]);
        localCentreVector     = new Vector3(orbitalDetails.getLocalCentreVector()[0], orbitalDetails.getLocalCentreVector()[1], orbitalDetails.getLocalCentreVector()[2]);
        currentTheta          = orbitalDetails.getCurrentTheta();
        cosineEllipseRotation = orbitalDetails.getCosineEllipseRotation();
        sineEllipseRotation   = orbitalDetails.getSineEllipseRotation();
        distanceFromFoci      = orbitalDetails.getDistanceFromFoci();

        gameObject.transform.localPosition = getPositionInOrbit(currentTheta);
    }
    public SerializableOrbitDetails(OrbitalDetails orbitalDetails)
    {
        radius                = orbitalDetails.getRadius();
        mass                  = orbitalDetails.getMass();
        semiMinorAxis         = orbitalDetails.getSemiMinorAxis();
        semiMajorAxis         = orbitalDetails.getSemiMajorAxis();
        eccentricity          = orbitalDetails.getEccentricity();
        foci1                 = orbitalDetails.getFoci1();
        foci2                 = orbitalDetails.getFoci2();
        centre                = orbitalDetails.getCentre();
        localCentreVector     = orbitalDetails.getLocalCentreVector();
        currentTheta          = orbitalDetails.getCurrentTheta();
        cosineEllipseRotation = orbitalDetails.getCosineEllipseRotation();
        sineEllipseRotation   = orbitalDetails.getSineEllipseRotation();
        distanceFromFoci      = orbitalDetails.getDistanceFromFoci();

        List <SerializableOrbitDetails> children = new List <SerializableOrbitDetails>();

        foreach (OrbitalDetails currentOrbitalDetails in orbitalDetails.getOrbitingBodies())
        {
            children.Add(new SerializableOrbitDetails(currentOrbitalDetails));
        }
        orbitingBodies = children;
    }