mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-22 04:23:09 +00:00
Some adjustments
This commit is contained in:
parent
284f727e9a
commit
00a48d4b4a
8 changed files with 142 additions and 36 deletions
|
@ -20,6 +20,8 @@ namespace Toolbox.Library
|
|||
public bool RotateSkeleton = false;
|
||||
public float RotateSkeletonAmount = 90;
|
||||
|
||||
static bool isDae;
|
||||
|
||||
public Scene scene;
|
||||
|
||||
public List<STGenericObject> objects = new List<STGenericObject>();
|
||||
|
@ -73,8 +75,10 @@ namespace Toolbox.Library
|
|||
|
||||
|
||||
scene = Importer.ImportFile(FileName, settings.GetFlags());
|
||||
if (Utils.GetExtension(FileName) == ".dae")
|
||||
if (Utils.GetExtension(FileName) == ".dae") {
|
||||
GetRealNodeNames(FileName);
|
||||
isDae = true;
|
||||
}
|
||||
|
||||
STConsole.WriteLine($"UnitScale {UnitScale}");
|
||||
|
||||
|
@ -733,9 +737,9 @@ namespace Toolbox.Library
|
|||
vert.uv2 = new Vector2(msh.TextureCoordinateChannels[2][v].X, msh.TextureCoordinateChannels[2][v].Y);
|
||||
if (msh.HasTangentBasis)
|
||||
vert.tan = new Vector4(msh.Tangents[v].X, msh.Tangents[v].Y, msh.Tangents[v].Z, 1);
|
||||
if (msh.HasVertexColors(0))
|
||||
if (msh.HasVertexColors(0) && !isDae)
|
||||
vert.col = new Vector4(msh.VertexColorChannels[0][v].R, msh.VertexColorChannels[0][v].G, msh.VertexColorChannels[0][v].B, msh.VertexColorChannels[0][v].A);
|
||||
if (msh.HasVertexColors(1))
|
||||
if (msh.HasVertexColors(1) && !isDae)
|
||||
vert.col2 = new Vector4(msh.VertexColorChannels[1][v].R, msh.VertexColorChannels[1][v].G, msh.VertexColorChannels[1][v].B, msh.VertexColorChannels[1][v].A);
|
||||
if (msh.HasTangentBasis)
|
||||
vert.bitan = new Vector4(msh.BiTangents[v].X, msh.BiTangents[v].Y, msh.BiTangents[v].Z, 1);
|
||||
|
|
89
Switch_Toolbox_Library/Forms/Custom/STButtonToggle.cs
Normal file
89
Switch_Toolbox_Library/Forms/Custom/STButtonToggle.cs
Normal file
|
@ -0,0 +1,89 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Toolbox.Library.IO;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace Toolbox.Library.Forms
|
||||
{
|
||||
public class STButtonToggle : STPanel
|
||||
{
|
||||
private bool check;
|
||||
public bool Checked
|
||||
{
|
||||
get { return check; }
|
||||
set {
|
||||
check = value;
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public string PropertyText { get; set; }
|
||||
|
||||
public Color BtnBackColor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Checked)
|
||||
return FormThemes.BaseTheme.CheckBoxEnabledBackColor;
|
||||
else
|
||||
return FormThemes.BaseTheme.CheckBoxBackColor;
|
||||
}
|
||||
}
|
||||
|
||||
public Color BtnForeColor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Checked)
|
||||
return FormThemes.BaseTheme.FormForeColor;
|
||||
else
|
||||
return FormThemes.BaseTheme.DisabledItemColor;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
|
||||
Rectangle r = e.ClipRectangle;
|
||||
if (r.Width <= 0 || r.Height <= 0)
|
||||
return;
|
||||
|
||||
Color c1 = BtnBackColor;
|
||||
Color c2 = BtnBackColor.Darken(20);
|
||||
LinearGradientBrush br = new LinearGradientBrush(r, c1, c2, 90, true);
|
||||
|
||||
ColorBlend cb = new ColorBlend();
|
||||
cb.Positions = new[] { 0.0f, 1.0f };
|
||||
cb.Colors = new[] { c1, c2 };
|
||||
br.InterpolationColors = cb;
|
||||
|
||||
SolidBrush br2 = new SolidBrush(BtnForeColor);
|
||||
|
||||
int tx2 = ClientSize.Width / 2;
|
||||
int ty2 = ClientSize.Height / 2 - 6;
|
||||
|
||||
e.Graphics.FillRectangle(br, r);
|
||||
|
||||
StringFormat sf = new StringFormat();
|
||||
sf.LineAlignment = StringAlignment.Center;
|
||||
sf.Alignment = StringAlignment.Center;
|
||||
e.Graphics.DrawString(PropertyText, this.Font, br2, ClientRectangle, sf);
|
||||
}
|
||||
|
||||
protected override void OnMouseClick(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseClick(e);
|
||||
|
||||
if (Checked)
|
||||
Checked = false;
|
||||
else
|
||||
Checked = true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -60,6 +60,11 @@ namespace Toolbox.Library
|
|||
return col;
|
||||
}
|
||||
|
||||
public OpenTK.Vector4 ToVector4()
|
||||
{
|
||||
return new OpenTK.Vector4(R,G,B,A);
|
||||
}
|
||||
|
||||
public STColor(Color color)
|
||||
{
|
||||
R = color.R / 255f;
|
||||
|
|
|
@ -76,6 +76,8 @@ namespace Toolbox.Library.IO
|
|||
if (fileFormat.Identify(stream) && fileFormat.GetType() == type)
|
||||
{
|
||||
fileFormat.IFileInfo = new IFileInfo();
|
||||
fileFormat.FileName = Path.GetFileName(FileName);
|
||||
fileFormat.FilePath = FileName;
|
||||
return OpenFileFormat(stream, FileName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ namespace Toolbox.Library
|
|||
else
|
||||
{
|
||||
return STFileLoader.OpenFileFormat(new MemoryStream(FileData),
|
||||
IOExtensions.RemoveIllegaleFolderNameCharacters( FileName), false, true);
|
||||
IOExtensions.RemoveIllegaleFolderNameCharacters(FileName), false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1142,6 +1142,40 @@ namespace Toolbox.Library
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static Tuple<List<byte[]>, ushort[]> GenerateMipList(byte[] uncompressedData, uint TexWidth, uint TexHeight,
|
||||
uint MipCount, TextureFormats Format, PaletteFormats PaletteFormat)
|
||||
{
|
||||
Bitmap Image = BitmapExtension.GetBitmap(uncompressedData, (int)TexWidth, (int)TexHeight);
|
||||
return GenerateMipList(Image, TexWidth, TexHeight, MipCount, Format, PaletteFormat);
|
||||
}
|
||||
|
||||
public static Tuple<List<byte[]>, ushort[]> GenerateMipList(Bitmap Image, uint TexWidth, uint TexHeight,
|
||||
uint MipCount, TextureFormats Format, PaletteFormats PaletteFormat)
|
||||
{
|
||||
ushort[] paletteData = new ushort[0];
|
||||
|
||||
List<byte[]> mipmaps = new List<byte[]>();
|
||||
for (int mipLevel = 0; mipLevel < MipCount; mipLevel++)
|
||||
{
|
||||
int MipWidth = Math.Max(1, (int)TexWidth >> mipLevel);
|
||||
int MipHeight = Math.Max(1, (int)TexHeight >> mipLevel);
|
||||
|
||||
if (mipLevel != 0)
|
||||
Image = BitmapExtension.Resize(Image, MipWidth, MipHeight);
|
||||
|
||||
var EncodedData = Decode_Gamecube.EncodeData(BitmapExtension.ImageToByte(Image), Format, PaletteFormat, MipWidth, MipHeight);
|
||||
|
||||
mipmaps.Add(EncodedData.Item1);
|
||||
|
||||
if (mipLevel == 0) //Set palette data once
|
||||
paletteData = EncodedData.Item2;
|
||||
}
|
||||
Image.Dispose();
|
||||
|
||||
return Tuple.Create(mipmaps, paletteData);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -296,6 +296,9 @@
|
|||
<Compile Include="Forms\Color\VertexColorTopBottomBox.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\Custom\STButtonToggle.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\Custom\ComboBox\ImagedComboBox.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
|
|
|
@ -43,39 +43,8 @@ vec3 CalculateIrradiance()
|
|||
);
|
||||
}
|
||||
|
||||
vec3 aglSH2Rgb( vec3 normal,
|
||||
vec4 sh00,
|
||||
vec4 sh01,
|
||||
vec4 sh02,
|
||||
vec4 sh10,
|
||||
vec4 sh11,
|
||||
vec4 sh12,
|
||||
vec4 sh2 )
|
||||
{
|
||||
vec4 normal4 = vec4( normal.x, normal.y, normal.z, 1.0 );
|
||||
|
||||
vec3 x0;
|
||||
x0.r = dot( sh00, normal4 );
|
||||
x0.g = dot( sh01, normal4 );
|
||||
x0.b = dot( sh02, normal4 );
|
||||
|
||||
vec4 v_b = normal4.xyzz * normal4.yzzx;
|
||||
vec3 x1;
|
||||
x1.r = dot( sh10, v_b );
|
||||
x1.g = dot( sh11, v_b );
|
||||
x1.b = dot( sh12, v_b );
|
||||
|
||||
float v_c = normal4.x * normal4.x - normal4.y * normal4.y;
|
||||
vec3 x2 = sh2.rgb * v_c;
|
||||
|
||||
return max( ( x0 + x1 + x2 ), 0.0 );
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 irr = aglSH2Rgb(vec3(1,1,1),
|
||||
coefficent0,coefficent1,coefficent2,
|
||||
coefficent3,coefficent4,coefficent5,coefficent6);
|
||||
// irr = CalculateIrradiance();
|
||||
vec3 irr = CalculateIrradiance();
|
||||
FragColor = vec4(irr, 1.0);
|
||||
}
|
Loading…
Reference in a new issue