Rework ptcl color handling so it works better
This commit is contained in:
parent
f70a18c3f8
commit
dd273d88ed
@ -1010,42 +1010,26 @@ namespace FirstPlugin
|
||||
|
||||
public class Emitter : TreeNodeCustom
|
||||
{
|
||||
public Color[] Color0s = new Color[8];
|
||||
public Color[] Color1s = new Color[8];
|
||||
public List<STGenericTexture> DrawableTex = new List<STGenericTexture>();
|
||||
public List<SamplerInfo> Samplers = new List<SamplerInfo>();
|
||||
public ColorData[] Color0Array = new ColorData[8];
|
||||
public ColorData[] Color1Array = new ColorData[8];
|
||||
|
||||
public class ColorData
|
||||
{
|
||||
public float R;
|
||||
public float G;
|
||||
public float B;
|
||||
public float A;
|
||||
}
|
||||
public STColor[] Color0Array = new STColor[8];
|
||||
public STColor[] Color1Array = new STColor[8];
|
||||
|
||||
public void Read(FileReader reader, Header ptclHeader)
|
||||
{
|
||||
uint Position = (uint)reader.Position;
|
||||
|
||||
Color0Array = new ColorData[8];
|
||||
Color1Array = new ColorData[8];
|
||||
Color0Array = new STColor[8];
|
||||
Color1Array = new STColor[8];
|
||||
|
||||
reader.Seek(Position + 880, SeekOrigin.Begin);
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
Color0Array[i] = new ColorData();
|
||||
Color0Array[i] = new STColor();
|
||||
Color0Array[i].R = reader.ReadSingle();
|
||||
Color0Array[i].G = reader.ReadSingle();
|
||||
Color0Array[i].B = reader.ReadSingle();
|
||||
float time = reader.ReadSingle();
|
||||
|
||||
int red = Utils.FloatToIntClamp(Color0Array[i].R);
|
||||
int green = Utils.FloatToIntClamp(Color0Array[i].G);
|
||||
int blue = Utils.FloatToIntClamp(Color0Array[i].B);
|
||||
|
||||
Color0s[i] = Color.FromArgb(255, red, green, blue);
|
||||
}
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
@ -1053,22 +1037,14 @@ namespace FirstPlugin
|
||||
float padding = reader.ReadSingle();
|
||||
float padding2 = reader.ReadSingle();
|
||||
float time = reader.ReadSingle();
|
||||
|
||||
int alpha = Utils.FloatToIntClamp(Color0Array[i].A);
|
||||
}
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
Color1Array[i] = new ColorData();
|
||||
Color1Array[i] = new STColor();
|
||||
Color1Array[i].R = reader.ReadSingle();
|
||||
Color1Array[i].G = reader.ReadSingle();
|
||||
Color1Array[i].B = reader.ReadSingle();
|
||||
float time = reader.ReadSingle();
|
||||
|
||||
int red = Utils.FloatToIntClamp(Color1Array[i].R);
|
||||
int green = Utils.FloatToIntClamp(Color1Array[i].G);
|
||||
int blue = Utils.FloatToIntClamp(Color1Array[i].B);
|
||||
|
||||
Color1s[i] = Color.FromArgb(255, red, green, blue);
|
||||
}
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
@ -1143,7 +1119,7 @@ namespace FirstPlugin
|
||||
{
|
||||
|
||||
}
|
||||
float R = reader.ReadSingle();
|
||||
float R = reader.ReadSingle();
|
||||
float G = reader.ReadSingle();
|
||||
float B = reader.ReadSingle();
|
||||
float A = reader.ReadSingle();
|
||||
|
@ -283,41 +283,21 @@ namespace FirstPlugin
|
||||
ColorPosition = reader.Position;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
ColorData clr = new ColorData();
|
||||
STColor clr = new STColor();
|
||||
clr.R = reader.ReadSingle();
|
||||
clr.G = reader.ReadSingle();
|
||||
clr.B = reader.ReadSingle();
|
||||
clr.A = reader.ReadSingle();
|
||||
Color0Array[i] = clr;
|
||||
|
||||
int red = Utils.FloatToIntClamp(clr.R);
|
||||
int green = Utils.FloatToIntClamp(clr.G);
|
||||
int blue = Utils.FloatToIntClamp(clr.B);
|
||||
int alpha = Utils.FloatToIntClamp(clr.A);
|
||||
|
||||
// Console.WriteLine($"Color0 {i} R {R} G {G} B {B} A {A}");
|
||||
// Console.WriteLine($"Color0 {i} R {red} G {green} B {blue} A {alpha}");
|
||||
|
||||
Color0s[i] = Color.FromArgb(alpha, red, green, blue);
|
||||
}
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
ColorData clr = new ColorData();
|
||||
STColor clr = new STColor();
|
||||
clr.R = reader.ReadSingle();
|
||||
clr.G = reader.ReadSingle();
|
||||
clr.B = reader.ReadSingle();
|
||||
clr.A = reader.ReadSingle();
|
||||
Color1Array[i] = clr;
|
||||
|
||||
int red = Utils.FloatToIntClamp(clr.R);
|
||||
int green = Utils.FloatToIntClamp(clr.G);
|
||||
int blue = Utils.FloatToIntClamp(clr.B);
|
||||
int alpha = Utils.FloatToIntClamp(clr.A);
|
||||
|
||||
// Console.WriteLine($"Color1 {i} R {R} G {G} B {B} A {A}");
|
||||
// Console.WriteLine($"Color1 {i} R {red} G {green} B {blue} A {alpha}");
|
||||
|
||||
Color1s[i] = Color.FromArgb(alpha, red, green, blue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,41 +262,21 @@ namespace FirstPlugin
|
||||
ColorPosition = reader.Position;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
ColorData clr = new ColorData();
|
||||
STColor clr = new STColor();
|
||||
clr.R = reader.ReadSingle();
|
||||
clr.G = reader.ReadSingle();
|
||||
clr.B = reader.ReadSingle();
|
||||
clr.A = reader.ReadSingle();
|
||||
Color0Array[i] = clr;
|
||||
|
||||
int red = Utils.FloatToIntClamp(clr.R);
|
||||
int green = Utils.FloatToIntClamp(clr.G);
|
||||
int blue = Utils.FloatToIntClamp(clr.B);
|
||||
int alpha = Utils.FloatToIntClamp(clr.A);
|
||||
|
||||
// Console.WriteLine($"Color0 {i} R {R} G {G} B {B} A {A}");
|
||||
// Console.WriteLine($"Color0 {i} R {red} G {green} B {blue} A {alpha}");
|
||||
|
||||
Color0s[i] = Color.FromArgb(alpha, red, green, blue);
|
||||
}
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
ColorData clr = new ColorData();
|
||||
STColor clr = new STColor();
|
||||
clr.R = reader.ReadSingle();
|
||||
clr.G = reader.ReadSingle();
|
||||
clr.B = reader.ReadSingle();
|
||||
clr.A = reader.ReadSingle();
|
||||
Color1Array[i] = clr;
|
||||
|
||||
int red = Utils.FloatToIntClamp(clr.R);
|
||||
int green = Utils.FloatToIntClamp(clr.G);
|
||||
int blue = Utils.FloatToIntClamp(clr.B);
|
||||
int alpha = Utils.FloatToIntClamp(clr.A);
|
||||
|
||||
// Console.WriteLine($"Color1 {i} R {R} G {G} B {B} A {A}");
|
||||
// Console.WriteLine($"Color1 {i} R {red} G {green} B {blue} A {alpha}");
|
||||
|
||||
Color1s[i] = Color.FromArgb(alpha, red, green, blue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,41 +103,41 @@ namespace FirstPlugin
|
||||
{
|
||||
IsColorsLoaded = false;
|
||||
|
||||
color0Index0.BackColor = Emitter.Color0s[0];
|
||||
color0Index1.BackColor = Emitter.Color0s[1];
|
||||
color0Index2.BackColor = Emitter.Color0s[2];
|
||||
color0Index3.BackColor = Emitter.Color0s[3];
|
||||
color0Index4.BackColor = Emitter.Color0s[4];
|
||||
color0Index5.BackColor = Emitter.Color0s[5];
|
||||
color0Index6.BackColor = Emitter.Color0s[6];
|
||||
color0Index7.BackColor = Emitter.Color0s[7];
|
||||
color0Index0.BackColor = Emitter.Color0Array[0].Color;
|
||||
color0Index1.BackColor = Emitter.Color0Array[1].Color;
|
||||
color0Index2.BackColor = Emitter.Color0Array[2].Color;
|
||||
color0Index3.BackColor = Emitter.Color0Array[3].Color;
|
||||
color0Index4.BackColor = Emitter.Color0Array[4].Color;
|
||||
color0Index5.BackColor = Emitter.Color0Array[5].Color;
|
||||
color0Index6.BackColor = Emitter.Color0Array[6].Color;
|
||||
color0Index7.BackColor = Emitter.Color0Array[7].Color;
|
||||
|
||||
|
||||
color1Index0.BackColor = Emitter.Color1s[0];
|
||||
color1Index1.BackColor = Emitter.Color1s[1];
|
||||
color1Index2.BackColor = Emitter.Color1s[2];
|
||||
color1Index3.BackColor = Emitter.Color1s[3];
|
||||
color1Index4.BackColor = Emitter.Color1s[4];
|
||||
color1Index5.BackColor = Emitter.Color1s[5];
|
||||
color1Index6.BackColor = Emitter.Color1s[6];
|
||||
color1Index7.BackColor = Emitter.Color1s[7];
|
||||
color1Index0.BackColor = Emitter.Color1Array[0].Color;
|
||||
color1Index1.BackColor = Emitter.Color1Array[1].Color;
|
||||
color1Index2.BackColor = Emitter.Color1Array[2].Color;
|
||||
color1Index3.BackColor = Emitter.Color1Array[3].Color;
|
||||
color1Index4.BackColor = Emitter.Color1Array[4].Color;
|
||||
color1Index5.BackColor = Emitter.Color1Array[5].Color;
|
||||
color1Index6.BackColor = Emitter.Color1Array[6].Color;
|
||||
color1Index7.BackColor = Emitter.Color1Array[7].Color;
|
||||
|
||||
color0TB.Text = Utils.ColorToHex(Emitter.Color0s[0]);
|
||||
color0TB2.Text = Utils.ColorToHex(Emitter.Color0s[1]);
|
||||
color0TB3.Text = Utils.ColorToHex(Emitter.Color0s[2]);
|
||||
color0TB4.Text = Utils.ColorToHex(Emitter.Color0s[3]);
|
||||
color0TB5.Text = Utils.ColorToHex(Emitter.Color0s[4]);
|
||||
color0TB6.Text = Utils.ColorToHex(Emitter.Color0s[5]);
|
||||
color0TB7.Text = Utils.ColorToHex(Emitter.Color0s[6]);
|
||||
color0TB8.Text = Utils.ColorToHex(Emitter.Color0s[7]);
|
||||
color1TB.Text = Utils.ColorToHex(Emitter.Color1s[0]);
|
||||
color1TB2.Text = Utils.ColorToHex(Emitter.Color1s[1]);
|
||||
color1TB3.Text = Utils.ColorToHex(Emitter.Color1s[2]);
|
||||
color1TB4.Text = Utils.ColorToHex(Emitter.Color1s[3]);
|
||||
color1TB5.Text = Utils.ColorToHex(Emitter.Color1s[4]);
|
||||
color1TB6.Text = Utils.ColorToHex(Emitter.Color1s[5]);
|
||||
color1TB7.Text = Utils.ColorToHex(Emitter.Color1s[6]);
|
||||
color1TB8.Text = Utils.ColorToHex(Emitter.Color1s[7]);
|
||||
color0TB.Text = Utils.ColorToHex(Emitter.Color0Array[0].Color);
|
||||
color0TB2.Text = Utils.ColorToHex(Emitter.Color0Array[1].Color);
|
||||
color0TB3.Text = Utils.ColorToHex(Emitter.Color0Array[2].Color);
|
||||
color0TB4.Text = Utils.ColorToHex(Emitter.Color0Array[3].Color);
|
||||
color0TB5.Text = Utils.ColorToHex(Emitter.Color0Array[4].Color);
|
||||
color0TB6.Text = Utils.ColorToHex(Emitter.Color0Array[5].Color);
|
||||
color0TB7.Text = Utils.ColorToHex(Emitter.Color0Array[6].Color);
|
||||
color0TB8.Text = Utils.ColorToHex(Emitter.Color0Array[7].Color);
|
||||
color1TB.Text = Utils.ColorToHex(Emitter.Color1Array[0].Color);
|
||||
color1TB2.Text = Utils.ColorToHex(Emitter.Color1Array[1].Color);
|
||||
color1TB3.Text = Utils.ColorToHex(Emitter.Color1Array[2].Color);
|
||||
color1TB4.Text = Utils.ColorToHex(Emitter.Color1Array[3].Color);
|
||||
color1TB5.Text = Utils.ColorToHex(Emitter.Color1Array[4].Color);
|
||||
color1TB6.Text = Utils.ColorToHex(Emitter.Color1Array[5].Color);
|
||||
color1TB7.Text = Utils.ColorToHex(Emitter.Color1Array[6].Color);
|
||||
color1TB8.Text = Utils.ColorToHex(Emitter.Color1Array[7].Color);
|
||||
|
||||
IsColorsLoaded = true;
|
||||
}
|
||||
@ -185,21 +185,9 @@ namespace FirstPlugin
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (button.Name.Contains("color0"))
|
||||
{
|
||||
ActiveEmitter.Color0Array[index].R = (float)dialog.Color.R / 255;
|
||||
ActiveEmitter.Color0Array[index].G = (float)dialog.Color.G / 255;
|
||||
ActiveEmitter.Color0Array[index].B = (float)dialog.Color.B / 255;
|
||||
ActiveEmitter.Color0Array[index].A = (float)dialog.Color.A / 255;
|
||||
ActiveEmitter.Color0s[index] = dialog.Color;
|
||||
}
|
||||
ActiveEmitter.Color0Array[index].Color = dialog.Color;
|
||||
else
|
||||
{
|
||||
ActiveEmitter.Color1Array[index].R = (float)dialog.Color.R / 255;
|
||||
ActiveEmitter.Color1Array[index].G = (float)dialog.Color.G / 255;
|
||||
ActiveEmitter.Color1Array[index].B = (float)dialog.Color.B / 255;
|
||||
ActiveEmitter.Color1Array[index].A = (float)dialog.Color.A / 255;
|
||||
ActiveEmitter.Color1s[index] = dialog.Color;
|
||||
}
|
||||
ActiveEmitter.Color1Array[index].Color = dialog.Color;
|
||||
|
||||
button.BackColor = dialog.Color;
|
||||
}
|
||||
@ -222,26 +210,23 @@ namespace FirstPlugin
|
||||
Color[] colors0 = new Color[8];
|
||||
Color[] colors1 = new Color[8];
|
||||
|
||||
colors0[0] = Utils.HexToColor(color0TB.Text);
|
||||
colors0[1] = Utils.HexToColor(color0TB2.Text);
|
||||
colors0[2] = Utils.HexToColor(color0TB3.Text);
|
||||
colors0[3] = Utils.HexToColor(color0TB4.Text);
|
||||
colors0[4] = Utils.HexToColor(color0TB5.Text);
|
||||
colors0[5] = Utils.HexToColor(color0TB6.Text);
|
||||
colors0[6] = Utils.HexToColor(color0TB7.Text);
|
||||
colors0[7] = Utils.HexToColor(color0TB8.Text);
|
||||
ActiveEmitter.Color0Array[0].Color = Utils.HexToColor(color0TB.Text);
|
||||
ActiveEmitter.Color0Array[1].Color = Utils.HexToColor(color0TB2.Text);
|
||||
ActiveEmitter.Color0Array[2].Color = Utils.HexToColor(color0TB3.Text);
|
||||
ActiveEmitter.Color0Array[3].Color = Utils.HexToColor(color0TB4.Text);
|
||||
ActiveEmitter.Color0Array[4].Color = Utils.HexToColor(color0TB5.Text);
|
||||
ActiveEmitter.Color0Array[5].Color = Utils.HexToColor(color0TB6.Text);
|
||||
ActiveEmitter.Color0Array[6].Color = Utils.HexToColor(color0TB7.Text);
|
||||
ActiveEmitter.Color0Array[7].Color = Utils.HexToColor(color0TB8.Text);
|
||||
|
||||
colors1[0] = Utils.HexToColor(color1TB.Text);
|
||||
colors1[1] = Utils.HexToColor(color1TB2.Text);
|
||||
colors1[2] = Utils.HexToColor(color1TB3.Text);
|
||||
colors1[3] = Utils.HexToColor(color1TB4.Text);
|
||||
colors1[4] = Utils.HexToColor(color1TB5.Text);
|
||||
colors1[5] = Utils.HexToColor(color1TB6.Text);
|
||||
colors1[6] = Utils.HexToColor(color1TB7.Text);
|
||||
colors1[7] = Utils.HexToColor(color1TB8.Text);
|
||||
|
||||
ActiveEmitter.Color0s = colors0;
|
||||
ActiveEmitter.Color1s = colors1;
|
||||
ActiveEmitter.Color1Array[0].Color = Utils.HexToColor(color1TB.Text);
|
||||
ActiveEmitter.Color1Array[1].Color = Utils.HexToColor(color1TB2.Text);
|
||||
ActiveEmitter.Color1Array[2].Color = Utils.HexToColor(color1TB3.Text);
|
||||
ActiveEmitter.Color1Array[3].Color = Utils.HexToColor(color1TB4.Text);
|
||||
ActiveEmitter.Color1Array[4].Color = Utils.HexToColor(color1TB5.Text);
|
||||
ActiveEmitter.Color1Array[5].Color = Utils.HexToColor(color1TB6.Text);
|
||||
ActiveEmitter.Color1Array[6].Color = Utils.HexToColor(color1TB7.Text);
|
||||
ActiveEmitter.Color1Array[7].Color = Utils.HexToColor(color1TB8.Text);
|
||||
|
||||
LoadColors(ActiveEmitter);
|
||||
}
|
||||
|
48
Switch_Toolbox_Library/IO/STColor.cs
Normal file
48
Switch_Toolbox_Library/IO/STColor.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Toolbox.Library
|
||||
{
|
||||
//Class that contains colors and useful color related methods
|
||||
public class STColor
|
||||
{
|
||||
public float R { get; set; }
|
||||
public float G { get; set; }
|
||||
public float B { get; set; }
|
||||
public float A { get; set; }
|
||||
|
||||
public Color Color
|
||||
{
|
||||
get
|
||||
{
|
||||
int red = Utils.FloatToIntClamp(R);
|
||||
int green = Utils.FloatToIntClamp(G);
|
||||
int blue = Utils.FloatToIntClamp(B);
|
||||
int alpha = Utils.FloatToIntClamp(A);
|
||||
|
||||
return Color.FromArgb(alpha, red, green, blue);
|
||||
}
|
||||
set
|
||||
{
|
||||
var color = value;
|
||||
R = color.R / 255f;
|
||||
G = color.G / 255f;
|
||||
B = color.B / 255f;
|
||||
A = color.A / 255f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public STColor()
|
||||
{
|
||||
R = 1;
|
||||
G = 1;
|
||||
B = 1;
|
||||
A = 1;
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -237,6 +237,7 @@
|
||||
<Compile Include="Interfaces\IMeshContainer.cs" />
|
||||
<Compile Include="Interfaces\ITextureContainer.cs" />
|
||||
<Compile Include="IO\Extensions\UintExtension.cs" />
|
||||
<Compile Include="IO\STColor.cs" />
|
||||
<Compile Include="Rendering\GenericModelRenderer\GenericModelRenderer.cs" />
|
||||
<Compile Include="Rendering\GenericModelRenderer\GenericRenderedObject.cs" />
|
||||
<Compile Include="Security\Cryptography\crc32.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user