More layout editor improvements.

Fixed texture coordinate transformations from materials.
Window panes of all types, horizinal, around, and 1,4, and 8 frames are all supported.
Note window pane uv coordinates are very wip, and need proper flipping and transformation from the flags.
Fix bflim editor issues with filling contents.
This commit is contained in:
KillzXGaming 2019-09-16 19:56:41 -04:00
parent 42c5b22d5c
commit 1198e3de6d
13 changed files with 560 additions and 270 deletions

View file

@ -17,7 +17,7 @@ namespace LayoutBXLYT
{
switch (wrapMode)
{
case WrapMode.Clamp: return (int)TextureWrapMode.Clamp;
case WrapMode.Clamp: return (int)TextureWrapMode.ClampToEdge;
case WrapMode.Mirror: return (int)TextureWrapMode.MirroredRepeat;
case WrapMode.Repeat: return (int)TextureWrapMode.Repeat;
default: return (int)TextureWrapMode.Clamp;
@ -258,192 +258,434 @@ namespace LayoutBXLYT
BxlytToGL.DrawRectangle(pane, pane.Rectangle, TexCoords, Colors, false, effectiveAlpha);
}
//Huge thanks to layout studio for the window pane rendering code
//https://github.com/Treeki/LayoutStudio/blob/master/layoutgl/widget.cpp
//Note i still need to fix UV coordinates being flips and transformed!
public static void DrawWindowPane(BasePane pane, byte effectiveAlpha, Dictionary<string, STGenericTexture> Textures)
{
if (!Runtime.LayoutEditor.DisplayWindowPane)
return;
uint sizeX = (uint)pane.Width;
uint sizeY = (uint)pane.Height;
var window = (IWindowPane)pane;
ushort FrameRight = window.FrameElementRight;
ushort FrameLeft = window.FrameElementLeft;
ushort FrameBottom = window.FrameElementBottm;
ushort FrameTop = window.FrameElementTop;
if (FrameRight == 0) FrameRight = 1;
if (FrameLeft == 0) FrameLeft = 1;
if (FrameBottom == 0) FrameBottom = 1;
if (FrameTop == 0) FrameTop = 1;
float dX = DrawnVertexX(pane.Width, pane.originX);
float dY = DrawnVertexY(pane.Height, pane.originY);
switch (window.WindowKind)
float frameLeft = 0;
float frameRight = 0;
float frameTop = 0;
float frameBottom = 0;
switch (window.FrameCount)
{
case WindowKind.Around:
if (window.FrameCount == 1) //1 texture for all
{
var mat = window.WindowFrames[0].Material;
if (mat.TextureMaps.Length == 0)
RenderWindowContent(pane, sizeX, sizeY, window.Content, effectiveAlpha, Textures);
else
{
var texture = mat.TextureMaps[0].Name;
if (!Textures.ContainsKey(texture))
{
RenderWindowContent(pane, sizeX, sizeY, window.Content, effectiveAlpha, Textures);
case 1:
float oneW, oneH;
GetTextureSize(window.WindowFrames[0].Material, Textures, out oneW, out oneH);
frameLeft = frameRight = oneW;
frameTop = frameBottom = oneH;
break;
case 4:
case 8:
GetTextureSize(window.WindowFrames[0].Material, Textures, out frameLeft, out frameTop);
GetTextureSize(window.WindowFrames[3].Material, Textures, out frameRight, out frameBottom);
break;
}
var image = Textures[texture];
if (frameLeft == 0) frameLeft = window.FrameElementLeft;
if (frameRight == 0) frameRight = window.FrameElementRight;
if (frameTop == 0) frameTop = window.FrameElementTop;
if (frameBottom == 0) frameBottom = window.FrameElementBottm;
FrameRight = (ushort)image.Width;
FrameLeft = (ushort)image.Width;
FrameTop = (ushort)image.Height;
FrameBottom = (ushort)image.Height;
Vector2[] texCoords = new Vector2[] {
new Vector2(0, 0),
new Vector2(1, 0),
new Vector2(1, 1),
new Vector2(0, 1),
};
uint contentWidth = sizeX - (uint)FrameRight - (uint)FrameLeft;
uint contentHeight = sizeY - (uint)FrameTop - (uint)FrameBottom;
if (window.Content.TexCoords.Count > 0)
{
texCoords = new Vector2[] {
window.Content.TexCoords[0].BottomLeft.ToTKVector2(),
window.Content.TexCoords[0].BottomRight.ToTKVector2(),
window.Content.TexCoords[0].TopRight.ToTKVector2(),
window.Content.TexCoords[0].TopLeft.ToTKVector2(),
};
}
RenderWindowContent(pane,
//Setup vertex colors
Color[] colors = new Color[] {
window.Content.ColorBottomLeft.Color,
window.Content.ColorBottomRight.Color,
window.Content.ColorTopRight.Color,
window.Content.ColorTopLeft.Color,
};
float contentWidth = ((window.StretchLeft + (pane.Width - frameLeft)) - frameRight) + window.StretchRight;
float contentHeight = ((window.StretchTop + (pane.Height - frameTop)) - frameBottom) + window.StretchBottm;
if (!window.NotDrawnContent)
{
SetupShaders(window.Content.Material, Textures);
DrawQuad(dX + frameLeft - window.StretchLeft,
dY - frameTop + window.StretchTop,
contentWidth,
contentHeight,
window.Content, effectiveAlpha, Textures);
texCoords, colors);
}
// _________
//|______| |
//| | | |
//| |___|__|
//|__|______|
//Top Left
SetupShaders(mat, Textures);
mat.Shader.SetInt("flipTexture", (int)window.WindowFrames[0].TextureFlip);
CustomRectangle rect;
GL.PushMatrix();
//After the content is draw, check this
//If it's disabled, frames do not use vertex color
if (!window.UseVertexColorForAll)
{
uint pieceWidth = sizeX - FrameRight;
uint pieceHeight = FrameTop;
int pieceX = (int)-(FrameRight / 2);
int pieceY = (int)((sizeY / 2) - (pieceHeight / 2));
GL.Translate(pieceX, pieceY, 0);
rect = pane.CreateRectangle(pieceWidth, pieceHeight);
GL.Begin(PrimitiveType.Quads);
GL.MultiTexCoord2(TextureUnit.Texture0, 0, 1);
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
GL.MultiTexCoord2(TextureUnit.Texture0, pieceWidth / FrameRight, 1);
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
GL.MultiTexCoord2(TextureUnit.Texture0, pieceWidth / FrameRight, 0);
GL.Vertex2(rect.RightPoint, rect.TopPoint);
GL.MultiTexCoord2(TextureUnit.Texture0, 0, 0);
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
GL.End();
colors = new Color[] {
Color.White, Color.White,
Color.White, Color.White,
};
}
GL.PopMatrix();
//Top Right
GL.PushMatrix();
//Apply pane alpha
for (int i = 0; i < colors.Length; i++)
{
uint pieceWidth = FrameRight;
uint pieceHeight = sizeY - FrameBottom;
int pieceX = (int)((contentWidth / 2) + (pieceWidth / 2));
int pieceY = (int)(FrameBottom / 2);
GL.Translate(pieceX, pieceY, 0);
rect = pane.CreateRectangle(pieceWidth, pieceHeight);
GL.Begin(PrimitiveType.Quads);
GL.MultiTexCoord2(TextureUnit.Texture0, 0, pieceHeight / FrameBottom);
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
GL.MultiTexCoord2(TextureUnit.Texture0, 1, pieceHeight / FrameBottom);
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
GL.MultiTexCoord2(TextureUnit.Texture0, 0, 0);
GL.Vertex2(rect.RightPoint, rect.TopPoint);
GL.MultiTexCoord2(TextureUnit.Texture0, 1, 0);
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
GL.End();
uint setalpha = (uint)((colors[i].A * effectiveAlpha) / 255);
colors[i] = Color.FromArgb((int)setalpha, colors[i]);
}
GL.PopMatrix();
//Bottom Right
GL.PushMatrix();
switch (window.FrameCount)
{
uint pieceWidth = FrameLeft;
uint pieceHeight = sizeY - FrameTop;
int pieceX = (int)-((contentWidth / 2) + (pieceWidth / 2));
int pieceY = (int)-(FrameTop / 2);
GL.Translate(pieceX, pieceY, 0);
rect = pane.CreateRectangle(pieceWidth, pieceHeight);
GL.Begin(PrimitiveType.Quads);
GL.MultiTexCoord2(TextureUnit.Texture0, 0, 0);
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
GL.MultiTexCoord2(TextureUnit.Texture0, 1, 0);
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
GL.MultiTexCoord2(TextureUnit.Texture0, 1, pieceHeight / FrameTop);
GL.Vertex2(rect.RightPoint, rect.TopPoint);
GL.MultiTexCoord2(TextureUnit.Texture0, 0, pieceHeight / FrameTop);
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
GL.End();
}
GL.PopMatrix();
//Bottom Right
GL.PushMatrix();
case 1: //1 frame. 1 texture for corners (around) or sides (horizontal)
{
uint pieceWidth = sizeX - FrameLeft;
uint pieceHeight = FrameBottom;
int pieceX = (int)(FrameLeft / 2);
int pieceY = (int)(-(sizeY / 2) + (pieceHeight / 2));
var windowFrame = window.WindowFrames[0];
SetupShaders(windowFrame.Material, Textures);
GL.Translate(pieceX, pieceY, 0);
rect = pane.CreateRectangle(pieceWidth, pieceHeight);
GL.Begin(PrimitiveType.Quads);
GL.MultiTexCoord2(TextureUnit.Texture0, pieceWidth / FrameLeft, 1);
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
GL.MultiTexCoord2(TextureUnit.Texture0, 0, 1);
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
GL.MultiTexCoord2(TextureUnit.Texture0, 0, 0);
GL.Vertex2(rect.RightPoint, rect.TopPoint);
GL.MultiTexCoord2(TextureUnit.Texture0, pieceWidth / FrameLeft, 0);
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
GL.End();
}
GL.PopMatrix();
}
}
else if (window.FrameCount == 4) //4 corners with specific texture mapping
//2 sides, no corners
if (window.WindowKind == WindowKind.Horizontal ||
window.WindowKind == WindowKind.HorizontalNoContent)
{
// _________
//|______| |
//| | | |
//| |___|__|
//|__|______|
texCoords = new Vector2[]
{
new Vector2(1, 0),
new Vector2(0, 0),
new Vector2(0, 1),
new Vector2(1, 1),
};
var frame1 = window.WindowFrames[0];
var frame2 = window.WindowFrames[0];
var frame3 = window.WindowFrames[0];
var frame4 = window.WindowFrames[0];
DrawQuad(dX + frameRight + contentWidth, dY, frameRight, pane.Height, texCoords, colors);
uint contentWidth = sizeX - (uint)FrameRight - (uint)FrameLeft;
uint contentHeight = sizeY - (uint)FrameTop - (uint)FrameBottom;
texCoords = new Vector2[]
{
new Vector2(0, 0),
new Vector2(1, 0),
new Vector2(1, 1),
new Vector2(0, 1),
};
RenderWindowContent(pane,
contentWidth,
contentHeight,
window.Content, effectiveAlpha, Textures);
DrawQuad(dX, dY, frameLeft, pane.Height, texCoords, colors);
}
else if (window.WindowKind == WindowKind.Around)
{
// top left
float pieceWidth = pane.Width - frameRight;
float pieceHeight = frameTop;
texCoords = new Vector2[]
{
new Vector2(0, 0),
new Vector2((pane.Width - frameLeft) / frameLeft, 0),
new Vector2((pane.Width - frameLeft) / frameLeft, 1),
new Vector2(0, 1),
};
DrawQuad(dX, dY, pieceWidth, pieceHeight, texCoords, colors);
// top right
pieceWidth = frameRight;
pieceHeight = pane.Height - frameBottom;
texCoords = new Vector2[]
{
new Vector2(1, 0),
new Vector2(0, 0),
new Vector2(0,(pane.Height - frameTop) / frameTop),
new Vector2(1,(pane.Height - frameTop) / frameTop),
};
DrawQuad(dX + pane.Width - frameRight, dY, pieceWidth, pieceHeight, texCoords, colors);
// bottom left
pieceWidth = frameLeft;
pieceHeight = pane.Height - frameTop;
texCoords = new Vector2[]
{
new Vector2(0,(pane.Height - frameBottom) / frameBottom),
new Vector2(1,(pane.Height - frameBottom) / frameBottom),
new Vector2(1, 0),
new Vector2(0, 0),
};
DrawQuad(dX, dY - frameTop, pieceWidth, pieceHeight, texCoords, colors);
// bottom right
pieceWidth = pane.Width - frameLeft;
pieceHeight = frameBottom;
texCoords = new Vector2[]
{
new Vector2((pane.Width - frameLeft) / frameLeft, 1),
new Vector2(0, 1),
new Vector2(0, 0),
new Vector2((pane.Width - frameLeft) / frameLeft, 0),
};
DrawQuad(dX + frameLeft, dY - pane.Height + frameBottom, pieceWidth, pieceHeight, texCoords, colors);
}
}
break;
case WindowKind.Horizontal:
break;
case WindowKind.HorizontalNoContent:
//4 or more will always be around types
case 4: //4 each corner
{
var matTL = window.WindowFrames[0].Material;
var matTR = window.WindowFrames[1].Material;
var matBL = window.WindowFrames[2].Material;
var matBR = window.WindowFrames[3].Material;
if (matTL.TextureMaps.Length > 0)
{
SetupShaders(matTL, Textures);
float pieceWidth = pane.Width - frameRight;
float pieceHeight = frameTop;
texCoords = new Vector2[]
{
new Vector2(0, 0),
new Vector2((pane.Width - frameLeft) / frameLeft, 0),
new Vector2((pane.Width - frameLeft) / frameLeft, 1),
new Vector2(0, 1),
};
DrawQuad(dX, dY, pieceWidth, pieceHeight, texCoords, colors);
}
if (matTR.TextureMaps.Length > 0)
{
SetupShaders(matTR, Textures);
float pieceWidth = frameRight;
float pieceHeight = pane.Height - frameBottom;
texCoords = new Vector2[]
{
new Vector2(1, 0),
new Vector2(0, 0),
new Vector2(0,(pane.Height - frameTop) / frameTop),
new Vector2(1,(pane.Height - frameTop) / frameTop),
};
DrawQuad(dX + pane.Width - frameRight, dY, pieceWidth, pieceHeight, texCoords, colors);
}
if (matBL.TextureMaps.Length > 0)
{
SetupShaders(matBL, Textures);
float pieceWidth = frameLeft;
float pieceHeight = pane.Height - frameTop;
texCoords = new Vector2[]
{
new Vector2(0,(pane.Height - frameBottom) / frameBottom),
new Vector2(1,(pane.Height - frameBottom) / frameBottom),
new Vector2(1, 0),
new Vector2(0, 0),
};
DrawQuad(dX, dY - frameTop, pieceWidth, pieceHeight, texCoords, colors);
}
if (matBR.TextureMaps.Length > 0)
{
SetupShaders(matBR, Textures);
float pieceWidth = pane.Width - frameLeft;
float pieceHeight = frameBottom;
texCoords = new Vector2[]
{
new Vector2((pane.Width - frameLeft) / frameLeft, 1),
new Vector2(0, 1),
new Vector2(0, 0),
new Vector2((pane.Width - frameLeft) / frameLeft, 0),
};
DrawQuad(dX + frameLeft, dY - pane.Height + frameBottom, pieceWidth, pieceHeight, texCoords, colors);
}
}
break;
case 8: //4 per corner, 4 per side
{
var matTL = window.WindowFrames[0].Material;
var matTR = window.WindowFrames[1].Material;
var matBL = window.WindowFrames[2].Material;
var matBR = window.WindowFrames[3].Material;
var matT = window.WindowFrames[4].Material;
var matB = window.WindowFrames[5].Material;
var matL = window.WindowFrames[6].Material;
var matR = window.WindowFrames[7].Material;
if (matTL.TextureMaps.Length > 0)
{
SetupShaders(matTL, Textures);
DrawQuad(dX, dY, frameLeft, frameTop, texCoords, colors);
}
GL.UseProgram(0);
if (matTR.TextureMaps.Length > 0)
{
SetupShaders(matTR, Textures);
DrawQuad(dX + pane.Width - frameRight, dY, frameRight, frameTop, texCoords, colors);
}
if (matBL.TextureMaps.Length > 0)
{
SetupShaders(matBL, Textures);
DrawQuad(dX, dY - pane.Height + frameTop, frameLeft, frameBottom, texCoords, colors);
}
if (matBR.TextureMaps.Length > 0)
{
SetupShaders(matBR, Textures);
DrawQuad(dX + pane.Width - frameLeft, dY - pane.Height + frameBottom, frameRight, frameBottom, texCoords, colors);
}
if (matT.TextureMaps.Length > 0)
{
SetupShaders(matT, Textures);
texCoords = new Vector2[]
{
new Vector2(0, 0),
new Vector2((pane.Width - frameLeft) / frameLeft, 0),
new Vector2((pane.Width - frameLeft) / frameLeft, 1),
new Vector2(0, 1),
};
DrawQuad(dX + frameLeft, dY, contentWidth, frameTop, texCoords, colors);
}
if (matB.TextureMaps.Length > 0)
{
SetupShaders(matB, Textures);
texCoords = new Vector2[]
{
new Vector2((pane.Width - frameLeft) / frameLeft, 1),
new Vector2(0, 1),
new Vector2(0, 0),
new Vector2((pane.Width - frameLeft) / frameLeft, 0),
};
DrawQuad(dX + frameRight, dY - (pane.Height - frameBottom), contentWidth, frameTop, texCoords, colors);
}
if (matL.TextureMaps.Length > 0)
{
SetupShaders(matL, Textures);
texCoords = new Vector2[]
{
new Vector2(0,(pane.Height - frameTop) / frameTop),
new Vector2(1,(pane.Height - frameTop) / frameTop),
new Vector2(1, 0),
new Vector2(0, 0),
};
DrawQuad(dX, dY - frameTop, frameLeft, contentHeight, texCoords, colors);
}
if (matR.TextureMaps.Length > 0)
{
SetupShaders(matR, Textures);
texCoords = new Vector2[]
{
new Vector2(0, 0),
new Vector2(1, 0),
new Vector2(1,(pane.Height - frameBottom) / frameBottom),
new Vector2(0,(pane.Height - frameBottom) / frameBottom),
};
DrawQuad(dX + (pane.Width - frameRight), dY - frameTop, frameRight, contentHeight, texCoords, colors);
}
}
break;
}
}
private static void GetTextureSize(BxlytMaterial pane, Dictionary<string, STGenericTexture> Textures, out float width, out float height)
{
width = 0;
height = 0;
if (pane.TextureMaps.Length > 0)
{
if (Textures.ContainsKey(pane.TextureMaps[0].Name))
{
var tex = Textures[pane.TextureMaps[0].Name];
width = tex.Width;
height = tex.Height;
}
}
}
private static float DrawnVertexX(float width, OriginX originX)
{
switch (originX)
{
case OriginX.Center: return -width / 2.0f;
case OriginX.Right: return -width;
default: return 0.0f;
}
}
private static float DrawnVertexY(float height, OriginY originX)
{
switch (originX)
{
case OriginY.Center: return height / 2.0f;
case OriginY.Bottom: return height;
default: return 0.0f;
}
}
private static void DrawQuad(float x, float y, float w, float h, Vector2[] texCoords, Color[] colors)
{
GL.Disable(EnableCap.AlphaTest);
GL.Disable(EnableCap.Blend);
GL.LineWidth(0.5f);
GL.Begin(PrimitiveType.LineLoop);
GL.Color4(Color.Green);
GL.Vertex2(x, y);
GL.Vertex2(x + w, y);
GL.Vertex2(x + w, y - h);
GL.Vertex2(x, y - h);
GL.End();
GL.LineWidth(1f);
GL.Enable(EnableCap.AlphaTest);
GL.Enable(EnableCap.Blend);
GL.Begin(PrimitiveType.Quads);
GL.Color4(colors[0]);
GL.MultiTexCoord2(TextureUnit.Texture0, texCoords[0].X, texCoords[0].Y);
GL.Vertex2(x, y);
GL.Color4(colors[1]);
GL.MultiTexCoord2(TextureUnit.Texture0, texCoords[1].X, texCoords[1].Y);
GL.Vertex2(x + w, y);
GL.Color4(colors[2]);
GL.MultiTexCoord2(TextureUnit.Texture0, texCoords[2].X, texCoords[2].Y);
GL.Vertex2(x + w, y - h);
GL.Color4(colors[3]);
GL.MultiTexCoord2(TextureUnit.Texture0, texCoords[3].X, texCoords[3].Y);
GL.Vertex2(x, y - h);
GL.End();
}
enum FrameType

View file

@ -241,11 +241,6 @@ namespace LayoutBXLYT.Cafe
{
if (header != null)
{
foreach (var mat in header.GetMaterials())
{
if (mat.Shader != null)
mat.Shader.Dispose();
}
}
}
@ -926,9 +921,57 @@ namespace LayoutBXLYT.Cafe
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowContent Content { get; set; }
[TypeConverter(typeof(ExpandableObjectConverter))]
[Browsable(false)]
public List<BxlytWindowFrame> WindowFrames { get; set; }
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowFrame TopLeftFrame
{
get { return WindowFrames.Count >= 1 ? WindowFrames[0] : null; }
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowFrame TopRightFrame
{
get { return WindowFrames.Count >= 2 ? WindowFrames[1] : null; }
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowFrame BottomLeftFrame
{
get { return WindowFrames.Count >= 3 ? WindowFrames[2] : null; }
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowFrame BottomRightFrame
{
get { return WindowFrames.Count >= 4 ? WindowFrames[3] : null; }
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowFrame TopFrame
{
get { return WindowFrames.Count >= 5 ? WindowFrames[4] : null; }
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowFrame BottomFrame
{
get { return WindowFrames.Count >= 6 ? WindowFrames[5] : null; }
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowFrame LeftFrame
{
get { return WindowFrames.Count >= 7 ? WindowFrames[6] : null; }
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowFrame RightFrame
{
get { return WindowFrames.Count >= 8 ? WindowFrames[7] : null; }
}
public WND1(FileReader reader, Header header) : base(reader)
{
WindowFrames = new List<BxlytWindowFrame>();

View file

@ -28,6 +28,9 @@ namespace LayoutBXLYT
SetInt("hasTexture0", 0);
SetInt("numTextureMaps", 0);
SetInt("flipTexture", 0);
SetInt("textures0", 0);
SetInt("textures1", 0);
SetInt("textures2", 0);
SetVec2("uvScale0", new Vector2(1,1));
SetFloat("uvRotate0", 0);
@ -51,14 +54,18 @@ namespace LayoutBXLYT
if (material.TextureMaps.Length > 0)
textureMap0 = material.GetTexture(0);
if (textures.ContainsKey(textureMap0))
for (int i = 0; i < material.TextureMaps.Length; i++)
{
GL.ActiveTexture(TextureUnit.Texture0);
SetInt("textures0", 0);
bool isBinded = BxlytToGL.BindGLTexture(material.TextureMaps[0], textures[textureMap0]);
if (textures.ContainsKey(material.TextureMaps[i].Name))
{
GL.ActiveTexture(TextureUnit.Texture0 + i);
SetInt($"textures{i}", 0);
bool isBinded = BxlytToGL.BindGLTexture(material.TextureMaps[i], textures[textureMap0]);
if (isBinded)
SetInt("hasTexture0", 1);
SetInt($"hasTexture{i}", 1);
}
}
if (material.TextureTransforms.Length > 0)
{

View file

@ -4,8 +4,8 @@ namespace LayoutBXLYT.Cafe
{
public class AlphaCompare
{
public byte CompareMode;
public uint Value;
public byte CompareMode { get; set; }
public uint Value { get; set; }
public AlphaCompare(FileReader reader, BFLYT.Header header)
{

View file

@ -4,9 +4,9 @@ namespace LayoutBXLYT.Cafe
{
public class TevStage
{
byte RGBMode;
byte AlphaMode;
ushort unk;
public byte RGBMode { get; set; }
public byte AlphaMode { get; set; }
public ushort unk { get; set; }
public TevStage(FileReader reader, BFLYT.Header header)
{

View file

@ -4,8 +4,8 @@ namespace LayoutBXLYT.Cafe
{
public class TexCoordGen
{
public MatrixType GenType;
public TextureGenerationType Source;
public MatrixType GenType { get; set; }
public TextureGenerationType Source { get; set; }
byte[] unkData;

View file

@ -5,9 +5,9 @@ namespace LayoutBXLYT.Cafe
{
public class TextureTransform
{
public Vector2F Translate;
public float Rotate;
public Vector2F Scale;
public Vector2F Translate { get; set; }
public float Rotate { get; set; }
public Vector2F Scale { get; set; }
public TextureTransform() { }

View file

@ -93,7 +93,8 @@ namespace LayoutBXLYT
}
}
private void UpdateRectangle() {
private void UpdateRectangle()
{
rectangle = CreateRectangle();
}
@ -456,6 +457,7 @@ namespace LayoutBXLYT
BxlytWindowContent Content { get; set; }
[Browsable(false)]
List<BxlytWindowFrame> WindowFrames { get; set; }
}

View file

@ -74,27 +74,7 @@ namespace FirstPlugin
public ImageEditorBase OpenForm()
{
bool IsDialog = IFileInfo != null && IFileInfo.InArchive;
Properties prop = new Properties();
prop.Width = Width;
prop.Height = Height;
prop.Depth = Depth;
prop.MipCount = MipCount;
prop.ArrayCount = ArrayCount;
prop.ImageSize = (uint)ImageData.Length;
prop.Format = Format;
prop.TileMode = image.TileMode;
prop.Swizzle = image.Swizzle;
form = new ImageEditorBase();
form.Text = Text;
form.Dock = DockStyle.Fill;
form.AddFileContextEvent("Save", Save);
form.AddFileContextEvent("Replace", Replace);
form.LoadProperties(prop);
form.LoadImage(this);
return form;
}
@ -107,8 +87,7 @@ namespace FirstPlugin
public void FillEditor(UserControl control)
{
form = (ImageEditorBase)control;
UpdateForm();
UpdateForm((ImageEditorBase)control);
}
private void UpdateForm(ImageEditorBase form)
@ -126,6 +105,10 @@ namespace FirstPlugin
prop.TileMode = image.TileMode;
prop.Swizzle = image.Swizzle;
form.Text = Text;
form.Dock = DockStyle.Fill;
form.AddFileContextEvent("Save", Save);
form.AddFileContextEvent("Replace", Replace);
form.LoadProperties(prop);
form.LoadImage(this);
}
@ -606,7 +589,6 @@ namespace FirstPlugin
public void Unload()
{
form.Dispose();
}
public void Save(System.IO.Stream stream)

View file

@ -186,6 +186,13 @@ namespace LayoutBXLYT
}
else
{
/*Matrix4 translate = Matrix4.CreateTranslation(pane.Translate.X, pane.Translate.Y, 0);
Matrix4 rotateX = Matrix4.CreateRotationX(MathHelper.DegreesToRadians(pane.Rotate.X));
Matrix4 rotateY = Matrix4.CreateRotationX(MathHelper.DegreesToRadians(pane.Rotate.Y));
Matrix4 rotateZ = Matrix4.CreateRotationX(MathHelper.DegreesToRadians(pane.Rotate.Z));
Matrix4 scale = Matrix4.CreateScale(pane.Scale.X, pane.Scale.Y, 0);
Matrix4 transform = scale * (rotateX * rotateY * rotateZ) * translate;*/
GL.Translate(pane.Translate.X, pane.Translate.Y, 0);
GL.Rotate(pane.Rotate.X, 1, 0, 0);
GL.Rotate(pane.Rotate.Y, 0, 1, 0);
@ -461,7 +468,8 @@ namespace LayoutBXLYT
private void SearchHit(BasePane pane, int X, int Y, ref BasePane SelectedPane)
{
if (pane.IsHit(X, Y)){
if (pane.IsHit(X, Y))
{
SelectedPane = pane;
return;
}

View file

@ -59,7 +59,6 @@ namespace Toolbox.Library
if (format == TEX_FORMAT.L8 || format == TEX_FORMAT.LA8)
compSel = new byte[4] { 2, 2, 2, 3 };
for (int Y = 0; Y < height; Y++)
{
for (int X = 0; X < width; X++)

View file

@ -1,10 +1,17 @@
uniform vec4 blackColor;
uniform vec4 whiteColor;
uniform int hasTexture0;
uniform int debugShading;
uniform int numTextureMaps;
uniform sampler2D textures0;
uniform sampler2D textures1;
uniform sampler2D textures2;
uniform int hasTexture0;
uniform int hasTexture1;
uniform int hasTexture2;
uniform sampler2D uvTestPattern;
void main()

View file

@ -33,7 +33,7 @@ vec2 SetFlip(vec2 tex)
void main()
{
gl_FrontColor = gl_Color;
vec2 texCoord0 = uvScale0 * gl_MultiTexCoord0.xy + uvTranslate0;
vec2 texCoord0 = uvScale0 * (gl_MultiTexCoord0.xy + uvTranslate0);
gl_TexCoord[0].st = SetFlip(texCoord0);
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}