private void BaseCoatButton_Click(object sender, EventArgs e) { for (uint j = 29; j >= 1 && j <= 29; j--) //Shift all mem back one { Vertex.OriginalVertexMem[j] = Vertex.OriginalVertexMem[j - 1]; } Vertex.OriginalVertexMem[0] = new UInt32[Vertex.CurrentVertexList.Length][]; //Set up new undo level with all combos for (uint i = 0; i < Vertex.CurrentVertexList.Length; i++) { Vertex.OriginalVertexMem[0][i] = new UInt32[2]; uint currentVTX = Vertex.CurrentVertexList[i]; Vertex.OriginalVertexMem[0][i][0] = currentVTX + 12; var BinAndAddr = BinManager.AttainCorrectBin(currentVTX); Vertex.OriginalVertexMem[0][i][1] = BinAndAddr.Item1.ReadFourBytes(BinAndAddr.Item2 + 12); //Initial RGBA } byte R = (byte)Math.Round(RedNum.Value * ((decimal)Brightness.Value / 100)); byte G = (byte)Math.Round(GreenNum.Value * ((decimal)Brightness.Value / 100)); byte B = (byte)Math.Round(BlueNum.Value * ((decimal)Brightness.Value / 100)); byte A = (byte)AlphaNum.Value; UInt32 colour = (uint)((R << 24) | (G << 16) | (B << 8) | A); for (int i = 0; i < Vertex.CurrentVertexList.Length; i++) { var BinAndAddr = BinManager.AttainCorrectBin(Vertex.CurrentVertexList[i]); BinManager.SetVertRGBA(BinAndAddr.Item1, BinAndAddr.Item2, colour, AlphaOnlyCheckbox.Checked); } }
public static void EditVertex(Rectangle ClientRectangle, int Width, int Height, GLControl RenderPanel, Point pt, byte R, byte G, byte B, byte A, bool AlphaOnly) { byte[] color = new byte[4]; Renderer.RenderColourBuffer(ClientRectangle, Width, Height, RenderPanel); GL.ReadPixels(pt.X, RenderPanel.Height - pt.Y - 1, 1, 1, OpenTK.Graphics.OpenGL.PixelFormat.Rgba, PixelType.UnsignedByte, color); UInt32 Addr = (UInt32)((color[0] << 24) | (color[1] << 16) | (color[2] << 8) | color[3]); if (Addr != 0) { for (uint i = 0; i < Vertex.CurrentVertexList.Length; i++) { bool alphabin = false; if (Addr > 0x80000000) { alphabin = true; //remove the alpha addr flag } uint[] list = Vertex.CurrentVertexList; uint rawAddr = Addr & 0x7FFFFFFF; BTBinFile currentbin; if (!alphabin) { currentbin = BinManager.MainBin; } else { currentbin = BinManager.AlphaBin; } if (Addr == Vertex.CurrentVertexList[i]) { UInt32 colour = (uint)((R << 24) | (G << 16) | (B << 8) | A); if (colour == currentbin.ReadFourBytes(rawAddr + 12)) { return; //If it's the same, don't do anything } for (uint j = 29; j >= 1 && j <= 29; j--) //Shift all mem back one { Vertex.OriginalVertexMem[j] = Vertex.OriginalVertexMem[j - 1]; } Vertex.OriginalVertexMem[0] = new UInt32[1][]; //Set up new undo level with one combo Vertex.OriginalVertexMem[0][0] = new UInt32[2]; Vertex.OriginalVertexMem[0][0][0] = Addr + 12; Vertex.OriginalVertexMem[0][0][1] = currentbin.ReadFourBytes(rawAddr + 12); //Initial RGBA BinManager.SetVertRGBA(currentbin, rawAddr, colour, AlphaOnly); break; } } } }