Beispiel #1
0
        public Overlay(string planet, float altitude, Material scaledMaterial, Material macroMaterial, Vector2 rotation, int layer, Transform celestialTransform, bool mainMenu, bool matchTerrain)
        {
            this.MainMenu          = mainMenu;
            this.OverlayGameObject = new GameObject();
            this.Body               = planet;
            this.Rotation           = rotation;
            this.scaledMaterial     = scaledMaterial;
            this.macroMaterial      = macroMaterial;
            this.OriginalLayer      = layer;
            this.celestialTransform = celestialTransform;
            this.altitude           = altitude;
            this.matchTerrain       = matchTerrain;

            CelestialBody[] celestialBodies = (CelestialBody[])CelestialBody.FindObjectsOfType(typeof(CelestialBody));
            celestialBody = celestialBodies.First(n => n.bodyName == this.Body);

            if (!mainMenu && matchTerrain)
            {
                IsoSphere.Create(OverlayGameObject, this.altitude, celestialBody);
            }
            else
            {
                IsoSphere.Create(OverlayGameObject, this.Radius, null);
            }

            var mr = OverlayGameObject.AddComponent <MeshRenderer>();

            mr.sharedMaterial = scaledMaterial;
            mr.castShadows    = false;
            mr.receiveShadows = false;
            //mr.enabled = mainMenu;
            mr.enabled = true;
        }
    public void Reset()
    {
        Destroy(_mesh);
        _mesh = IsoSphere.Create(recursionLevel);
        var meshFilter = GetComponent <MeshFilter>();

        meshFilter.mesh = _mesh;
    }
Beispiel #3
0
    void OnGUI()
    {
        // Manipulator values
        GUI.Box(new Rect(0, 0, 220, 125), "Manipulator");
        GUI.Label(new Rect(10, 30, 200, 30), "Strength: " + manipulatorStrength.ToString("f1"));
        manipulatorStrength = GUI.HorizontalSlider(new Rect(10, 55, 200, 30), manipulatorStrength, 0f, 30f);
        if (GUI.Button(new Rect(10, 85, 200, 30), "Transition: " + manipulator.property.transition.ToString()))
        {
            if (manipulator.property.transition == MANIPULATORPROPERTYTRANSITIONC.Linear)
            {
                manipulator.property.transition = MANIPULATORPROPERTYTRANSITIONC.Lerp;
            }
            else
            {
                manipulator.property.transition = MANIPULATORPROPERTYTRANSITIONC.Linear;
            }
        }

        // Turbulence values
        GUI.Box(new Rect(240, 0, 220, 125), "Turbulence");
        GUI.Label(new Rect(250, 30, 200, 30), "Strength: " + particles.turbulenceStrength.ToString("f1"));
        particles.turbulenceStrength = GUI.HorizontalSlider(new Rect(250, 55, 200, 30), particles.turbulenceStrength, 0f, 50f);
        if (GUI.Button(new Rect(250, 85, 200, 30), "Type: " + particles.turbulenceType.ToString()))
        {
            if (particles.turbulenceType == TURBULENCETYPE.Perlin)
            {
                particles.turbulenceType = TURBULENCETYPE.Simplex;
            }
            else
            {
                particles.turbulenceType = TURBULENCETYPE.Perlin;
            }
        }

        // Mesh values
        GUI.Box(new Rect(Screen.width - 220, 0, 220, 125), "Mesh");
        GUI.Label(new Rect(Screen.width - 210, 30, 200, 30), "Rotation Speed: " + rotationSpeed.ToString("f1"));
        rotationSpeed = GUI.HorizontalSlider(new Rect(Screen.width - 210, 55, 200, 30), rotationSpeed, -100f, 100f);
        if (GUI.Button(new Rect(Screen.width - 210, 85, 200, 30), "Subdivide x" + subdivisionFactor.ToString()))
        {
            subdivisionFactor++; subdivisionFactor = subdivisionFactor % 4;

            // Subdivide or recreate the original mesh depending on subdivision factor
            if (subdivisionFactor == 0)
            {
                IsoSphere.CreateMesh(gameObject, 1, proceduralMeshSize, false);
            }
            else
            {
                SubdivideMesh.Subdivide(gameObject.GetComponent <MeshFilter>().mesh);
            }

            UpdateTargetManipulator();
        }
    }
Beispiel #4
0
    void Start()
    {
        // Create an isosphere on this GameObject (could be any type of mesh configuration)
        IsoSphere.CreateMesh(gameObject, proceduralMeshRecursion, proceduralMeshSize, false);

        // Create a Manipulator on the particle system and set it up to work as a mesh target
        if (particles != null)
        {
            // Create the new manipulator
            manipulator = PlaygroundC.ManipulatorObject(gameObject.transform, particles);

            // Set the manipulator to Property: Mesh Target and make it transition its particles
            manipulator.type          = MANIPULATORTYPEC.Property;
            manipulator.property.type = MANIPULATORPROPERTYTYPEC.MeshTarget;
            manipulator.property.meshTarget.gameObject = gameObject;
            manipulator.property.transition            = MANIPULATORPROPERTYTRANSITIONC.Linear;
        }
        else
        {
            Debug.Log("You must assign a Particle Playground system to this script.", gameObject);
        }
    }
Beispiel #5
0
 public void UpdateAltitude(bool meshUpdate, float altitude = -1)
 {
     if (altitude > 0)
     {
         this.altitude = altitude;
     }
     if (IsScaledSpace)
     {
         OverlayGameObject.transform.parent        = celestialTransform;
         OverlayGameObject.transform.localPosition = Vector3.zero;
         OverlayGameObject.transform.localScale    = (float)(1002f / celestialBody.Radius) * Vector3.one;
     }
     else
     {
         OverlayGameObject.transform.parent        = celestialBody.transform;
         OverlayGameObject.transform.localPosition = Vector3.zero;
         OverlayGameObject.transform.localScale    = Vector3.one;
     }
     if (!matchTerrain && meshUpdate)
     {
         IsoSphere.UpdateRadius(OverlayGameObject, Radius);
         OverlayMgr.Log(celestialBody.name + " radius+Altitude: " + Radius);
     }
 }