KCL cleanup
This commit is contained in:
parent
9df93a02af
commit
e0dc6bd12d
@ -7,13 +7,10 @@ using GL_EditorFramework.Interfaces;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using OpenTK;
|
||||
using Toolbox.Library.Rendering;
|
||||
using GL_EditorFramework.GL_Core;
|
||||
using System.Drawing;
|
||||
using Toolbox.Library.IO;
|
||||
using Toolbox.Library.Forms;
|
||||
using GL_EditorFramework.EditorDrawables;
|
||||
using FirstPlugin.Forms;
|
||||
using static GL_EditorFramework.EditorDrawables.EditorSceneBase;
|
||||
|
||||
namespace FirstPlugin
|
||||
{
|
||||
@ -47,9 +44,8 @@ namespace FirstPlugin
|
||||
}
|
||||
}
|
||||
|
||||
byte[] data;
|
||||
|
||||
STToolStripItem EndiannessToolstrip;
|
||||
private byte[] data;
|
||||
private STToolStripItem EndiannessToolstrip;
|
||||
|
||||
public KCL()
|
||||
{
|
||||
@ -64,7 +60,7 @@ namespace FirstPlugin
|
||||
IFileInfo = new IFileInfo();
|
||||
}
|
||||
|
||||
public void OpenMaterialEditor(object sender, EventArgs args)
|
||||
private void OpenMaterialEditor(object sender, EventArgs args)
|
||||
{
|
||||
CollisionMaterialEditor editor = new CollisionMaterialEditor();
|
||||
editor.LoadCollisionValues(kcl, Renderer);
|
||||
@ -75,7 +71,7 @@ namespace FirstPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public DrawableContainer DrawableContainer = new DrawableContainer();
|
||||
private DrawableContainer DrawableContainer = new DrawableContainer();
|
||||
|
||||
public void Load(System.IO.Stream stream)
|
||||
{
|
||||
@ -250,7 +246,7 @@ namespace FirstPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public void Export(object sender, EventArgs args)
|
||||
private void Export(object sender, EventArgs args)
|
||||
{
|
||||
if (kcl == null)
|
||||
return;
|
||||
@ -266,7 +262,7 @@ namespace FirstPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public void Replace(object sender, EventArgs args)
|
||||
private void Replace(object sender, EventArgs args)
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = "Supported Formats|*.obj";
|
||||
@ -286,7 +282,7 @@ namespace FirstPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public void SwapEndianess(object sender, EventArgs args)
|
||||
private void SwapEndianess(object sender, EventArgs args)
|
||||
{
|
||||
if (EndiannessToolstrip.Checked)
|
||||
{
|
||||
@ -300,7 +296,7 @@ namespace FirstPlugin
|
||||
}
|
||||
}
|
||||
|
||||
Viewport viewport
|
||||
private Viewport viewport
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -314,7 +310,7 @@ namespace FirstPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public KCLRendering Renderer;
|
||||
private KCLRendering Renderer;
|
||||
bool DrawablesLoaded = false;
|
||||
public override void OnClick(TreeView treeView)
|
||||
{
|
||||
@ -339,8 +335,8 @@ namespace FirstPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public MarioKart.MK7.KCL kcl = null;
|
||||
public void Read(byte[] file_data)
|
||||
private MarioKart.MK7.KCL kcl;
|
||||
private void Read(byte[] file_data)
|
||||
{
|
||||
data = file_data;
|
||||
|
||||
@ -356,7 +352,8 @@ namespace FirstPlugin
|
||||
}
|
||||
Read(kcl);
|
||||
}
|
||||
public void Read(MarioKart.MK7.KCL kcl)
|
||||
|
||||
private void Read(MarioKart.MK7.KCL kcl)
|
||||
{
|
||||
Vector3 min = new Vector3();
|
||||
Vector3 max = new Vector3();
|
||||
@ -445,412 +442,12 @@ namespace FirstPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public class KCLRendering : AbstractGlDrawable
|
||||
{
|
||||
public Vector3 Max = new Vector3(0);
|
||||
public Vector3 Min = new Vector3(0);
|
||||
|
||||
public List<ushort> SelectedTypes = new List<ushort>();
|
||||
|
||||
public Vector3 position = new Vector3(0, 0, 0);
|
||||
|
||||
protected bool Selected = false;
|
||||
protected bool Hovered = false;
|
||||
|
||||
// public override bool IsSelected() => Selected;
|
||||
// public override bool IsSelected(int partIndex) => Selected;
|
||||
|
||||
public bool IsHovered() => Selected;
|
||||
|
||||
// gl buffer objects
|
||||
int vbo_position;
|
||||
int ibo_elements;
|
||||
|
||||
//Set the game's material list
|
||||
public GameSet GameMaterialSet = GameSet.MarioKart8D;
|
||||
public List<KCLModel> models = new List<KCLModel>();
|
||||
|
||||
private void GenerateBuffers()
|
||||
{
|
||||
GL.GenBuffers(1, out vbo_position);
|
||||
GL.GenBuffers(1, out ibo_elements);
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
GL.DeleteBuffer(vbo_position);
|
||||
GL.DeleteBuffer(ibo_elements);
|
||||
}
|
||||
|
||||
public void UpdateVertexData()
|
||||
{
|
||||
if (!Runtime.OpenTKInitialized)
|
||||
return;
|
||||
|
||||
DisplayVertex[] Vertices;
|
||||
int[] Faces;
|
||||
|
||||
int poffset = 0;
|
||||
int voffset = 0;
|
||||
List<DisplayVertex> Vs = new List<DisplayVertex>();
|
||||
List<int> Ds = new List<int>();
|
||||
foreach (KCLModel m in models)
|
||||
{
|
||||
m.Offset = poffset * 4;
|
||||
List<DisplayVertex> pv = m.CreateDisplayVertices();
|
||||
Vs.AddRange(pv);
|
||||
|
||||
for (int i = 0; i < m.displayFaceSize; i++)
|
||||
{
|
||||
Ds.Add(m.display[i] + voffset);
|
||||
}
|
||||
poffset += m.displayFaceSize;
|
||||
voffset += pv.Count;
|
||||
}
|
||||
|
||||
// Binds
|
||||
Vertices = Vs.ToArray();
|
||||
Faces = Ds.ToArray();
|
||||
|
||||
// Bind only once!
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position);
|
||||
GL.BufferData<DisplayVertex>(BufferTarget.ArrayBuffer, (IntPtr)(Vertices.Length * DisplayVertex.Size), Vertices, BufferUsageHint.StaticDraw);
|
||||
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements);
|
||||
GL.BufferData<int>(BufferTarget.ElementArrayBuffer, (IntPtr)(Faces.Length * sizeof(int)), Faces, BufferUsageHint.StaticDraw);
|
||||
|
||||
LibraryGUI.UpdateViewport();
|
||||
}
|
||||
|
||||
public void DrawGlobalOctree()
|
||||
{
|
||||
var size = Max - Min;
|
||||
var BoxSize = size / 2f;
|
||||
for (int k = 0; k < 2; k++)
|
||||
{
|
||||
for (int l = 0; l < 2; l++)
|
||||
{
|
||||
for (int m = 0; m < 2; m++)
|
||||
{
|
||||
var Boxmin = Min + new Vector3(BoxSize.X * m, BoxSize.Y * l, BoxSize.Z * k);
|
||||
var pos = new Vector3(BoxSize.X * m, BoxSize.Y * l, BoxSize.Z * k);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ShaderProgram defaultShaderProgram;
|
||||
public ShaderProgram solidColorShaderProgram;
|
||||
|
||||
public override void Prepare(GL_ControlModern control)
|
||||
{
|
||||
string pathFrag = System.IO.Path.Combine(Runtime.ExecutableDir, "Shader") + "\\KCL.frag";
|
||||
string pathVert = System.IO.Path.Combine(Runtime.ExecutableDir, "Shader") + "\\KCL.vert";
|
||||
|
||||
var defaultFrag = new FragmentShader(File.ReadAllText(pathFrag));
|
||||
var defaultVert = new VertexShader(File.ReadAllText(pathVert));
|
||||
|
||||
var solidColorFrag = new FragmentShader(
|
||||
@"#version 330
|
||||
uniform vec4 color;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main(){
|
||||
FragColor = color;
|
||||
}");
|
||||
|
||||
var solidColorVert = new VertexShader(
|
||||
@"#version 330
|
||||
in vec3 vPosition;
|
||||
in vec3 vNormal;
|
||||
in vec3 vColor;
|
||||
|
||||
out vec3 normal;
|
||||
out vec3 color;
|
||||
out vec3 position;
|
||||
|
||||
uniform mat4 mtxMdl;
|
||||
uniform mat4 mtxCam;
|
||||
|
||||
void main(){
|
||||
normal = vNormal;
|
||||
color = vColor;
|
||||
position = vPosition;
|
||||
|
||||
gl_Position = mtxMdl * mtxCam * vec4(vPosition.xyz, 1.0);
|
||||
}");
|
||||
|
||||
defaultShaderProgram = new ShaderProgram(defaultFrag, defaultVert, control);
|
||||
solidColorShaderProgram = new ShaderProgram(solidColorFrag, solidColorVert, control);
|
||||
|
||||
}
|
||||
|
||||
public override void Prepare(GL_ControlLegacy control)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void CheckBuffers()
|
||||
{
|
||||
if (!Runtime.OpenTKInitialized)
|
||||
return;
|
||||
|
||||
bool buffersWereInitialized = ibo_elements != 0 && vbo_position != 0;
|
||||
if (!buffersWereInitialized)
|
||||
{
|
||||
GenerateBuffers();
|
||||
UpdateVertexData();
|
||||
}
|
||||
}
|
||||
public override void Draw(GL_ControlLegacy control, Pass pass)
|
||||
{
|
||||
if (!Runtime.OpenTKInitialized)
|
||||
return;
|
||||
|
||||
Matrix4 mvpMat = control.ModelMatrix * control.CameraMatrix * control.ProjectionMatrix;
|
||||
|
||||
Matrix4 invertedCamera = Matrix4.Identity;
|
||||
if (invertedCamera.Determinant != 0)
|
||||
invertedCamera = mvpMat.Inverted();
|
||||
|
||||
Vector3 lightDirection = new Vector3(0f, 0f, -1f);
|
||||
Vector3 difLightDirection = Vector3.TransformNormal(lightDirection, invertedCamera).Normalized();
|
||||
|
||||
GL.Disable(EnableCap.Texture2D);
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
|
||||
foreach (var model in models)
|
||||
{
|
||||
if (Runtime.RenderModels && model.Checked && model.Checked)
|
||||
{
|
||||
List<int> faces = model.getDisplayFace();
|
||||
|
||||
GL.Begin(PrimitiveType.Triangles);
|
||||
foreach (var index in faces)
|
||||
{
|
||||
Vertex vert = model.vertices[index];
|
||||
float normal = Vector3.Dot(difLightDirection, vert.nrm) * 0.5f + 0.5f;
|
||||
GL.Color3(new Vector3(normal));
|
||||
GL.Vertex3(vert.pos);
|
||||
}
|
||||
GL.End();
|
||||
}
|
||||
}
|
||||
|
||||
GL.Enable(EnableCap.Texture2D);
|
||||
}
|
||||
|
||||
public override void Draw(GL_ControlModern control, Pass pass)
|
||||
{
|
||||
CheckBuffers();
|
||||
|
||||
if (!Runtime.OpenTKInitialized)
|
||||
return;
|
||||
|
||||
control.CurrentShader = defaultShaderProgram;
|
||||
|
||||
control.UpdateModelMatrix(
|
||||
Matrix4.CreateScale(Runtime.previewScale));
|
||||
|
||||
SetRenderSettings(defaultShaderProgram);
|
||||
|
||||
Matrix4 camMat = control.ModelMatrix * control.CameraMatrix * control.ProjectionMatrix;
|
||||
|
||||
GL.Disable(EnableCap.CullFace);
|
||||
|
||||
GL.Uniform3(defaultShaderProgram["difLightDirection"], Vector3.TransformNormal(new Vector3(0f, 0f, -1f), camMat.Inverted()).Normalized());
|
||||
GL.Uniform3(defaultShaderProgram["difLightColor"], new Vector3(1));
|
||||
GL.Uniform3(defaultShaderProgram["ambLightColor"], new Vector3(1));
|
||||
|
||||
defaultShaderProgram.EnableVertexAttributes();
|
||||
|
||||
foreach (KCLModel mdl in models)
|
||||
{
|
||||
DrawModel(mdl, defaultShaderProgram);
|
||||
}
|
||||
|
||||
defaultShaderProgram.DisableVertexAttributes();
|
||||
|
||||
GL.UseProgram(0);
|
||||
GL.Disable(EnableCap.DepthTest);
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
GL.Enable(EnableCap.CullFace);
|
||||
}
|
||||
private void SetRenderSettings(ShaderProgram shader)
|
||||
{
|
||||
shader.SetBoolToInt("renderVertColor", Runtime.renderVertColor);
|
||||
GL.Uniform1(defaultShaderProgram["renderType"], (int)Runtime.viewportShading);
|
||||
|
||||
}
|
||||
private void DrawModel(KCLModel m, ShaderProgram shader, bool drawSelection = false)
|
||||
{
|
||||
if (m.faces.Count <= 3)
|
||||
return;
|
||||
|
||||
SetVertexAttributes(m, shader);
|
||||
|
||||
if (m.Checked)
|
||||
{
|
||||
if ((m.IsSelected))
|
||||
{
|
||||
DrawModelSelection(m, shader);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Runtime.RenderModelWireframe)
|
||||
{
|
||||
DrawModelWireframe(m, shader);
|
||||
}
|
||||
|
||||
if (Runtime.RenderModels)
|
||||
{
|
||||
GL.DrawElements(PrimitiveType.Triangles, m.displayFaceSize, DrawElementsType.UnsignedInt, m.Offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void DrawModelSelection(KCLModel p, ShaderProgram shader)
|
||||
{
|
||||
//This part needs to be reworked for proper outline. Currently would make model disappear
|
||||
|
||||
GL.DrawElements(PrimitiveType.Triangles, p.displayFaceSize, DrawElementsType.UnsignedInt, p.Offset);
|
||||
|
||||
GL.Enable(EnableCap.StencilTest);
|
||||
// use vertex color for wireframe color
|
||||
GL.Uniform1(shader["colorOverride"], 1);
|
||||
GL.PolygonMode(MaterialFace.Front, PolygonMode.Line);
|
||||
GL.Enable(EnableCap.LineSmooth);
|
||||
GL.LineWidth(1.5f);
|
||||
GL.DrawElements(PrimitiveType.Triangles, p.displayFaceSize, DrawElementsType.UnsignedInt, p.Offset);
|
||||
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
|
||||
GL.Uniform1(shader["colorOverride"], 0);
|
||||
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
}
|
||||
private void SetVertexAttributes(KCLModel m, ShaderProgram shader)
|
||||
{
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position);
|
||||
GL.VertexAttribPointer(shader.GetAttribute("vPosition"), 3, VertexAttribPointerType.Float, false, DisplayVertex.Size, 0);
|
||||
GL.VertexAttribPointer(shader.GetAttribute("vNormal"), 3, VertexAttribPointerType.Float, false, DisplayVertex.Size, 12);
|
||||
GL.VertexAttribPointer(shader.GetAttribute("vColor"), 3, VertexAttribPointerType.Float, false, DisplayVertex.Size, 24);
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements);
|
||||
}
|
||||
private static void DrawModelWireframe(KCLModel p, ShaderProgram shader)
|
||||
{
|
||||
// use vertex color for wireframe color
|
||||
GL.Uniform1(shader["colorOverride"], 1);
|
||||
GL.PolygonMode(MaterialFace.Front, PolygonMode.Line);
|
||||
GL.Enable(EnableCap.LineSmooth);
|
||||
GL.LineWidth(1.5f);
|
||||
GL.DrawElements(PrimitiveType.Triangles, p.displayFaceSize, DrawElementsType.UnsignedInt, p.Offset);
|
||||
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
|
||||
GL.Uniform1(shader["colorOverride"], 0);
|
||||
}
|
||||
|
||||
/* public override BoundingBox GetSelectionBox()
|
||||
{
|
||||
Vector3 Min = new Vector3(0);
|
||||
Vector3 Max = new Vector3(0);
|
||||
|
||||
foreach (var model in models)
|
||||
{
|
||||
foreach (var vertex in model.vertices)
|
||||
{
|
||||
Min.X = Math.Min(Min.X, vertex.pos.X);
|
||||
Min.Y = Math.Min(Min.Y, vertex.pos.Y);
|
||||
Min.Z = Math.Min(Min.Z, vertex.pos.Z);
|
||||
Max.X = Math.Max(Max.X, vertex.pos.X);
|
||||
Max.Y = Math.Max(Max.Y, vertex.pos.Y);
|
||||
Max.Z = Math.Max(Max.Z, vertex.pos.Z);
|
||||
}
|
||||
}
|
||||
|
||||
return new BoundingBox()
|
||||
{
|
||||
minX = Min.X,
|
||||
minY = Min.Y,
|
||||
minZ = Min.Z,
|
||||
maxX = Max.X,
|
||||
maxY = Max.Y,
|
||||
maxZ = Max.Z,
|
||||
};
|
||||
}
|
||||
|
||||
public override LocalOrientation GetLocalOrientation(int partIndex)
|
||||
{
|
||||
return new LocalOrientation(position);
|
||||
}
|
||||
|
||||
public override bool TryStartDragging(DragActionType actionType, int hoveredPart, out LocalOrientation localOrientation, out bool dragExclusively)
|
||||
{
|
||||
localOrientation = new LocalOrientation(position);
|
||||
dragExclusively = false;
|
||||
return Selected;
|
||||
}
|
||||
|
||||
public override bool IsInRange(float range, float rangeSquared, Vector3 pos)
|
||||
{
|
||||
range = 20000; //Make the range large for now. Todo go back to this
|
||||
|
||||
BoundingBox box = GetSelectionBox();
|
||||
|
||||
if (pos.X < box.maxX + range && pos.X > box.minX - range &&
|
||||
pos.Y < box.maxY + range && pos.Y > box.minY - range &&
|
||||
pos.Z < box.maxZ + range && pos.Z > box.minZ - range)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public override uint SelectAll(GL_ControlBase control)
|
||||
{
|
||||
Selected = true;
|
||||
return REDRAW;
|
||||
}
|
||||
|
||||
public override uint SelectDefault(GL_ControlBase control)
|
||||
{
|
||||
Selected = true;
|
||||
return REDRAW;
|
||||
}
|
||||
|
||||
public override uint Select(int partIndex, GL_ControlBase control)
|
||||
{
|
||||
Selected = true;
|
||||
return REDRAW;
|
||||
}
|
||||
|
||||
public override uint Deselect(int partIndex, GL_ControlBase control)
|
||||
{
|
||||
Selected = false;
|
||||
return REDRAW;
|
||||
}
|
||||
|
||||
public override uint DeselectAll(GL_ControlBase control)
|
||||
{
|
||||
Selected = false;
|
||||
return REDRAW;
|
||||
}
|
||||
|
||||
public override Vector3 Position
|
||||
{
|
||||
get
|
||||
{
|
||||
return position;
|
||||
}
|
||||
set
|
||||
{
|
||||
position = value;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
//Convert KCL lib vec3 to opentk one so i can use the cross and dot methods
|
||||
public static Vector3 Vec3D_To_Vec3(System.Windows.Media.Media3D.Vector3D v)
|
||||
{
|
||||
return new Vector3((float)v.X, (float)v.Y, (float)v.Z);
|
||||
}
|
||||
|
||||
public struct DisplayVertex
|
||||
{
|
||||
// Used for rendering.
|
||||
@ -860,6 +457,7 @@ namespace FirstPlugin
|
||||
|
||||
public static int Size = 4 * (3 + 3 + 3);
|
||||
}
|
||||
|
||||
public class KCLModel : STGenericObject
|
||||
{
|
||||
public KCLModel()
|
||||
|
@ -4,6 +4,7 @@ using System.Windows.Forms;
|
||||
using Toolbox.Library;
|
||||
using Toolbox.Library.Forms;
|
||||
using Toolbox.Library.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace FirstPlugin
|
||||
{
|
||||
@ -52,11 +53,13 @@ namespace FirstPlugin
|
||||
[7] = TEX_FORMAT.RGBA32,
|
||||
};
|
||||
|
||||
public short Unknown;
|
||||
|
||||
public void Load(System.IO.Stream stream)
|
||||
{
|
||||
Text = FileName;
|
||||
//Set this if you want to save the file format
|
||||
CanSave = false;
|
||||
CanSave = true;
|
||||
CanReplace = true;
|
||||
|
||||
ImageKey = "Texture";
|
||||
@ -69,7 +72,7 @@ namespace FirstPlugin
|
||||
|
||||
Width = reader.ReadUInt16();
|
||||
Height = reader.ReadUInt16();
|
||||
reader.ReadInt16();
|
||||
Unknown = reader.ReadInt16();
|
||||
//Turn this format into a common format used by this tool
|
||||
ushort texFormat = reader.ReadUInt16();
|
||||
Format = FormatsTXE[texFormat];
|
||||
@ -89,6 +92,17 @@ namespace FirstPlugin
|
||||
|
||||
public void Save(System.IO.Stream stream)
|
||||
{
|
||||
using (var writer = new FileWriter(stream))
|
||||
{
|
||||
writer.Write((ushort)Width);
|
||||
writer.Write((ushort)Height);
|
||||
writer.Write(Unknown);
|
||||
writer.Write(Unknown);
|
||||
ushort format = FormatsTXE.FirstOrDefault(x => x.Value == Format).Key;
|
||||
writer.Write(format);
|
||||
writer.SeekBegin(32);
|
||||
writer.Write(ImageData);
|
||||
}
|
||||
}
|
||||
|
||||
public void Unload()
|
||||
@ -123,21 +137,23 @@ namespace FirstPlugin
|
||||
get { return Decode_Gamecube.FromGenericFormat(Format); }
|
||||
}
|
||||
|
||||
|
||||
public override bool CanEdit { get; set; } = false;
|
||||
public override bool CanEdit { get; set; } = true;
|
||||
|
||||
//This gets used in the image editor if the image gets edited
|
||||
//This wll not be ran if "CanEdit" is set to false!
|
||||
public override void SetImageData(System.Drawing.Bitmap bitmap, int ArrayLevel)
|
||||
{
|
||||
this.Width = (ushort)bitmap.Width;
|
||||
this.Height = (ushort)bitmap.Height;
|
||||
|
||||
this.ImageData = Decode_Gamecube.EncodeFromBitmap(bitmap, DolphinTextureFormat).Item1;
|
||||
}
|
||||
|
||||
//Gets the raw image data in bytes
|
||||
//Gets decoded automatically
|
||||
public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
|
||||
{
|
||||
return Decode_Gamecube.GetMipLevel(ImageData, Width, Height, MipCount, (uint)MipLevel, DolphinTextureFormat);
|
||||
return Decode_Gamecube.GetMipLevel(ImageData, Width, Height, MipCount, (uint)MipLevel, Format);
|
||||
}
|
||||
|
||||
|
||||
@ -170,6 +186,9 @@ namespace FirstPlugin
|
||||
GamecubeTextureImporterList importer = new GamecubeTextureImporterList(SupportedFormats);
|
||||
GameCubeTextureImporterSettings settings = new GameCubeTextureImporterSettings();
|
||||
|
||||
importer.ForceMipCount = true;
|
||||
importer.SelectedMipCount = 1;
|
||||
|
||||
if (Utils.GetExtension(FileName) == ".dds" ||
|
||||
Utils.GetExtension(FileName) == ".dds2")
|
||||
{
|
||||
@ -201,7 +220,7 @@ namespace FirstPlugin
|
||||
this.Width = settings.TexWidth;
|
||||
this.Height = settings.TexHeight;
|
||||
this.Format = settings.GenericFormat;
|
||||
this.MipCount = settings.MipCount;
|
||||
this.MipCount = 1; //Always 1
|
||||
this.Depth = settings.Depth;
|
||||
this.ArrayCount = (uint)settings.DataBlockOutput.Count;
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ namespace FirstPlugin
|
||||
//Gets decoded automatically
|
||||
public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
|
||||
{
|
||||
return ImageData;
|
||||
return Decode_Gamecube.GetMipLevel(ImageData, Width, Height, MipCount, (uint)MipLevel, Format);
|
||||
}
|
||||
|
||||
|
||||
|
@ -193,7 +193,7 @@ namespace FirstPlugin
|
||||
|
||||
public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
|
||||
{
|
||||
return ImageData;
|
||||
return Decode_Gamecube.GetMipLevel(ImageData, Width, Height, MipCount, (uint)MipLevel, Format);
|
||||
}
|
||||
|
||||
public override void OnClick(TreeView treeView)
|
||||
|
@ -287,6 +287,7 @@
|
||||
<Compile Include="GL\BMD_Renderer.cs" />
|
||||
<Compile Include="GL\CMB_Renderer.cs" />
|
||||
<Compile Include="GL\GXToOpenGL.cs" />
|
||||
<Compile Include="GL\KCL_Render.cs" />
|
||||
<Compile Include="GL\LM2_Render.cs" />
|
||||
<Compile Include="GUI\BFFNT\BffntEditor.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
|
416
File_Format_Library/GL/KCL_Render.cs
Normal file
416
File_Format_Library/GL/KCL_Render.cs
Normal file
@ -0,0 +1,416 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using GL_EditorFramework.GL_Core;
|
||||
using GL_EditorFramework.Interfaces;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using Toolbox.Library;
|
||||
using Toolbox.Library.Rendering;
|
||||
|
||||
namespace FirstPlugin
|
||||
{
|
||||
public class KCLRendering : AbstractGlDrawable
|
||||
{
|
||||
public Vector3 Max = new Vector3(0);
|
||||
public Vector3 Min = new Vector3(0);
|
||||
|
||||
public List<ushort> SelectedTypes = new List<ushort>();
|
||||
|
||||
public Vector3 position = new Vector3(0, 0, 0);
|
||||
|
||||
protected bool Selected = false;
|
||||
protected bool Hovered = false;
|
||||
|
||||
// public override bool IsSelected() => Selected;
|
||||
// public override bool IsSelected(int partIndex) => Selected;
|
||||
|
||||
public bool IsHovered() => Selected;
|
||||
|
||||
// gl buffer objects
|
||||
int vbo_position;
|
||||
int ibo_elements;
|
||||
|
||||
//Set the game's material list
|
||||
public KCL.GameSet GameMaterialSet = KCL.GameSet.MarioKart8D;
|
||||
public List<KCL.KCLModel> models = new List<KCL.KCLModel>();
|
||||
|
||||
private void GenerateBuffers()
|
||||
{
|
||||
GL.GenBuffers(1, out vbo_position);
|
||||
GL.GenBuffers(1, out ibo_elements);
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
GL.DeleteBuffer(vbo_position);
|
||||
GL.DeleteBuffer(ibo_elements);
|
||||
}
|
||||
|
||||
public void UpdateVertexData()
|
||||
{
|
||||
if (!Runtime.OpenTKInitialized)
|
||||
return;
|
||||
|
||||
KCL.DisplayVertex[] Vertices;
|
||||
int[] Faces;
|
||||
|
||||
int poffset = 0;
|
||||
int voffset = 0;
|
||||
List<KCL.DisplayVertex> Vs = new List<KCL.DisplayVertex>();
|
||||
List<int> Ds = new List<int>();
|
||||
foreach (KCL.KCLModel m in models)
|
||||
{
|
||||
m.Offset = poffset * 4;
|
||||
List<KCL.DisplayVertex> pv = m.CreateDisplayVertices();
|
||||
Vs.AddRange(pv);
|
||||
|
||||
for (int i = 0; i < m.displayFaceSize; i++)
|
||||
{
|
||||
Ds.Add(m.display[i] + voffset);
|
||||
}
|
||||
poffset += m.displayFaceSize;
|
||||
voffset += pv.Count;
|
||||
}
|
||||
|
||||
// Binds
|
||||
Vertices = Vs.ToArray();
|
||||
Faces = Ds.ToArray();
|
||||
|
||||
// Bind only once!
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position);
|
||||
GL.BufferData<KCL.DisplayVertex>(BufferTarget.ArrayBuffer, (IntPtr)(Vertices.Length * KCL.DisplayVertex.Size), Vertices, BufferUsageHint.StaticDraw);
|
||||
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements);
|
||||
GL.BufferData<int>(BufferTarget.ElementArrayBuffer, (IntPtr)(Faces.Length * sizeof(int)), Faces, BufferUsageHint.StaticDraw);
|
||||
|
||||
LibraryGUI.UpdateViewport();
|
||||
}
|
||||
|
||||
public void DrawGlobalOctree()
|
||||
{
|
||||
var size = Max - Min;
|
||||
var BoxSize = size / 2f;
|
||||
for (int k = 0; k < 2; k++)
|
||||
{
|
||||
for (int l = 0; l < 2; l++)
|
||||
{
|
||||
for (int m = 0; m < 2; m++)
|
||||
{
|
||||
var Boxmin = Min + new Vector3(BoxSize.X * m, BoxSize.Y * l, BoxSize.Z * k);
|
||||
var pos = new Vector3(BoxSize.X * m, BoxSize.Y * l, BoxSize.Z * k);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ShaderProgram defaultShaderProgram;
|
||||
public ShaderProgram solidColorShaderProgram;
|
||||
|
||||
public override void Prepare(GL_ControlModern control)
|
||||
{
|
||||
string pathFrag = System.IO.Path.Combine(Runtime.ExecutableDir, "Shader") + "\\KCL.frag";
|
||||
string pathVert = System.IO.Path.Combine(Runtime.ExecutableDir, "Shader") + "\\KCL.vert";
|
||||
|
||||
var defaultFrag = new FragmentShader(File.ReadAllText(pathFrag));
|
||||
var defaultVert = new VertexShader(File.ReadAllText(pathVert));
|
||||
|
||||
var solidColorFrag = new FragmentShader(
|
||||
@"#version 330
|
||||
uniform vec4 color;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main(){
|
||||
FragColor = color;
|
||||
}");
|
||||
|
||||
var solidColorVert = new VertexShader(
|
||||
@"#version 330
|
||||
in vec3 vPosition;
|
||||
in vec3 vNormal;
|
||||
in vec3 vColor;
|
||||
|
||||
out vec3 normal;
|
||||
out vec3 color;
|
||||
out vec3 position;
|
||||
|
||||
uniform mat4 mtxMdl;
|
||||
uniform mat4 mtxCam;
|
||||
|
||||
void main(){
|
||||
normal = vNormal;
|
||||
color = vColor;
|
||||
position = vPosition;
|
||||
|
||||
gl_Position = mtxMdl * mtxCam * vec4(vPosition.xyz, 1.0);
|
||||
}");
|
||||
|
||||
defaultShaderProgram = new ShaderProgram(defaultFrag, defaultVert, control);
|
||||
solidColorShaderProgram = new ShaderProgram(solidColorFrag, solidColorVert, control);
|
||||
|
||||
}
|
||||
|
||||
public override void Prepare(GL_ControlLegacy control)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void CheckBuffers()
|
||||
{
|
||||
if (!Runtime.OpenTKInitialized)
|
||||
return;
|
||||
|
||||
bool buffersWereInitialized = ibo_elements != 0 && vbo_position != 0;
|
||||
if (!buffersWereInitialized)
|
||||
{
|
||||
GenerateBuffers();
|
||||
UpdateVertexData();
|
||||
}
|
||||
}
|
||||
public override void Draw(GL_ControlLegacy control, Pass pass)
|
||||
{
|
||||
if (!Runtime.OpenTKInitialized)
|
||||
return;
|
||||
|
||||
Matrix4 mvpMat = control.ModelMatrix * control.CameraMatrix * control.ProjectionMatrix;
|
||||
|
||||
Matrix4 invertedCamera = Matrix4.Identity;
|
||||
if (invertedCamera.Determinant != 0)
|
||||
invertedCamera = mvpMat.Inverted();
|
||||
|
||||
Vector3 lightDirection = new Vector3(0f, 0f, -1f);
|
||||
Vector3 difLightDirection = Vector3.TransformNormal(lightDirection, invertedCamera).Normalized();
|
||||
|
||||
GL.Disable(EnableCap.Texture2D);
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
|
||||
foreach (var model in models)
|
||||
{
|
||||
if (Runtime.RenderModels && model.Checked && model.Checked)
|
||||
{
|
||||
List<int> faces = model.getDisplayFace();
|
||||
|
||||
GL.Begin(PrimitiveType.Triangles);
|
||||
foreach (var index in faces)
|
||||
{
|
||||
Vertex vert = model.vertices[index];
|
||||
float normal = Vector3.Dot(difLightDirection, vert.nrm) * 0.5f + 0.5f;
|
||||
GL.Color3(new Vector3(normal));
|
||||
GL.Vertex3(vert.pos);
|
||||
}
|
||||
GL.End();
|
||||
}
|
||||
}
|
||||
|
||||
GL.Enable(EnableCap.Texture2D);
|
||||
}
|
||||
|
||||
public override void Draw(GL_ControlModern control, Pass pass)
|
||||
{
|
||||
CheckBuffers();
|
||||
|
||||
if (!Runtime.OpenTKInitialized)
|
||||
return;
|
||||
|
||||
control.CurrentShader = defaultShaderProgram;
|
||||
|
||||
control.UpdateModelMatrix(
|
||||
Matrix4.CreateScale(Runtime.previewScale));
|
||||
|
||||
SetRenderSettings(defaultShaderProgram);
|
||||
|
||||
Matrix4 camMat = control.ModelMatrix * control.CameraMatrix * control.ProjectionMatrix;
|
||||
|
||||
GL.Disable(EnableCap.CullFace);
|
||||
|
||||
GL.Uniform3(defaultShaderProgram["difLightDirection"], Vector3.TransformNormal(new Vector3(0f, 0f, -1f), camMat.Inverted()).Normalized());
|
||||
GL.Uniform3(defaultShaderProgram["difLightColor"], new Vector3(1));
|
||||
GL.Uniform3(defaultShaderProgram["ambLightColor"], new Vector3(1));
|
||||
|
||||
defaultShaderProgram.EnableVertexAttributes();
|
||||
|
||||
foreach (KCL.KCLModel mdl in models)
|
||||
{
|
||||
DrawModel(mdl, defaultShaderProgram);
|
||||
}
|
||||
|
||||
defaultShaderProgram.DisableVertexAttributes();
|
||||
|
||||
GL.UseProgram(0);
|
||||
GL.Disable(EnableCap.DepthTest);
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
GL.Enable(EnableCap.CullFace);
|
||||
}
|
||||
private void SetRenderSettings(ShaderProgram shader)
|
||||
{
|
||||
shader.SetBoolToInt("renderVertColor", Runtime.renderVertColor);
|
||||
GL.Uniform1(defaultShaderProgram["renderType"], (int)Runtime.viewportShading);
|
||||
|
||||
}
|
||||
private void DrawModel(KCL.KCLModel m, ShaderProgram shader, bool drawSelection = false)
|
||||
{
|
||||
if (m.faces.Count <= 3)
|
||||
return;
|
||||
|
||||
SetVertexAttributes(m, shader);
|
||||
|
||||
if (m.Checked)
|
||||
{
|
||||
if ((m.IsSelected))
|
||||
{
|
||||
DrawModelSelection(m, shader);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Runtime.RenderModelWireframe)
|
||||
{
|
||||
DrawModelWireframe(m, shader);
|
||||
}
|
||||
|
||||
if (Runtime.RenderModels)
|
||||
{
|
||||
GL.DrawElements(PrimitiveType.Triangles, m.displayFaceSize, DrawElementsType.UnsignedInt, m.Offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void DrawModelSelection(KCL.KCLModel p, ShaderProgram shader)
|
||||
{
|
||||
//This part needs to be reworked for proper outline. Currently would make model disappear
|
||||
|
||||
GL.DrawElements(PrimitiveType.Triangles, p.displayFaceSize, DrawElementsType.UnsignedInt, p.Offset);
|
||||
|
||||
GL.Enable(EnableCap.StencilTest);
|
||||
// use vertex color for wireframe color
|
||||
GL.Uniform1(shader["colorOverride"], 1);
|
||||
GL.PolygonMode(MaterialFace.Front, PolygonMode.Line);
|
||||
GL.Enable(EnableCap.LineSmooth);
|
||||
GL.LineWidth(1.5f);
|
||||
GL.DrawElements(PrimitiveType.Triangles, p.displayFaceSize, DrawElementsType.UnsignedInt, p.Offset);
|
||||
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
|
||||
GL.Uniform1(shader["colorOverride"], 0);
|
||||
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
}
|
||||
private void SetVertexAttributes(KCL.KCLModel m, ShaderProgram shader)
|
||||
{
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position);
|
||||
GL.VertexAttribPointer(shader.GetAttribute("vPosition"), 3, VertexAttribPointerType.Float, false, KCL.DisplayVertex.Size, 0);
|
||||
GL.VertexAttribPointer(shader.GetAttribute("vNormal"), 3, VertexAttribPointerType.Float, false, KCL.DisplayVertex.Size, 12);
|
||||
GL.VertexAttribPointer(shader.GetAttribute("vColor"), 3, VertexAttribPointerType.Float, false, KCL.DisplayVertex.Size, 24);
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements);
|
||||
}
|
||||
private static void DrawModelWireframe(KCL.KCLModel p, ShaderProgram shader)
|
||||
{
|
||||
// use vertex color for wireframe color
|
||||
GL.Uniform1(shader["colorOverride"], 1);
|
||||
GL.PolygonMode(MaterialFace.Front, PolygonMode.Line);
|
||||
GL.Enable(EnableCap.LineSmooth);
|
||||
GL.LineWidth(1.5f);
|
||||
GL.DrawElements(PrimitiveType.Triangles, p.displayFaceSize, DrawElementsType.UnsignedInt, p.Offset);
|
||||
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
|
||||
GL.Uniform1(shader["colorOverride"], 0);
|
||||
}
|
||||
|
||||
/* public override BoundingBox GetSelectionBox()
|
||||
{
|
||||
Vector3 Min = new Vector3(0);
|
||||
Vector3 Max = new Vector3(0);
|
||||
|
||||
foreach (var model in models)
|
||||
{
|
||||
foreach (var vertex in model.vertices)
|
||||
{
|
||||
Min.X = Math.Min(Min.X, vertex.pos.X);
|
||||
Min.Y = Math.Min(Min.Y, vertex.pos.Y);
|
||||
Min.Z = Math.Min(Min.Z, vertex.pos.Z);
|
||||
Max.X = Math.Max(Max.X, vertex.pos.X);
|
||||
Max.Y = Math.Max(Max.Y, vertex.pos.Y);
|
||||
Max.Z = Math.Max(Max.Z, vertex.pos.Z);
|
||||
}
|
||||
}
|
||||
|
||||
return new BoundingBox()
|
||||
{
|
||||
minX = Min.X,
|
||||
minY = Min.Y,
|
||||
minZ = Min.Z,
|
||||
maxX = Max.X,
|
||||
maxY = Max.Y,
|
||||
maxZ = Max.Z,
|
||||
};
|
||||
}
|
||||
|
||||
public override LocalOrientation GetLocalOrientation(int partIndex)
|
||||
{
|
||||
return new LocalOrientation(position);
|
||||
}
|
||||
|
||||
public override bool TryStartDragging(DragActionType actionType, int hoveredPart, out LocalOrientation localOrientation, out bool dragExclusively)
|
||||
{
|
||||
localOrientation = new LocalOrientation(position);
|
||||
dragExclusively = false;
|
||||
return Selected;
|
||||
}
|
||||
|
||||
public override bool IsInRange(float range, float rangeSquared, Vector3 pos)
|
||||
{
|
||||
range = 20000; //Make the range large for now. Todo go back to this
|
||||
|
||||
BoundingBox box = GetSelectionBox();
|
||||
|
||||
if (pos.X < box.maxX + range && pos.X > box.minX - range &&
|
||||
pos.Y < box.maxY + range && pos.Y > box.minY - range &&
|
||||
pos.Z < box.maxZ + range && pos.Z > box.minZ - range)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public override uint SelectAll(GL_ControlBase control)
|
||||
{
|
||||
Selected = true;
|
||||
return REDRAW;
|
||||
}
|
||||
|
||||
public override uint SelectDefault(GL_ControlBase control)
|
||||
{
|
||||
Selected = true;
|
||||
return REDRAW;
|
||||
}
|
||||
|
||||
public override uint Select(int partIndex, GL_ControlBase control)
|
||||
{
|
||||
Selected = true;
|
||||
return REDRAW;
|
||||
}
|
||||
|
||||
public override uint Deselect(int partIndex, GL_ControlBase control)
|
||||
{
|
||||
Selected = false;
|
||||
return REDRAW;
|
||||
}
|
||||
|
||||
public override uint DeselectAll(GL_ControlBase control)
|
||||
{
|
||||
Selected = false;
|
||||
return REDRAW;
|
||||
}
|
||||
|
||||
public override Vector3 Position
|
||||
{
|
||||
get
|
||||
{
|
||||
return position;
|
||||
}
|
||||
set
|
||||
{
|
||||
position = value;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
@ -27,9 +27,9 @@ namespace FirstPlugin.Forms
|
||||
public string Type { get; set; }
|
||||
}
|
||||
|
||||
KCL.KCLRendering Render;
|
||||
KCLRendering Render;
|
||||
|
||||
public void LoadCollisionValues(MarioKart.MK7.KCL kcl, KCL.KCLRendering renderer)
|
||||
public void LoadCollisionValues(MarioKart.MK7.KCL kcl, KCLRendering renderer)
|
||||
{
|
||||
Render = renderer;
|
||||
|
||||
|
@ -274,7 +274,7 @@ namespace FirstPlugin
|
||||
private Type[] LoadMenus()
|
||||
{
|
||||
List<Type> MenuItems = new List<Type>();
|
||||
MenuItems.Add(typeof(MenuExt));
|
||||
// MenuItems.Add(typeof(MenuExt));
|
||||
return MenuItems.ToArray();
|
||||
}
|
||||
|
||||
@ -287,22 +287,22 @@ namespace FirstPlugin
|
||||
private Type[] LoadFileFormats()
|
||||
{
|
||||
List<Type> Formats = new List<Type>();
|
||||
Formats.Add(typeof(BFRES));
|
||||
Formats.Add(typeof(BTI));
|
||||
Formats.Add(typeof(TXE));
|
||||
Formats.Add(typeof(SARC));
|
||||
Formats.Add(typeof(BFRES));
|
||||
Formats.Add(typeof(BCRES));
|
||||
Formats.Add(typeof(BNTX));
|
||||
Formats.Add(typeof(BEA));
|
||||
Formats.Add(typeof(BYAML));
|
||||
Formats.Add(typeof(XTX));
|
||||
Formats.Add(typeof(KCL));
|
||||
Formats.Add(typeof(BFFNT));
|
||||
Formats.Add(typeof(MSBT));
|
||||
Formats.Add(typeof(BARS));
|
||||
Formats.Add(typeof(GFPAK));
|
||||
Formats.Add(typeof(NUTEXB));
|
||||
Formats.Add(typeof(NUT));
|
||||
Formats.Add(typeof(KCL));
|
||||
Formats.Add(typeof(GTXFile));
|
||||
Formats.Add(typeof(AAMP));
|
||||
Formats.Add(typeof(PTCL));
|
||||
|
@ -190,6 +190,11 @@ namespace Toolbox.Library
|
||||
|
||||
#region MethodsHelpers
|
||||
|
||||
public static byte[] GetMipLevel(byte[] ImageData, uint Width, uint Height, uint MipCount, uint MipLevel, TEX_FORMAT format)
|
||||
{
|
||||
return GetMipLevel(ImageData, Width, Height, MipCount, MipLevel, FromGenericFormat(format));
|
||||
}
|
||||
|
||||
public static byte[] GetMipLevel(byte[] ImageData, uint Width, uint Height, uint MipCount, uint MipLevel, TextureFormats format)
|
||||
{
|
||||
uint offset = 0;
|
||||
@ -220,6 +225,25 @@ namespace Toolbox.Library
|
||||
private static readonly int[] TileSizeW = { 8, 8, 8, 4, 4, 4, 4, 0, 8, 8, 4, 0, 0, 0, 8 };
|
||||
private static readonly int[] TileSizeH = { 8, 4, 4, 4, 4, 4, 4, 0, 8, 4, 4, 0, 0, 0, 8 };
|
||||
|
||||
public static int GetDataSizeWithMips(TextureFormats format, uint Width, uint Height, uint MipCount)
|
||||
{
|
||||
return GetDataSizeWithMips((uint)format, Width, Height, MipCount);
|
||||
}
|
||||
|
||||
public static int GetDataSizeWithMips(uint format, uint Width, uint Height, uint MipCount)
|
||||
{
|
||||
int size = 0;
|
||||
for (int m = 0; m < MipCount; m++)
|
||||
{
|
||||
uint width = (uint)Math.Max(1, Width >> m);
|
||||
uint height = (uint)Math.Max(1, Height >> m);
|
||||
|
||||
size =+ Decode_Gamecube.GetDataSize(format, width, height);
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
public static int GetDataSize(uint Format, uint Width, uint Height)
|
||||
{
|
||||
return GetDataSize((TextureFormats)Format, (int)Width, (int)Height);
|
||||
@ -889,7 +913,7 @@ namespace Toolbox.Library
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static Tuple<byte[], ushort[]> EncodeFromBitmap(System.Drawing.Bitmap bitmap, TextureFormats Format, PaletteFormats PaletteFormat)
|
||||
public static Tuple<byte[], ushort[]> EncodeFromBitmap(System.Drawing.Bitmap bitmap, TextureFormats Format, PaletteFormats PaletteFormat = PaletteFormats.RGB565)
|
||||
{
|
||||
byte[] m_rgbaImageData = new byte[bitmap.Width * bitmap.Height * 4];
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
@ -100,7 +100,7 @@ namespace Toolbox
|
||||
|
||||
Application.Idle += Application_Idle;
|
||||
|
||||
if (Runtime.UseOpenGL)
|
||||
/* if (Runtime.UseOpenGL)
|
||||
{
|
||||
ShaderTools.executableDir = Runtime.ExecutableDir;
|
||||
|
||||
@ -112,7 +112,7 @@ namespace Toolbox
|
||||
Runtime.openGLVersion = GL.GetString(StringName.Version);
|
||||
Runtime.GLSLVersion = GL.GetString(StringName.ShadingLanguageVersion);
|
||||
ParseGLVersion();
|
||||
}
|
||||
}*/
|
||||
|
||||
LoadPLugins();
|
||||
UpdateToolbar(HasVersionFile);
|
||||
|
Loading…
x
Reference in New Issue
Block a user