Adjust the vertex color view to clamp values above 255
This commit is contained in:
parent
976c214799
commit
ba6fef722d
Binary file not shown.
@ -7,6 +7,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Toolbox.Library;
|
||||
using OpenTK;
|
||||
|
||||
namespace FirstPlugin
|
||||
@ -48,16 +49,11 @@ namespace FirstPlugin
|
||||
{
|
||||
Color SetColor = Color.White;
|
||||
|
||||
int someIntX = (int)Math.Ceiling(value.X * 255);
|
||||
int someIntY = (int)Math.Ceiling(value.Y * 255);
|
||||
int someIntZ = (int)Math.Ceiling(value.Z * 255);
|
||||
int someIntW = (int)Math.Ceiling(value.W * 255);
|
||||
|
||||
SetColor = Color.FromArgb(
|
||||
255,
|
||||
someIntX,
|
||||
someIntY,
|
||||
someIntZ
|
||||
Utils.FloatToIntClamp(value.X),
|
||||
Utils.FloatToIntClamp(value.Y),
|
||||
Utils.FloatToIntClamp(value.Z)
|
||||
);
|
||||
|
||||
columnHeader2.Text = "R";
|
||||
|
@ -545,6 +545,9 @@ namespace Toolbox.Library
|
||||
Width = header.width;
|
||||
Height = header.height;
|
||||
MipCount = header.mipmapCount;
|
||||
Depth = header.depth;
|
||||
if (Depth == 0)
|
||||
Depth = 1;
|
||||
|
||||
byte[] Components = new byte[4] { 0, 1, 2, 3 };
|
||||
|
||||
@ -897,37 +900,40 @@ namespace Toolbox.Library
|
||||
return surfaces;
|
||||
}
|
||||
|
||||
public void SetArrayLevel(byte[] data, int ArrayIndex)
|
||||
public void SetArrayLevel(byte[] data, int ArrayIndex, int DepthIndex = 0)
|
||||
{
|
||||
uint formatSize = GetBytesPerPixel(Format);
|
||||
|
||||
uint Offset = 0;
|
||||
for (byte i = 0; i < ArrayCount; ++i)
|
||||
for (byte d = 0; d < Depth; ++d)
|
||||
{
|
||||
if (i == ArrayIndex)
|
||||
for (byte i = 0; i < ArrayCount; ++i)
|
||||
{
|
||||
Array.Copy(data, 0, bdata, Offset, data.Length);
|
||||
}
|
||||
|
||||
uint MipWidth = Width, MipHeight = Height;
|
||||
for (int j = 0; j < MipCount; ++j)
|
||||
{
|
||||
MipWidth = (uint)Math.Max(1, Width >> j);
|
||||
MipHeight = (uint)Math.Max(1, Height >> j);
|
||||
|
||||
uint size = (MipWidth * MipHeight); //Total pixels
|
||||
if (IsCompressed(Format))
|
||||
if (i == ArrayIndex)
|
||||
{
|
||||
size = ((MipWidth + 3) >> 2) * ((MipHeight + 3) >> 2) * formatSize;
|
||||
if (size < formatSize)
|
||||
size = formatSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
size = (uint)(size * GetBytesPerPixel(Format)); //Bytes per pixel
|
||||
Array.Copy(data, 0, bdata, Offset, data.Length);
|
||||
}
|
||||
|
||||
Offset += size;
|
||||
uint MipWidth = Width, MipHeight = Height;
|
||||
for (int j = 0; j < MipCount; ++j)
|
||||
{
|
||||
MipWidth = (uint)Math.Max(1, Width >> j);
|
||||
MipHeight = (uint)Math.Max(1, Height >> j);
|
||||
|
||||
uint size = (MipWidth * MipHeight); //Total pixels
|
||||
if (IsCompressed(Format))
|
||||
{
|
||||
size = ((MipWidth + 3) >> 2) * ((MipHeight + 3) >> 2) * formatSize;
|
||||
if (size < formatSize)
|
||||
size = formatSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
size = (uint)(size * GetBytesPerPixel(Format)); //Bytes per pixel
|
||||
}
|
||||
|
||||
Offset += size;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -941,32 +947,35 @@ namespace Toolbox.Library
|
||||
uint formatSize = GetBytesPerPixel(tex.Format);
|
||||
|
||||
uint Offset = 0;
|
||||
for (byte i = 0; i < Length; ++i)
|
||||
for (byte d = 0; d < tex.Depth; ++d)
|
||||
{
|
||||
var Surface = new STGenericTexture.Surface();
|
||||
|
||||
uint MipWidth = tex.Width, MipHeight = tex.Height;
|
||||
for (int j = 0; j < tex.MipCount; ++j)
|
||||
for (byte i = 0; i < Length; ++i)
|
||||
{
|
||||
MipWidth = (uint)Math.Max(1, tex.Width >> j);
|
||||
MipHeight = (uint)Math.Max(1, tex.Height >> j);
|
||||
var Surface = new STGenericTexture.Surface();
|
||||
|
||||
uint size = (MipWidth * MipHeight); //Total pixels
|
||||
if (IsCompressed(tex.Format))
|
||||
uint MipWidth = tex.Width, MipHeight = tex.Height;
|
||||
for (int j = 0; j < tex.MipCount; ++j)
|
||||
{
|
||||
size = ((MipWidth + 3) >> 2) * ((MipHeight + 3) >> 2) * formatSize;
|
||||
if (size < formatSize)
|
||||
size = formatSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
size = (uint)(size * GetBytesPerPixel(tex.Format)); //Bytes per pixel
|
||||
}
|
||||
MipWidth = (uint)Math.Max(1, tex.Width >> j);
|
||||
MipHeight = (uint)Math.Max(1, tex.Height >> j);
|
||||
|
||||
Surface.mipmaps.Add(reader.getSection((int)Offset, (int)size));
|
||||
Offset += size;
|
||||
uint size = (MipWidth * MipHeight); //Total pixels
|
||||
if (IsCompressed(tex.Format))
|
||||
{
|
||||
size = ((MipWidth + 3) >> 2) * ((MipHeight + 3) >> 2) * formatSize;
|
||||
if (size < formatSize)
|
||||
size = formatSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
size = (uint)(size * GetBytesPerPixel(tex.Format)); //Bytes per pixel
|
||||
}
|
||||
|
||||
Surface.mipmaps.Add(reader.getSection((int)Offset, (int)size));
|
||||
Offset += size;
|
||||
}
|
||||
Surfaces.Add(Surface);
|
||||
}
|
||||
Surfaces.Add(Surface);
|
||||
}
|
||||
|
||||
return Surfaces;
|
||||
|
@ -1073,18 +1073,18 @@ namespace Toolbox.Library
|
||||
[Category("Image Info")]
|
||||
public uint Width { get; set; }
|
||||
|
||||
[Browsable(true)]
|
||||
[ReadOnly(true)]
|
||||
[Description("Format of the image.")]
|
||||
[Category("Image Info")]
|
||||
public TEX_FORMAT Format { get; set; }
|
||||
|
||||
[Browsable(true)]
|
||||
[ReadOnly(true)]
|
||||
[Description("Depth of the image (3D type).")]
|
||||
[Category("Image Info")]
|
||||
public uint Depth { get; set; }
|
||||
|
||||
[Browsable(true)]
|
||||
[ReadOnly(true)]
|
||||
[Description("Format of the image.")]
|
||||
[Category("Image Info")]
|
||||
public TEX_FORMAT Format { get; set; }
|
||||
|
||||
[Browsable(true)]
|
||||
[ReadOnly(true)]
|
||||
[Description("Mip map count of the image.")]
|
||||
|
Loading…
x
Reference in New Issue
Block a user