public void nextTextureEvent() { TextureSet next = SSTUUtils.findNext(textureSetData, m => m.setName == currentTextureSet, false); currentTextureSet = next?.setName; onTextureUpdated(null, null); }
public void Load(string filePath, ObjectDatabase objectDatabase, TextureDatabase textureDatabase) { string textureSetFilePath = string.Empty; var objectEntry = objectDatabase?.GetObjectByFileName(Path.GetFileName(filePath)); if (objectEntry != null) { textureSetFilePath = Path.Combine(Path.GetDirectoryName(filePath), objectEntry.TextureFileName); } if (string.IsNullOrEmpty(textureSetFilePath) || !File.Exists(textureSetFilePath)) { if (filePath.EndsWith("_obj.bin", StringComparison.OrdinalIgnoreCase)) { textureSetFilePath = $"{filePath.Substring( 0, filePath.Length - 8 )}_tex.bin"; } else if (filePath.EndsWith(".osd", StringComparison.OrdinalIgnoreCase)) { textureSetFilePath = Path.ChangeExtension(filePath, "txd"); } } TextureSet textureSet = null; if (File.Exists(textureSetFilePath)) { textureSet = Load <TextureSet>(textureSetFilePath); } using (var source = File.OpenRead(filePath)) Load(source, textureSet, textureDatabase); }
private TextureSet CreateTexture(Vector4 color1, Vector4 color2) { TextureSet textureSet = new TextureSet(); const int width = 2; const int height = 1; uint size = width * height * 4; byte[] pixelBuffer = new byte[size]; pixelBuffer[0] = (byte)(0xFF * color1.X); pixelBuffer[1] = (byte)(0xFF * color1.Y); pixelBuffer[2] = (byte)(0xFF * color1.Z); pixelBuffer[3] = (byte)(0xFF * color1.W); pixelBuffer[4] = (byte)(0xFF * color2.X); pixelBuffer[5] = (byte)(0xFF * color2.Y); pixelBuffer[6] = (byte)(0xFF * color2.Z); pixelBuffer[7] = (byte)(0xFF * color2.W); PixelData pixelData = new PixelData(pixelBuffer, size, width, height, PixelFormat.RGBA8888, PixelData.ReleaseFunction.DeleteArray); Texture texture = new Texture(TextureType.TEXTURE_2D, PixelFormat.RGBA8888, width, height); texture.Upload(pixelData); textureSet.SetTexture(0u, texture); return(textureSet); }
private void AddOverlay(TextureSet mTexture, TextureSet dTexture, float altitude, float fadeDistance, float pqsfadeDistance) { Assembly assembly = Assembly.GetExecutingAssembly(); string[] resources = assembly.GetManifestResourceNames(); StreamReader shaderStreamReader = new StreamReader(assembly.GetManifestResourceStream("CityLights.Shaders.Compiled-SphereCityLights.shader")); Log("read stream"); String shaderString = shaderStreamReader.ReadToEnd(); Material lightMaterial = new Material(shaderString); Material pqsLightMaterial = new Material(shaderString); lightMaterial.SetTexture("_MainTex", mTexture.Texture); lightMaterial.SetTexture("_DetailTex", dTexture.Texture); lightMaterial.SetFloat("_DetailScale", dTexture.Scale); lightMaterial.SetVector("_DetailOffset", dTexture.Offset); lightMaterial.SetFloat("_FadeDist", fadeDistance); lightMaterial.SetFloat("_FadeScale", 1); pqsLightMaterial.SetTexture("_MainTex", mTexture.Texture); pqsLightMaterial.SetTexture("_DetailTex", dTexture.Texture); pqsLightMaterial.SetFloat("_DetailScale", dTexture.Scale); pqsLightMaterial.SetVector("_DetailOffset", dTexture.Offset); pqsLightMaterial.SetFloat("_FadeDist", pqsfadeDistance); pqsLightMaterial.SetFloat("_FadeScale", .02f); overlayList.Add(Overlay.GeneratePlanetOverlay("Kerbin", altitude, lightMaterial, pqsLightMaterial, mTexture.StartOffset, false, true)); }
void Update() { Texture2D newTexture = targetRenderer.sprite.texture; if (previousTexture != newTexture) { previousTexture = newTexture; if (textureLookup.ContainsKey(newTexture)) { TextureSet thisSet = new TextureSet(); textureLookup.TryGetValue(newTexture, out thisSet); if (thisSet.normalDepthMap != null) { targetMaterial.SetTexture("_NormalDepth", thisSet.normalDepthMap); } if (thisSet.emissiveMap != null) { targetMaterial.SetTexture("_EmissiveColour", thisSet.emissiveMap); } if (thisSet.specMap != null) { targetMaterial.SetTexture("_SpecGloss", thisSet.emissiveMap); } if (thisSet.aoMap != null) { targetMaterial.SetTexture("_AmbientOcclusion", thisSet.emissiveMap); } } } }
/// <summary> /// Initializes a new instance of the <see cref="pudink.Brouk"/> class. /// </summary> /// <param name="texset">Texture set.</param> /// <param name="typ">Type.</param> public Brouk(TextureSet texset,Typ typ) { this.textureset = texset; this.typbug = typ; this.NastavTyp (typ); this.schopnosti = new Abilities (typ); }
private static Ai.Material ConvertAiMaterialFromMaterial(Material material, TextureSet textures) { var aiMaterial = new Ai.Material { Name = material.Name, ColorDiffuse = material.DiffuseColor.ToAssimp(), ColorAmbient = material.AmbientColor.ToAssimp(), ColorSpecular = material.SpecularColor.ToAssimp(), ColorEmissive = material.EmissionColor.ToAssimp(), Shininess = material.Shininess, ShadingMode = Ai.ShadingMode.Phong, }; ConvertMaterialTexture(material.Diffuse, Ai.TextureType.Diffuse); ConvertMaterialTexture(material.Ambient, Ai.TextureType.Ambient); ConvertMaterialTexture(material.Normal, Ai.TextureType.Normals); ConvertMaterialTexture(material.Specular, Ai.TextureType.Specular); ConvertMaterialTexture(material.Reflection, Ai.TextureType.Reflection); ConvertMaterialTexture(material.SpecularPower, Ai.TextureType.Shininess); void ConvertMaterialTexture(MaterialTexture materialTexture, Ai.TextureType textureType) { if (materialTexture.IsActive) { var texture = ConvertTextureSlotFromTextureId(materialTexture.TextureId, textureType, textures); aiMaterial.AddMaterialTexture(ref texture); } } return(aiMaterial); }
/// <summary> /// Standard MonoBehavior Start method, creates the TextureSet and internal WebView /// note that WebViews are uniquely named and requests for a WebView with an identical view name /// will reuse that view /// </summary> void Start() { TSet = new TextureSet(); TSet.Init(Width, Height, SmartRects); if (_windowId == 0) { _windowId = sWindowId; sWindowId++; // defaults to front BringToFront(false); } if (!JSPopup) { Command cmd = Command.NewCommand("CRVW", Name, Width, Height, SmartRects ? 1 : 0); cmd.Post().Process += processCRVW; } // listen in on inbound commands Plugin.ProcessInbound += processInbound; _mobileRect = new Rect(0, 0, Width, Height); _mobileRectDirty = false; if (JSPopup) { validate(); } }
/// <summary> /// Sets the texture set to be used by this renderer. /// </summary> /// <param name="textureSet">The texture set to be used by this renderer.</param> /// <since_tizen> 3 </since_tizen> public void SetTextures(TextureSet textureSet) { NDalicPINVOKE.Renderer_SetTextures(swigCPtr, TextureSet.getCPtr(textureSet)); if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } }
public void setData(TextureSet set) { bInitialized = false; data = set; getModifiedData(); bInitialized = true; refreshListBox(false); }
private IEnumerator DeleteTextureSetCoroutine(TextureSet textureSetToDelete, int gameobjectID) { // Wait a conservative amount of time for gpu upload to finish. Unity 2017 doesn't support async GPU calls, // so this 10 second time is a very conservative delay for this process to occur, which should be <1 sec. yield return(new WaitForSeconds(GPU_TEXTURE_COPY_WAIT_TIME)); // Spin if an avatar is loading while (OvrAvatarSDKManager.Instance.IsAvatarLoading()) { yield return(null); } // The avatar's texture set is compared against all other loaded or loading avatar texture sets. foreach (var textureIdAndSingleMeshFlag in textureSetToDelete.TextureIDSingleMeshPair) { bool triggerDelete = !textureIdAndSingleMeshFlag.Value; if (triggerDelete) { foreach (KeyValuePair <int, TextureSet> textureSet in textureSets) { if (textureSet.Key == gameobjectID) { continue; } foreach (var comparisonTextureIDSingleMeshPair in textureSet.Value.TextureIDSingleMeshPair) { // Mark the texture as not deletable if it's present in another set and that set hasn't been processed // or that texture ID is marked as part of a single mesh component. if (comparisonTextureIDSingleMeshPair.Key == textureIdAndSingleMeshFlag.Key && (!textureSet.Value.IsProcessed || comparisonTextureIDSingleMeshPair.Value)) { triggerDelete = false; break; } } if (!triggerDelete) { break; } } } if (triggerDelete) { Texture2D textureToDelete = OvrAvatarComponent.GetLoadedTexture(textureIdAndSingleMeshFlag.Key); if (textureToDelete != null) { AvatarLogger.Log("Deleting texture " + textureIdAndSingleMeshFlag.Key); OvrAvatarSDKManager.Instance.DeleteAssetFromCache(textureIdAndSingleMeshFlag.Key); Destroy(textureToDelete); } } } textureSetToDelete.IsProcessed = true; textureSets.Remove(gameobjectID); }
public static NetInfo SetAllNodesTexture(this NetInfo info, TextureSet newTextures, LODTextureSet newLODTextures = null) { foreach (var node in info.m_nodes) { node.SetTextures(newTextures, newLODTextures); } return(info); }
public Tile(string name, TextureSet set, RectangleF uv) { this.name = name; this.set = set; this.uv = uv; this.aspectRatio = uv.Width / uv.Height; CreateTileBitmap(); }
public static NetInfo SetAllSegmentsTexture(this NetInfo info, TextureSet newTextures, LODTextureSet newLODTextures = null) { foreach (var segment in info.m_segments) { segment.SetTextures(newTextures, newLODTextures); } return(info); }
public void CreateTextureSet(TextureSet s) { textureSetList.Add(s); if (Program.tilePicker != null) { Program.tilePicker.UpdateUI(); } }
public void SetTextureSet(TextureSet set) { foreach (var registeredMat in _textureSetMaterials) { registeredMat.ApplySet(set); } CurrentTextureSet = set; }
public TextureSetUpdater(int receiverId, IPEndPoint senderEndPoint) { State = PrepareState.Unprepared; this.receiverId = receiverId; this.senderEndPoint = senderEndPoint; textureSet = new TextureSet(); Debug.Log($"textureSet ID: {textureSet.GetId()}"); lastFrameId = -1; }
public static NetInfo SetAllSegmentsTexture(this NetInfo info, TextureSet newTextures, LODTextureSet newLODTextures = null) { for (var i = 0; i < info.m_segments.Length; i++) { info.m_segments[i].SetTextures(newTextures, newLODTextures); } return(info); }
public static bool Equals(TextureBundle a, TextureBundle b) { return(TextureSet.Equals(a.albedo, b.albedo) && TextureSet.Equals(a.normals, b.normals) && //TextureSet.Equals(a.roughness, b.roughness) && //TextureSet.Equals(a.ao, b.ao) && //TextureSet.Equals(a.height, b.height) && TextureSet.Equals(a.rho, b.rho)); }
public TextureSet getTextureSet(string textureListName) { if (!textures.ContainsKey(textureListName)) { textures[textureListName] = new TextureSet(this); } return(textures[textureListName]); }
public GLMaterial(Material material, Dictionary <int, GLTexture> textures, TextureSet textureSet) { if (textureSet == null) { return; } Diffuse = GetTexture(material.Diffuse); Ambient = GetTexture(material.Ambient); Normal = GetTexture(material.Normal); Specular = GetTexture(material.Specular); Reflection = GetTexture(material.Reflection); if (material.Shader.Equals("EYEBALL", StringComparison.OrdinalIgnoreCase)) { DiffuseColor = Vector4.One; } else { DiffuseColor = new Vector4(material.DiffuseColor.R, material.DiffuseColor.G, material.DiffuseColor.B, material.DiffuseColor.A); } AmbientColor = new Vector4(material.AmbientColor.R, material.AmbientColor.G, material.AmbientColor.B, material.AmbientColor.A); SpecularColor = new Vector4(material.SpecularColor.R, material.SpecularColor.G, material.SpecularColor.B, material.SpecularColor.A); EmissionColor = new Vector4(material.EmissionColor.R, material.EmissionColor.G, material.EmissionColor.B, material.EmissionColor.A); Shininess = material.Shininess; GLTexture GetTexture(MaterialTexture materialTexture) { if (!materialTexture.IsActive) { return(null); } if (textures.TryGetValue(materialTexture.TextureId, out GLTexture texture)) { return(texture); } else { var textureToUpload = textureSet.Textures.FirstOrDefault(x => x.Id.Equals(materialTexture.TextureId)); if (textureToUpload == null) { return(null); } texture = new GLTexture(textureToUpload); textures.Add(textureToUpload.Id, texture); return(texture); } } }
void ParseTextureSet(string name, JSONNode textureSetJson) { TextureSet textureSet = new TextureSet(); textureSet.m_Name = name; textureSet.m_Shader = textureSetJson["shader"]; textureSet.ParseMasks(textureSetJson["stacks"]); m_TextureSets.Add(textureSet); Utils.Log("Parsed texture set " + textureSet.m_Name); }
private string getTIXPathFromTextureSet(Dream dream, TextureSet textureSet) { if (string.IsNullOrWhiteSpace(dream.LBDFolder)) { Debug.LogError("Could not get TIX path from dream, dream did not have LBD folder"); return(null); } return(LSDUtil.GetTIXPathFromLBDPath(dream.LBDFolder, textureSet)); }
public GLMaterial(Material material, Dictionary <uint, GLTexture> textures, TextureSet textureSet) { if (textureSet == null) { return; } Diffuse = GetTexture(MaterialTextureType.Color, 0); Ambient = GetTexture(MaterialTextureType.Color, 1); Normal = GetTexture(MaterialTextureType.Normal, 0); Specular = GetTexture(MaterialTextureType.Specular, 0); Reflection = GetTexture(MaterialTextureType.EnvironmentCube, 0); DiffuseColor = material.Diffuse.ToGL(); SpecularColor = material.Specular.ToGL(); AmbientColor = new Color4(0.25f, 0.25f, 0.25f, 1.0f); Shininess = material.Shininess; AnisoDirection = material.AnisoDirection; GLTexture GetTexture(MaterialTextureType type, uint offset) { uint index = 0; foreach (var materialTexture in material.MaterialTextures) { if (materialTexture.Type != type) { continue; } if (index++ < offset) { continue; } if (textures.TryGetValue(materialTexture.TextureId, out var texture)) { return(texture); } var textureToUpload = textureSet.Textures.FirstOrDefault(x => x.Id.Equals(materialTexture.TextureId)); if (textureToUpload == null) { return(null); } texture = new GLTexture(textureToUpload); textures.Add(textureToUpload.Id, texture); return(texture); } return(null); } }
public void SetModel(Mesh mesh, TextureSet textureSet) { if (!CanRender) { return; } Reset(); mModel = new GLMesh(mesh, new Dictionary <int, GLTexture>(), textureSet); SetCamera(mesh.BoundingSphere); }
bool BeginReadRequest(int count, ref ReadRequest req) { if (count == 0) { return(false); } BeginReadMarker.Begin(); TextureSet TextureSet = null; if (AvailableRenderTextures.Count != 0) { TextureSet = AvailableRenderTextures.Pop(); } if (TextureSet == null) { TextureSet = new TextureSet(); TextureSet.Alloc(RenderTextureWidth, RenderTextureHeight); } else if (!TextureSet.IsValid()) { TextureSet.Release(); TextureSet.Alloc(RenderTextureWidth, RenderTextureHeight); } activeTarget = TextureSet; SensorCamera.SetTargetBuffers( activeTarget.colorTexture.rt.colorBuffer, activeTarget.depthTexture.rt.depthBuffer); SensorCamera.Render(); req = new ReadRequest() { TextureSet = TextureSet, Index = CurrentIndex, Count = count, Origin = SensorCamera.transform.position, CameraToWorldMatrix = SensorCamera.cameraToWorldMatrix, }; if (!Compensated) { req.Transform = transform.worldToLocalMatrix; } BeginReadMarker.End(); CurrentIndex = (CurrentIndex + count) % CurrentMeasurementsPerRotation; return(true); }
public static void RefreshTextureSet(bool canUseCurrent) { TextureSet textureSet = (TextureSet)RandUtil.Int(1, 5); if (!canUseCurrent && textureSet == CurrentTextureSet) { RefreshTextureSet(false); } CurrentTextureSet = textureSet; Shader.SetGlobalInt("_TextureSet", (int)textureSet); }
public virtual void AddTexture(TextureSet textureSet) { if (textureSets.ContainsKey(textureSet.name)) { Debug.LogError("TEXTURE ALREADY EXISTS WITH NAME: " + textureSet.name); } else { textureSets.Add(textureSet.name, textureSet); } }
public GLModel(Model model, TextureSet textureSet) { Meshes = new List <GLMesh>(); var textures = new Dictionary <int, GLTexture>(); foreach (var mesh in model.Meshes) { Meshes.Add(new GLMesh(mesh, textures, textureSet)); } }
public void SetModel(Object obj, TextureSet textureSet) { if (!CanRender) { return; } Reset(); mModel = new GLObject(obj, new Dictionary <int, GLTexture>(), textureSet); SetCamera(obj.BoundingSphere); }
public Shader FindTextureSetShader(string name) { TextureSet textureSet = FindTextureSet(name); if (textureSet == null) { return(null); } return(FindShader(textureSet.m_Shader)); }
protected void Awake() { if (HighLogic.LoadedScene == GameScenes.FLIGHT && !setup) { OverlayMgr.Init(); ConfigNode[] cityLightsConfigs = GameDatabase.Instance.GetConfigNodes("CITY_LIGHTS"); foreach (ConfigNode node in cityLightsConfigs) { float altitude = float.Parse(node.GetValue("altitude")); float fadeDistance = float.Parse(node.GetValue("fadeDistance")); float pqsfadeDistance = float.Parse(node.GetValue("pqsFadeDistance")); TextureSet mTexture = new TextureSet(node.GetNode("main_texture"), false); TextureSet dTexture = new TextureSet(node.GetNode("detail_texture"), false); AddOverlay(mTexture, dTexture, altitude, fadeDistance, pqsfadeDistance); } setup = true; } }
public CloudLayer(String url, ConfigNode node, String body, Color color, float altitude, TextureSet mainTexture, TextureSet detailTexture, ShaderFloats ScaledShaderFloats, ShaderFloats ShaderFloats, bool useVolume) { if (!BodyDatabase.ContainsKey(body)) { BodyDatabase.Add(body, new List<CloudLayer>()); } BodyDatabase[body].Add(this); if (!ConfigBodyDatabase.ContainsKey(url)) { ConfigBodyDatabase.Add(url, new Dictionary<String, List<CloudLayer>>()); ConfigBodyDatabase[url].Add(body, new List<CloudLayer>()); } else if (!ConfigBodyDatabase[url].ContainsKey(body)) { ConfigBodyDatabase[url].Add(body, new List<CloudLayer>()); } ConfigBodyDatabase[url][body].Add(this); this.url = url; this.node = node; this.body = body; this.color = color; this.altitude = altitude; this.mainTexture = mainTexture; this.detailTexture = detailTexture; this.scaledShaderFloats = ScaledShaderFloats; this.shaderFloats = ShaderFloats; this.useVolume = useVolume; Init(); }
protected void DrawWater(World world, System.Drawing.Rectangle region, bool background, Graphics g, TextureSet textures) { for (int y = region.Top; y < region.Bottom; y++) { for (int x = region.Left; x < region.Right; x++) { if (y == 0) { continue; } // Skip if the tile contains no liquid. if (world.tile[x, y].Liquid <= 0) { continue; } // What is the liquid level of the tile? float liquidLevel = 256 - world.tile[x, y].Liquid; liquidLevel /= 32f; int liquidTextureIndex = 0; if (world.tile[x, y].Lava) { liquidTextureIndex = 1; } float intensity = 0.5f; if (background) { intensity = 1f; } Vector2 vector = new Vector2((float) (x * 16), (float) ((y * 16) + (((int) liquidLevel) * 2))); Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(0, 0, 16, 16 - (((int) liquidLevel) * 2)); if ((world.tile[x, y + 1].Liquid < 245) && ((!world.tile[x, y + 1].Active || !World.tileSolid[world.tile[x, y + 1].Type]) || World.tileSolidTop[world.tile[x, y + 1].Type])) { float num10 = 256 - world.tile[x, y + 1].Liquid; num10 /= 32f; intensity = (0.5f * (8f - liquidLevel)) / 4f; if (intensity > 0.55) { intensity = 0.55f; } if (intensity < 0.35) { intensity = 0.35f; } float num11 = liquidLevel / 2f; if (world.tile[x, y + 1].Liquid < 200) { if (background) { continue; } if ((world.tile[x, y - 1].Liquid > 0) && (world.tile[x, y - 1].Liquid > 0)) { rectangle = new Microsoft.Xna.Framework.Rectangle(0, 4, 16, 16); intensity = 0.5f; } else if (world.tile[x, y - 1].Liquid > 0) { vector = new Vector2((float) (x * 16), (float) ((y * 16) + 4)); rectangle = new Microsoft.Xna.Framework.Rectangle(0, 4, 16, 12); intensity = 0.5f; } else if (world.tile[x, y + 1].Liquid > 0) { vector = new Vector2((float) (x * 16), (float) (((y * 16) + (((int) liquidLevel) * 2)) + (((int) num10) * 2))); rectangle = new Microsoft.Xna.Framework.Rectangle(0, 4, 16, 16 - (((int) liquidLevel) * 2)); } else { vector = new Vector2((float) ((x * 16) + ((int) num11)), (float) (((y * 16) + (((int) num11) * 2)) + (((int) num10) * 2))); rectangle = new Microsoft.Xna.Framework.Rectangle(0, 4, 16 - (((int) num11) * 2), 16 - (((int) num11) * 2)); } } else { intensity = 0.5f; rectangle = new Microsoft.Xna.Framework.Rectangle(0, 4, 16, (16 - (((int) liquidLevel) * 2)) + (((int) num10) * 2)); } } else if (world.tile[x, y - 1].Liquid > 32) { rectangle = new Microsoft.Xna.Framework.Rectangle(0, 4, rectangle.Width, rectangle.Height - 4); } else if (((liquidLevel < 1f) && world.tile[x, y - 1].Active) && (World.tileSolid[world.tile[x, y - 1].Type] && !World.tileSolidTop[world.tile[x, y - 1].Type])) { vector = new Vector2((float) (x * 16), (float) (y * 16)); rectangle = new Microsoft.Xna.Framework.Rectangle(0, 4, 16, 16 - 4); } else { bool flag = true; for (int k = y + 1; k < (y + 6); k++) { if ((world.tile[x, k].Active && World.tileSolid[world.tile[x, k].Type]) && !World.tileSolidTop[world.tile[x, k].Type]) { break; } if (world.tile[x, k].Liquid < 200) { flag = false; break; } } if (!flag) { intensity = 0.5f; rectangle = new Microsoft.Xna.Framework.Rectangle(0, 4, 16, 16 - 4); } else if (world.tile[x, y - 1].Liquid > 0) { rectangle = new Microsoft.Xna.Framework.Rectangle(0, 2, rectangle.Width, rectangle.Height - 2); } } if (world.tile[x, y].Lava) { intensity *= 1.6f; } if (intensity > 1f) { intensity = 1f; } ColorMatrix colorMatrix = new ColorMatrix(); colorMatrix.Matrix33 = intensity; ImageAttributes imageAttributes = new ImageAttributes(); imageAttributes.SetColorMatrix(colorMatrix); int waterWidth = 16; int waterHeight = 16 - ((int) vector.Y - (y * 16)); g.DrawImage(textures.liquidTexture[liquidTextureIndex], new System.Drawing.Rectangle((int) (vector.X - region.Left * 16), (int) (vector.Y - region.Top * 16), waterWidth, waterHeight), rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, GraphicsUnit.Pixel, imageAttributes); } } }
private static TextureSet LoadTextureSet(ConfigNode node) { string textureSet = node.name; // Sanity check if (node.GetNode("sides") == null || node.GetNode("ends") == null) { Debug.LogError("*ST* Invalid Textureset " + textureSet); return null; } if (!node.GetNode("sides").HasValue("texture") || !node.GetNode("ends").HasValue("texture")) { Debug.LogError("*ST* Invalid Textureset " + textureSet); return null; } // get settings TextureSet tex = new TextureSet { name = textureSet, sidesName = node.GetNode("sides").GetValue("texture"), endsName = node.GetNode("ends").GetValue("texture"), sidesBumpName = "" }; if (node.GetNode("sides").HasValue("bump")) tex.sidesBumpName = node.GetNode("sides").GetValue("bump"); if (node.GetNode("sides").HasValue("uScale")) float.TryParse(node.GetNode("sides").GetValue("uScale"), out tex.scale.x); if (node.GetNode("sides").HasValue("vScale")) float.TryParse(node.GetNode("sides").GetValue("vScale"), out tex.scale.y); if (node.GetNode("sides").HasValue("autoScale")) bool.TryParse(node.GetNode("sides").GetValue("autoScale"), out tex.autoScale); if (node.GetNode("sides").HasValue("autoWidthDivide")) bool.TryParse(node.GetNode("sides").GetValue("autoWidthDivide"), out tex.autoWidthDivide); if (node.GetNode("sides").HasValue("autoHeightSteps")) float.TryParse(node.GetNode("sides").GetValue("autoHeightSteps"), out tex.autoHeightSteps); if (node.GetNode("sides").HasValue("specular")) tex.sidesSpecular = ConfigNode.ParseColor(node.GetNode("sides").GetValue("specular")); if (node.GetNode("sides").HasValue("shininess")) float.TryParse(node.GetNode("sides").GetValue("shininess"), out tex.sidesShininess); Texture[] textures = Resources.FindObjectsOfTypeAll(typeof(Texture)) as Texture[]; if (!TryFindTexture(textures, ref tex.sidesName, out tex.sides)) { Debug.LogError("*ST* Sides textures not found for " + textureSet); return null; } if (!TryFindTexture(textures, ref tex.endsName, out tex.ends)) { Debug.LogError("*ST* Ends textures not found for " + textureSet); return null; } if (string.IsNullOrEmpty(tex.sidesBumpName)) tex.sidesBump = null; else if (!TryFindTexture(textures, ref tex.sidesBumpName, out tex.sidesBump)) { Debug.LogError("*ST* Side bump textures not found for " + textureSet); return null; } return tex; }
/// <summary> /// Initializes a new instance of the <see cref="pudink.PowerUp"/> class. /// </summary> public PowerUp(TextureSet tex) { TexturesSet = tex; }
/// <summary> /// Initializes a new instance of the <see cref="pudink.Brouk"/> class. /// </summary> /// <param name="texset">Texture set.</param> public Brouk(TextureSet texset) { this.textureset = texset; this.schopnosti = new Abilities (Typ.Normal); }
private void initialize() { if (initialized) { return; } initialized = true; ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData); ConfigNode[] textureNodes = node.GetNodes("TEXTURESET"); textureSetData = TextureSet.loadTextureSets(textureNodes); currentTextureSetData = Array.Find(textureSetData, m => m.setName == currentTextureSet); if (currentTextureSetData == null) { currentTextureSetData = textureSetData[0]; currentTextureSet = currentTextureSetData.setName; } int len = textureSetData.Length; string[] textureSetNames = new string[len]; for (int i = 0; i < len; i++) { textureSetNames[i] = textureSetData[i].setName; } this.updateUIChooseOptionControl("currentTextureSet", textureSetNames, textureSetNames, true, currentTextureSet); TextureData data = currentTextureSetData.textureDatas[0]; fairingMaterial = SSTUUtils.loadMaterial(data.diffuseTextureName, null, "KSP/Specular"); fuelType = VolumeContainerLoader.getPreset(fuelPreset); Transform modelBase = part.transform.FindRecursive("model"); setupEngineModels(modelBase); minHeight = engineHeight * getEngineScale(); Transform root = modelBase.FindOrCreate(baseTransformName); Transform collider = modelBase.FindOrCreate("InterstageFairingBaseCollider"); fairingBase = new InterstageDecouplerModel(root.gameObject, collider.gameObject, 0.25f, cylinderSides, numberOfPanels, wallThickness); updateEditorFields(); buildFairing(); updateNodePositions(false); if (!initializedResources && (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor)) { initializedResources = true; updateResources(); } updatePartMass(); updateEngineThrust(); }
protected void DrawBackground(World world, System.Drawing.Rectangle region, Graphics g, TextureSet textures) { float regionWidth = region.Width * 16; float regionHeight = region.Height * 16; int skyEnd = (int) world.worldSurface + 1; // Draw the Dirt Sky Blend if (region.Top < skyEnd && skyEnd <= region.Bottom) { float destinationTop = (skyEnd - region.Top - 1) * 16; // How many across need to be rendered. int instances = (int) Math.Ceiling(regionWidth / textures.backgroundTexture[1].Width) + 1; int offset = ((region.Left % 6) + 3) * 16; for (int i = 0; i < instances; ++i) { g.DrawImage(textures.backgroundTexture[1], new PointF(i * textures.backgroundTexture[1].Width - offset, destinationTop)); } } int rockStart = (int) world.rockLayer + 38; // Draw the Dirt Background if (skyEnd < region.Bottom || region.Top <= rockStart) { int minBlockY = region.Top; float startOffsetY = 0.0f; if (skyEnd > region.Top) { minBlockY = skyEnd; startOffsetY = (skyEnd - region.Top) * 16; } int maxBlockY = (int) ((rockStart < region.Bottom) ? rockStart : region.Bottom); int blockCount = maxBlockY - minBlockY; int dirtBackgroundTextureWidth = textures.backgroundTexture[2].Width; int dirtBackgroundTextureHeight = textures.backgroundTexture[2].Height; // How many vertical repeats. int instancesToDrawY = (int) Math.Ceiling(blockCount * 16.0f / dirtBackgroundTextureHeight) + 1; int instancesToDrawX = (int) Math.Ceiling((regionWidth / dirtBackgroundTextureWidth)) + 1; int offsetX = (((region.Left) % (dirtBackgroundTextureWidth / 16)) + 3) * 16; int offsetY = ((minBlockY - (int) skyEnd) % (dirtBackgroundTextureHeight / 16)) * 16; for (int i = 0; i < instancesToDrawX; ++i) { for (int j = 0; j < instancesToDrawY; ++j) { g.DrawImage(textures.backgroundTexture[2], new PointF(i * dirtBackgroundTextureWidth - offsetX, startOffsetY + j * dirtBackgroundTextureHeight - offsetY)); } } } // Draw the Dirt Rock Blend if (region.Top < rockStart && rockStart <= region.Bottom) { float destinationTop = (rockStart - region.Top - 1) * 16; // How many across need to be rendered. int instances = (int) Math.Ceiling(regionWidth / textures.backgroundTexture[4].Width) + 1; int offset = ((region.Left % 6) + 3) * 16; for (int i = 0; i < instances; ++i) { g.DrawImage(textures.backgroundTexture[4], new PointF(i * textures.backgroundTexture[4].Width - offset, destinationTop)); } } int hellStart = world.Size.Height - 230; // Draw the Rock Background if (region.Bottom > rockStart || region.Top < hellStart) { int minBlockY = region.Top; float startOffsetY = 0.0f; if (rockStart > region.Top) { minBlockY = rockStart; startOffsetY = (rockStart - region.Top) * 16; } int maxBlockY = (hellStart < region.Bottom) ? hellStart : region.Bottom; int blockCount = maxBlockY - minBlockY; int rockBackgroundTextureWidth = textures.backgroundTexture[3].Width; int rockBackgroundTextureHeight = textures.backgroundTexture[3].Height; // How many vertical repeats. int instancesToDrawY = (int) Math.Ceiling(blockCount * 16.0f / rockBackgroundTextureHeight) + 1; int instancesToDrawX = (int) Math.Ceiling((regionWidth / rockBackgroundTextureWidth)) + 1; int offsetX = (((region.Left) % (rockBackgroundTextureWidth / 16)) + 3) * 16; int offsetY = ((minBlockY - (int) rockStart - 1) % (rockBackgroundTextureHeight / 16)) * 16 + 8; for (int i = 0; i < instancesToDrawX; ++i) { for (int j = 0; j < instancesToDrawY; ++j) { g.DrawImage(textures.backgroundTexture[3], new PointF(i * rockBackgroundTextureWidth - offsetX, startOffsetY + j * rockBackgroundTextureHeight - offsetY)); } } } // Draw the Rock Hell Blend if (region.Top < hellStart && hellStart <= region.Bottom) { float destinationTop = (hellStart - region.Top - 1) * 16 + 24; // How many across need to be rendered. int instances = (int) Math.Ceiling(regionWidth / textures.backgroundTexture[6].Width) + 1; int offset = ((region.Left % 6) + 3) * 16; for (int i = 0; i < instances; ++i) { g.DrawImage(textures.backgroundTexture[6], new PointF(i * textures.backgroundTexture[6].Width - offset, destinationTop)); } } // Draw the Hell Background if (region.Bottom > hellStart) { int minBlockY = region.Top; float startOffsetY = 0.0f; if (hellStart > region.Top) { minBlockY = hellStart; startOffsetY = (hellStart - region.Top) * 16; } int maxBlockY = region.Bottom; int blockCount = maxBlockY - minBlockY; int rockBackgroundTextureWidth = textures.backgroundTexture[5].Width; int rockBackgroundTextureHeight = textures.backgroundTexture[5].Height; // How many vertical repeats. int instancesToDrawY = (int) Math.Ceiling(blockCount * 16.0f / rockBackgroundTextureHeight) + 1; int instancesToDrawX = (int) Math.Ceiling((regionWidth / rockBackgroundTextureWidth)) + 1; int offsetX = (((region.Left) % (rockBackgroundTextureWidth / 16)) + 3) * 16; int offsetY = ((minBlockY - (int) hellStart - 1) % (rockBackgroundTextureHeight / 16)) * 16 - 16; for (int i = 0; i < instancesToDrawX; ++i) { for (int j = 0; j < instancesToDrawY; ++j) { g.DrawImage(textures.backgroundTexture[5], new PointF(i * rockBackgroundTextureWidth - offsetX, startOffsetY + j * rockBackgroundTextureHeight - offsetY)); } } } }
public TextureSet Copy() { lock (copyLock) { TextureSet newSet = new TextureSet(); for (int i = 0; i < World.NumTiles; i++) { newSet.tileTexture[i] = tileTexture[i].Clone() as Image; } for (int i = 1; i < wallTexture.Length; i++) { newSet.wallTexture[i] = wallTexture[i].Clone() as Image; } for (int i = 0; i < backgroundTexture.Length; i++) { newSet.backgroundTexture[i] = backgroundTexture[i].Clone() as Image; } for (int i = 0; i < npcTexture.Length; i++) { newSet.npcTexture[i] = npcTexture[i].Clone() as Image; } for (int i = 0; i < cloudTexture.Length; i++) { newSet.cloudTexture[i] = cloudTexture[i].Clone() as Image; } for (int i = 0; i < liquidTexture.Length; i++) { newSet.liquidTexture[i] = liquidTexture[i].Clone() as Image; } for (int i = 0; i < treeTopTexture.Length; i++) { newSet.treeTopTexture[i] = treeTopTexture[i].Clone() as Image; } for (int i = 0; i < treeBranchTexture.Length; i++) { newSet.treeBranchTexture[i] = treeBranchTexture[i].Clone() as Image; } newSet.sunTexture = sunTexture.Clone() as Image; newSet.moonTexture = moonTexture.Clone() as Image; newSet.shroomCapTexture = shroomCapTexture.Clone() as Image; return newSet; } }
private Image CreateBlockImage(World world, System.Drawing.Rectangle region, float zoomLevel, MapGeneratorLayerOptions layer) { Image blockImage = new Bitmap(16 * options.BlockSize.Width, 16 * options.BlockSize.Height, PixelFormat.Format32bppArgb); TextureSet textures = null; lock (availableTextureSetLock) { if (availableTextureSet.Count == 0) { System.Diagnostics.Trace.WriteLine("Creating new texture set for thread: " + Thread.CurrentThread.ManagedThreadId); textures = this.textures.Copy(); } else { textures = availableTextureSet.Dequeue(); } } using (Graphics g = Graphics.FromImage(blockImage)) { g.Clip = new Region(new RectangleF(0, 0, region.Width * 16 * zoomLevel, region.Height * 16 * zoomLevel)); g.ScaleTransform(zoomLevel, zoomLevel); g.PixelOffsetMode = PixelOffsetMode.Half; g.CompositingMode = CompositingMode.SourceOver; g.InterpolationMode = InterpolationMode.NearestNeighbor; g.CompositingQuality = CompositingQuality.HighSpeed; if (layer.DrawBackground) { DrawSky(world, region, g); } if (layer.DrawBackgroundWater) { DrawWater(world, region, true, g, textures); } if (layer.DrawBackground) { DrawBackground(world, region, g, textures); } if (layer.DrawWalls) { DrawWalls(world, region, g, textures); } if (layer.DrawBackgroundTiles) { DrawTiles(world, region, false, g, textures); } if (layer.DrawForegroundTiles) { DrawTiles(world, region, true, g, textures); } if (layer.DrawForegroundWater) { DrawWater(world, region, false, g, textures); } } lock (availableTextureSetLock) { availableTextureSet.Enqueue(textures); } return blockImage; }
private void textureWasUpdated() { currentTextureSetData = Array.Find(textureSetData, m => m.setName == currentTextureSet); if (currentTextureSetData == null) { currentTextureSetData = textureSetData[0]; currentTextureSet = currentTextureSetData.setName; } TextureData data = currentTextureSetData.textureDatas[0]; fairingMaterial.mainTexture = GameDatabase.Instance.GetTexture(data.diffuseTextureName, false); data.enableForced(fairingBase.rootObject.transform, true); }
private void DrawTiles(World world, System.Drawing.Rectangle region, bool foreground, Graphics g, TextureSet textures) { int height = 16; int width = 16; bool solidOnly = !foreground; int frameOverlap = 4; int frameOverlapTimes2 = frameOverlap * 2; int startX = region.Left - frameOverlap; int startY = region.Top - frameOverlap; int endX = region.Right + frameOverlapTimes2; int endY = region.Bottom + frameOverlapTimes2; if (startX < 0) { startX = 0; } if (startY < 0) { startY = 0; } if (endX >= world.Size.Width) { endX = world.Size.Width - 1; } if (endY >= world.Size.Height) { endY = world.Size.Height - 1; } for (int y = startY; y < endY; y++) { for (int x = startX; x < endX; x++) { if (world.tile[x, y].Active && (World.tileSolid[world.tile[x, y].Type] == solidOnly)) { int num9 = 0; // Pot if (world.tile[x, y].Type == 78) { num9 = 2; } // Red candle, blue candle. if ((world.tile[x, y].Type == 33) || (world.tile[x, y].Type == 49)) { num9 = -4; } // Flowers, torches, trees, fungus, red candle, blue candle, grass, mushrooms. if ((((world.tile[x, y].Type == 3) || (world.tile[x, y].Type == 4)) || ((world.tile[x, y].Type == 5) || (world.tile[x, y].Type == 24))) || (((world.tile[x, y].Type == 33) || (world.tile[x, y].Type == 49)) || ((world.tile[x, y].Type == 61) || (world.tile[x, y].Type == 71)))) { height = 20; // Chairs, table, anvil, forge, workbench, sappling, chest, demon forge, sunflowers, corrupted thorns, thorns, ?, hell forge } else if (((((world.tile[x, y].Type == 15) || (world.tile[x, y].Type == 14)) || ((world.tile[x, y].Type == 16) || (world.tile[x, y].Type == 17))) || (((world.tile[x, y].Type == 18) || (world.tile[x, y].Type == 20)) || ((world.tile[x, y].Type == 21) || (world.tile[x, y].Type == 26)))) || (((world.tile[x, y].Type == 27) || (world.tile[x, y].Type == 32)) || (((world.tile[x, y].Type == 69) || (world.tile[x, y].Type == 72)) || (world.tile[x, y].Type == 77) || (world.tile[x, y].Type == 80)))) { height = 18; } else { height = 16; } // Torch, tree if ((world.tile[x, y].Type == 4) || (world.tile[x, y].Type == 5)) { width = 20; } else { width = 16; } // Grass, grass. if ((world.tile[x, y].Type == 73) || (world.tile[x, y].Type == 74)) { num9 -= 12; height = 32; } // Draw tree tops and branches. if (((world.tile[x, y].Type == 5) && (world.tile[x, y].FrameY >= 198)) && (world.tile[x, y].FrameX >= 22)) { int num11 = 0; if (world.tile[x, y].FrameX == 22) { if (world.tile[x, y].FrameY == 220) { num11 = 1; } else if (world.tile[x, y].FrameY == 242) { num11 = 2; } int num14 = 0; int num15 = 80; int num16 = 80; int num17 = 0x20; for (int k = y; k < (y + 100); k++) { if (world.tile[x, k].Type == 2) { num14 = 0; break; } if (world.tile[x, k].Type == 0x17) { num14 = 1; break; } if (world.tile[x, k].Type == 60) { num14 = 2; num15 = 0x72; num16 = 0x60; num17 = 0x30; break; } } g.DrawImage(textures.treeTopTexture[num14], (x - region.Left) * 16 - num17, (y - region.Top) * 16 - num16 + 16, new RectangleF(num11 * (num15 + 2), 0, num15, num16), GraphicsUnit.Pixel); } else if (world.tile[x, y].FrameX == 44) { if (world.tile[x, y].FrameY == 220) { num11 = 1; } else if (world.tile[x, y].FrameY == 242) { num11 = 2; } int num19 = 0; for (int m = y; m < (y + 100); m++) { if (world.tile[x, m].Type == 2) { num19 = 0; break; } if (world.tile[x, m].Type == 0x17) { num19 = 1; break; } if (world.tile[x, m].Type == 60) { num19 = 2; break; } } g.DrawImage(textures.treeBranchTexture[num19], (x - region.Left) * 16 - 24, (y - region.Top) * 16 - 12, new RectangleF(0, num11 * 42, 40, 40), GraphicsUnit.Pixel); } else if (world.tile[x, y].FrameX == 66) { if (world.tile[x, y].FrameY == 220) { num11 = 1; } else if (world.tile[x, y].FrameY == 242) { num11 = 2; } int num21 = 0; for (int n = y; n < (y + 100); n++) { if (world.tile[x, n].Type == 2) { num21 = 0; break; } if (world.tile[x, n].Type == 0x17) { num21 = 1; break; } if (world.tile[x, n].Type == 60) { num21 = 2; break; } } g.DrawImage(textures.treeBranchTexture[num21], (x - region.Left) * 16, (y - region.Top) * 16 - 12, new RectangleF(42, num11 * 42, 40, 40), GraphicsUnit.Pixel); } } // Drawn mushroom tops. if ((world.tile[x, y].Type == 72) && (world.tile[x, y].FrameX >= 36)) { int num12 = 0; if (world.tile[x, y].FrameY == 18) { num12 = 1; } else if (world.tile[x, y].FrameY == 36) { num12 = 2; } g.DrawImage(textures.shroomCapTexture, (x - region.Left) * 16 - 22, (y - region.Top) * 16 - 26, new RectangleF(num12 * 62, 0, 60, 42), GraphicsUnit.Pixel); } // Draw liquids behind solids. if (solidOnly && (x > 1 && y > 1 && x < world.Size.Width - 2 && y < world.Size.Height - 2) && (((world.tile[x - 1, y].Liquid > 0) || (world.tile[x + 1, y].Liquid > 0)) || ((world.tile[x, y - 1].Liquid > 0) || (world.tile[x, y + 1].Liquid > 0)))) { int liquidLevel = 0; bool liquidToLeft = false; bool liquidToRight = false; bool liquidAbove = false; bool liquidBelow = false; bool hasLava = false; bool hasWater = false; if (world.tile[x - 1, y].Liquid > 0) { liquidToLeft = true; if (world.tile[x - 1, y].Liquid > liquidLevel) { liquidLevel = world.tile[x - 1, y].Liquid; } if (world.tile[x - 1, y].Lava) { hasLava = true; } else { hasWater = true; } } if (world.tile[x + 1, y].Liquid > 0) { liquidToRight = true; liquidLevel = world.tile[x + 1, y].Liquid; if (world.tile[x + 1, y].Lava) { hasLava = true; } else { hasWater = true; } } if (world.tile[x, y - 1].Liquid > 0) { liquidAbove = true; if (world.tile[x, y - 1].Lava) { hasLava = true; } else { hasWater = true; } } if (world.tile[x, y + 1].Liquid > 0) { if (world.tile[x, y + 1].Lava) { hasLava = true; } else { hasWater = true; } if (world.tile[x, y + 1].Liquid > 240) { liquidBelow = true; } } if (!hasWater || !hasLava) { float num15 = 0f; Vector2 vector = new Vector2((float) (x * 16), (float) (y * 16)); Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(0, 4, 16, 16 - 4); if (liquidBelow && (liquidToLeft || liquidToRight)) { liquidToLeft = true; liquidToRight = true; } if ((!liquidAbove || (!liquidToLeft && !liquidToRight)) && (!liquidBelow || !liquidAbove)) { if (liquidAbove) { rectangle = new Microsoft.Xna.Framework.Rectangle(0, 4, 16, 4); } else if ((liquidBelow && !liquidToLeft) && !liquidToRight) { vector = new Vector2((float) (x * 16), (float) ((y * 16) + 12)); rectangle = new Microsoft.Xna.Framework.Rectangle(0, 4, 16, 4); } else { num15 = 256 - liquidLevel; num15 /= 32f; if (liquidToLeft && liquidToRight) { vector = new Vector2((float) (x * 16), (float) ((y * 16) + (((int) num15) * 2))); rectangle = new Microsoft.Xna.Framework.Rectangle(0, 4, 16, 16 - (((int) num15) * 2) - 4); } else if (liquidToLeft) { vector = new Vector2((float) (x * 16), (float) ((y * 16) + (((int) num15) * 2))); rectangle = new Microsoft.Xna.Framework.Rectangle(0, 4, 4, 16 - (((int) num15) * 2) - 4); } else { vector = new Vector2((float) (x * 16), (float) ((y * 16) + (((int) num15) * 2))); rectangle = new Microsoft.Xna.Framework.Rectangle(0, 4, 4, 16 - (((int) num15) * 2) - 4); } } } float intensity = 0.5f; int liquidTextureIndex = hasWater ? 0 : 1; if (liquidTextureIndex == 1) { intensity *= 1.6f; } if ((y < world.worldSurface) || (intensity > 1f)) { intensity = 1f; } ColorMatrix colorMatrix = new ColorMatrix(); colorMatrix.Matrix33 = intensity; ImageAttributes imageAttributes = new ImageAttributes(); imageAttributes.SetColorMatrix(colorMatrix); int waterWidth = 16; int waterHeight = 16 - ((int) vector.Y - (y * 16)); g.DrawImage(textures.liquidTexture[liquidTextureIndex], new System.Drawing.Rectangle((int) (vector.X - region.Left * 16), (int) (vector.Y - region.Top * 16), waterWidth, waterHeight), rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height, GraphicsUnit.Pixel, imageAttributes); } } g.DrawImage(textures.tileTexture[world.tile[x, y].Type], (x - region.Left) * 16 - (width - 16) / 2, (y - region.Top) * 16 + num9, new RectangleF(world.tile[x, y].FrameX, world.tile[x, y].FrameY, width, height), GraphicsUnit.Pixel); } } } }
protected void DrawWalls(World world, System.Drawing.Rectangle region, Graphics g, TextureSet textures) { for (int y = region.Top; y < region.Bottom; y++) { for (int x = region.Left; x < region.Right; x++) { if (world.tile[x, y].Wall > 0) { System.Drawing.RectangleF rectangle3 = new System.Drawing.RectangleF(world.tile[x, y].WallFrameX * 2, world.tile[x, y].WallFrameY * 2, 32, 32); g.DrawImage(textures.wallTexture[world.tile[x, y].Wall], new System.Drawing.RectangleF((x - region.Left) * 16 - 8, (y - region.Top) * 16 - 8, 32, 32), rectangle3, GraphicsUnit.Pixel); } } } }
private static int TextureSetNameComparison(TextureSet s1, TextureSet s2) { bool s1Start = s1.sidesName.StartsWith("ProceduralParts"); if (s1Start != s2.sidesName.StartsWith("ProceduralParts")) { return s1Start ? -1 : 1; } return string.Compare(s1.name, s2.name, StringComparison.Ordinal); }
private static int TextureSetNameComparison(TextureSet s1, TextureSet s2) { bool s1Start = s1.sidesName.StartsWith("ProceduralParts"); if (s1Start != s2.sidesName.StartsWith("ProceduralParts")) { return s1Start ? -1 : 1; } return s1.name.CompareTo(s2.name); }
/// <summary> /// Initializes a new instance of the <see cref="pudink.Pudink"/> class. /// </summary> /// <param name="pudink">Type of pudding</param> /// <param name="setTextur">Set of textures</param> public Pudink(Typ pudink, TextureSet setTextur) { textury = setTextur; typpudinku = pudink; schopnosti = new Abilities(pudink); }
private void LoadConfigNode(ConfigNode node, string url, bool useVolume, bool defaults) { ConfigNode loadNode = node.GetNode("SAVED"); if ((loadNode == null || defaults) && node.HasNode("DEFAULTS")) { loadNode = node.GetNode("DEFAULTS"); loadNode.RemoveValue("REMOVED"); } else if( node.HasValue("REMOVED") && bool.Parse(node.GetValue("REMOVED"))) { return; } else if (defaults && !node.HasNode("DEFAULTS")) { node.AddValue("REMOVED", true); return; } String body = loadNode.GetValue("body"); Transform bodyTransform = null; try { bodyTransform = ScaledSpace.Instance.scaledSpaceTransforms.Single(t => t.name == body); } catch { } if (bodyTransform != null) { float altitude = float.Parse(loadNode.GetValue("altitude")); TextureSet mTexture = new TextureSet(loadNode.GetNode("main_texture"), false); TextureSet dTexture = new TextureSet(loadNode.GetNode("detail_texture"), false); ConfigNode floatsConfig = loadNode.GetNode("shader_floats"); ShaderFloats shaderFloats = null; if (floatsConfig != null) { shaderFloats = new ShaderFloats(floatsConfig); } ConfigNode scaledfloatsConfig = loadNode.GetNode("scaled_shader_floats"); ShaderFloats scaledShaderFloats = null; if (scaledfloatsConfig != null) { scaledShaderFloats = new ShaderFloats(scaledfloatsConfig); } ConfigNode colorNode = loadNode.GetNode("color"); Color color = new Color( float.Parse(colorNode.GetValue("r")), float.Parse(colorNode.GetValue("g")), float.Parse(colorNode.GetValue("b")), float.Parse(colorNode.GetValue("a"))); if (useVolume) { bool.TryParse(loadNode.GetValue("volume"), out useVolume); } CloudLayer.Layers.Add( new CloudLayer(url, node, body, color, altitude, mTexture, dTexture, scaledShaderFloats, shaderFloats, useVolume)); } else { CloudLayer.Log("body " + body + " does not exist!"); } }