public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value) { int data = Terrain.ExtractData(value); MekClothData clothingData = GetClothingData(data); int clothingColor = GetClothingColor(data); if (clothingColor != 0) { return(SubsystemPalette.GetName(subsystemTerrain, clothingColor, "染色的 " + clothingData.DisplayName)); } return(clothingData.DisplayName); }
public static int get_block_id(Color c, SubsystemPalette p) { if (c.A == 0) { return(0); } for (int i = 0; i < p.m_colors.Length; i++) { if (p.m_colors[i] == c) { return(arr[i]); } } return(1); }
public static void top_colors(int ofs_p, bool sv_c, int dc, Image img, SubsystemPalette p) { System.Drawing.Bitmap image = new System.Drawing.Bitmap(img.Width, img.Height); List <System.Drawing.Color> colors = new List <System.Drawing.Color>(image.Width * image.Height); for (int x = 0; x < img.Width; x++) { for (int y = 0; y < img.Height; y++) { colors.Add(System.Drawing.Color.FromArgb(img.GetPixel(x, y).R, img.GetPixel(x, y).G, img.GetPixel(x, y).B)); } } KMeansClusteringCalculator clustering = new KMeansClusteringCalculator(); IList <System.Drawing.Color> dominantColours = clustering.Calculate(dc, colors, 6.0d); Color[] c_c = WorldPalette.DefaultColors; for (int i = 0; i < dominantColours.Count; i++) { c_c[i + ofs_p] = new Engine.Color(dominantColours[i].R, dominantColours[i].G, dominantColours[i].B); } p.m_colors = c_c.ToArray(); if (sv_c) { p_c__ = c_c.ToArray(); //p_c = "158,2,81;158,131,100;1,0,1;190,2,107;186,2,80;91,45,42;128,4,62;178,90,65;130,78,56;224,2,96;209,102,76;143,94,88;186,144,135;242,123,90;227,174,167;255,255,255"; n_w = GameManager.WorldInfo.DirectoryName; //dat.ValuesDictionary.GetValue<ValuesDictionary>("GameInfo").GetValue<ValuesDictionary>("Palette").SetValue<string>(str1,"Colors"); } }
public void UpdateRenderTargets() { if (m_skinTexture == null || m_componentPlayer.PlayerData.CharacterSkinName != m_skinTextureName) { m_skinTexture = CharacterSkinsManager.LoadTexture(m_componentPlayer.PlayerData.CharacterSkinName); m_skinTextureName = m_componentPlayer.PlayerData.CharacterSkinName; Utilities.Dispose(ref m_innerClothedTexture); Utilities.Dispose(ref m_outerClothedTexture); } if (m_innerClothedTexture == null || m_innerClothedTexture.Width != m_skinTexture.Width || m_innerClothedTexture.Height != m_skinTexture.Height) { m_innerClothedTexture = new RenderTarget2D(m_skinTexture.Width, m_skinTexture.Height, ColorFormat.Rgba8888, DepthFormat.None); m_componentHumanModel.TextureOverride = m_innerClothedTexture; m_clothedTexturesValid = false; } if (m_outerClothedTexture == null || m_outerClothedTexture.Width != m_skinTexture.Width || m_outerClothedTexture.Height != m_skinTexture.Height) { m_outerClothedTexture = new RenderTarget2D(m_skinTexture.Width, m_skinTexture.Height, ColorFormat.Rgba8888, DepthFormat.None); m_componentOuterClothingModel.TextureOverride = m_outerClothedTexture; m_clothedTexturesValid = false; } if (DrawClothedTexture && !m_clothedTexturesValid) { m_clothedTexturesValid = true; Rectangle scissorRectangle = Display.ScissorRectangle; RenderTarget2D renderTarget = Display.RenderTarget; try { Display.RenderTarget = m_innerClothedTexture; Display.Clear(new Vector4(Color.Transparent)); int num = 0; TexturedBatch2D texturedBatch2D = m_primitivesRenderer.TexturedBatch(m_skinTexture, useAlphaTest: false, num++, DepthStencilState.None, null, BlendState.NonPremultiplied, SamplerState.PointClamp); texturedBatch2D.QueueQuad(Vector2.Zero, new Vector2(m_innerClothedTexture.Width, m_innerClothedTexture.Height), 0f, Vector2.Zero, Vector2.One, Color.White); ClothingSlot[] innerSlotsOrder = m_innerSlotsOrder; foreach (ClothingSlot slot in innerSlotsOrder) { foreach (int clothe in GetClothes(slot)) { int data = Terrain.ExtractData(clothe); MekClothData clothingData = MekClothingBlock.GetClothingData(data); Color fabricColor = SubsystemPalette.GetFabricColor(m_subsystemTerrain, ClothingBlock.GetClothingColor(data)); texturedBatch2D = m_primitivesRenderer.TexturedBatch(clothingData.Texture, useAlphaTest: false, num++, DepthStencilState.None, null, BlendState.NonPremultiplied, SamplerState.PointClamp); if (!clothingData.IsOuter) { texturedBatch2D.QueueQuad(new Vector2(0f, 0f), new Vector2(m_innerClothedTexture.Width, m_innerClothedTexture.Height), 0f, Vector2.Zero, Vector2.One, fabricColor); } } } m_primitivesRenderer.Flush(); Display.RenderTarget = m_outerClothedTexture; Display.Clear(new Vector4(Color.Transparent)); num = 0; innerSlotsOrder = m_outerSlotsOrder; foreach (ClothingSlot slot2 in innerSlotsOrder) { foreach (int clothe2 in GetClothes(slot2)) { int data2 = Terrain.ExtractData(clothe2); ClothingData clothingData2 = ClothingBlock.GetClothingData(data2); Color fabricColor2 = SubsystemPalette.GetFabricColor(m_subsystemTerrain, ClothingBlock.GetClothingColor(data2)); texturedBatch2D = m_primitivesRenderer.TexturedBatch(clothingData2.Texture, useAlphaTest: false, num++, DepthStencilState.None, null, BlendState.NonPremultiplied, SamplerState.PointClamp); if (clothingData2.IsOuter) { texturedBatch2D.QueueQuad(new Vector2(0f, 0f), new Vector2(m_outerClothedTexture.Width, m_outerClothedTexture.Height), 0f, Vector2.Zero, Vector2.One, fabricColor2); } } } m_primitivesRenderer.Flush(); } finally { Display.RenderTarget = renderTarget; Display.ScissorRectangle = scissorRectangle; } } }
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { int data = Terrain.ExtractData(value); int clothingColor = GetClothingColor(data); MekClothData clothingData = GetClothingData(data); Matrix matrix2 = m_slotTransforms[(int)clothingData.Slot] * Matrix.CreateScale(size) * matrix; if (clothingData.IsOuter) { BlocksManager.DrawMeshBlock(primitivesRenderer, m_outerMesh, clothingData.Texture, color * SubsystemPalette.GetFabricColor(environmentData, clothingColor), 1f, ref matrix2, environmentData); } else { BlocksManager.DrawMeshBlock(primitivesRenderer, m_innerMesh, clothingData.Texture, color * SubsystemPalette.GetFabricColor(environmentData, clothingColor), 1f, ref matrix2, environmentData); } }