Exemple #1
0
 public void Awake()
 {
     if (ThisHasBeenDuplicated("skysphereMaterial") == true)
     {
         skysphereMaterial = SGT_Helper.CloneObject(skysphereMaterial);
     }
 }
 public void Awake()
 {
     if (ThisHasBeenDuplicated() == true)
     {
         starfieldMaterial = SGT_Helper.CloneObject(starfieldMaterial);
         meshes            = SGT_Helper.CloneObjects(meshes);
     }
 }
Exemple #3
0
 public void Awake()
 {
     if (ThisHasBeenDuplicated("atmosphereMaterial", "lightingTexture") == true)
     {
         atmosphereMaterial = SGT_Helper.CloneObject(atmosphereMaterial);
         lightingTexture    = SGT_Helper.CloneObject(lightingTexture);
     }
 }
 public void Awake()
 {
     if (ThisHasBeenDuplicated() == true)
     {
         ringMaterial  = SGT_Helper.CloneObject(ringMaterial);
         generatedMesh = SGT_Helper.CloneObject(generatedMesh);
     }
 }
 public void Awake()
 {
     if (ThisHasBeenDuplicated("generatedMesh", "coronaMaterial") == true)
     {
         generatedMesh  = SGT_Helper.CloneObject(generatedMesh);
         coronaMaterial = SGT_Helper.CloneObject(coronaMaterial);
     }
 }
 public void Awake()
 {
     if (ThisHasBeenDuplicated("ringMaterial", "generatedMeshes") == true)
     {
         ringMaterial    = SGT_Helper.CloneObject(ringMaterial);
         generatedMeshes = SGT_Helper.CloneObjects(generatedMeshes);
     }
 }
Exemple #7
0
 public void Awake()
 {
     if (ThisHasBeenDuplicated("atmosphereMaterial", "surfaceMaterials") == true)
     {
         surfaceMaterials         = SGT_Helper.CloneObjects(surfaceMaterials);
         atmosphereMaterial       = SGT_Helper.CloneObject(atmosphereMaterial);
         atmosphereTexture        = SGT_Helper.CloneObject(atmosphereTexture);
         atmosphereSurfaceTexture = SGT_Helper.CloneObject(atmosphereSurfaceTexture);
     }
 }
    public void Awake()
    {
        if (ThisHasBeenDuplicated("probeMaterial") == true)
        {
            SGT_Helper.RemoveSharedMaterial(GetComponent <Renderer>(), probeMaterial, probeRecursive);

            probeMaterial = SGT_Helper.CloneObject(probeMaterial);

            SGT_Helper.SetRenderQueue(probeMaterial, probeRenderQueue);
        }
    }
Exemple #9
0
 public void Awake()
 {
     if (ThisHasBeenDuplicated() == true)
     {
         surfaceLightingTexture   = SGT_Helper.CloneObject(surfaceLightingTexture);
         atmosphereTexture        = SGT_Helper.CloneObject(atmosphereTexture);
         atmosphereSurfaceTexture = SGT_Helper.CloneObject(atmosphereSurfaceTexture);
         cloudsLightingTexture    = SGT_Helper.CloneObject(cloudsLightingTexture);
         surfaceMaterials         = SGT_Helper.CloneObjects(surfaceMaterials);
         atmosphereMaterial       = SGT_Helper.CloneObject(atmosphereMaterial);
         cloudsMaterials          = SGT_Helper.CloneObjects(cloudsMaterials);
     }
 }
    public void Awake()
    {
        if (ThisHasBeenDuplicated("starfieldMaterial", "meshes") == true)
        {
            starfieldMaterial = SGT_Helper.CloneObject(starfieldMaterial);
            meshes            = SGT_Helper.CloneObjects(meshes);

            if (packer != null)
            {
                packer.Duplicated();
            }
        }
    }
Exemple #11
0
    public static Material[] CreateMaterials(SGT_SurfaceConfiguration surfaceConfiguration, string shaderName, int renderQueue)
    {
        var surfaceCount = SurfaceCount(surfaceConfiguration);
        var materials    = new Material[surfaceCount];

        materials[0] = SGT_Helper.CreateMaterial(shaderName, renderQueue);

        for (var i = 1; i < surfaceCount; i++)
        {
            materials[i] = SGT_Helper.CloneObject(materials[0]);
        }

        return(materials);
    }
Exemple #12
0
    public void Regenerate()
    {
        if (modified == false)
        {
            CheckForModifications();
        }

        if (modified == true)
        {
            if (displacementTexture != null && sourceSurfaceMesh != null)
            {
                if (generatedSurfaceMesh == null)
                {
                    generatedSurfaceMesh = new SGT_SurfaceMultiMesh();
                }

                // Destroy old meshes
                generatedSurfaceMesh.DestroyAllMeshes();

                sourceSurfaceMesh.CopyMeshesInto(generatedSurfaceMesh);

                var surfaceCount = generatedSurfaceMesh.Count;

                for (var i = 0; i < surfaceCount; i++)
                {
                    var multiMesh = generatedSurfaceMesh.GetMultiMesh(i);

                    if (multiMesh != null)
                    {
                        for (var j = 0; j < multiMesh.Count; j++)
                        {
                            var mesh = multiMesh.GetSharedMesh(j);

                            if (mesh != null)
                            {
                                mesh           = SGT_Helper.CloneObject(mesh);
                                mesh.hideFlags = HideFlags.DontSave;

                                var positions      = mesh.vertices;
                                var uv0s           = mesh.uv;
                                var newPositions   = new Vector3[positions.Length];
                                var displacementUV = Vector2.zero;

                                for (var k = 0; k < positions.Length; k++)
                                {
                                    var texture  = (Texture2D)null;
                                    var position = positions[k];

                                    switch (displacementTexture.Configuration)
                                    {
                                    case SGT_SurfaceConfiguration.Sphere:
                                    {
                                        texture = displacementTexture.GetTexture2D(0);

                                        if (texture != null)
                                        {
                                            displacementUV = useUV == true ? uv0s[k] : SGT_Helper.CartesianToPolarUV(position);

                                            if (clamp == true)
                                            {
                                                displacementUV = SGT_Helper.ClampCollapseV(displacementUV, SGT_Helper.PixelUV(texture));
                                            }
                                        }
                                    }
                                    break;

                                    case SGT_SurfaceConfiguration.Cube:
                                    {
                                        texture = displacementTexture.GetTexture2D(position);

                                        if (texture != null)
                                        {
                                            displacementUV = useUV == true ? uv0s[k] : SGT_Helper.CubeUV(position, true);

                                            if (clamp == true)
                                            {
                                                displacementUV = SGT_Helper.ClampUV(displacementUV, SGT_Helper.PixelUV(texture));
                                            }
                                        }
                                    }
                                    break;
                                    }

                                    var displacement = texture != null?texture.GetPixelBilinear(displacementUV.x, displacementUV.y).r : 0.0f;

                                    newPositions[k] = position * Mathf.Lerp(scaleMin, scaleMax, displacement);
                                }

                                mesh.name    += "(Displaced)";
                                mesh.vertices = newPositions;
                                mesh.bounds   = new Bounds(mesh.bounds.center, mesh.bounds.size * scaleMax);
                                mesh.RecalculateNormals();

                                multiMesh.SetSharedMesh(mesh, j);
                            }
                        }
                    }
                }

                MarkAsUnmodified();

                SendMessage("SetSurfaceMultiMesh", generatedSurfaceMesh, SendMessageOptions.DontRequireReceiver);
            }
        }
    }