public void RemoveInput(int index) { if (SGT_ArrayHelper.Remove(inputs, index) == true) { modified = true; } }
private void RecalculateCoords() { SGT_ArrayHelper.Resize(ref starVariants, starfieldTextureTilesX * starfieldTextureTilesY, false); for (var i = 0; i < starVariants.Count; i++) { GetStarVariant(i).RecalculateCoords(starfieldTextureTilesX, starfieldTextureTilesY, i); } }
public SGT_StarfieldStarVariant GetStarVariant(int index) { if (packer != null) { SGT_ArrayHelper.Resize(ref starVariants, packer.OutputCount, true); } return(SGT_ArrayHelper.Index(starVariants, index)); }
private void CheckForModifications() { if (modified == false) { if (SGT_ArrayHelper.Filled(generatedMeshes, 1) == false) { modified = true; } } }
public void SetTexture(Texture newTexture, int faceIndex) { var surfaceCount = Count; if (textures == null || textures.Length != surfaceCount) { textures = new Texture[surfaceCount]; } modified |= SGT_ArrayHelper.CheckSet(textures, newTexture, faceIndex); }
public SGT_StarfieldStarVariant GetStarVariant(int index) { SGT_ArrayHelper.Resize(ref starVariants, starfieldTextureTilesX * starfieldTextureTilesY, false); var starVariant = starVariants[index]; if (starVariant == null) { starVariant = starVariants[index] = new SGT_StarfieldStarVariant(); } starVariant.Parent = this; return(starVariant); }
public void ReplaceAll(Mesh[] newSharedMeshes, Material[] newSharedMaterials = null, PhysicMaterial[] newSharedPhysicsMaterials = null) { if (newSharedMeshes != null) { Resize(newSharedMeshes.Length); sharedMesh = null; if (newSharedMaterials != null) { sharedMaterial = null; } if (newSharedPhysicsMaterials != null) { sharedPhysicsMaterial = null; } // Set all meshes for (var i = 0; i < newSharedMeshes.Length; i++) { var mesh = meshes[i]; if (mesh != null) { mesh.SharedMesh = newSharedMeshes[i]; if (newSharedMaterials != null) { mesh.SharedMaterial = SGT_ArrayHelper.Index(newSharedMaterials, i); } if (newSharedPhysicsMaterials != null) { mesh.SharedPhysicsMaterial = SGT_ArrayHelper.Index(newSharedPhysicsMaterials, i); } } } } }
public SGT_DebrisVariant GetDebrisVariant(int index) { return(SGT_ArrayHelper.Index(variantList, index)); }
public Mesh GetMesh(int index) { return(SGT_ArrayHelper.Index(meshes, index)); }
public SGT_PackerOutput GetOutput(int index) { return(SGT_ArrayHelper.Index(outputs, index)); }
public Texture2D GetAtlas(int index = 0) { return(SGT_ArrayHelper.Index(atlases, index)); }
public SGT_PackerInput GetInput(int index) { return(SGT_ArrayHelper.Index(inputs, index)); }
public void RemoveDebrisVariant(int index) { SGT_ArrayHelper.Remove(variantList, index); }
public void RemoveThruster(SGT_Thruster thruster) { SGT_ArrayHelper.Remove(thrusters, thruster); }
public int GetRenderQueue(int index) { return(SGT_ArrayHelper.Index(renderQueues, index)); }
private void UpdateTechnique() { var targetSurfaceTechnique = "Variant"; var targetAtmosphereTechnique = string.Empty; var tagetCloudsTechnique = string.Empty; if (atmosphere == true) { targetSurfaceTechnique += "Atmosphere"; targetAtmosphereTechnique = "Variant"; if (planetObserver != null) { if (InsideAtmosphere(planetObserver.transform.position) == false) { targetSurfaceTechnique += "Outer"; targetAtmosphereTechnique += "Outer"; } } if (atmosphereScattering == true) { //targetSurfaceTechnique += "Scattering"; targetAtmosphereTechnique += "Scattering"; } } if (clouds == true) { tagetCloudsTechnique = "Variant"; } if (surfaceTextureNormal.ContainsSomething == true) { targetSurfaceTechnique += "Normal"; } if (surfaceTextureSpecular.ContainsSomething == true) { targetSurfaceTechnique += "Specular"; } if (shadow == true) { switch (shadowCasterType) { case SGT_ShadowOccluder.Ring: { targetSurfaceTechnique += "RingShadow"; if (atmosphere == true) { targetAtmosphereTechnique += "RingShadow"; } if (clouds == true) { tagetCloudsTechnique += "RingShadow"; } } break; case SGT_ShadowOccluder.Planet: { targetSurfaceTechnique += "PlanetShadow"; if (atmosphere == true) { targetAtmosphereTechnique += "PlanetShadow"; } if (clouds == true) { tagetCloudsTechnique += "PlanetShadow"; } } break; } } if (surfaceTextureDetail != null) { targetSurfaceTechnique += "Detail"; } if (surfaceMaterials != null && (surfaceTechnique != targetSurfaceTechnique || SGT_ArrayHelper.ContainsSomething(surfaceMaterials) == false || surfaceMaterials.Length != SGT_SurfaceConfiguration_.SurfaceCount(SurfaceConfiguration))) { surfaceMaterials = SGT_Helper.DestroyObjects(surfaceMaterials); } if (atmosphereMaterial != null && (atmosphere == false || atmosphereTechnique != targetAtmosphereTechnique)) { atmosphereMaterial = SGT_Helper.DestroyObject(atmosphereMaterial); } if (cloudsMaterials != null && (clouds == false || cloudsTechnique != tagetCloudsTechnique || SGT_ArrayHelper.ContainsSomething(cloudsMaterials) == false || cloudsMaterials.Length != SGT_SurfaceConfiguration_.SurfaceCount(CloudsConfiguration))) { cloudsMaterials = SGT_Helper.DestroyObjects(cloudsMaterials); } // Create planet surface shaders? if (surfaceMaterials == null) { updateShader |= ShaderFlags.Surface; surfaceTechnique = targetSurfaceTechnique; surfaceMaterials = SGT_SurfaceConfiguration_.CreateMaterials(SurfaceConfiguration, "Hidden/SGT/PlanetSurface/" + surfaceTechnique, surfaceRenderQueue); } else { SGT_Helper.SetRenderQueues(surfaceMaterials, surfaceRenderQueue); } // Create planet atmosphere shaders? if (atmosphere == true) { if (atmosphereMaterial == null) { updateShader |= ShaderFlags.Atmosphere; atmosphereTechnique = targetAtmosphereTechnique; atmosphereMaterial = SGT_Helper.CreateMaterial("Hidden/SGT/PlanetAtmosphere/" + atmosphereTechnique, atmosphereRenderQueue); } else { SGT_Helper.SetRenderQueue(atmosphereMaterial, atmosphereRenderQueue); } } // Create planet cloud shaders? if (clouds == true) { if (cloudsMaterials == null) { updateShader |= ShaderFlags.Clouds; cloudsTechnique = tagetCloudsTechnique; cloudsMaterials = SGT_SurfaceConfiguration_.CreateMaterials(CloudsConfiguration, "Hidden/SGT/PlanetClouds/" + cloudsTechnique, atmosphereRenderQueue); } else { SGT_Helper.SetRenderQueues(cloudsMaterials, atmosphereRenderQueue); } } else { if (cloudsMaterials != null) { cloudsMaterials = SGT_Helper.DestroyObjects(cloudsMaterials); } } }
public Texture GetTexture(int faceIndex) { return(SGT_ArrayHelper.Index(textures, faceIndex)); }
public void Remove(int index) { SGT_ArrayHelper.Remove(materials, index); SGT_ArrayHelper.Remove(renderQueues, index); }
public void SetRenderQueue(int renderQueue, int index) { SGT_ArrayHelper.Set(renderQueues, renderQueue, index); }
public void SetMaterial(Material material, int index) { SGT_ArrayHelper.Set(materials, material, index); }
public void Update() { if (meshes == null) { meshes = new MeshList(); } if (meshGameObjects == null) { meshGameObjects = new GameObjectList(); } if (meshGameObjects.Count != meshes.Count) { SGT_ArrayHelper.Resize(ref meshGameObjects, meshes.Count, true); } // Update meshes for (var i = meshes.Count - 1; i >= 0; i--) { var mesh = meshes[i]; var meshGameObject = meshGameObjects[i]; if (mesh == null) { mesh = new SGT_Mesh(); meshes[i] = mesh; } if (meshGameObject == null) { meshGameObject = SGT_Helper.CreateGameObject("Mesh " + (i + 1), gameObject); meshGameObjects[i] = meshGameObject; } if (gameObject != null) { SGT_Helper.SetParent(meshGameObject, gameObject); SGT_Helper.SetLayer(meshGameObject, gameObject.layer); SGT_Helper.SetTag(meshGameObject, gameObject.tag); } if (sharedMesh != null) { mesh.SharedMesh = sharedMesh; } if (sharedMaterial != null) { mesh.SharedMaterial = sharedMaterial; } if (sharedPhysicsMaterial != null) { mesh.SharedPhysicsMaterial = sharedPhysicsMaterial; } mesh.GameObject = meshGameObject; mesh.HasMeshRenderer = hasMeshRenderers; mesh.MeshRendererEnabled = meshRenderersEnabled; mesh.HasMeshCollider = hasMeshColliders; mesh.MeshColliderEnabled = meshCollidersEnabled; mesh.Update(); } // Check integrity if (gameObject != null && meshGameObjects.Count != gameObject.transform.childCount) { SGT_Helper.DestroyChildren(gameObject); SGT_Helper.DestroyGameObjects(meshGameObjects); } }
public void SetInput(SGT_PackerInput input, int index) { SGT_ArrayHelper.Set(inputs, input, index); }
public SGT_Thruster GetThruster(int index) { return(SGT_ArrayHelper.Index(thrusters, index)); }
public Material GetMaterial(int index) { return(SGT_ArrayHelper.Index(materials, index)); }
public void RemoveThruster(int index) { SGT_ArrayHelper.Remove(thrusters, index); }
private void UpdateMaterial() { var targetSurfaceTechnique = "Variant"; var targetAtmosphereTechnique = "Variant"; if (starObserver != null) { if (InsideAtmosphere(starObserver.transform.position) == false) { targetSurfaceTechnique += "Outer"; targetAtmosphereTechnique += "Outer"; } } if (atmosphereSurfacePerPixel == true) { targetSurfaceTechnique += "PerPixel"; } // Update surface? if (surfaceMaterials == null || (surfaceTechnique != targetSurfaceTechnique || SGT_ArrayHelper.ContainsSomething(surfaceMaterials) == false || surfaceMaterials.Length != SGT_SurfaceConfiguration_.SurfaceCount(SurfaceConfiguration))) { SGT_Helper.DestroyObjects(surfaceMaterials); surfaceTechnique = targetSurfaceTechnique; surfaceMaterials = SGT_SurfaceConfiguration_.CreateMaterials(surfaceMultiMesh.Configuration, "Hidden/SGT/StarSurface/" + surfaceTechnique, surfaceRenderQueue); } else { SGT_Helper.SetRenderQueues(surfaceMaterials, surfaceRenderQueue); } // Update atmosphere? if (atmosphereTechnique != targetAtmosphereTechnique || atmosphereMaterial == null) { SGT_Helper.DestroyObject(atmosphereMaterial); atmosphereTechnique = targetAtmosphereTechnique; atmosphereMaterial = SGT_Helper.CreateMaterial("Hidden/SGT/StarAtmosphere/" + atmosphereTechnique, atmosphereRenderQueue); } else { SGT_Helper.SetRenderQueue(atmosphereMaterial, atmosphereRenderQueue); } }