1
0
mirror of synced 2024-11-30 18:24:39 +01:00

Alot of additions.

General
- Always allow multiple instances of the tool by default. (UseSingleInstance in config.XML)
- Yaz0 now uses a new library using c code. This improves compression times and is comparable to wzst's yaz0 compressor. Thanks to AboodXD for helping port the code.
- Add flat buffer templates for gfbmdl and gfbanm.
- Redid UV editor. Now using new 2D engine with some improvements. Should work better with mutliple file formats than just bfres.
- Auto compress bfres with .sbfres extension.

BFLYT:
-Add animation reference list to panes if they have any animations.
- Note the animation editor in it is not functional yet.

GFBMDL
- Progress on model importing. Currently crashes on many tests so saving is currently disabled till i figure out why.
- Add new texture map display with UV coordinates shown. Displays how transforms are handled.
- Add option to export materials and models entirely as .json files.

DAE
- improve bone/joint check.
This commit is contained in:
KillzXGaming 2019-12-07 20:16:13 -05:00
parent f979f73162
commit e4722ed1af
82 changed files with 6775 additions and 3005 deletions

View File

@ -816,18 +816,6 @@ namespace Bfres.Structs
ImportedMaterials = seModel.materials;
ImportedSkeleton = seModel.skeleton;
}
else if (Runtime.DEVELOPER_DEBUG_MODE)
{
DAE daeFile = new DAE();
bool IsLoaded = daeFile.LoadFile(FileName);
if (!IsLoaded)
return;
ImportedObjects = daeFile.objects;
ImportedMaterials = daeFile.materials;
ImportedSkeleton = daeFile.skeleton;
}
else
{
AssimpData assimp = new AssimpData();

View File

@ -738,6 +738,8 @@ namespace Bfres.Structs
public float MaxLod;
public float BiasLod;
public override STGenericTexture GetTexture()
{
foreach (var bntx in PluginRuntime.bntxContainers)

View File

@ -695,10 +695,21 @@ namespace FirstPlugin
int VertexCount = (int)Slice.Size / StrideSize;
VertexAttribute.VertexData = new Syroot.Maths.Vector4F[VertexCount];
for (int v = 0; v < VertexCount; v++)
if (VertexAttribute.Mode == SepdVertexAttribMode.ARRAY)
{
VertexAttribute.VertexData[v] = ReadVertexBufferData(reader, VertexAttribute, elementCount);
for (int v = 0; v < VertexCount; v++) {
VertexAttribute.VertexData[v] = ReadVertexBufferData(reader, VertexAttribute, elementCount);
}
}
else
{
VertexAttribute.VertexData[0] = new Syroot.Maths.Vector4F(
VertexAttribute.Constants[0],
VertexAttribute.Constants[1],
VertexAttribute.Constants[2],
VertexAttribute.Constants[3]);
}
}
private static Syroot.Maths.Vector4F ReadVertexBufferData(FileReader reader, SepdVertexAttribute VertexAttribute, int elementCount)

View File

@ -821,6 +821,11 @@ namespace LayoutBXLYT
return (int[])data;
}
public byte[] GetBytes()
{
return (byte[])data;
}
public void SetValue(string value)
{
data = value;
@ -839,14 +844,123 @@ namespace LayoutBXLYT
Type = UserDataType.Int;
}
public void SetValue(List<UserDataStruct> value)
{
data = value;
Type = UserDataType.StructData;
}
public List<UserDataStruct> GetStructs()
{
return (List<UserDataStruct>)data;
}
internal long _pos;
}
public class UserDataStruct
{
public ushort Unknown { get; set; } // 0
public List<UserDataStructEntry> Entries = new List<UserDataStructEntry>();
public UserDataStruct(FileReader reader, BxlytHeader header)
{
long pos = reader.Position;
ushort unknown = reader.ReadUInt16();
ushort numEntries = reader.ReadUInt16();
uint[] offsets = reader.ReadUInt32s(numEntries);
for (int i = 0; i < numEntries; i++)
{
reader.SeekBegin(pos + offsets[i]);
Entries.Add(new UserDataStructEntry(reader, header));
}
}
public void Write(FileWriter writer, LayoutHeader header)
{
long pos = writer.Position;
writer.Write(Unknown);
writer.Write((ushort)Entries.Count);
long _ofsPos = writer.Position;
//Fill empty spaces for offsets later
writer.Write(new uint[Entries.Count]);
for (int i = 0; i < Entries.Count; i++)
{
writer.WriteUint32Offset(_ofsPos + (i * 4), pos);
Entries[i].Write(writer, header);
}
}
}
public class UserDataStructEntry
{
public uint DataType { get; set; }
public List<object> Data { get; set; }
public UserDataStructEntry(FileReader reader, BxlytHeader header)
{
long pos = reader.Position;
DataType = reader.ReadUInt32();
uint numEntries = reader.ReadUInt32();
uint[] offsets = reader.ReadUInt32s((int)numEntries);
Console.WriteLine($"USD1 Struct DataType " + DataType);
Data = new List<object>();
for (int i = 0; i < numEntries; i++)
{
reader.SeekBegin(pos + offsets[i]);
switch (DataType)
{
case 0:
Data.Add(reader.ReadZeroTerminatedString());
break;
}
}
}
public void Write(FileWriter writer, LayoutHeader header)
{
long pos = writer.Position;
writer.Write(DataType);
writer.Write(Data.Count);
long _ofsPos = writer.Position;
//Fill empty spaces for offsets later
writer.Write(new uint[Data.Count]);
for (int i = 0; i < Data.Count; i++)
{
writer.WriteUint32Offset(_ofsPos + (i * 4), pos);
switch (DataType)
{
case 0:
writer.WriteString((string)Data[i]);
break;
}
if (i == Data.Count - 1)
writer.Align(64);
}
}
}
public enum UserDataType : byte
{
String,
Int,
Float,
StructData,
}
public enum AnimationTarget : byte
@ -1379,6 +1493,53 @@ namespace LayoutBXLYT
public BxlanPAT1 AnimationTag;
public BxlanPAI1 AnimationInfo;
public static bool ContainsEntry(byte[] bxlanFile, string[] EntryNames)
{
using (var reader = new FileReader(new System.IO.MemoryStream(bxlanFile)))
{
reader.SetByteOrder(true);
reader.ReadUInt32(); //magic
ushort byteOrderMark = reader.ReadUInt16();
reader.CheckByteOrderMark(byteOrderMark);
ushort HeaderSize = reader.ReadUInt16();
uint Version = reader.ReadUInt32();
uint FileSize = reader.ReadUInt32();
ushort sectionCount = reader.ReadUInt16();
reader.ReadUInt16(); //Padding
reader.SeekBegin(HeaderSize);
for (int i = 0; i < sectionCount; i++)
{
long pos = reader.Position;
string Signature = reader.ReadString(4, Encoding.ASCII);
uint SectionSize = reader.ReadUInt32();
if (Signature == "pai1")
{
reader.ReadUInt16(); //FrameSize
reader.ReadBoolean(); //Loop
reader.ReadByte(); //padding
var numTextures = reader.ReadUInt16();
var numEntries = reader.ReadUInt16();
var entryOffsetTbl = reader.ReadUInt32();
reader.SeekBegin(pos + entryOffsetTbl);
var entryOffsets = reader.ReadUInt32s(numEntries);
for (int e = 0; e < numEntries; e++)
{
reader.SeekBegin(pos + entryOffsets[e]);
string name = reader.ReadString(28, true);
if (EntryNames.Contains(name))
return true;
}
}
reader.SeekBegin(pos + SectionSize);
}
}
return false;
}
public BxlanPaiEntry TryGetTag(string name)
{
for (int i = 0; i < AnimationInfo.Entries?.Count; i++)
@ -1389,6 +1550,15 @@ namespace LayoutBXLYT
return null;
}
public bool ContainsEntry(string name)
{
for (int i = 0; i < AnimationInfo.Entries?.Count; i++) {
if (AnimationInfo.Entries[i].Name == name)
return true;
}
return false;
}
public virtual void Read(FileReader reader, BXLAN header)
{

View File

@ -1,195 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Toolbox;
using System.Windows.Forms;
using Toolbox.Library;
using Toolbox.Library.IO;
using Toolbox.Library.Forms;
using Toolbox.Library.Rendering;
using OpenTK;
using FirstPlugin.Forms;
namespace FirstPlugin
{
public class GFBMDL : TreeNodeFile, IContextMenuNode, IFileFormat
{
public FileType FileType { get; set; } = FileType.Model;
public bool CanSave { get; set; }
public string[] Description { get; set; } = new string[] { "Graphic Model" };
public string[] Extension { get; set; } = new string[] { "*.gfbmdl" };
public string FileName { get; set; }
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public bool Identify(System.IO.Stream stream)
{
using (var reader = new Toolbox.Library.IO.FileReader(stream, true))
{
reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
bool IsMatch = reader.ReadUInt32() == 0x20000000;
reader.Position = 0;
return IsMatch;
}
}
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
bool DrawablesLoaded = false;
public override void OnClick(TreeView treeView) {
LoadEditor<STPropertyGrid>();
}
public T LoadEditor<T>() where T : UserControl, new()
{
T control = new T();
control.Dock = DockStyle.Fill;
ViewportEditor editor = (ViewportEditor)LibraryGUI.GetActiveContent(typeof(ViewportEditor));
if (editor == null)
{
editor = new ViewportEditor(true);
editor.Dock = DockStyle.Fill;
LibraryGUI.LoadEditor(editor);
}
if (!DrawablesLoaded)
{
ObjectEditor.AddContainer(DrawableContainer);
DrawablesLoaded = true;
}
if (Runtime.UseOpenGL)
editor.LoadViewport(DrawableContainer);
editor.LoadEditor(control);
return control;
}
public GFBMDL_Render Renderer;
public DrawableContainer DrawableContainer = new DrawableContainer();
public GFLXModel Model;
public void Load(System.IO.Stream stream)
{
CanSave = false;
Text = FileName;
DrawableContainer.Name = FileName;
Renderer = new GFBMDL_Render();
DrawableContainer.Drawables.Add(Renderer);
Model = new GFLXModel();
Model.LoadFile(FlatBuffers.Gfbmdl.Model.GetRootAsModel(
new FlatBuffers.ByteBuffer(stream.ToBytes())),this, Renderer);
TreeNode SkeletonWrapper = new TreeNode("Skeleton");
TreeNode MaterialFolderWrapper = new TreeNode("Materials");
TreeNode VisualGroupWrapper = new TreeNode("Visual Groups");
TreeNode Textures = new TreeNode("Textures");
if (Model.Skeleton.bones.Count > 0)
{
Nodes.Add(SkeletonWrapper);
DrawableContainer.Drawables.Add(Model.Skeleton);
foreach (var bone in Model.Skeleton.bones) {
if (bone.Parent == null)
SkeletonWrapper.Nodes.Add(bone);
}
}
List<string> loadedTextures = new List<string>();
for (int i = 0; i < Model.Textures.Count; i++)
{
foreach (var bntx in PluginRuntime.bntxContainers)
{
if (bntx.Textures.ContainsKey(Model.Textures[i]) &&
!loadedTextures.Contains(Model.Textures[i]))
{
TreeNode tex = new TreeNode(Model.Textures[i]);
tex.ImageKey = "texture";
tex.SelectedImageKey = "texture";
tex.Tag = bntx.Textures[Model.Textures[i]];
Textures.Nodes.Add(tex);
loadedTextures.Add(Model.Textures[i]);
}
}
}
loadedTextures.Clear();
Nodes.Add(MaterialFolderWrapper);
Nodes.Add(VisualGroupWrapper);
if (Textures.Nodes.Count > 0)
Nodes.Add(Textures);
for (int i = 0; i < Model.GenericMaterials.Count; i++)
MaterialFolderWrapper.Nodes.Add(Model.GenericMaterials[i]);
for (int i = 0; i < Model.GenericMeshes.Count; i++)
VisualGroupWrapper.Nodes.Add(Model.GenericMeshes[i]);
}
public void Save(System.IO.Stream stream)
{
Model.SaveFile(stream);
}
public ToolStripItem[] GetContextMenuItems()
{
List<ToolStripItem> Items = new List<ToolStripItem>();
Items.Add(new ToolStripMenuItem("Export Model", null, ExportAction, Keys.Control | Keys.E));
return Items.ToArray();
}
private void ExportAction(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Supported Formats|*.dae;";
if (sfd.ShowDialog() == DialogResult.OK)
{
ExportModelSettings exportDlg = new ExportModelSettings();
if (exportDlg.ShowDialog() == DialogResult.OK)
ExportModel(sfd.FileName, exportDlg.Settings);
}
}
public void ExportModel(string fileName, DAE.ExportSettings settings)
{
var model = new STGenericModel();
model.Materials = Model.GenericMaterials;
model.Objects = Model.GenericMeshes;
var textures = new List<STGenericTexture>();
foreach (var bntx in PluginRuntime.bntxContainers)
foreach (var tex in bntx.Textures.Values)
{
if (Model.Textures.Contains(tex.Text))
textures.Add(tex);
}
DAE.Export(fileName, settings, model, textures, Model.Skeleton);
}
public void Unload()
{
}
}
}

View File

@ -1,333 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using FlatBuffers.Gfbmdl;
using Toolbox.Library;
using Toolbox.Library.IO;
using Toolbox.Library.Rendering;
using FirstPlugin.Forms;
namespace FirstPlugin
{
public class GFLXModel
{
public GFBMDL ParentFile;
public List<GFLXMaterialData> GenericMaterials = new List<GFLXMaterialData>();
public List<GFLXMesh> GenericMeshes = new List<GFLXMesh>();
public STSkeleton Skeleton = new STSkeleton();
public Model Model;
public List<string> Textures = new List<string>();
public List<string> Shaders = new List<string>();
public T LoadEditor<T>() where T :
System.Windows.Forms.UserControl, new()
{
return ParentFile.LoadEditor<T>();
}
public void UpdateVertexData(bool updateViewport) {
ParentFile.Renderer.UpdateVertexData();
if (updateViewport)
LibraryGUI.UpdateViewport();
}
public void LoadFile(Model model, GFBMDL file, GFBMDL_Render Renderer) {
Model = model;
ParentFile = file;
for (int t = 0; t < Model.TextureNamesLength; t++)
Textures.Add(Model.TextureNames(t));
for (int s = 0; s < Model.ShaderNamesLength; s++)
Shaders.Add(Model.ShaderNames(s));
for (int m = 0; m < Model.MaterialsLength; m++) {
var mat = Model.Materials(m).Value;
GenericMaterials.Add(new GFLXMaterialData(this, mat));
}
List<int> SkinningIndices = new List<int>();
for (int b = 0; b < Model.BonesLength; b++) {
var bone = Model.Bones(b).Value;
Skeleton.bones.Add(new GFLXBone(this, bone));
if (bone.SkinCheck == null)
SkinningIndices.Add(b);
}
Skeleton.reset();
Skeleton.update();
for (int g = 0; g < Model.GroupsLength; g++) {
var group = Model.Groups(g).Value;
var mesh = Model.Meshes(g).Value;
OpenTK.Matrix4 transform = OpenTK.Matrix4.Identity;
GFLXMesh genericMesh = new GFLXMesh(this, group, mesh);
genericMesh.Checked = true;
genericMesh.ImageKey = "model";
genericMesh.SelectedImageKey = "model";
int boneIndex = (int)group.BoneID;
if (boneIndex < Skeleton.bones.Count && boneIndex > 0)
{
genericMesh.BoneIndex = boneIndex;
transform = Skeleton.bones[boneIndex].Transform;
genericMesh.Text = Skeleton.bones[boneIndex].Text;
}
// if (group.MeshID < Skeleton.bones.Count && group.MeshID > 0)
// genericMesh.Text = Skeleton.bones[(int)group.MeshID].Text;
Renderer.Meshes.Add(genericMesh);
GenericMeshes.Add(genericMesh);
//Load the vertex data
genericMesh.vertices = GFLXMeshBufferHelper.LoadVertexData(mesh, transform, SkinningIndices);
genericMesh.FlipUvsVertical();
//Load faces
for (int p = 0; p < mesh.PolygonsLength; p++)
{
var poly = mesh.Polygons(p).Value;
var polygonGroup = new STGenericPolygonGroup();
polygonGroup.MaterialIndex = (int)poly.MaterialID;
genericMesh.PolygonGroups.Add(polygonGroup);
for (int f = 0; f < poly.DataLength; f++)
polygonGroup.faces.Add((int)poly.Data(f));
}
}
}
public void SaveFile(System.IO.Stream stream)
{
using (var writer = new FileWriter(stream)) {
writer.Write(Model.ByteBuffer.ToFullArray());
}
}
}
public class GFLXMaterialData : STGenericMaterial
{
private Material Material;
private GFLXModel ParentModel;
public Dictionary<string, GFLXSwitchParam> SwitchParams = new Dictionary<string, GFLXSwitchParam>();
public Dictionary<string, GFLXValueParam> ValueParams = new Dictionary<string, GFLXValueParam>();
public Dictionary<string, GFLXColorParam> ColorParams = new Dictionary<string, GFLXColorParam>();
public override void OnClick(TreeView treeView) {
var editor = ParentModel.LoadEditor<GFLXMaterialEditor>();
editor.LoadMaterial(this);
}
public GFLXMaterialData(GFLXModel parent, Material mat)
{
ParentModel = parent;
Material = mat;
Text = mat.Name;
for (int i = 0; i < Material.SwitchesLength; i++) {
var val = Material.Switches(i).Value;
SwitchParams.Add(val.Name, new GFLXSwitchParam(val));
}
for (int i = 0; i < Material.ValuesLength; i++) {
var val = Material.Values(i).Value;
ValueParams.Add(val.Name, new GFLXValueParam(val));
}
for (int i = 0; i < Material.ColorsLength; i++) {
var val = Material.Colors(i).Value;
ColorParams.Add(val.Name, new GFLXColorParam(val));
}
int textureUnit = 1;
for (int t = 0; t < Material.TexturesLength; t++)
{
var tex = Material.Textures(t).Value;
string name = ParentModel.Textures[tex.Index];
STGenericMatTexture matTexture = new STGenericMatTexture();
matTexture.Name = name;
matTexture.SamplerName = tex.Name;
matTexture.textureUnit = textureUnit++;
matTexture.WrapModeS = STTextureWrapMode.Mirror;
matTexture.WrapModeT = STTextureWrapMode.Repeat;
TextureMaps.Add(matTexture);
switch (tex.Name)
{
case "Col0Tex":
matTexture.Type = STGenericMatTexture.TextureType.Diffuse;
break;
case "EmissionMaskTex":
// matTexture.Type = STGenericMatTexture.TextureType.Emission;
break;
case "LyCol0Tex":
break;
case "NormalMapTex":
matTexture.WrapModeT = STTextureWrapMode.Repeat;
matTexture.WrapModeT = STTextureWrapMode.Repeat;
matTexture.Type = STGenericMatTexture.TextureType.Normal;
break;
case "AmbientTex":
break;
case "LightTblTex":
break;
case "SphereMapTex":
break;
case "EffectTex":
break;
}
}
}
}
public class GFLXBone : STBone
{
private Bone Bone;
private GFLXModel ParentModel;
public GFLXBone(GFLXModel parent, Bone bone) : base(parent.Skeleton)
{
ParentModel = parent;
Bone = bone;
Text = bone.Name;
parentIndex = bone.Parent;
if (bone.Translation != null)
{
position = new float[3]
{ bone.Translation.Value.X,
bone.Translation.Value.Y,
bone.Translation.Value.Z
};
}
if (bone.Rotation != null)
{
rotation = new float[4]
{ bone.Rotation.Value.X,
bone.Rotation.Value.Y,
bone.Rotation.Value.Z,
1.0f,
};
}
if (bone.Scale != null)
{
scale = new float[3]
{ bone.Scale.Value.X,
bone.Scale.Value.Y,
bone.Scale.Value.Z
};
}
}
}
public class GFLXColorParam
{
private MatColor Param;
public GFLXColorParam(MatColor param)
{
Param = param;
}
public string Name
{
get { return Param.Name; }
set
{
Param.ByteBuffer.PutStringUTF8(0, value);
}
}
public OpenTK.Vector3 Value
{
get { return new OpenTK.Vector3(
Param.Color.Value.R,
Param.Color.Value.G,
Param.Color.Value.B);
}
set
{
var vec3 = value;
Param.Color.Value.ByteBuffer.PutFloat(0, vec3.X);
Param.Color.Value.ByteBuffer.PutFloat(1, vec3.Y);
Param.Color.Value.ByteBuffer.PutFloat(2, vec3.Z);
}
}
}
public class GFLXValueParam
{
private MatFloat Param;
public GFLXValueParam(MatFloat param) {
Param = param;
}
public string Name
{
get { return Param.Name; }
set {
Param.ByteBuffer.PutStringUTF8(0, value);
}
}
public float Value
{
get { return Param.Value; }
set {
Param.ByteBuffer.PutFloat(1, value);
}
}
}
public class GFLXSwitchParam
{
private MatSwitch Param;
public GFLXSwitchParam(MatSwitch param)
{
Param = param;
}
public string Name
{
get { return Param.Name; }
set
{
Param.ByteBuffer.PutStringUTF8(0, value);
}
}
public bool Value
{
get { return Param.Value; }
set
{
Param.ByteBuffer.PutByte(1, value ? (byte)1 : (byte)0);
}
}
}
}

View File

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FlatBuffers.Gfbmdl;
using FlatBuffers;
namespace FirstPlugin
{
public class FlatBufferHelper
{
public static StringOffset[] CreateStringList(FlatBufferBuilder builder, List<string> strings)
{
StringOffset[] offsets = new StringOffset[strings.Count];
for (int i = 0; i < strings.Count; i++)
offsets[i] = builder.CreateString(strings[i]);
return offsets;
}
public static Offset<Vector3> CreateVector(
FlatBufferBuilder builder, Vector3? vector)
{
return Vector3.CreateVector3(builder,
vector.Value.X,
vector.Value.Y,
vector.Value.Z);
}
public static Offset<Vector3> CreateVector(
FlatBufferBuilder builder, Vector3 vector)
{
return Vector3.CreateVector3(builder,
vector.X,
vector.Y,
vector.Z);
}
}
}

View File

@ -12,10 +12,11 @@ using System.Reflection;
using Toolbox.Library.IO.FlatBuffer;
using Toolbox.Library.Animations;
using FirstPlugin.Forms;
using Toolbox.Library.Forms;
namespace FirstPlugin
{
public class GFBANM : TreeNodeFile, IFileFormat, IAnimationContainer
public class GFBANM : TreeNodeFile, IFileFormat, IAnimationContainer, IConvertableTextFormat
{
public STAnimation AnimationController => AnimationData;
@ -44,6 +45,30 @@ namespace FirstPlugin
}
}
#region Text Converter Interface
public TextFileType TextFileType => TextFileType.Json;
public bool CanConvertBack => false;
public string ConvertToString()
{
if (IFileInfo.ArchiveParent != null)
{
foreach (var file in IFileInfo.ArchiveParent.Files)
if (file.FileName == FileName)
return FlatBufferConverter.DeserializeToJson(new System.IO.MemoryStream(file.FileData), "gfbanm");
}
else
return FlatBufferConverter.DeserializeToJson(FilePath, "gfbanm");
return "";
}
public void ConvertFromString(string text)
{
}
#endregion
public Type[] Types
{
get
@ -90,8 +115,31 @@ namespace FirstPlugin
{
}
public class MeshAnimationController
{
public bool IsVisible = true;
}
public class Animation : STSkeletonAnimation
{
private GFBMDL ActiveModel
{
get
{
GFBMDL model = null;
foreach (var container in ObjectEditor.GetDrawableContainers()) {
if (container.ContainerState == ContainerState.Active) {
foreach (var drawable in container.Drawables)
{
if (drawable is GFBMDL_Render)
model = ((GFBMDL_Render)drawable).GfbmdlFile;
}
}
}
return model;
}
}
public override void NextFrame()
{
if (Frame > FrameCount) return;
@ -105,6 +153,26 @@ namespace FirstPlugin
bool Updated = false; // no need to update skeleton of animations that didn't change
foreach (var animGroup in AnimGroups)
{
if (animGroup is VisibiltyGroup && ActiveModel != null)
{
var node = animGroup as VisibiltyGroup;
foreach (var mesh in ActiveModel.Model.GenericMeshes) {
if (animGroup.Name == mesh.Text)
{
var value = node.BooleanTrack.GetFrameValue(Frame);
mesh.AnimationController.IsVisible = value == 1;
}
}
}
if (animGroup is MaterialGroup && ActiveModel != null)
{
foreach (var mat in ActiveModel.Model.GenericMaterials) {
if (animGroup.Name == mat.Text)
{
}
}
}
if (animGroup is BoneGroup)
{
var node = animGroup as BoneGroup;
@ -134,17 +202,22 @@ namespace FirstPlugin
if (node.RotationX.HasKeys || node.RotationY.HasKeys || node.RotationZ.HasKeys)
{
float x = node.RotationX.HasKeys ? node.RotationX.GetFrameValue(Frame) : b.rotation[0];
float y = node.RotationY.HasKeys ? node.RotationY.GetFrameValue(Frame) : b.rotation[1];
float z = node.RotationZ.HasKeys ? node.RotationZ.GetFrameValue(Frame) : b.rotation[2];
ushort value1 = (ushort)node.RotationX.GetFrameValue(Frame);
ushort value2 = (ushort)node.RotationY.GetFrameValue(Frame);
ushort value3 = (ushort)node.RotationZ.GetFrameValue(Frame);
var Rotation = new Vector3(x / 0xffff, y/ 0xffff, z / 0xffff).Normalized();
b.rot = EulerToQuat(Rotation.Z, Rotation.Y, Rotation.X);
int x = value1 >> 5;
int y = value2 >> 5;
int z = value3 >> 5;
var Rotation = new Vector3(x / (float)0xff, y/ (float)0xff, z / (float)0xff);
// b.rot = EulerToQuat(Rotation.Z, Rotation.Y, Rotation.X);
// Console.WriteLine($"{animGroup.Name} {Frame} {Rotation}");
// b.rot = EulerToQuat(Rotation.Z, Rotation.Y, Rotation.X);
float Angle = Rotation.Length;
Console.WriteLine($"{node.Name} Angle {Angle}");
// b.rot = Angle > 0
// ? Quaternion.FromAxisAngle(Vector3.Normalize(Rotation), Angle)
@ -168,7 +241,7 @@ namespace FirstPlugin
Quaternion xRotation = Quaternion.FromAxisAngle(Vector3.UnitX, x);
Quaternion yRotation = Quaternion.FromAxisAngle(Vector3.UnitY, y);
Quaternion zRotation = Quaternion.FromAxisAngle(Vector3.UnitZ, z);
return (zRotation * yRotation * xRotation);
return (zRotation * yRotation * xRotation);
}
public void LoadBoneGroup(Gfbanim.Bone boneAnim)
@ -193,7 +266,7 @@ namespace FirstPlugin
var rotate = boneAnim.Rotate<Gfbanim.DynamicQuatTrack>();
if (rotate.HasValue)
{
var values = LoadRotationTrack(rotate.Value);
var values = GfbanimKeyFrameLoader.LoadRotationTrack(rotate.Value);
groupAnim.RotationX = values[0];
groupAnim.RotationY = values[1];
groupAnim.RotationZ = values[2];
@ -206,9 +279,9 @@ namespace FirstPlugin
if (rotate.HasValue)
{
var vec = rotate.Value.Value.Value;
groupAnim.RotationX.KeyFrames.Add(new STKeyFrame(0, ConvertRotation(vec.X)));
groupAnim.RotationY.KeyFrames.Add(new STKeyFrame(0, ConvertRotation(vec.Y)));
groupAnim.RotationZ.KeyFrames.Add(new STKeyFrame(0, ConvertRotation(vec.Z)));
groupAnim.RotationX.KeyFrames.Add(new STKeyFrame(0, GfbanimKeyFrameLoader.ConvertRotation(vec.X)));
groupAnim.RotationY.KeyFrames.Add(new STKeyFrame(0, GfbanimKeyFrameLoader.ConvertRotation(vec.Y)));
groupAnim.RotationZ.KeyFrames.Add(new STKeyFrame(0, GfbanimKeyFrameLoader.ConvertRotation(vec.Z)));
}
}
break;
@ -217,7 +290,7 @@ namespace FirstPlugin
var rotate = boneAnim.Rotate<Gfbanim.FramedQuatTrack>();
if (rotate.HasValue)
{
var values = LoadRotationTrack(rotate.Value);
var values = GfbanimKeyFrameLoader.LoadRotationTrack(rotate.Value);
groupAnim.RotationX = values[0];
groupAnim.RotationY = values[1];
groupAnim.RotationZ = values[2];
@ -247,7 +320,7 @@ namespace FirstPlugin
var scale = boneAnim.Scale<Gfbanim.DynamicVectorTrack>();
if (scale.HasValue)
{
var values = LoadVectorTrack(scale.Value);
var values = GfbanimKeyFrameLoader.LoadVectorTrack(scale.Value);
groupAnim.ScaleX = values[0];
groupAnim.ScaleY = values[1];
groupAnim.ScaleZ = values[2];
@ -259,7 +332,7 @@ namespace FirstPlugin
var scale = boneAnim.Scale<Gfbanim.FramedVectorTrack>();
if (scale.HasValue)
{
var values = LoadVectorTrack(scale.Value);
var values = GfbanimKeyFrameLoader.LoadVectorTrack(scale.Value);
groupAnim.ScaleX = values[0];
groupAnim.ScaleY = values[1];
groupAnim.ScaleZ = values[2];
@ -286,7 +359,7 @@ namespace FirstPlugin
var trans = boneAnim.Translate<Gfbanim.DynamicVectorTrack>();
if (trans.HasValue)
{
var values = LoadVectorTrack(trans.Value);
var values = GfbanimKeyFrameLoader.LoadVectorTrack(trans.Value);
groupAnim.TranslateX = values[0];
groupAnim.TranslateY = values[1];
groupAnim.TranslateZ = values[2];
@ -298,7 +371,7 @@ namespace FirstPlugin
var trans = boneAnim.Translate<Gfbanim.FramedVectorTrack>();
if (trans.HasValue)
{
var values = LoadVectorTrack(trans.Value);
var values = GfbanimKeyFrameLoader.LoadVectorTrack(trans.Value);
groupAnim.TranslateX = values[0];
groupAnim.TranslateY = values[1];
groupAnim.TranslateZ = values[2];
@ -320,101 +393,53 @@ namespace FirstPlugin
}
}
public float ConvertRotation(ushort val)
{
return val;
}
public STAnimationTrack[] LoadRotationTrack(Gfbanim.DynamicQuatTrack dynamicTrack)
{
STAnimationTrack[] tracks = new STAnimationTrack[3];
tracks[0] = new STAnimationTrack(STInterpoaltionType.Linear);
tracks[1] = new STAnimationTrack(STInterpoaltionType.Linear);
tracks[2] = new STAnimationTrack(STInterpoaltionType.Linear);
for (int i = 0; i < dynamicTrack.ValuesLength; i++)
{
var quat = dynamicTrack.Values(i).Value;
tracks[0].KeyFrames.Add(new STKeyFrame(i, ConvertRotation(quat.X)));
tracks[1].KeyFrames.Add(new STKeyFrame(i, ConvertRotation(quat.Y)));
tracks[2].KeyFrames.Add(new STKeyFrame(i, ConvertRotation(quat.Z)));
Console.WriteLine($"{i} { ConvertRotation(quat.X)} { ConvertRotation(quat.Y)} {ConvertRotation(quat.Z)}");
}
return tracks;
}
public STAnimationTrack[] LoadVectorTrack(Gfbanim.DynamicVectorTrack dynamicTrack)
{
STAnimationTrack[] tracks = new STAnimationTrack[3];
tracks[0] = new STAnimationTrack(STInterpoaltionType.Linear);
tracks[1] = new STAnimationTrack(STInterpoaltionType.Linear);
tracks[2] = new STAnimationTrack(STInterpoaltionType.Linear);
for (int i = 0; i < dynamicTrack.ValuesLength; i++)
{
var vec = dynamicTrack.Values(i).Value;
tracks[0].KeyFrames.Add(new STKeyFrame(i, vec.X));
tracks[1].KeyFrames.Add(new STKeyFrame(i, vec.Y));
tracks[2].KeyFrames.Add(new STKeyFrame(i, vec.Z));
}
return tracks;
}
public STAnimationTrack[] LoadVectorTrack(Gfbanim.FramedVectorTrack framedTrack)
{
ushort[] frames = framedTrack.GetFramesArray();
STAnimationTrack[] tracks = new STAnimationTrack[3];
tracks[0] = new STAnimationTrack(STInterpoaltionType.Linear);
tracks[1] = new STAnimationTrack(STInterpoaltionType.Linear);
tracks[2] = new STAnimationTrack(STInterpoaltionType.Linear);
for (int i = 0; i < framedTrack.ValuesLength; i++)
{
var vec = framedTrack.Values(i).Value;
int frame = i;
if (i < frames?.Length) frame = frames[i];
tracks[0].KeyFrames.Add(new STKeyFrame(frame, vec.X));
tracks[1].KeyFrames.Add(new STKeyFrame(frame, vec.Y));
tracks[2].KeyFrames.Add(new STKeyFrame(frame, vec.Z));
}
return tracks;
}
public STAnimationTrack[] LoadRotationTrack(Gfbanim.FramedQuatTrack framedTrack)
{
ushort[] frames = framedTrack.GetFramesArray();
STAnimationTrack[] tracks = new STAnimationTrack[3];
tracks[0] = new STAnimationTrack(STInterpoaltionType.Linear);
tracks[1] = new STAnimationTrack(STInterpoaltionType.Linear);
tracks[2] = new STAnimationTrack(STInterpoaltionType.Linear);
for (int i = 0; i < framedTrack.ValuesLength; i++)
{
var quat = framedTrack.Values(i).Value;
int frame = i;
if (i < frames?.Length) frame = frames[i];
tracks[0].KeyFrames.Add(new STKeyFrame(frame, ConvertRotation(quat.X)));
tracks[1].KeyFrames.Add(new STKeyFrame(frame, ConvertRotation(quat.Y)));
tracks[2].KeyFrames.Add(new STKeyFrame(frame, ConvertRotation(quat.Z)));
}
return tracks;
}
public void LoadMaterialGroup(Gfbanim.Material matAnim)
{
for (int i = 0; i < matAnim.SwitchesLength; i++)
{
var switchTrack = matAnim.Switches(i).Value;
}
for (int i = 0; i < matAnim.ValuesLength; i++)
{
var valueTrack = matAnim.Values(i).Value;
}
for (int i = 0; i < matAnim.VectorsLength; i++)
{
var vectorTrack = matAnim.Vectors(i).Value;
}
}
public void LoadVisibilyGroup(Gfbanim.Group visAnim)
{
VisibiltyGroup groupAnim = new VisibiltyGroup();
groupAnim.Name = visAnim.Name;
AnimGroups.Add(groupAnim);
if (visAnim.ValueType == Gfbanim.BooleanTrack.FixedBooleanTrack) {
var track = visAnim.Value<Gfbanim.FixedBooleanTrack>();
if (track.HasValue)
{
var animTrack = new STAnimationTrack();
animTrack.KeyFrames.Add(new STKeyFrame(0, track.Value.Value));
groupAnim.BooleanTrack = animTrack;
}
}
else if (visAnim.ValueType == Gfbanim.BooleanTrack.DynamicBooleanTrack) {
var track = visAnim.Value<Gfbanim.DynamicBooleanTrack>();
if (track.HasValue) {
groupAnim.BooleanTrack = GfbanimKeyFrameLoader.LoadBooleanTrack(track.Value);
}
}
else if(visAnim.ValueType == Gfbanim.BooleanTrack.FramedBooleanTrack) {
var track = visAnim.Value<Gfbanim.FramedBooleanTrack>();
if (track.HasValue)
{
groupAnim.BooleanTrack = GfbanimKeyFrameLoader.LoadBooleanTrack(track.Value);
}
}
}
public void LoadTriggerGroup(Gfbanim.Trigger triggerAnim)

View File

@ -0,0 +1,129 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.Animations;
namespace FirstPlugin
{
public class GfbanimKeyFrameLoader
{
public static STAnimationTrack[] LoadRotationTrack(Gfbanim.DynamicQuatTrack dynamicTrack)
{
STAnimationTrack[] tracks = new STAnimationTrack[3];
tracks[0] = new STAnimationTrack(STInterpoaltionType.Linear);
tracks[1] = new STAnimationTrack(STInterpoaltionType.Linear);
tracks[2] = new STAnimationTrack(STInterpoaltionType.Linear);
for (int i = 0; i < dynamicTrack.ValuesLength; i++)
{
var quat = dynamicTrack.Values(i).Value;
tracks[0].KeyFrames.Add(new STKeyFrame(i, ConvertRotation(quat.X)));
tracks[1].KeyFrames.Add(new STKeyFrame(i, ConvertRotation(quat.Y)));
tracks[2].KeyFrames.Add(new STKeyFrame(i, ConvertRotation(quat.Z)));
}
return tracks;
}
public static float ConvertRotation(ushort val)
{
return val;
}
public static STAnimationTrack[] LoadVectorTrack(Gfbanim.DynamicVectorTrack dynamicTrack)
{
STAnimationTrack[] tracks = new STAnimationTrack[3];
tracks[0] = new STAnimationTrack(STInterpoaltionType.Linear);
tracks[1] = new STAnimationTrack(STInterpoaltionType.Linear);
tracks[2] = new STAnimationTrack(STInterpoaltionType.Linear);
for (int i = 0; i < dynamicTrack.ValuesLength; i++)
{
var vec = dynamicTrack.Values(i).Value;
tracks[0].KeyFrames.Add(new STKeyFrame(i, vec.X));
tracks[1].KeyFrames.Add(new STKeyFrame(i, vec.Y));
tracks[2].KeyFrames.Add(new STKeyFrame(i, vec.Z));
}
return tracks;
}
public static STAnimationTrack[] LoadVectorTrack(Gfbanim.FramedVectorTrack framedTrack)
{
ushort[] frames = framedTrack.GetFramesArray();
STAnimationTrack[] tracks = new STAnimationTrack[3];
tracks[0] = new STAnimationTrack(STInterpoaltionType.Linear);
tracks[1] = new STAnimationTrack(STInterpoaltionType.Linear);
tracks[2] = new STAnimationTrack(STInterpoaltionType.Linear);
for (int i = 0; i < framedTrack.ValuesLength; i++)
{
var vec = framedTrack.Values(i).Value;
int frame = i;
if (i < frames?.Length) frame = frames[i];
tracks[0].KeyFrames.Add(new STKeyFrame(frame, vec.X));
tracks[1].KeyFrames.Add(new STKeyFrame(frame, vec.Y));
tracks[2].KeyFrames.Add(new STKeyFrame(frame, vec.Z));
}
return tracks;
}
public static STAnimationTrack LoadBooleanTrack(Gfbanim.DynamicBooleanTrack framedTrack)
{
STAnimationTrack track = new STAnimationTrack(STInterpoaltionType.Step);
for (int i = 0; i < framedTrack.ValuesLength; i++)
{
ushort val = framedTrack.Values(i);
int frame = i;
//Visibily is handled by bits from a ushort
track.KeyFrames.Add(new STKeyFrame(frame, val));
}
return track;
}
public static STAnimationTrack LoadBooleanTrack(Gfbanim.FramedBooleanTrack framedTrack)
{
ushort[] frames = framedTrack.GetFramesArray();
STAnimationTrack track = new STAnimationTrack(STInterpoaltionType.Step);
for (int i = 0; i < framedTrack.ValuesLength; i++)
{
ushort val = framedTrack.Values(i);
int frame = i;
if (i < frames?.Length) frame = frames[i];
//Visibily is handled by bits from a ushort
track.KeyFrames.Add(new STKeyFrame(frame, val));
}
return track;
}
public static STAnimationTrack[] LoadRotationTrack(Gfbanim.FramedQuatTrack framedTrack)
{
ushort[] frames = framedTrack.GetFramesArray();
STAnimationTrack[] tracks = new STAnimationTrack[3];
tracks[0] = new STAnimationTrack(STInterpoaltionType.Linear);
tracks[1] = new STAnimationTrack(STInterpoaltionType.Linear);
tracks[2] = new STAnimationTrack(STInterpoaltionType.Linear);
for (int i = 0; i < framedTrack.ValuesLength; i++)
{
var quat = framedTrack.Values(i).Value;
int frame = i;
if (i < frames?.Length) frame = frames[i];
tracks[0].KeyFrames.Add(new STKeyFrame(frame, ConvertRotation(quat.X)));
tracks[1].KeyFrames.Add(new STKeyFrame(frame, ConvertRotation(quat.Y)));
tracks[2].KeyFrames.Add(new STKeyFrame(frame, ConvertRotation(quat.Z)));
}
return tracks;
}
}
}

View File

@ -0,0 +1,312 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FirstPlugin.GFMDLStructs;
using Toolbox.Library.IO;
namespace FirstPlugin
{
public class BufferToStruct
{
public static Model LoadFile(System.IO.Stream stream)
{
var buffer = FlatBuffers.Gfbmdl.Model.GetRootAsModel(
new FlatBuffers.ByteBuffer(stream.ToBytes()));
Model model = new Model();
model.Version = buffer.Version;
model.Bounding = ConvertBounding(buffer.Bounding);
model.TextureNames = new List<string>();
model.ShaderNames = new List<string>();
model.MaterialNames = new List<string>();
for (int i = 0; i < buffer.TextureNamesLength; i++)
model.TextureNames.Add(buffer.TextureNames(i));
for (int i = 0; i < buffer.ShaderNamesLength; i++)
model.ShaderNames.Add(buffer.ShaderNames(i));
for (int i = 0; i < buffer.MaterialNamesLength; i++)
model.MaterialNames.Add(buffer.MaterialNames(i));
model.Materials = new List<Material>();
for (int i = 0; i < buffer.MaterialsLength; i++)
{
var mat = buffer.Materials(i).Value;
List<MatColor> colors = new List<MatColor>();
List<MatSwitch> switches = new List<MatSwitch>();
List<MatFloat> values = new List<MatFloat>();
List<TextureMap> textures = new List<TextureMap>();
MaterialCommon common = null;
if (mat.Common != null)
{
var com = mat.Common.Value;
List<MatColor> sharedColors = new List<MatColor>();
List<MatSwitch> sharedSwitches = new List<MatSwitch>();
List<MatInt> sharedValues = new List<MatInt>();
for (int j = 0; j < com.ColorsLength; j++)
{
var col = com.Colors(j).Value;
sharedColors.Add(new MatColor()
{
Color = ConvertColor(col.Color),
Name = col.Name,
});
}
for (int j = 0; j < com.ValuesLength; j++)
{
var val = com.Values(j).Value;
sharedValues.Add(new MatInt()
{
Value = val.Value,
Name = val.Name,
});
}
for (int j = 0; j < com.SwitchesLength; j++)
{
var val = com.Switches(j).Value;
sharedSwitches.Add(new MatSwitch()
{
Value = val.Value,
Name = val.Name,
});
}
common = new MaterialCommon()
{
Switches = sharedSwitches,
Values = sharedValues,
Colors = sharedColors,
};
}
for (int j = 0; j < mat.TextureMapsLength; j++)
{
var tex = mat.TextureMaps(j).Value;
TextureParams parameters = null;
if (tex.Params != null)
{
var param = tex.Params.Value;
parameters = new TextureParams()
{
Unknown1 = param.Unknown1,
Unknown2 = param.Unknown2,
Unknown3 = param.Unknown3,
Unknown4 = param.Unknown4,
Unknown5 = param.Unknown5,
Unknown6 = param.Unknown6,
Unknown7 = param.Unknown7,
Unknown8 = param.Unknown8,
lodBias = param.LodBias,
};
}
textures.Add(new TextureMap()
{
Index = (uint)tex.Index,
Sampler = tex.Sampler,
Params = parameters,
});
}
for (int j = 0; j < mat.ColorsLength; j++)
{
var col = mat.Colors(j).Value;
colors.Add(new MatColor()
{
Color = ConvertColor(col.Color),
Name = col.Name,
});
}
for (int j = 0; j < mat.ValuesLength; j++)
{
var val = mat.Values(j).Value;
values.Add(new MatFloat()
{
Value = val.Value,
Name = val.Name,
});
}
for (int j = 0; j < mat.SwitchesLength; j++)
{
var val = mat.Switches(j).Value;
switches.Add(new MatSwitch()
{
Value = val.Value,
Name = val.Name,
});
}
model.Materials.Add(new Material()
{
Name = mat.Name,
Switches = switches,
Colors = colors,
Values = values,
Parameter1 = mat.Parameter1,
Parameter2 = mat.Parameter2,
Parameter3 = mat.Parameter3,
Parameter4 = mat.Parameter4,
Parameter5 = mat.Parameter5,
Parameter6 = mat.Parameter6,
RenderLayer = mat.RenderLayer,
ShaderGroup = mat.ShaderGroup,
Unknown1 = mat.Unknown1,
Unknown2 = mat.Unknown2,
Unknown3 = mat.Unknown3,
Unknown4 = mat.Unknown4,
Unknown5 = mat.Unknown5,
Unknown6 = mat.Unknown6,
Unknown7 = mat.Unknown7,
Common = common,
TextureMaps = textures,
});
}
model.Groups = new List<Group>();
for (int i = 0; i < buffer.GroupsLength; i++)
{
var group = buffer.Groups(i).Value;
model.Groups.Add(new Group()
{
BoneIndex = group.BoneIndex,
Layer = group.Layer,
MeshIndex= group.MeshIndex,
Bounding = ConvertBounding(group.Bounding),
});
}
model.Meshes = new List<Mesh>();
for (int i = 0; i < buffer.MeshesLength; i++)
{
var mesh = buffer.Meshes(i).Value;
List<MeshAttribute> attributes = new List<MeshAttribute>();
for (int j = 0; j < mesh.AttributesLength; j++)
{
var att = mesh.Attributes(j).Value;
attributes.Add(new MeshAttribute()
{
BufferFormat = att.BufferFormat,
ElementCount = att.ElementCount,
VertexType = att.VertexType,
});
}
List<MeshPolygon> polygons = new List<MeshPolygon>();
for (int j = 0; j < mesh.PolygonsLength; j++)
{
var poly = mesh.Polygons(j).Value;
polygons.Add(new MeshPolygon()
{
MaterialIndex = poly.MaterialIndex,
Faces = poly.GetFacesArray().ToList(),
});
}
model.Meshes.Add(new Mesh()
{
Attributes = attributes,
Polygons = polygons,
Data = mesh.GetDataArray().ToList(),
});
}
model.Bones = new List<Bone>();
for (int i = 0; i < buffer.BonesLength; i++)
{
var bone = buffer.Bones(i).Value;
BoneRigidData rigidData = null;
if (bone.RigidCheck != null)
{
rigidData = new BoneRigidData();
rigidData.Unknown1 = (uint)bone.RigidCheck.Value.Unknown1;
}
model.Bones.Add(new Bone()
{
Name = bone.Name,
BoneType = bone.BoneType,
Parent = bone.Parent,
Scale = ConvertVec3(bone.Scale),
Rotation = ConvertVec3(bone.Rotation),
Translation = ConvertVec3(bone.Translation),
RadiusEnd = ConvertVec3(bone.RadiusEnd),
RadiusStart = ConvertVec3(bone.RadiusStart),
Visible = bone.Visible,
Zero = bone.Zero,
RigidCheck = rigidData,
});
}
model.CollisionGroups = new List<CollisionGroup>();
for (int i = 0; i < buffer.CollisionGroupsLength; i++)
{
var colGroup = buffer.CollisionGroups(i).Value;
List<uint> children = colGroup.GetBoneChildrenArray().ToList();
model.CollisionGroups.Add(new CollisionGroup()
{
BoneIndex = colGroup.BoneIndex,
Unknown1 = colGroup.Unknown1,
Bounding = ConvertBounding(colGroup.Bounding),
BoneChildren = children,
});
}
model.Unknown = new List<UnknownEmpty>();
return model;
}
public static BoundingBox ConvertBounding(FlatBuffers.Gfbmdl.BoundingBox? buffer)
{
if (buffer != null && buffer.HasValue)
{
BoundingBox bounding = new BoundingBox();
bounding.MinX = buffer.Value.MinX;
bounding.MinY = buffer.Value.MinY;
bounding.MinZ = buffer.Value.MinZ;
bounding.MaxX = buffer.Value.MaxX;
bounding.MaxY = buffer.Value.MaxY;
bounding.MaxZ = buffer.Value.MaxZ;
return bounding;
}
else
return null;
}
public static Vector3 ConvertVec3(FlatBuffers.Gfbmdl.Vector3? vec3)
{
if (vec3 != null && vec3.HasValue)
return new Vector3(vec3.Value.X, vec3.Value.Y, vec3.Value.Z);
else
return null;
}
public static Vector4 ConvertVec4(FlatBuffers.Gfbmdl.Vector4? vec3)
{
if (vec3 != null && vec3.HasValue)
return new Vector4(vec3.Value.X, vec3.Value.Y, vec3.Value.Z, vec3.Value.W);
else
return null;
}
public static ColorRGB32 ConvertColor(FlatBuffers.Gfbmdl.ColorRGB32? col)
{
if (col != null && col.HasValue)
return new ColorRGB32(col.Value.R, col.Value.G, col.Value.B);
else
return null;
}
}
}

View File

@ -4,6 +4,7 @@
namespace FlatBuffers.Gfbmdl
{
using global::System;
using global::FlatBuffers;
@ -66,8 +67,8 @@ namespace FlatBuffers.Gfbmdl
public int MeshesLength { get { int o = __p.__offset(20); return o != 0 ? __p.__vector_len(o) : 0; } }
public Bone? Bones(int j) { int o = __p.__offset(22); return o != 0 ? (Bone?)(new Bone()).__assign(__p.__indirect(__p.__vector(o) + j * 4), __p.bb) : null; }
public int BonesLength { get { int o = __p.__offset(22); return o != 0 ? __p.__vector_len(o) : 0; } }
public RenderInfo? RenderData(int j) { int o = __p.__offset(24); return o != 0 ? (RenderInfo?)(new RenderInfo()).__assign(__p.__indirect(__p.__vector(o) + j * 4), __p.bb) : null; }
public int RenderDataLength { get { int o = __p.__offset(24); return o != 0 ? __p.__vector_len(o) : 0; } }
public CollisionGroup? CollisionGroups(int j) { int o = __p.__offset(24); return o != 0 ? (CollisionGroup?)(new CollisionGroup()).__assign(__p.__indirect(__p.__vector(o) + j * 4), __p.bb) : null; }
public int CollisionGroupsLength { get { int o = __p.__offset(24); return o != 0 ? __p.__vector_len(o) : 0; } }
public static void StartModel(FlatBufferBuilder builder) { builder.StartObject(11); }
public static void AddVersion(FlatBufferBuilder builder, uint Version) { builder.AddUint(0, Version, 0); }
@ -104,10 +105,10 @@ namespace FlatBuffers.Gfbmdl
public static VectorOffset CreateBonesVector(FlatBufferBuilder builder, Offset<Bone>[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
public static VectorOffset CreateBonesVectorBlock(FlatBufferBuilder builder, Offset<Bone>[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
public static void StartBonesVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
public static void AddRenderData(FlatBufferBuilder builder, VectorOffset RenderDataOffset) { builder.AddOffset(10, RenderDataOffset.Value, 0); }
public static VectorOffset CreateRenderDataVector(FlatBufferBuilder builder, Offset<RenderInfo>[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
public static VectorOffset CreateRenderDataVectorBlock(FlatBufferBuilder builder, Offset<RenderInfo>[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
public static void StartRenderDataVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
public static void AddCollisionGroups(FlatBufferBuilder builder, VectorOffset CollisionGroupsOffset) { builder.AddOffset(10, CollisionGroupsOffset.Value, 0); }
public static VectorOffset CreateCollisionGroupsVector(FlatBufferBuilder builder, Offset<CollisionGroup>[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
public static VectorOffset CreateCollisionGroupsVectorBlock(FlatBufferBuilder builder, Offset<CollisionGroup>[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
public static void StartCollisionGroupsVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
public static Offset<Model> EndModel(FlatBufferBuilder builder)
{
int o = builder.EndObject();
@ -169,50 +170,50 @@ namespace FlatBuffers.Gfbmdl
#endif
public byte[] GetShaderGroupArray() { return __p.__vector_as_array<byte>(6); }
public int RenderLayer { get { int o = __p.__offset(8); return o != 0 ? __p.bb.GetInt(o + __p.bb_pos) : (int)0; } }
public sbyte Unknown1 { get { int o = __p.__offset(10); return o != 0 ? __p.bb.GetSbyte(o + __p.bb_pos) : (sbyte)0; } }
public sbyte Unknown2 { get { int o = __p.__offset(12); return o != 0 ? __p.bb.GetSbyte(o + __p.bb_pos) : (sbyte)0; } }
public byte Unknown1 { get { int o = __p.__offset(10); return o != 0 ? __p.bb.Get(o + __p.bb_pos) : (byte)0; } }
public byte Unknown2 { get { int o = __p.__offset(12); return o != 0 ? __p.bb.Get(o + __p.bb_pos) : (byte)0; } }
public int Parameter1 { get { int o = __p.__offset(14); return o != 0 ? __p.bb.GetInt(o + __p.bb_pos) : (int)0; } }
public int Parameter2 { get { int o = __p.__offset(16); return o != 0 ? __p.bb.GetInt(o + __p.bb_pos) : (int)0; } }
public int Parameter3 { get { int o = __p.__offset(18); return o != 0 ? __p.bb.GetInt(o + __p.bb_pos) : (int)0; } }
public int Parameter4 { get { int o = __p.__offset(20); return o != 0 ? __p.bb.GetInt(o + __p.bb_pos) : (int)0; } }
public int Parameter5 { get { int o = __p.__offset(22); return o != 0 ? __p.bb.GetInt(o + __p.bb_pos) : (int)0; } }
public int Parameter6 { get { int o = __p.__offset(24); return o != 0 ? __p.bb.GetInt(o + __p.bb_pos) : (int)0; } }
public TextureMap? Textures(int j) { int o = __p.__offset(26); return o != 0 ? (TextureMap?)(new TextureMap()).__assign(__p.__indirect(__p.__vector(o) + j * 4), __p.bb) : null; }
public int TexturesLength { get { int o = __p.__offset(26); return o != 0 ? __p.__vector_len(o) : 0; } }
public TextureMap? TextureMaps(int j) { int o = __p.__offset(26); return o != 0 ? (TextureMap?)(new TextureMap()).__assign(__p.__indirect(__p.__vector(o) + j * 4), __p.bb) : null; }
public int TextureMapsLength { get { int o = __p.__offset(26); return o != 0 ? __p.__vector_len(o) : 0; } }
public MatSwitch? Switches(int j) { int o = __p.__offset(28); return o != 0 ? (MatSwitch?)(new MatSwitch()).__assign(__p.__indirect(__p.__vector(o) + j * 4), __p.bb) : null; }
public int SwitchesLength { get { int o = __p.__offset(28); return o != 0 ? __p.__vector_len(o) : 0; } }
public MatFloat? Values(int j) { int o = __p.__offset(30); return o != 0 ? (MatFloat?)(new MatFloat()).__assign(__p.__indirect(__p.__vector(o) + j * 4), __p.bb) : null; }
public int ValuesLength { get { int o = __p.__offset(30); return o != 0 ? __p.__vector_len(o) : 0; } }
public MatColor? Colors(int j) { int o = __p.__offset(32); return o != 0 ? (MatColor?)(new MatColor()).__assign(__p.__indirect(__p.__vector(o) + j * 4), __p.bb) : null; }
public int ColorsLength { get { int o = __p.__offset(32); return o != 0 ? __p.__vector_len(o) : 0; } }
public sbyte Unknown3 { get { int o = __p.__offset(34); return o != 0 ? __p.bb.GetSbyte(o + __p.bb_pos) : (sbyte)0; } }
public sbyte Unknown4 { get { int o = __p.__offset(36); return o != 0 ? __p.bb.GetSbyte(o + __p.bb_pos) : (sbyte)0; } }
public sbyte Unknown5 { get { int o = __p.__offset(38); return o != 0 ? __p.bb.GetSbyte(o + __p.bb_pos) : (sbyte)0; } }
public sbyte Unknown6 { get { int o = __p.__offset(40); return o != 0 ? __p.bb.GetSbyte(o + __p.bb_pos) : (sbyte)0; } }
public sbyte Unknown7 { get { int o = __p.__offset(42); return o != 0 ? __p.bb.GetSbyte(o + __p.bb_pos) : (sbyte)0; } }
public byte Unknown3 { get { int o = __p.__offset(34); return o != 0 ? __p.bb.Get(o + __p.bb_pos) : (byte)0; } }
public byte Unknown4 { get { int o = __p.__offset(36); return o != 0 ? __p.bb.Get(o + __p.bb_pos) : (byte)0; } }
public byte Unknown5 { get { int o = __p.__offset(38); return o != 0 ? __p.bb.Get(o + __p.bb_pos) : (byte)0; } }
public byte Unknown6 { get { int o = __p.__offset(40); return o != 0 ? __p.bb.Get(o + __p.bb_pos) : (byte)0; } }
public byte Unknown7 { get { int o = __p.__offset(42); return o != 0 ? __p.bb.Get(o + __p.bb_pos) : (byte)0; } }
public MaterialCommon? Common { get { int o = __p.__offset(44); return o != 0 ? (MaterialCommon?)(new MaterialCommon()).__assign(__p.__indirect(o + __p.bb_pos), __p.bb) : null; } }
public static Offset<Material> CreateMaterial(FlatBufferBuilder builder,
StringOffset NameOffset = default(StringOffset),
StringOffset ShaderGroupOffset = default(StringOffset),
int RenderLayer = 0,
sbyte Unknown1 = 0,
sbyte Unknown2 = 0,
byte Unknown1 = 0,
byte Unknown2 = 0,
int Parameter1 = 0,
int Parameter2 = 0,
int Parameter3 = 0,
int Parameter4 = 0,
int Parameter5 = 0,
int Parameter6 = 0,
VectorOffset TexturesOffset = default(VectorOffset),
VectorOffset TextureMapsOffset = default(VectorOffset),
VectorOffset SwitchesOffset = default(VectorOffset),
VectorOffset ValuesOffset = default(VectorOffset),
VectorOffset ColorsOffset = default(VectorOffset),
sbyte Unknown3 = 0,
sbyte Unknown4 = 0,
sbyte Unknown5 = 0,
sbyte Unknown6 = 0,
sbyte Unknown7 = 0,
byte Unknown3 = 0,
byte Unknown4 = 0,
byte Unknown5 = 0,
byte Unknown6 = 0,
byte Unknown7 = 0,
Offset<MaterialCommon> CommonOffset = default(Offset<MaterialCommon>))
{
builder.StartObject(21);
@ -220,7 +221,7 @@ namespace FlatBuffers.Gfbmdl
Material.AddColors(builder, ColorsOffset);
Material.AddValues(builder, ValuesOffset);
Material.AddSwitches(builder, SwitchesOffset);
Material.AddTextures(builder, TexturesOffset);
Material.AddTextureMaps(builder, TextureMapsOffset);
Material.AddParameter6(builder, Parameter6);
Material.AddParameter5(builder, Parameter5);
Material.AddParameter4(builder, Parameter4);
@ -244,18 +245,18 @@ namespace FlatBuffers.Gfbmdl
public static void AddName(FlatBufferBuilder builder, StringOffset NameOffset) { builder.AddOffset(0, NameOffset.Value, 0); }
public static void AddShaderGroup(FlatBufferBuilder builder, StringOffset ShaderGroupOffset) { builder.AddOffset(1, ShaderGroupOffset.Value, 0); }
public static void AddRenderLayer(FlatBufferBuilder builder, int RenderLayer) { builder.AddInt(2, RenderLayer, 0); }
public static void AddUnknown1(FlatBufferBuilder builder, sbyte Unknown1) { builder.AddSbyte(3, Unknown1, 0); }
public static void AddUnknown2(FlatBufferBuilder builder, sbyte Unknown2) { builder.AddSbyte(4, Unknown2, 0); }
public static void AddUnknown1(FlatBufferBuilder builder, byte Unknown1) { builder.AddByte(3, Unknown1, 0); }
public static void AddUnknown2(FlatBufferBuilder builder, byte Unknown2) { builder.AddByte(4, Unknown2, 0); }
public static void AddParameter1(FlatBufferBuilder builder, int Parameter1) { builder.AddInt(5, Parameter1, 0); }
public static void AddParameter2(FlatBufferBuilder builder, int Parameter2) { builder.AddInt(6, Parameter2, 0); }
public static void AddParameter3(FlatBufferBuilder builder, int Parameter3) { builder.AddInt(7, Parameter3, 0); }
public static void AddParameter4(FlatBufferBuilder builder, int Parameter4) { builder.AddInt(8, Parameter4, 0); }
public static void AddParameter5(FlatBufferBuilder builder, int Parameter5) { builder.AddInt(9, Parameter5, 0); }
public static void AddParameter6(FlatBufferBuilder builder, int Parameter6) { builder.AddInt(10, Parameter6, 0); }
public static void AddTextures(FlatBufferBuilder builder, VectorOffset TexturesOffset) { builder.AddOffset(11, TexturesOffset.Value, 0); }
public static VectorOffset CreateTexturesVector(FlatBufferBuilder builder, Offset<TextureMap>[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
public static VectorOffset CreateTexturesVectorBlock(FlatBufferBuilder builder, Offset<TextureMap>[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
public static void StartTexturesVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
public static void AddTextureMaps(FlatBufferBuilder builder, VectorOffset TextureMapsOffset) { builder.AddOffset(11, TextureMapsOffset.Value, 0); }
public static VectorOffset CreateTextureMapsVector(FlatBufferBuilder builder, Offset<TextureMap>[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
public static VectorOffset CreateTextureMapsVectorBlock(FlatBufferBuilder builder, Offset<TextureMap>[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
public static void StartTextureMapsVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
public static void AddSwitches(FlatBufferBuilder builder, VectorOffset SwitchesOffset) { builder.AddOffset(12, SwitchesOffset.Value, 0); }
public static VectorOffset CreateSwitchesVector(FlatBufferBuilder builder, Offset<MatSwitch>[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
public static VectorOffset CreateSwitchesVectorBlock(FlatBufferBuilder builder, Offset<MatSwitch>[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
@ -268,11 +269,11 @@ namespace FlatBuffers.Gfbmdl
public static VectorOffset CreateColorsVector(FlatBufferBuilder builder, Offset<MatColor>[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
public static VectorOffset CreateColorsVectorBlock(FlatBufferBuilder builder, Offset<MatColor>[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
public static void StartColorsVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
public static void AddUnknown3(FlatBufferBuilder builder, sbyte Unknown3) { builder.AddSbyte(15, Unknown3, 0); }
public static void AddUnknown4(FlatBufferBuilder builder, sbyte Unknown4) { builder.AddSbyte(16, Unknown4, 0); }
public static void AddUnknown5(FlatBufferBuilder builder, sbyte Unknown5) { builder.AddSbyte(17, Unknown5, 0); }
public static void AddUnknown6(FlatBufferBuilder builder, sbyte Unknown6) { builder.AddSbyte(18, Unknown6, 0); }
public static void AddUnknown7(FlatBufferBuilder builder, sbyte Unknown7) { builder.AddSbyte(19, Unknown7, 0); }
public static void AddUnknown3(FlatBufferBuilder builder, byte Unknown3) { builder.AddByte(15, Unknown3, 0); }
public static void AddUnknown4(FlatBufferBuilder builder, byte Unknown4) { builder.AddByte(16, Unknown4, 0); }
public static void AddUnknown5(FlatBufferBuilder builder, byte Unknown5) { builder.AddByte(17, Unknown5, 0); }
public static void AddUnknown6(FlatBufferBuilder builder, byte Unknown6) { builder.AddByte(18, Unknown6, 0); }
public static void AddUnknown7(FlatBufferBuilder builder, byte Unknown7) { builder.AddByte(19, Unknown7, 0); }
public static void AddCommon(FlatBufferBuilder builder, Offset<MaterialCommon> CommonOffset) { builder.AddOffset(20, CommonOffset.Value, 0); }
public static Offset<Material> EndMaterial(FlatBufferBuilder builder)
{
@ -480,32 +481,32 @@ namespace FlatBuffers.Gfbmdl
public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; }
public TextureMap __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public string Name { get { int o = __p.__offset(4); return o != 0 ? __p.__string(o + __p.bb_pos) : null; } }
public string Sampler { get { int o = __p.__offset(4); return o != 0 ? __p.__string(o + __p.bb_pos) : null; } }
#if ENABLE_SPAN_T
public Span<byte> GetNameBytes() { return __p.__vector_as_span(4); }
public Span<byte> GetSamplerBytes() { return __p.__vector_as_span(4); }
#else
public ArraySegment<byte>? GetNameBytes() { return __p.__vector_as_arraysegment(4); }
public ArraySegment<byte>? GetSamplerBytes() { return __p.__vector_as_arraysegment(4); }
#endif
public byte[] GetNameArray() { return __p.__vector_as_array<byte>(4); }
public byte[] GetSamplerArray() { return __p.__vector_as_array<byte>(4); }
public int Index { get { int o = __p.__offset(6); return o != 0 ? __p.bb.GetInt(o + __p.bb_pos) : (int)0; } }
public TextureMapping? Mapping { get { int o = __p.__offset(8); return o != 0 ? (TextureMapping?)(new TextureMapping()).__assign(__p.__indirect(o + __p.bb_pos), __p.bb) : null; } }
public TextureMapping? Params { get { int o = __p.__offset(8); return o != 0 ? (TextureMapping?)(new TextureMapping()).__assign(__p.__indirect(o + __p.bb_pos), __p.bb) : null; } }
public static Offset<TextureMap> CreateTextureMap(FlatBufferBuilder builder,
StringOffset NameOffset = default(StringOffset),
StringOffset SamplerOffset = default(StringOffset),
int Index = 0,
Offset<TextureMapping> MappingOffset = default(Offset<TextureMapping>))
Offset<TextureMapping> ParamsOffset = default(Offset<TextureMapping>))
{
builder.StartObject(3);
TextureMap.AddMapping(builder, MappingOffset);
TextureMap.AddParams(builder, ParamsOffset);
TextureMap.AddIndex(builder, Index);
TextureMap.AddName(builder, NameOffset);
TextureMap.AddSampler(builder, SamplerOffset);
return TextureMap.EndTextureMap(builder);
}
public static void StartTextureMap(FlatBufferBuilder builder) { builder.StartObject(3); }
public static void AddName(FlatBufferBuilder builder, StringOffset NameOffset) { builder.AddOffset(0, NameOffset.Value, 0); }
public static void AddSampler(FlatBufferBuilder builder, StringOffset SamplerOffset) { builder.AddOffset(0, SamplerOffset.Value, 0); }
public static void AddIndex(FlatBufferBuilder builder, int Index) { builder.AddInt(1, Index, 0); }
public static void AddMapping(FlatBufferBuilder builder, Offset<TextureMapping> MappingOffset) { builder.AddOffset(2, MappingOffset.Value, 0); }
public static void AddParams(FlatBufferBuilder builder, Offset<TextureMapping> ParamsOffset) { builder.AddOffset(2, ParamsOffset.Value, 0); }
public static Offset<TextureMap> EndTextureMap(FlatBufferBuilder builder)
{
int o = builder.EndObject();
@ -522,50 +523,50 @@ namespace FlatBuffers.Gfbmdl
public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; }
public TextureMapping __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public uint Type { get { int o = __p.__offset(4); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint Scale { get { int o = __p.__offset(6); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint Translation { get { int o = __p.__offset(8); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint Rotation { get { int o = __p.__offset(10); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint WrapS { get { int o = __p.__offset(12); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint WrapT { get { int o = __p.__offset(14); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint MagFilter { get { int o = __p.__offset(16); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint MinFilter { get { int o = __p.__offset(18); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public float MinLOD { get { int o = __p.__offset(20); return o != 0 ? __p.bb.GetFloat(o + __p.bb_pos) : (float)0.0f; } }
public uint Unknown1 { get { int o = __p.__offset(4); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint Unknown2 { get { int o = __p.__offset(6); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint Unknown3 { get { int o = __p.__offset(8); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint Unknown4 { get { int o = __p.__offset(10); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint Unknown5 { get { int o = __p.__offset(12); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint Unknown6 { get { int o = __p.__offset(14); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint Unknown7 { get { int o = __p.__offset(16); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint Unknown8 { get { int o = __p.__offset(18); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public float LodBias { get { int o = __p.__offset(20); return o != 0 ? __p.bb.GetFloat(o + __p.bb_pos) : (float)0.0f; } }
public static Offset<TextureMapping> CreateTextureMapping(FlatBufferBuilder builder,
uint Type = 0,
uint Scale = 0,
uint Translation = 0,
uint Rotation = 0,
uint WrapS = 0,
uint WrapT = 0,
uint magFilter = 0,
uint minFilter = 0,
float minLOD = 0.0f)
uint Unknown1 = 0,
uint Unknown2 = 0,
uint Unknown3 = 0,
uint Unknown4 = 0,
uint Unknown5 = 0,
uint Unknown6 = 0,
uint Unknown7 = 0,
uint Unknown8 = 0,
float lodBias = 0.0f)
{
builder.StartObject(9);
TextureMapping.AddMinLOD(builder, minLOD);
TextureMapping.AddMinFilter(builder, minFilter);
TextureMapping.AddMagFilter(builder, magFilter);
TextureMapping.AddWrapT(builder, WrapT);
TextureMapping.AddWrapS(builder, WrapS);
TextureMapping.AddRotation(builder, Rotation);
TextureMapping.AddTranslation(builder, Translation);
TextureMapping.AddScale(builder, Scale);
TextureMapping.AddType(builder, Type);
TextureMapping.AddLodBias(builder, lodBias);
TextureMapping.AddUnknown8(builder, Unknown8);
TextureMapping.AddUnknown7(builder, Unknown7);
TextureMapping.AddUnknown6(builder, Unknown6);
TextureMapping.AddUnknown5(builder, Unknown5);
TextureMapping.AddUnknown4(builder, Unknown4);
TextureMapping.AddUnknown3(builder, Unknown3);
TextureMapping.AddUnknown2(builder, Unknown2);
TextureMapping.AddUnknown1(builder, Unknown1);
return TextureMapping.EndTextureMapping(builder);
}
public static void StartTextureMapping(FlatBufferBuilder builder) { builder.StartObject(9); }
public static void AddType(FlatBufferBuilder builder, uint Type) { builder.AddUint(0, Type, 0); }
public static void AddScale(FlatBufferBuilder builder, uint Scale) { builder.AddUint(1, Scale, 0); }
public static void AddTranslation(FlatBufferBuilder builder, uint Translation) { builder.AddUint(2, Translation, 0); }
public static void AddRotation(FlatBufferBuilder builder, uint Rotation) { builder.AddUint(3, Rotation, 0); }
public static void AddWrapS(FlatBufferBuilder builder, uint WrapS) { builder.AddUint(4, WrapS, 0); }
public static void AddWrapT(FlatBufferBuilder builder, uint WrapT) { builder.AddUint(5, WrapT, 0); }
public static void AddMagFilter(FlatBufferBuilder builder, uint magFilter) { builder.AddUint(6, magFilter, 0); }
public static void AddMinFilter(FlatBufferBuilder builder, uint minFilter) { builder.AddUint(7, minFilter, 0); }
public static void AddMinLOD(FlatBufferBuilder builder, float minLOD) { builder.AddFloat(8, minLOD, 0.0f); }
public static void AddUnknown1(FlatBufferBuilder builder, uint Unknown1) { builder.AddUint(0, Unknown1, 0); }
public static void AddUnknown2(FlatBufferBuilder builder, uint Unknown2) { builder.AddUint(1, Unknown2, 0); }
public static void AddUnknown3(FlatBufferBuilder builder, uint Unknown3) { builder.AddUint(2, Unknown3, 0); }
public static void AddUnknown4(FlatBufferBuilder builder, uint Unknown4) { builder.AddUint(3, Unknown4, 0); }
public static void AddUnknown5(FlatBufferBuilder builder, uint Unknown5) { builder.AddUint(4, Unknown5, 0); }
public static void AddUnknown6(FlatBufferBuilder builder, uint Unknown6) { builder.AddUint(5, Unknown6, 0); }
public static void AddUnknown7(FlatBufferBuilder builder, uint Unknown7) { builder.AddUint(6, Unknown7, 0); }
public static void AddUnknown8(FlatBufferBuilder builder, uint Unknown8) { builder.AddUint(7, Unknown8, 0); }
public static void AddLodBias(FlatBufferBuilder builder, float lodBias) { builder.AddFloat(8, lodBias, 0.0f); }
public static Offset<TextureMapping> EndTextureMapping(FlatBufferBuilder builder)
{
int o = builder.EndObject();
@ -582,16 +583,16 @@ namespace FlatBuffers.Gfbmdl
public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; }
public Group __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public uint BoneID { get { int o = __p.__offset(4); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint MeshID { get { int o = __p.__offset(6); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint BoneIndex { get { int o = __p.__offset(4); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint MeshIndex { get { int o = __p.__offset(6); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public BoundingBox? Bounding { get { int o = __p.__offset(8); return o != 0 ? (BoundingBox?)(new BoundingBox()).__assign(o + __p.bb_pos, __p.bb) : null; } }
public uint Layer { get { int o = __p.__offset(10); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public static void StartGroup(FlatBufferBuilder builder) { builder.StartObject(4); }
public static void AddBoneID(FlatBufferBuilder builder, uint boneID) { builder.AddUint(0, boneID, 0); }
public static void AddMeshID(FlatBufferBuilder builder, uint meshID) { builder.AddUint(1, meshID, 0); }
public static void AddBoneIndex(FlatBufferBuilder builder, uint BoneIndex) { builder.AddUint(0, BoneIndex, 0); }
public static void AddMeshIndex(FlatBufferBuilder builder, uint MeshIndex) { builder.AddUint(1, MeshIndex, 0); }
public static void AddBounding(FlatBufferBuilder builder, Offset<BoundingBox> BoundingOffset) { builder.AddStruct(2, BoundingOffset.Value, 0); }
public static void AddLayer(FlatBufferBuilder builder, uint layer) { builder.AddUint(3, layer, 0); }
public static void AddLayer(FlatBufferBuilder builder, uint Layer) { builder.AddUint(3, Layer, 0); }
public static Offset<Group> EndGroup(FlatBufferBuilder builder)
{
int o = builder.EndObject();
@ -610,8 +611,8 @@ namespace FlatBuffers.Gfbmdl
public MeshPolygon? Polygons(int j) { int o = __p.__offset(4); return o != 0 ? (MeshPolygon?)(new MeshPolygon()).__assign(__p.__indirect(__p.__vector(o) + j * 4), __p.bb) : null; }
public int PolygonsLength { get { int o = __p.__offset(4); return o != 0 ? __p.__vector_len(o) : 0; } }
public MeshAlignment? Alignments(int j) { int o = __p.__offset(6); return o != 0 ? (MeshAlignment?)(new MeshAlignment()).__assign(__p.__indirect(__p.__vector(o) + j * 4), __p.bb) : null; }
public int AlignmentsLength { get { int o = __p.__offset(6); return o != 0 ? __p.__vector_len(o) : 0; } }
public MeshAttribute? Attributes(int j) { int o = __p.__offset(6); return o != 0 ? (MeshAttribute?)(new MeshAttribute()).__assign(__p.__indirect(__p.__vector(o) + j * 4), __p.bb) : null; }
public int AttributesLength { get { int o = __p.__offset(6); return o != 0 ? __p.__vector_len(o) : 0; } }
public byte Data(int j) { int o = __p.__offset(8); return o != 0 ? __p.bb.Get(__p.__vector(o) + j * 1) : (byte)0; }
public int DataLength { get { int o = __p.__offset(8); return o != 0 ? __p.__vector_len(o) : 0; } }
#if ENABLE_SPAN_T
@ -623,12 +624,12 @@ namespace FlatBuffers.Gfbmdl
public static Offset<Mesh> CreateMesh(FlatBufferBuilder builder,
VectorOffset PolygonsOffset = default(VectorOffset),
VectorOffset AlignmentsOffset = default(VectorOffset),
VectorOffset AttributesOffset = default(VectorOffset),
VectorOffset DataOffset = default(VectorOffset))
{
builder.StartObject(3);
Mesh.AddData(builder, DataOffset);
Mesh.AddAlignments(builder, AlignmentsOffset);
Mesh.AddAttributes(builder, AttributesOffset);
Mesh.AddPolygons(builder, PolygonsOffset);
return Mesh.EndMesh(builder);
}
@ -638,10 +639,10 @@ namespace FlatBuffers.Gfbmdl
public static VectorOffset CreatePolygonsVector(FlatBufferBuilder builder, Offset<MeshPolygon>[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
public static VectorOffset CreatePolygonsVectorBlock(FlatBufferBuilder builder, Offset<MeshPolygon>[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
public static void StartPolygonsVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
public static void AddAlignments(FlatBufferBuilder builder, VectorOffset AlignmentsOffset) { builder.AddOffset(1, AlignmentsOffset.Value, 0); }
public static VectorOffset CreateAlignmentsVector(FlatBufferBuilder builder, Offset<MeshAlignment>[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
public static VectorOffset CreateAlignmentsVectorBlock(FlatBufferBuilder builder, Offset<MeshAlignment>[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
public static void StartAlignmentsVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
public static void AddAttributes(FlatBufferBuilder builder, VectorOffset AttributesOffset) { builder.AddOffset(1, AttributesOffset.Value, 0); }
public static VectorOffset CreateAttributesVector(FlatBufferBuilder builder, Offset<MeshAttribute>[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
public static VectorOffset CreateAttributesVectorBlock(FlatBufferBuilder builder, Offset<MeshAttribute>[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
public static void StartAttributesVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
public static void AddData(FlatBufferBuilder builder, VectorOffset DataOffset) { builder.AddOffset(2, DataOffset.Value, 0); }
public static VectorOffset CreateDataVector(FlatBufferBuilder builder, byte[] data) { builder.StartVector(1, data.Length, 1); for (int i = data.Length - 1; i >= 0; i--) builder.AddByte(data[i]); return builder.EndVector(); }
public static VectorOffset CreateDataVectorBlock(FlatBufferBuilder builder, byte[] data) { builder.StartVector(1, data.Length, 1); builder.Add(data); return builder.EndVector(); }
@ -662,32 +663,32 @@ namespace FlatBuffers.Gfbmdl
public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; }
public MeshPolygon __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public uint MaterialID { get { int o = __p.__offset(4); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public ushort Data(int j) { int o = __p.__offset(6); return o != 0 ? __p.bb.GetUshort(__p.__vector(o) + j * 2) : (ushort)0; }
public int DataLength { get { int o = __p.__offset(6); return o != 0 ? __p.__vector_len(o) : 0; } }
public uint MaterialIndex { get { int o = __p.__offset(4); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public ushort Faces(int j) { int o = __p.__offset(6); return o != 0 ? __p.bb.GetUshort(__p.__vector(o) + j * 2) : (ushort)0; }
public int FacesLength { get { int o = __p.__offset(6); return o != 0 ? __p.__vector_len(o) : 0; } }
#if ENABLE_SPAN_T
public Span<byte> GetDataBytes() { return __p.__vector_as_span(6); }
public Span<byte> GetFacesBytes() { return __p.__vector_as_span(6); }
#else
public ArraySegment<byte>? GetDataBytes() { return __p.__vector_as_arraysegment(6); }
public ArraySegment<byte>? GetFacesBytes() { return __p.__vector_as_arraysegment(6); }
#endif
public ushort[] GetDataArray() { return __p.__vector_as_array<ushort>(6); }
public ushort[] GetFacesArray() { return __p.__vector_as_array<ushort>(6); }
public static Offset<MeshPolygon> CreateMeshPolygon(FlatBufferBuilder builder,
uint materialID = 0,
VectorOffset dataOffset = default(VectorOffset))
uint MaterialIndex = 0,
VectorOffset FacesOffset = default(VectorOffset))
{
builder.StartObject(2);
MeshPolygon.AddData(builder, dataOffset);
MeshPolygon.AddMaterialID(builder, materialID);
MeshPolygon.AddFaces(builder, FacesOffset);
MeshPolygon.AddMaterialIndex(builder, MaterialIndex);
return MeshPolygon.EndMeshPolygon(builder);
}
public static void StartMeshPolygon(FlatBufferBuilder builder) { builder.StartObject(2); }
public static void AddMaterialID(FlatBufferBuilder builder, uint materialID) { builder.AddUint(0, materialID, 0); }
public static void AddData(FlatBufferBuilder builder, VectorOffset dataOffset) { builder.AddOffset(1, dataOffset.Value, 0); }
public static VectorOffset CreateDataVector(FlatBufferBuilder builder, ushort[] data) { builder.StartVector(2, data.Length, 2); for (int i = data.Length - 1; i >= 0; i--) builder.AddUshort(data[i]); return builder.EndVector(); }
public static VectorOffset CreateDataVectorBlock(FlatBufferBuilder builder, ushort[] data) { builder.StartVector(2, data.Length, 2); builder.Add(data); return builder.EndVector(); }
public static void StartDataVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(2, numElems, 2); }
public static void AddMaterialIndex(FlatBufferBuilder builder, uint MaterialIndex) { builder.AddUint(0, MaterialIndex, 0); }
public static void AddFaces(FlatBufferBuilder builder, VectorOffset FacesOffset) { builder.AddOffset(1, FacesOffset.Value, 0); }
public static VectorOffset CreateFacesVector(FlatBufferBuilder builder, ushort[] data) { builder.StartVector(2, data.Length, 2); for (int i = data.Length - 1; i >= 0; i--) builder.AddUshort(data[i]); return builder.EndVector(); }
public static VectorOffset CreateFacesVectorBlock(FlatBufferBuilder builder, ushort[] data) { builder.StartVector(2, data.Length, 2); builder.Add(data); return builder.EndVector(); }
public static void StartFacesVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(2, numElems, 2); }
public static Offset<MeshPolygon> EndMeshPolygon(FlatBufferBuilder builder)
{
int o = builder.EndObject();
@ -695,39 +696,39 @@ namespace FlatBuffers.Gfbmdl
}
};
public struct MeshAlignment : IFlatbufferObject
public struct MeshAttribute : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
public static MeshAlignment GetRootAsMeshAlignment(ByteBuffer _bb) { return GetRootAsMeshAlignment(_bb, new MeshAlignment()); }
public static MeshAlignment GetRootAsMeshAlignment(ByteBuffer _bb, MeshAlignment obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public static MeshAttribute GetRootAsMeshAttribute(ByteBuffer _bb) { return GetRootAsMeshAttribute(_bb, new MeshAttribute()); }
public static MeshAttribute GetRootAsMeshAttribute(ByteBuffer _bb, MeshAttribute obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; }
public MeshAlignment __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public MeshAttribute __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public VertexType TypeID { get { int o = __p.__offset(4); return o != 0 ? (VertexType)__p.bb.GetUint(o + __p.bb_pos) : VertexType.Position; } }
public BufferFormat FormatID { get { int o = __p.__offset(6); return o != 0 ? (BufferFormat)__p.bb.GetUint(o + __p.bb_pos) : BufferFormat.Float; } }
public uint VertexType { get { int o = __p.__offset(4); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint BufferFormat { get { int o = __p.__offset(6); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint ElementCount { get { int o = __p.__offset(8); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public static Offset<MeshAlignment> CreateMeshAlignment(FlatBufferBuilder builder,
VertexType TypeID = VertexType.Position,
BufferFormat FormatID = BufferFormat.Float,
public static Offset<MeshAttribute> CreateMeshAttribute(FlatBufferBuilder builder,
uint VertexType = 0,
uint BufferFormat = 0,
uint ElementCount = 0)
{
builder.StartObject(3);
MeshAlignment.AddElementCount(builder, ElementCount);
MeshAlignment.AddFormatID(builder, FormatID);
MeshAlignment.AddTypeID(builder, TypeID);
return MeshAlignment.EndMeshAlignment(builder);
MeshAttribute.AddElementCount(builder, ElementCount);
MeshAttribute.AddBufferFormat(builder, BufferFormat);
MeshAttribute.AddVertexType(builder, VertexType);
return MeshAttribute.EndMeshAttribute(builder);
}
public static void StartMeshAlignment(FlatBufferBuilder builder) { builder.StartObject(3); }
public static void AddTypeID(FlatBufferBuilder builder, VertexType TypeID) { builder.AddUint(0, (uint)TypeID, 0); }
public static void AddFormatID(FlatBufferBuilder builder, BufferFormat FormatID) { builder.AddUint(1, (uint)FormatID, 0); }
public static void StartMeshAttribute(FlatBufferBuilder builder) { builder.StartObject(3); }
public static void AddVertexType(FlatBufferBuilder builder, uint VertexType) { builder.AddUint(0, VertexType, 0); }
public static void AddBufferFormat(FlatBufferBuilder builder, uint BufferFormat) { builder.AddUint(1, BufferFormat, 0); }
public static void AddElementCount(FlatBufferBuilder builder, uint ElementCount) { builder.AddUint(2, ElementCount, 0); }
public static Offset<MeshAlignment> EndMeshAlignment(FlatBufferBuilder builder)
public static Offset<MeshAttribute> EndMeshAttribute(FlatBufferBuilder builder)
{
int o = builder.EndObject();
return new Offset<MeshAlignment>(o);
return new Offset<MeshAttribute>(o);
}
};
@ -747,7 +748,7 @@ namespace FlatBuffers.Gfbmdl
public ArraySegment<byte>? GetNameBytes() { return __p.__vector_as_arraysegment(4); }
#endif
public byte[] GetNameArray() { return __p.__vector_as_array<byte>(4); }
public BoneType Type { get { int o = __p.__offset(6); return o != 0 ? (BoneType)__p.bb.GetUint(o + __p.bb_pos) : BoneType.NoSkinning; } }
public uint BoneType { get { int o = __p.__offset(6); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public int Parent { get { int o = __p.__offset(8); return o != 0 ? __p.bb.GetInt(o + __p.bb_pos) : (int)0; } }
public uint Zero { get { int o = __p.__offset(10); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public bool Visible { get { int o = __p.__offset(12); return o != 0 ? 0 != __p.bb.Get(o + __p.bb_pos) : (bool)false; } }
@ -756,11 +757,11 @@ namespace FlatBuffers.Gfbmdl
public Vector3? Translation { get { int o = __p.__offset(18); return o != 0 ? (Vector3?)(new Vector3()).__assign(o + __p.bb_pos, __p.bb) : null; } }
public Vector3? RadiusStart { get { int o = __p.__offset(20); return o != 0 ? (Vector3?)(new Vector3()).__assign(o + __p.bb_pos, __p.bb) : null; } }
public Vector3? RadiusEnd { get { int o = __p.__offset(22); return o != 0 ? (Vector3?)(new Vector3()).__assign(o + __p.bb_pos, __p.bb) : null; } }
public UnknownData? SkinCheck { get { int o = __p.__offset(24); return o != 0 ? (UnknownData?)(new UnknownData()).__assign(o + __p.bb_pos, __p.bb) : null; } }
public BoneRigidData? RigidCheck { get { int o = __p.__offset(24); return o != 0 ? (BoneRigidData?)(new BoneRigidData()).__assign(o + __p.bb_pos, __p.bb) : null; } }
public static void StartBone(FlatBufferBuilder builder) { builder.StartObject(11); }
public static void AddName(FlatBufferBuilder builder, StringOffset NameOffset) { builder.AddOffset(0, NameOffset.Value, 0); }
public static void AddType(FlatBufferBuilder builder, BoneType Type) { builder.AddUint(1, (uint)Type, 0); }
public static void AddBoneType(FlatBufferBuilder builder, uint BoneType) { builder.AddUint(1, BoneType, 0); }
public static void AddParent(FlatBufferBuilder builder, int Parent) { builder.AddInt(2, Parent, 0); }
public static void AddZero(FlatBufferBuilder builder, uint Zero) { builder.AddUint(3, Zero, 0); }
public static void AddVisible(FlatBufferBuilder builder, bool Visible) { builder.AddBool(4, Visible, false); }
@ -769,7 +770,7 @@ namespace FlatBuffers.Gfbmdl
public static void AddTranslation(FlatBufferBuilder builder, Offset<Vector3> TranslationOffset) { builder.AddStruct(7, TranslationOffset.Value, 0); }
public static void AddRadiusStart(FlatBufferBuilder builder, Offset<Vector3> RadiusStartOffset) { builder.AddStruct(8, RadiusStartOffset.Value, 0); }
public static void AddRadiusEnd(FlatBufferBuilder builder, Offset<Vector3> RadiusEndOffset) { builder.AddStruct(9, RadiusEndOffset.Value, 0); }
public static void AddSkinCheck(FlatBufferBuilder builder, Offset<UnknownData> SkinCheckOffset) { builder.AddStruct(10, SkinCheckOffset.Value, 0); }
public static void AddRigidCheck(FlatBufferBuilder builder, Offset<BoneRigidData> RigidCheckOffset) { builder.AddStruct(10, RigidCheckOffset.Value, 0); }
public static Offset<Bone> EndBone(FlatBufferBuilder builder)
{
int o = builder.EndObject();
@ -777,136 +778,56 @@ namespace FlatBuffers.Gfbmdl
}
};
public struct UnknownData : IFlatbufferObject
public struct BoneRigidData : IFlatbufferObject
{
private Struct __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; }
public UnknownData __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public BoneRigidData __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public sbyte NoSkin { get { return __p.bb.GetSbyte(__p.bb_pos + 0); } }
public sbyte Unknown1 { get { return __p.bb.GetSbyte(__p.bb_pos + 0); } }
public static Offset<UnknownData> CreateUnknownData(FlatBufferBuilder builder, sbyte NoSkin)
public static Offset<BoneRigidData> CreateBoneRigidData(FlatBufferBuilder builder, sbyte Unknown1)
{
builder.Prep(1, 1);
builder.PutSbyte(NoSkin);
return new Offset<UnknownData>(builder.Offset);
builder.PutSbyte(Unknown1);
return new Offset<BoneRigidData>(builder.Offset);
}
};
public struct RenderInfo : IFlatbufferObject
public struct CollisionGroup : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
public static RenderInfo GetRootAsRenderInfo(ByteBuffer _bb) { return GetRootAsRenderInfo(_bb, new RenderInfo()); }
public static RenderInfo GetRootAsRenderInfo(ByteBuffer _bb, RenderInfo obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public static CollisionGroup GetRootAsCollisionGroup(ByteBuffer _bb) { return GetRootAsCollisionGroup(_bb, new CollisionGroup()); }
public static CollisionGroup GetRootAsCollisionGroup(ByteBuffer _bb, CollisionGroup obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; }
public RenderInfo __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public CollisionGroup __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public uint Unknown1 { get { int o = __p.__offset(4); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint Unknown2 { get { int o = __p.__offset(6); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public RenderUnknown? Unknown3 { get { int o = __p.__offset(8); return o != 0 ? (RenderUnknown?)(new RenderUnknown()).__assign(__p.__indirect(o + __p.bb_pos), __p.bb) : null; } }
public RenderUnknown2? Unknown4 { get { int o = __p.__offset(10); return o != 0 ? (RenderUnknown2?)(new RenderUnknown2()).__assign(__p.__indirect(o + __p.bb_pos), __p.bb) : null; } }
public uint BoneIndex { get { int o = __p.__offset(4); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint Unknown1 { get { int o = __p.__offset(6); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public uint BoneChildren(int j) { int o = __p.__offset(8); return o != 0 ? __p.bb.GetUint(__p.__vector(o) + j * 4) : (uint)0; }
public int BoneChildrenLength { get { int o = __p.__offset(8); return o != 0 ? __p.__vector_len(o) : 0; } }
#if ENABLE_SPAN_T
public Span<byte> GetBoneChildrenBytes() { return __p.__vector_as_span(8); }
#else
public ArraySegment<byte>? GetBoneChildrenBytes() { return __p.__vector_as_arraysegment(8); }
#endif
public uint[] GetBoneChildrenArray() { return __p.__vector_as_array<uint>(8); }
public BoundingBox? Bounding { get { int o = __p.__offset(10); return o != 0 ? (BoundingBox?)(new BoundingBox()).__assign(o + __p.bb_pos, __p.bb) : null; } }
public static Offset<RenderInfo> CreateRenderInfo(FlatBufferBuilder builder,
uint Unknown1 = 0,
uint Unknown2 = 0,
Offset<RenderUnknown> Unknown3Offset = default(Offset<RenderUnknown>),
Offset<RenderUnknown2> Unknown4Offset = default(Offset<RenderUnknown2>))
{
builder.StartObject(4);
RenderInfo.AddUnknown4(builder, Unknown4Offset);
RenderInfo.AddUnknown3(builder, Unknown3Offset);
RenderInfo.AddUnknown2(builder, Unknown2);
RenderInfo.AddUnknown1(builder, Unknown1);
return RenderInfo.EndRenderInfo(builder);
}
public static void StartRenderInfo(FlatBufferBuilder builder) { builder.StartObject(4); }
public static void AddUnknown1(FlatBufferBuilder builder, uint Unknown1) { builder.AddUint(0, Unknown1, 0); }
public static void AddUnknown2(FlatBufferBuilder builder, uint Unknown2) { builder.AddUint(1, Unknown2, 0); }
public static void AddUnknown3(FlatBufferBuilder builder, Offset<RenderUnknown> Unknown3Offset) { builder.AddOffset(2, Unknown3Offset.Value, 0); }
public static void AddUnknown4(FlatBufferBuilder builder, Offset<RenderUnknown2> Unknown4Offset) { builder.AddOffset(3, Unknown4Offset.Value, 0); }
public static Offset<RenderInfo> EndRenderInfo(FlatBufferBuilder builder)
public static void StartCollisionGroup(FlatBufferBuilder builder) { builder.StartObject(4); }
public static void AddBoneIndex(FlatBufferBuilder builder, uint BoneIndex) { builder.AddUint(0, BoneIndex, 0); }
public static void AddUnknown1(FlatBufferBuilder builder, uint Unknown1) { builder.AddUint(1, Unknown1, 0); }
public static void AddBoneChildren(FlatBufferBuilder builder, VectorOffset BoneChildrenOffset) { builder.AddOffset(2, BoneChildrenOffset.Value, 0); }
public static VectorOffset CreateBoneChildrenVector(FlatBufferBuilder builder, uint[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddUint(data[i]); return builder.EndVector(); }
public static VectorOffset CreateBoneChildrenVectorBlock(FlatBufferBuilder builder, uint[] data) { builder.StartVector(4, data.Length, 4); builder.Add(data); return builder.EndVector(); }
public static void StartBoneChildrenVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
public static void AddBounding(FlatBufferBuilder builder, Offset<BoundingBox> BoundingOffset) { builder.AddStruct(3, BoundingOffset.Value, 0); }
public static Offset<CollisionGroup> EndCollisionGroup(FlatBufferBuilder builder)
{
int o = builder.EndObject();
return new Offset<RenderInfo>(o);
}
};
public struct RenderUnknown : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
public static RenderUnknown GetRootAsRenderUnknown(ByteBuffer _bb) { return GetRootAsRenderUnknown(_bb, new RenderUnknown()); }
public static RenderUnknown GetRootAsRenderUnknown(ByteBuffer _bb, RenderUnknown obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; }
public RenderUnknown __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public uint Unknown { get { int o = __p.__offset(4); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } }
public static Offset<RenderUnknown> CreateRenderUnknown(FlatBufferBuilder builder,
uint Unknown = 0)
{
builder.StartObject(1);
RenderUnknown.AddUnknown(builder, Unknown);
return RenderUnknown.EndRenderUnknown(builder);
}
public static void StartRenderUnknown(FlatBufferBuilder builder) { builder.StartObject(1); }
public static void AddUnknown(FlatBufferBuilder builder, uint Unknown) { builder.AddUint(0, Unknown, 0); }
public static Offset<RenderUnknown> EndRenderUnknown(FlatBufferBuilder builder)
{
int o = builder.EndObject();
return new Offset<RenderUnknown>(o);
}
};
public struct RenderUnknown2 : IFlatbufferObject
{
private Table __p;
public ByteBuffer ByteBuffer { get { return __p.bb; } }
public static RenderUnknown2 GetRootAsRenderUnknown2(ByteBuffer _bb) { return GetRootAsRenderUnknown2(_bb, new RenderUnknown2()); }
public static RenderUnknown2 GetRootAsRenderUnknown2(ByteBuffer _bb, RenderUnknown2 obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; }
public RenderUnknown2 __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public float Unknown1 { get { int o = __p.__offset(4); return o != 0 ? __p.bb.GetFloat(o + __p.bb_pos) : (float)0.0f; } }
public float Unknown2 { get { int o = __p.__offset(6); return o != 0 ? __p.bb.GetFloat(o + __p.bb_pos) : (float)0.0f; } }
public float Unknown3 { get { int o = __p.__offset(8); return o != 0 ? __p.bb.GetFloat(o + __p.bb_pos) : (float)0.0f; } }
public float Unknown4 { get { int o = __p.__offset(10); return o != 0 ? __p.bb.GetFloat(o + __p.bb_pos) : (float)0.0f; } }
public float Unknown5 { get { int o = __p.__offset(12); return o != 0 ? __p.bb.GetFloat(o + __p.bb_pos) : (float)0.0f; } }
public float Unknown6 { get { int o = __p.__offset(14); return o != 0 ? __p.bb.GetFloat(o + __p.bb_pos) : (float)0.0f; } }
public static Offset<RenderUnknown2> CreateRenderUnknown2(FlatBufferBuilder builder,
float Unknown1 = 0.0f,
float Unknown2 = 0.0f,
float Unknown3 = 0.0f,
float Unknown4 = 0.0f,
float Unknown5 = 0.0f,
float Unknown6 = 0.0f)
{
builder.StartObject(6);
RenderUnknown2.AddUnknown6(builder, Unknown6);
RenderUnknown2.AddUnknown5(builder, Unknown5);
RenderUnknown2.AddUnknown4(builder, Unknown4);
RenderUnknown2.AddUnknown3(builder, Unknown3);
RenderUnknown2.AddUnknown2(builder, Unknown2);
RenderUnknown2.AddUnknown1(builder, Unknown1);
return RenderUnknown2.EndRenderUnknown2(builder);
}
public static void StartRenderUnknown2(FlatBufferBuilder builder) { builder.StartObject(6); }
public static void AddUnknown1(FlatBufferBuilder builder, float Unknown1) { builder.AddFloat(0, Unknown1, 0.0f); }
public static void AddUnknown2(FlatBufferBuilder builder, float Unknown2) { builder.AddFloat(1, Unknown2, 0.0f); }
public static void AddUnknown3(FlatBufferBuilder builder, float Unknown3) { builder.AddFloat(2, Unknown3, 0.0f); }
public static void AddUnknown4(FlatBufferBuilder builder, float Unknown4) { builder.AddFloat(3, Unknown4, 0.0f); }
public static void AddUnknown5(FlatBufferBuilder builder, float Unknown5) { builder.AddFloat(4, Unknown5, 0.0f); }
public static void AddUnknown6(FlatBufferBuilder builder, float Unknown6) { builder.AddFloat(5, Unknown6, 0.0f); }
public static Offset<RenderUnknown2> EndRenderUnknown2(FlatBufferBuilder builder)
{
int o = builder.EndObject();
return new Offset<RenderUnknown2>(o);
return new Offset<CollisionGroup>(o);
}
};

View File

@ -0,0 +1,655 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Toolbox;
using System.Windows.Forms;
using Toolbox.Library;
using Toolbox.Library.IO;
using Toolbox.Library.Forms;
using Toolbox.Library.Rendering;
using OpenTK;
using FirstPlugin.Forms;
using FirstPlugin.GFMDLStructs;
using Newtonsoft.Json;
namespace FirstPlugin
{
public class GFBMDL : TreeNodeFile, IContextMenuNode, IFileFormat
{
public FileType FileType { get; set; } = FileType.Model;
public bool CanSave { get; set; }
public string[] Description { get; set; } = new string[] { "Graphic Model" };
public string[] Extension { get; set; } = new string[] { "*.gfbmdl" };
public string FileName { get; set; }
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public bool Identify(System.IO.Stream stream)
{
using (var reader = new Toolbox.Library.IO.FileReader(stream, true))
{
reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
bool IsMatch = reader.ReadUInt32() == 0x20000000;
reader.Position = 0;
return IsMatch;
}
}
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
bool DrawablesLoaded = false;
public override void OnClick(TreeView treeView) {
LoadEditor<STPropertyGrid>();
}
public T LoadEditor<T>() where T : UserControl, new()
{
T control = new T();
control.Dock = DockStyle.Fill;
ViewportEditor editor = (ViewportEditor)LibraryGUI.GetActiveContent(typeof(ViewportEditor));
if (editor == null)
{
editor = new ViewportEditor(true);
editor.Dock = DockStyle.Fill;
LibraryGUI.LoadEditor(editor);
}
if (!DrawablesLoaded)
{
ObjectEditor.AddContainer(DrawableContainer);
DrawablesLoaded = true;
}
if (Runtime.UseOpenGL)
editor.LoadViewport(DrawableContainer);
editor.LoadEditor(control);
return control;
}
public GFBMDL_Render Renderer;
public DrawableContainer DrawableContainer = new DrawableContainer();
public GFLXModel Model;
public void Load(System.IO.Stream stream)
{
// CanSave = true;
Text = FileName;
DrawableContainer.Name = FileName;
Renderer = new GFBMDL_Render();
Renderer.GfbmdlFile = this;
DrawableContainer.Drawables.Add(Renderer);
//Here i convert buffer classes generated from flatc to c# classes that are much nicer to alter
var model = BufferToStruct.LoadFile(stream);
ReloadModel(model);
}
private void ReloadModel(Model model)
{
Nodes.Clear();
if (Renderer.Meshes == null)
Renderer.Meshes = new List<STGenericObject>();
Renderer.Meshes.Clear();
Model = new GFLXModel();
Model.LoadFile(model, this, Renderer);
TreeNode SkeletonWrapper = new TreeNode("Skeleton");
TreeNode MaterialFolderWrapper = new TreeNode("Materials");
TreeNode VisualGroupWrapper = new TreeNode("Visual Groups");
TreeNode Textures = new TreeNode("Textures");
if (Model.Skeleton.bones.Count > 0)
{
Nodes.Add(SkeletonWrapper);
DrawableContainer.Drawables.Add(Model.Skeleton);
foreach (var bone in Model.Skeleton.bones)
{
if (bone.Parent == null)
SkeletonWrapper.Nodes.Add(bone);
}
}
List<string> loadedTextures = new List<string>();
for (int i = 0; i < Model.Textures.Count; i++)
{
foreach (var bntx in PluginRuntime.bntxContainers)
{
if (bntx.Textures.ContainsKey(Model.Textures[i]) &&
!loadedTextures.Contains(Model.Textures[i]))
{
TreeNode tex = new TreeNode(Model.Textures[i]);
tex.ImageKey = "texture";
tex.SelectedImageKey = "texture";
tex.Tag = bntx.Textures[Model.Textures[i]];
Textures.Nodes.Add(tex);
loadedTextures.Add(Model.Textures[i]);
}
}
}
loadedTextures.Clear();
Nodes.Add(MaterialFolderWrapper);
Nodes.Add(VisualGroupWrapper);
if (Textures.Nodes.Count > 0)
Nodes.Add(Textures);
for (int i = 0; i < Model.GenericMaterials.Count; i++)
MaterialFolderWrapper.Nodes.Add(Model.GenericMaterials[i]);
for (int i = 0; i < Model.GenericMeshes.Count; i++)
VisualGroupWrapper.Nodes.Add(Model.GenericMeshes[i]);
}
public void Save(System.IO.Stream stream)
{
Model.SaveFile(stream);
}
public ToolStripItem[] GetContextMenuItems()
{
List<ToolStripItem> Items = new List<ToolStripItem>();
Items.Add(new ToolStripMenuItem("Export Model", null, ExportAction, Keys.Control | Keys.E));
Items.Add(new ToolStripMenuItem("Replace Model", null, ReplaceAction, Keys.Control | Keys.R));
return Items.ToArray();
}
private void ExportAction(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Supported Formats|*.dae;*.json;";
sfd.FileName = Text;
sfd.DefaultExt = "dae";
if (sfd.ShowDialog() == DialogResult.OK)
{
string ext = Utils.GetExtension(sfd.FileName);
if (ext == ".json")
{
string json = JsonConvert.SerializeObject(Model.Model, Formatting.Indented);
System.IO.File.WriteAllText(sfd.FileName, json);
}
else
{
ExportModelSettings exportDlg = new ExportModelSettings();
if (exportDlg.ShowDialog() == DialogResult.OK)
ExportModel(sfd.FileName, exportDlg.Settings);
}
}
}
private void ReplaceAction(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.dae;*.json;";
if (ofd.ShowDialog() == DialogResult.OK)
{
string ext = Utils.GetExtension(ofd.FileName);
if (ext == ".json")
{
var model = JsonConvert.DeserializeObject<Model>(
System.IO.File.ReadAllText(ofd.FileName));
Model.LoadFile(model, this, Renderer);
}
else
{
AssimpData assimp = new AssimpData();
bool IsLoaded = assimp.LoadFile(ofd.FileName);
if (!IsLoaded)
return;
GFLXModelImporter dialog = new GFLXModelImporter();
dialog.LoadMeshes(assimp.objects, assimp.materials, Model.GenericMaterials, Model.GenericMeshes);
if (dialog.ShowDialog() == DialogResult.OK) {
ImportModel(dialog, assimp.materials, assimp.objects, assimp.skeleton);
}
}
}
}
private List<STGenericObject> GeneratePolygonGroups(List<STGenericObject> importedMeshes,
List<STGenericMaterial> importedMaterials, List<string> textures, GfbmdlImportSettings settings)
{
List<STGenericObject> meshes = new List<STGenericObject>();
foreach (var mesh in importedMeshes)
{
var lod = mesh.lodMeshes[0];
var setting = settings.MeshSettings[importedMeshes.IndexOf(mesh)];
//Create or map existing materials to the polygon group
var currentMaterial = Model.Model.Materials.FirstOrDefault(x => x.Name == setting.Material);
if (currentMaterial == null)
{
currentMaterial = Material.Replace(setting.MaterialFile);
//Get the imported material and set it's material data to the gfbmdl one
if (mesh.MaterialIndex < importedMaterials.Count && mesh.MaterialIndex >= 0)
SetupMaterial(importedMaterials[mesh.MaterialIndex], currentMaterial, textures);
Model.Model.Materials.Add(currentMaterial);
}
mesh.MaterialIndex = Model.Model.Materials.IndexOf(currentMaterial);
//Merge dupes with the same name
//Some are duped but use different material index
//Which go into a polygon group
var existingMesh = meshes.FirstOrDefault(x => x.ObjectName == mesh.ObjectName);
//Don't split atm since it's buggy
//The faces seemed fine, but vertices are split by assimp giving issues
bool splitPolygonGroups = false;
if (existingMesh != null && splitPolygonGroups)
{
int offset = 0;
foreach (var poly in existingMesh.PolygonGroups)
{
for (int f = 0; f < poly.faces.Count; f++)
offset = Math.Max(offset, poly.faces[f]);
}
List<int> faces = new List<int>();
for (int f = 0; f < lod.faces.Count; f++) {
faces.Add((int)(lod.faces[f] + offset + 1 ));
}
foreach (var vertex in mesh.vertices)
existingMesh.vertices.Add(vertex);
existingMesh.PolygonGroups.Add(new STGenericPolygonGroup()
{
MaterialIndex = mesh.MaterialIndex,
faces = faces,
});
}
else
{
mesh.PolygonGroups.Add(new STGenericPolygonGroup()
{
MaterialIndex = mesh.MaterialIndex,
faces = lod.faces,
});
meshes.Add(mesh);
}
}
return meshes;
}
private void SetupMaterial(STGenericMaterial importedMaterial, Material newMaterial, List<string> textures)
{
return;
//Here all we want is the diffuse texture and swap them
foreach (var texMap in importedMaterial.TextureMaps)
{
var diffuseTex = newMaterial.TextureMaps.FirstOrDefault(x =>
x.Sampler == "Col0Tex" || x.Sampler == "BaseColor0");
if (diffuseTex != null) {
diffuseTex.Index = (uint)textures.IndexOf(texMap.Name);
}
}
}
private void ImportModel(GFLXModelImporter importer,
List<STGenericMaterial> importedMaterials, List<STGenericObject> importedMeshes,
STSkeleton skeleton)
{
Model.Model.Groups.Clear();
Model.Model.Meshes.Clear();
List<string> textures = Model.Textures.ToList();
foreach (var mat in importedMaterials)
{
}
var meshes = GeneratePolygonGroups(importedMeshes, importedMaterials, textures, importer.Settings);
//Once mesh groups are merged search for bone nodes
//The bone section is basically a node tree
//Which contains nodes for meshes
//We need to remove the original and replace with new ones
//Then index these in our mesh groups
if (importer.ImportNewBones)
{
//Clear the original bones and nodes
Model.Skeleton.bones.Clear();
Model.Model.Bones.Clear();
List<int> SkinningIndices = new List<int>();
foreach (var genericBone in skeleton.bones)
{
var scale = genericBone.scale;
var trans = genericBone.position;
var rot = genericBone.rotation;
Bone bone = new Bone();
bone.Name = genericBone.Text;
bone.BoneType = 0;
bone.Parent = genericBone.parentIndex;
bone.Zero = 0;
bone.Visible = false;
bone.Scale = new GFMDLStructs.Vector3(scale[0], scale[1], scale[2]);
bone.Rotation = new GFMDLStructs.Vector3(rot[0], rot[1], rot[2]);
bone.Translation = new GFMDLStructs.Vector3(trans[0], trans[1], trans[2]);
bone.RadiusStart = new GFMDLStructs.Vector3(0, 0, 0);
bone.RadiusEnd = new GFMDLStructs.Vector3(0, 0, 0);
bone.RigidCheck = new BoneRigidData() { Unknown1 = 0 };
//Check if the bone is rigged
for (int i = 0; i < meshes.Count; i++)
{
if (meshes[i].vertices.Any(x => x.boneNames.Contains(bone.Name))) {
bone.BoneType = 1;
bone.RigidCheck = null;
}
}
Model.Model.Bones.Add(bone);
}
}
Dictionary<string, int> NodeIndices = new Dictionary<string, int>();
//Go through each bone and remove the original mesh node
for (int i = 0; i < Model.Skeleton.bones.Count; i++)
{
var node = (GFLXBone)Model.Skeleton.bones[i];
if (Model.GenericMeshes.Any(x => x.Text == node.Text))
{
NodeIndices.Add(node.Text, i);
Console.WriteLine($"match {node.Text}");
Model.Model.Bones.Remove(node.Bone);
Model.Skeleton.bones.Remove(node);
}
/* if (Model.Model.CollisionGroups?.Count != 0)
{
var collisionGroups = Model.Model.CollisionGroups;
for (int c = 0; c < collisionGroups.Count; c++)
{
if (collisionGroups[c].BoneIndex == i)
{
}
}
}*/
}
// Model.Model.CollisionGroups = new List<CollisionGroup>();
List<int> skinningIndices = Model.GenerateSkinningIndices();
List<string> unmappedBones = new List<string>();
foreach (var mesh in meshes)
{
for (int i = 0; i < mesh.vertices.Count; i++)
{
if (importer.RotationY != 0)
{
var transform = OpenTK.Matrix4.CreateRotationX(OpenTK.MathHelper.DegreesToRadians(importer.RotationY));
mesh.vertices[i].pos = OpenTK.Vector3.TransformPosition(mesh.vertices[i].pos, transform);
mesh.vertices[i].nrm = OpenTK.Vector3.TransformPosition(mesh.vertices[i].nrm, transform);
}
for (int j = 0; j < mesh.vertices[i].boneNames?.Count; j++)
{
string boneName = mesh.vertices[i].boneNames[j];
int boneIndex = Model.Model.Bones.IndexOf(Model.Model.Bones.Where(p => p.Name == boneName).FirstOrDefault());
if (boneIndex != -1)
mesh.vertices[i].boneIds.Add(boneIndex);
else
{
if (!unmappedBones.Contains(boneName))
unmappedBones.Add(boneName);
}
}
}
}
//Now add brand new mesh nodes
foreach (var mesh in meshes)
{
int index = meshes.IndexOf(mesh);
var setting = importer.Settings.MeshSettings[index];
Bone bone = new Bone();
bone.Name = mesh.ObjectName;
bone.BoneType = 0;
bone.Parent = 0;
bone.Zero = 0;
bone.Visible = false;
bone.Scale = new GFMDLStructs.Vector3(1, 1, 1);
bone.Rotation = new GFMDLStructs.Vector3(0, 0, 0);
bone.Translation = new GFMDLStructs.Vector3(0,0,0);
bone.RadiusStart = new GFMDLStructs.Vector3(0, 0, 0);
bone.RadiusEnd = new GFMDLStructs.Vector3(0, 0, 0);
bone.RigidCheck = new BoneRigidData();
int NodeIndex = Model.Model.Bones.IndexOf(bone);
Model.Model.Bones.Add(bone);
//Now create the associated group
var group = new Group();
group.Bounding = Model.GenerateBoundingBox(mesh);
group.BoneIndex = (uint)NodeIndex;
group.MeshIndex = (uint)index;
group.Layer = 0;
Model.Model.Groups.Add(group);
//Now create our mesh data
var meshData = new Mesh();
Model.Model.Meshes.Add(meshData);
if (setting.HasBitangents)
{
try {
mesh.CalculateTangentBitangent(false);
}
catch { }
}
//Add attributes based on settings
IList<MeshAttribute> attributes = new List<MeshAttribute>();
attributes.Add(new MeshAttribute()
{
VertexType = (uint)VertexType.Position,
BufferFormat = (uint)setting.PositionFormat,
ElementCount = 3,
});
if (setting.HasNormals) {
attributes.Add(new MeshAttribute()
{
VertexType = (uint)VertexType.Normal,
BufferFormat = (uint)setting.NormalFormat,
ElementCount = 4,
});
}
if (setting.HasTexCoord1) {
attributes.Add(new MeshAttribute()
{
VertexType = (uint)VertexType.UV1,
BufferFormat = (uint)setting.TexCoord1Format,
ElementCount = 2,
});
}
if (setting.HasTexCoord2) {
attributes.Add(new MeshAttribute()
{
VertexType = (uint)VertexType.UV2,
BufferFormat = (uint)setting.TexCoord2Format,
ElementCount = 2,
});
}
if (setting.HasTexCoord3) {
attributes.Add(new MeshAttribute()
{
VertexType = (uint)VertexType.UV3,
BufferFormat = (uint)setting.TexCoord3Format,
ElementCount = 2,
});
}
if (setting.HasTexCoord4) {
attributes.Add(new MeshAttribute()
{
VertexType = (uint)VertexType.UV4,
BufferFormat = (uint)setting.TexCoord4Format,
ElementCount = 2,
});
}
if (setting.HasColor1) {
attributes.Add(new MeshAttribute()
{
VertexType = (uint)VertexType.Color1,
BufferFormat = (uint)setting.Color1Format,
ElementCount = 4,
});
}
if (setting.HasColor2) {
attributes.Add(new MeshAttribute()
{
VertexType = (uint)VertexType.Color2,
BufferFormat = (uint)setting.Color2Format,
ElementCount = 4,
});
}
if (setting.HasBitangents) {
attributes.Add(new MeshAttribute()
{
VertexType = (uint)VertexType.Binormal,
BufferFormat = (uint)setting.BitangentnFormat,
ElementCount = 4,
});
}
if (setting.HasWeights) {
attributes.Add(new MeshAttribute()
{
VertexType = (uint)VertexType.BoneWeight,
BufferFormat = (uint)setting.BoneWeightFormat,
ElementCount = 4,
});
}
if (setting.HasBoneIndices) {
attributes.Add(new MeshAttribute()
{
VertexType = (uint)VertexType.BoneID,
BufferFormat = (uint)setting.BoneIndexFormat,
ElementCount = 4,
});
}
if (setting.HasTangents) {
attributes.Add(new MeshAttribute()
{
VertexType = (uint)VertexType.Tangents,
BufferFormat = (uint)setting.TangentsFormat,
ElementCount = 4,
});
}
meshData.Attributes = attributes;
meshData.SetData(GFLXMeshBufferHelper.CreateVertexDataBuffer(mesh, skinningIndices, attributes));
//Lastly add the polygon groups
foreach (var poly in mesh.PolygonGroups)
{
List<ushort> faces = new List<ushort>();
for (int f = 0; f < poly.faces.Count; f++)
faces.Add((ushort)poly.faces[f]);
if (poly.MaterialIndex < 0)
poly.MaterialIndex = 0;
meshData.Polygons = new List<MeshPolygon>();
meshData.Polygons.Add(new MeshPolygon()
{
MaterialIndex = (uint)poly.MaterialIndex,
Faces = faces,
});
}
}
foreach (var bone in unmappedBones)
Console.WriteLine($"unmapped bone! {bone}");
Console.WriteLine($"");
//Generate bounding box
Model.GenerateBoundingBox();
ReloadModel(Model.Model);
Model.UpdateVertexData(true);
}
public void ExportModel(string fileName, DAE.ExportSettings settings)
{
var model = new STGenericModel();
model.Materials = Model.GenericMaterials;
model.Objects = Model.GenericMeshes;
var textures = new List<STGenericTexture>();
foreach (var bntx in PluginRuntime.bntxContainers)
foreach (var tex in bntx.Textures.Values)
{
if (Model.Textures.Contains(tex.Text))
textures.Add(tex);
}
foreach (var mesh in model.Objects)
{
foreach (var poly in mesh.PolygonGroups)
{
GFLXMaterialData mat = (GFLXMaterialData)poly.Material;
var faces = poly.GetDisplayFace();
for (int v = 0; v < poly.displayFaceSize; v += 3)
{
if (faces.Count < v + 2)
break;
var diffuse = mat.TextureMaps.FirstOrDefault(x => x.Type == STGenericMatTexture.TextureType.Diffuse);
STTextureTransform transform = new STTextureTransform();
if (diffuse != null)
transform = diffuse.Transform;
mesh.vertices[faces[v]].uv0 += transform.Translate * transform.Scale;
mesh.vertices[faces[v + 1]].uv0 += transform.Translate * transform.Scale;
mesh.vertices[faces[v + 2]].uv0 += transform.Translate * transform.Scale;
}
}
}
DAE.Export(fileName, settings, model, textures, Model.Skeleton);
}
public void Unload()
{
}
}
}

View File

@ -8,6 +8,7 @@ using Toolbox.Library.Rendering;
using OpenTK;
using Toolbox.Library.Forms;
using System.Windows.Forms;
using FirstPlugin.Forms;
namespace FirstPlugin
{
@ -18,8 +19,17 @@ namespace FirstPlugin
public GFLXModel ParentModel { get; set; }
public FlatBuffers.Gfbmdl.Mesh MeshData { get; set; }
public FlatBuffers.Gfbmdl.Group GroupData { get; set; }
public GFBANM.MeshAnimationController AnimationController = new GFBANM.MeshAnimationController();
public Matrix4 Transform { get; set; }
public GFMDLStructs.Mesh MeshData { get; set; }
public GFMDLStructs.Group GroupData { get; set; }
public override void OnClick(TreeView treeView) {
var editor = ParentModel.LoadEditor<GFLXMeshEditor>();
editor.LoadMesh(this);
}
public GFLXMaterialData GetMaterial(STGenericPolygonGroup polygroup)
{
@ -31,11 +41,35 @@ namespace FirstPlugin
List<ToolStripItem> Items = new List<ToolStripItem>();
var uvMenu = new ToolStripMenuItem("UVs");
Items.Add(uvMenu);
Items.Add(new ToolStripMenuItem("Recalculate Bitangents", null, CalculateTangentBitangenAction, Keys.Control | Keys.T));
uvMenu.DropDownItems.Add(new ToolStripMenuItem("Flip Vertical", null, FlipVerticalAction, Keys.Control | Keys.V));
uvMenu.DropDownItems.Add(new ToolStripMenuItem("Flip Horizontal", null, FlipHorizontalAction, Keys.Control | Keys.H));
var colorMenu = new ToolStripMenuItem("Vertex Colors");
colorMenu.DropDownItems.Add(new ToolStripMenuItem("Set Color", null, SetVertexColorDialog, Keys.Control | Keys.C));
Items.Add(colorMenu);
return Items.ToArray();
}
private void SetVertexColorDialog(object sender, EventArgs args)
{
if (!MeshData.Attributes.Any(x => x.VertexType == (uint)GFMDLStructs.VertexType.Color1))
return;
ColorDialog dlg = new ColorDialog();
if (dlg.ShowDialog() == DialogResult.OK) {
SetVertexColor(new Vector4(
dlg.Color.R / 255.0f,
dlg.Color.G / 255.0f,
dlg.Color.B / 255.0f,
dlg.Color.A / 255.0f));
UpdateMesh();
}
}
private void FlipVerticalAction(object sender, EventArgs args) {
this.FlipUvsVertical();
UpdateMesh();
@ -46,9 +80,16 @@ namespace FirstPlugin
UpdateMesh();
}
private void CalculateTangentBitangenAction(object sender, EventArgs args)
{
this.CalculateTangentBitangent(false);
UpdateMesh();
}
private void UpdateMesh() {
MeshData.SetData(GFLXMeshBufferHelper.CreateVertexDataBuffer(this));
ParentModel.UpdateVertexData(true);
GFLXMeshBufferHelper.ReloadVertexData(this);
}
public struct DisplayVertex
@ -69,8 +110,8 @@ namespace FirstPlugin
}
public GFLXMesh(GFLXModel model,
FlatBuffers.Gfbmdl.Group group,
FlatBuffers.Gfbmdl.Mesh mesh)
GFMDLStructs.Group group,
GFMDLStructs.Mesh mesh)
{
ParentModel = model;
GroupData = group;

View File

@ -1,102 +1,205 @@
using System;
using FirstPlugin.GFMDLStructs;
using FlatBuffers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
using OpenTK;
using FlatBuffers.Gfbmdl;
using Toolbox.Library.Rendering;
using Toolbox.Library;
using Toolbox.Library.IO;
using Toolbox.Library.Rendering;
using System.Linq;
namespace FirstPlugin
{
public class GFLXMeshBufferHelper
{
public static void ReloadVertexData(GFLXMesh mesh)
public static byte[] CreateVertexDataBuffer(GFLXMesh mesh)
{
var flatMesh = mesh.MeshData;
var buf = flatMesh.ByteBuffer;
for (int v = 0; v < mesh.vertices.Count; v++)
var meshData = mesh.MeshData;
//Get all the bones from model and create skin index list
List<int> SkinningIndices = new List<int>();
foreach (GFLXBone bone in mesh.ParentModel.Skeleton.bones)
{
// flatMesh.ByteBuffer.PutByte();
// flatMesh.Data(v);
if (bone.HasSkinning)
SkinningIndices.Add(mesh.ParentModel.Skeleton.bones.IndexOf(bone));
}
return CreateVertexDataBuffer(mesh, SkinningIndices, mesh.MeshData.Attributes);
}
public static byte[] CreateVertexDataBuffer(STGenericObject mesh, List<int> SkinningIndices, IList<MeshAttribute> attributes)
{
var mem = new System.IO.MemoryStream();
using (var writer = new FileWriter(mem))
{
//Generate a buffer based on the attributes used
for (int v = 0; v < mesh.vertices.Count; v++)
{
for (int a = 0; a < attributes.Count; a++)
{
uint numAttributes = attributes[a].ElementCount;
List<float> values = new List<float>();
switch ((VertexType)attributes[a].VertexType)
{
case VertexType.Position:
values.Add(mesh.vertices[v].pos.X);
values.Add(mesh.vertices[v].pos.Y);
values.Add(mesh.vertices[v].pos.Z);
break;
case VertexType.Normal:
values.Add(mesh.vertices[v].nrm.X);
values.Add(mesh.vertices[v].nrm.Y);
values.Add(mesh.vertices[v].nrm.Z);
values.Add(0);
// values.Add(((GFLXMesh.GFLXVertex)mesh.vertices[v]).NormalW);
break;
case VertexType.Color1:
values.Add(mesh.vertices[v].col.X * 255);
values.Add(mesh.vertices[v].col.Y * 255);
values.Add(mesh.vertices[v].col.Z * 255);
values.Add(mesh.vertices[v].col.W * 255);
break;
case VertexType.UV1:
values.Add(mesh.vertices[v].uv0.X);
values.Add(1 - mesh.vertices[v].uv0.Y);
break;
case VertexType.UV2:
values.Add(mesh.vertices[v].uv1.X);
values.Add(1 - mesh.vertices[v].uv1.Y);
break;
case VertexType.UV3:
values.Add(mesh.vertices[v].uv2.X);
values.Add(1 - mesh.vertices[v].uv2.Y);
break;
case VertexType.UV4:
values.Add(mesh.vertices[v].uv3.X);
values.Add(1 - mesh.vertices[v].uv3.Y);
break;
case VertexType.BoneWeight:
var weights = mesh.vertices[v].boneWeights;
for (int b = 0; b < numAttributes; b++)
{
if (weights.Count > b)
values.Add(weights[b]);
else
values.Add(0);
}
break;
case VertexType.BoneID:
var boneIds = mesh.vertices[v].boneIds;
for (int b = 0; b < numAttributes; b++)
{
if (boneIds.Count > b)
values.Add(SkinningIndices.IndexOf(boneIds[b]));
else
values.Add(0);
}
break;
case VertexType.Binormal:
values.Add(mesh.vertices[v].bitan.X);
values.Add(mesh.vertices[v].bitan.Y);
values.Add(mesh.vertices[v].bitan.Z);
values.Add(mesh.vertices[v].bitan.W);
break;
case VertexType.Color2:
values.Add(mesh.vertices[v].col2.X * 255);
values.Add(mesh.vertices[v].col2.Y * 255);
values.Add(mesh.vertices[v].col2.Z * 255);
values.Add(mesh.vertices[v].col2.W * 255);
break;
case VertexType.Tangents:
values.Add(mesh.vertices[v].tan.X);
values.Add(mesh.vertices[v].tan.Y);
values.Add(mesh.vertices[v].tan.Z);
values.Add(mesh.vertices[v].tan.W);
break;
default:
throw new Exception("unsupported format!");
}
WriteBuffer(writer, numAttributes, values.ToArray(),
(BufferFormat)attributes[a].BufferFormat, (VertexType)attributes[a].VertexType);
}
}
}
return mem.ToArray();
}
public static uint GetTotalBufferStride(Mesh mesh)
{
uint VertBufferStride = 0;
for (int i = 0; i < mesh.AlignmentsLength; i++)
for (int i = 0; i < mesh.Attributes?.Count; i++)
{
var attribute = mesh.Alignments(i).Value;
switch (attribute.TypeID)
var attribute = mesh.Attributes[i];
switch ((VertexType)attribute.VertexType)
{
case VertexType.Position:
if (attribute.FormatID == BufferFormat.HalfFloat)
if (attribute.BufferFormat == (uint)BufferFormat.HalfFloat)
VertBufferStride += 0x08;
else if (attribute.FormatID == BufferFormat.Float)
else if (attribute.BufferFormat == (uint)BufferFormat.Float)
VertBufferStride += 0x0C;
else
throw new Exception($"Unknown Combination! {attribute.TypeID} {attribute.FormatID}");
throw new Exception($"Unknown Combination! {attribute.VertexType} {attribute.BufferFormat}");
break;
case VertexType.Normal:
if (attribute.FormatID == BufferFormat.HalfFloat)
if (attribute.BufferFormat == (uint)BufferFormat.HalfFloat)
VertBufferStride += 0x08;
else if (attribute.FormatID == BufferFormat.Float)
else if (attribute.BufferFormat == (uint)BufferFormat.Float)
VertBufferStride += 0x0C;
else
throw new Exception($"Unknown Combination! {attribute.TypeID} {attribute.FormatID}");
throw new Exception($"Unknown Combination! {attribute.VertexType} {attribute.BufferFormat}");
break;
case VertexType.Binormal:
if (attribute.FormatID == BufferFormat.HalfFloat)
if (attribute.BufferFormat == (uint)BufferFormat.HalfFloat)
VertBufferStride += 0x08;
else if (attribute.FormatID == BufferFormat.Float)
else if (attribute.BufferFormat == (uint)BufferFormat.Float)
VertBufferStride += 0x0C;
else
throw new Exception($"Unknown Combination! {attribute.TypeID} {attribute.FormatID}");
throw new Exception($"Unknown Combination! {attribute.VertexType} {attribute.BufferFormat}");
break;
case VertexType.UV1:
case VertexType.UV2:
case VertexType.UV3:
case VertexType.UV4:
if (attribute.FormatID == BufferFormat.HalfFloat)
if (attribute.BufferFormat == (uint)BufferFormat.HalfFloat)
VertBufferStride += 0x04;
else if (attribute.FormatID == BufferFormat.Float)
else if (attribute.BufferFormat == (uint)BufferFormat.Float)
VertBufferStride += 0x08;
else
throw new Exception($"Unknown Combination! {attribute.TypeID} {attribute.FormatID}");
throw new Exception($"Unknown Combination! {attribute.VertexType} {attribute.BufferFormat}");
break;
case VertexType.Color1:
case VertexType.Color2:
if (attribute.FormatID == BufferFormat.Byte)
if (attribute.BufferFormat == (uint)BufferFormat.Byte)
VertBufferStride += 0x04;
else
throw new Exception($"Unknown Combination! {attribute.TypeID} {attribute.FormatID}");
throw new Exception($"Unknown Combination! {attribute.VertexType} {attribute.BufferFormat}");
break;
case VertexType.BoneID:
if (attribute.FormatID == BufferFormat.Short)
if (attribute.BufferFormat == (uint)BufferFormat.Short)
VertBufferStride += 0x08;
else if (attribute.FormatID == BufferFormat.Byte)
else if (attribute.BufferFormat == (uint)BufferFormat.Byte)
VertBufferStride += 0x04;
else
throw new Exception($"Unknown Combination! {attribute.TypeID} {attribute.FormatID}");
throw new Exception($"Unknown Combination! {attribute.VertexType} {attribute.BufferFormat}");
break;
case VertexType.BoneWeight:
if (attribute.FormatID == BufferFormat.BytesAsFloat)
if (attribute.BufferFormat == (uint)BufferFormat.BytesAsFloat)
VertBufferStride += 0x04;
else
throw new Exception($"Unknown Combination! {attribute.TypeID} {attribute.FormatID}");
throw new Exception($"Unknown Combination! {attribute.VertexType} {attribute.BufferFormat}");
break;
case VertexType.Tangents:
if (attribute.BufferFormat == (uint)BufferFormat.HalfFloat)
VertBufferStride += 0x08;
else
throw new Exception($"Unknown Combination! {attribute.VertexType} {attribute.BufferFormat}");
break;
default:
Console.WriteLine($"attribute.FormatID {attribute.FormatID}");
if (attribute.FormatID == BufferFormat.HalfFloat)
VertBufferStride += 0x08;
else if (attribute.FormatID == BufferFormat.Float)
VertBufferStride += 0x0C;
else
throw new Exception($"Unknown Combination! {attribute.TypeID} {attribute.FormatID}");
break;
throw new Exception($"Unknown Combination! {attribute.VertexType} {attribute.BufferFormat}");
}
}
@ -109,7 +212,7 @@ namespace FirstPlugin
uint VertBufferStride = GetTotalBufferStride(mesh);
using (var reader = new FileReader(mesh.GetDataArray()))
using (var reader = new FileReader(mesh.Data.ToArray()))
{
uint numVertex = (uint)reader.BaseStream.Length / VertBufferStride;
for (int v = 0; v < numVertex; v++)
@ -117,39 +220,41 @@ namespace FirstPlugin
Vertex vertex = new Vertex();
Vertices.Add(vertex);
for (int att = 0; att < mesh.AlignmentsLength; att++)
for (int att = 0; att < mesh.Attributes?.Count; att++)
{
var attribute = mesh.Alignments(att).Value;
var attribute = mesh.Attributes[att];
switch (attribute.TypeID)
switch ((VertexType)attribute.VertexType)
{
case VertexType.Position:
var pos = ParseBuffer(reader, attribute.FormatID, attribute.TypeID);
var pos = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount);
vertex.pos = new OpenTK.Vector3(pos.X, pos.Y, pos.Z);
vertex.pos = OpenTK.Vector3.TransformPosition(vertex.pos, transform);
break;
case VertexType.Normal:
var normal = ParseBuffer(reader, attribute.FormatID, attribute.TypeID);
var normal = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount);
vertex.nrm = new OpenTK.Vector3(normal.X, normal.Y, normal.Z);
vertex.normalW = normal.W;
vertex.nrm = OpenTK.Vector3.TransformNormal(vertex.nrm, transform);
break;
case VertexType.UV1:
var texcoord1 = ParseBuffer(reader, attribute.FormatID, attribute.TypeID);
var texcoord1 = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount);
vertex.uv0 = new OpenTK.Vector2(texcoord1.X, texcoord1.Y);
break;
case VertexType.UV2:
var texcoord2 = ParseBuffer(reader, attribute.FormatID, attribute.TypeID);
var texcoord2 = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount);
vertex.uv1 = new OpenTK.Vector2(texcoord2.X, texcoord2.Y);
break;
case VertexType.UV3:
var texcoord3 = ParseBuffer(reader, attribute.FormatID, attribute.TypeID);
var texcoord3 = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount);
vertex.uv2 = new OpenTK.Vector2(texcoord3.X, texcoord3.Y);
break;
case VertexType.UV4:
var texcoord4 = ParseBuffer(reader, attribute.FormatID, attribute.TypeID);
var texcoord4 = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount);
vertex.uv3 = new OpenTK.Vector2(texcoord4.X, texcoord4.Y);
break;
case VertexType.BoneWeight:
var weights = ParseBuffer(reader, attribute.FormatID, attribute.TypeID);
var weights = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount);
vertex.boneWeights.AddRange(new float[]
{
weights.X,
@ -159,7 +264,7 @@ namespace FirstPlugin
});
break;
case VertexType.BoneID:
var boneIndices = ParseBuffer(reader, attribute.FormatID, attribute.TypeID);
var boneIndices = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount);
vertex.boneIds.AddRange(new int[]
{
boneSkinningIds[(int)boneIndices.X],
@ -170,24 +275,29 @@ namespace FirstPlugin
break;
case VertexType.Color1:
OpenTK.Vector4 colors1 = new OpenTK.Vector4(1, 1, 1, 1);
if (attribute.FormatID == BufferFormat.Byte)
colors1 = ParseBuffer(reader, attribute.FormatID, attribute.TypeID);
if (attribute.BufferFormat == (uint)BufferFormat.Byte)
colors1 = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount);
vertex.col = colors1 / 255f;
break;
case VertexType.Color2:
OpenTK.Vector4 colors2 = new OpenTK.Vector4(1, 1, 1, 1);
if (attribute.FormatID == BufferFormat.Byte)
colors2 = ParseBuffer(reader, attribute.FormatID, attribute.TypeID);
if (attribute.BufferFormat == (uint)BufferFormat.Byte)
colors2 = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount);
vertex.col2 = colors2 / 255f;
break;
case VertexType.Binormal:
var binormals = ParseBuffer(reader, attribute.FormatID, attribute.TypeID);
var binormals = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount);
vertex.bitan = new OpenTK.Vector4(binormals.X, binormals.Y, binormals.Z, binormals.W);
break;
case VertexType.Tangents:
var tans = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount);
vertex.tan = new OpenTK.Vector4(tans.X, tans.Y, tans.Z, tans.W);
break;
default:
ParseBuffer(reader, attribute.FormatID, attribute.TypeID);
var values = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount);
vertex.Unknowns.Add(values);
break;
}
}
@ -197,8 +307,11 @@ namespace FirstPlugin
return Vertices;
}
private static OpenTK.Vector4 ParseBuffer(FileReader reader, BufferFormat Format, VertexType AttributeType)
private static OpenTK.Vector4 ParseBuffer(FileReader reader, uint format, uint attType, uint numElements)
{
VertexType AttributeType = (VertexType)attType;
BufferFormat Format = (BufferFormat)format;
if (AttributeType == VertexType.Position)
{
switch (Format)
@ -292,8 +405,34 @@ namespace FirstPlugin
switch (Format)
{
case BufferFormat.HalfFloat:
return new OpenTK.Vector4(reader.ReadHalfSingle(), reader.ReadHalfSingle(),
reader.ReadHalfSingle(), reader.ReadHalfSingle());
float[] values = new float[4];
for (int i = 0; i < numElements; i++)
values[i] = reader.ReadHalfSingle();
return new OpenTK.Vector4(values[0], values[1], values[2], values[3]);
default:
throw new Exception($"Unknown Combination! {AttributeType} {Format}");
}
}
}
private static void WriteBuffer(FileWriter writer, uint ElementCount, float[] value, BufferFormat Format, VertexType AttributeType)
{
for (int i = 0; i < ElementCount; i++)
{
switch (Format)
{
case BufferFormat.Float:
writer.Write(value[i]); break;
case BufferFormat.HalfFloat:
writer.WriteHalfFloat(value[i]); break;
case BufferFormat.Byte:
writer.Write((byte)value[i]); break;
case BufferFormat.Short:
writer.Write((short)value[i]); break;
case BufferFormat.BytesAsFloat:
writer.Write((byte)(value[i] * 255)); break;
default:
throw new Exception($"Unknown Combination! {AttributeType} {Format}");
}

View File

@ -0,0 +1,508 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Toolbox.Library;
using Toolbox.Library.IO;
using Toolbox.Library.Rendering;
using FirstPlugin.Forms;
using FirstPlugin.GFMDLStructs;
using Newtonsoft.Json;
namespace FirstPlugin
{
public class GFLXModel
{
public GFBMDL ParentFile;
public List<GFLXMaterialData> GenericMaterials = new List<GFLXMaterialData>();
public List<GFLXMesh> GenericMeshes = new List<GFLXMesh>();
public STSkeleton Skeleton = new STSkeleton();
public Model Model;
public IList<string> Textures
{
get { return Model.TextureNames; }
set { Model.TextureNames = value; }
}
public IList<string> Shaders
{
get { return Model.ShaderNames; }
set { Model.ShaderNames = value; }
}
public T LoadEditor<T>() where T :
System.Windows.Forms.UserControl, new()
{
return ParentFile.LoadEditor<T>();
}
public void UpdateVertexData(bool updateViewport) {
ParentFile.Renderer.UpdateVertexData();
if (updateViewport)
LibraryGUI.UpdateViewport();
}
public void LoadFile(Model model, GFBMDL file, GFBMDL_Render Renderer) {
Model = model;
ParentFile = file;
for (int m = 0; m < Model.Materials?.Count; m++) {
GenericMaterials.Add(new GFLXMaterialData(this, Model.Materials[m]));
}
List<int> SkinningIndices = new List<int>();
for (int b = 0; b < Model.Bones?.Count; b++) {
var bone = Model.Bones[b];
Skeleton.bones.Add(new GFLXBone(this, bone));
if (bone.RigidCheck == null)
SkinningIndices.Add(b);
}
Skeleton.reset();
Skeleton.update();
for (int g = 0; g < Model.Groups?.Count; g++) {
var group = Model.Groups[g];
var mesh = Model.Meshes[g];
OpenTK.Matrix4 transform = OpenTK.Matrix4.Identity;
GFLXMesh genericMesh = new GFLXMesh(this, group, mesh);
genericMesh.Checked = true;
genericMesh.ImageKey = "model";
genericMesh.SelectedImageKey = "model";
int boneIndex = (int)group.BoneIndex;
if (boneIndex < Skeleton.bones.Count && boneIndex > 0)
{
genericMesh.BoneIndex = boneIndex;
transform = Skeleton.bones[boneIndex].Transform;
genericMesh.Text = Skeleton.bones[boneIndex].Text;
}
// if (group.MeshID < Skeleton.bones.Count && group.MeshID > 0)
// genericMesh.Text = Skeleton.bones[(int)group.MeshID].Text;
Renderer.Meshes.Add(genericMesh);
GenericMeshes.Add(genericMesh);
//Load the vertex data
genericMesh.Transform = transform;
genericMesh.vertices = GFLXMeshBufferHelper.LoadVertexData(mesh, transform, SkinningIndices);
genericMesh.FlipUvsVertical();
//Load faces
for (int p = 0; p < mesh.Polygons?.Count; p++)
{
var poly = mesh.Polygons[p];
var polygonGroup = new STGenericPolygonGroup();
polygonGroup.MaterialIndex = (int)poly.MaterialIndex;
genericMesh.PolygonGroups.Add(polygonGroup);
if (GenericMaterials.Count > poly.MaterialIndex)
polygonGroup.Material = GenericMaterials[(int)poly.MaterialIndex];
for (int f = 0; f < poly.Faces?.Count; f++)
polygonGroup.faces.Add((int)poly.Faces[f]);
}
}
}
public void SaveFile(System.IO.Stream stream)
{
}
public List<int> GenerateSkinningIndices()
{
List<int> indices = new List<int>();
for (int i = 0; i < Model.Bones?.Count; i++)
{
if (Model.Bones[i].RigidCheck == null)
indices.Add(Model.Bones.IndexOf(Model.Bones[i]));
}
return indices;
}
public GFMDLStructs.BoundingBox GenerateBoundingBox(STGenericObject mesh)
{
float minX = 0;
float minY = 0;
float minZ = 0;
float maxX = 0;
float maxY = 0;
float maxZ = 0;
for (int v = 0; v < mesh.vertices.Count; v++)
{
minX = Math.Min(minX, mesh.vertices[v].pos.X);
minY = Math.Min(minY, mesh.vertices[v].pos.Y);
minZ = Math.Min(minZ, mesh.vertices[v].pos.Z);
maxX = Math.Max(maxX, mesh.vertices[v].pos.X);
maxY = Math.Max(maxY, mesh.vertices[v].pos.Y);
maxZ = Math.Max(maxZ, mesh.vertices[v].pos.Z);
}
var bounding = new GFMDLStructs.BoundingBox();
bounding.MinX = minX;
bounding.MinY = minY;
bounding.MinZ = minZ;
bounding.MaxX = maxX;
bounding.MaxY = maxY;
bounding.MaxZ = maxZ;
return bounding;
}
public void GenerateBoundingBox()
{
float minX = 0;
float minY = 0;
float minZ = 0;
float maxX = 0;
float maxY = 0;
float maxZ = 0;
foreach (var mesh in GenericMeshes)
{
for (int v = 0; v < mesh.vertices.Count; v++)
{
minX = Math.Min(minX, mesh.vertices[v].pos.X);
minY = Math.Min(minY, mesh.vertices[v].pos.Y);
minZ = Math.Min(minZ, mesh.vertices[v].pos.Z);
maxX = Math.Max(maxX, mesh.vertices[v].pos.X);
maxY = Math.Max(maxY, mesh.vertices[v].pos.Y);
maxZ = Math.Max(maxZ, mesh.vertices[v].pos.Z);
}
}
Model.Bounding = new GFMDLStructs.BoundingBox();
Model.Bounding.MinX = minX;
Model.Bounding.MinY = minY;
Model.Bounding.MinZ = minZ;
Model.Bounding.MaxX = maxX;
Model.Bounding.MaxY = maxY;
Model.Bounding.MaxZ = maxZ;
}
}
public class GFLXMaterialData : STGenericMaterial, IContextMenuNode
{
private Material Material;
public GFLXModel ParentModel;
public Dictionary<string, GFLXSwitchParam> SwitchParams = new Dictionary<string, GFLXSwitchParam>();
public Dictionary<string, GFLXValueParam> ValueParams = new Dictionary<string, GFLXValueParam>();
public Dictionary<string, GFLXColorParam> ColorParams = new Dictionary<string, GFLXColorParam>();
public override void OnClick(TreeView treeView) {
var editor = ParentModel.LoadEditor<GFLXMaterialEditor>();
editor.LoadMaterial(this);
}
public string ConvertToJson() {
return JsonConvert.SerializeObject(Material, Formatting.Indented);
}
public void ConvertFromJson(string text)
{
Material = JsonConvert.DeserializeObject<Material>(text);
ReloadMaterial();
var editor = ParentModel.LoadEditor<GFLXMaterialEditor>();
editor.LoadMaterial(this);
}
public ToolStripItem[] GetContextMenuItems()
{
List<ToolStripItem> Items = new List<ToolStripItem>();
Items.Add(new ToolStripMenuItem("Export", null, ExportAction, Keys.Control | Keys.E));
Items.Add(new ToolStripMenuItem("Replace", null, ReplaceAction, Keys.Control | Keys.R));
return Items.ToArray();
}
private void ExportAction(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Supported Formats|*.json;";
sfd.FileName = Text;
sfd.DefaultExt = "json";
if (sfd.ShowDialog() == DialogResult.OK) {
string json = JsonConvert.SerializeObject(Material, Formatting.Indented);
System.IO.File.WriteAllText(sfd.FileName, json);
}
}
private void ReplaceAction(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.json;";
if (ofd.ShowDialog() == DialogResult.OK)
{
Material = JsonConvert.DeserializeObject<Material>(
System.IO.File.ReadAllText(ofd.FileName));
ReloadMaterial();
var editor = ParentModel.LoadEditor<GFLXMaterialEditor>();
editor.LoadMaterial(this);
}
}
public GFLXMaterialData(GFLXModel parent, Material mat)
{
ParentModel = parent;
Material = mat;
Text = mat.Name;
ReloadMaterial();
}
private void ReloadMaterial()
{
SwitchParams.Clear();
ValueParams.Clear();
ColorParams.Clear();
TextureMaps.Clear();
for (int i = 0; i < Material.Switches?.Count; i++)
{
var val = Material.Switches[i];
SwitchParams.Add(val.Name, new GFLXSwitchParam(val));
}
for (int i = 0; i < Material.Values?.Count; i++)
{
var val = Material.Values[i];
ValueParams.Add(val.Name, new GFLXValueParam(val));
}
for (int i = 0; i < Material.Colors?.Count; i++)
{
var val = Material.Colors[i];
ColorParams.Add(val.Name, new GFLXColorParam(val));
}
int textureUnit = 1;
for (int t = 0; t < Material.TextureMaps?.Count; t++)
{
var tex = Material.TextureMaps[t];
string name = ParentModel.Textures[(int)tex.Index];
GFLXTextureMap matTexture = new GFLXTextureMap();
matTexture.gflxTextureMap = tex;
matTexture.Name = name;
matTexture.Transform = new STTextureTransform();
matTexture.SamplerName = tex.Sampler;
matTexture.textureUnit = textureUnit++;
matTexture.WrapModeS = STTextureWrapMode.Mirror;
matTexture.WrapModeT = STTextureWrapMode.Repeat;
TextureMaps.Add(matTexture);
switch (tex.Sampler)
{
case "BaseColor0":
matTexture.Type = STGenericMatTexture.TextureType.Diffuse;
break;
case "Col0Tex":
matTexture.Type = STGenericMatTexture.TextureType.Diffuse;
break;
case "EmissionMaskTex":
// matTexture.Type = STGenericMatTexture.TextureType.Emission;
break;
case "LyCol0Tex":
break;
case "NormalMapTex":
matTexture.WrapModeT = STTextureWrapMode.Repeat;
matTexture.WrapModeT = STTextureWrapMode.Repeat;
matTexture.Type = STGenericMatTexture.TextureType.Normal;
break;
case "AmbientTex":
break;
case "LightTblTex":
break;
case "SphereMapTex":
break;
case "EffectTex":
break;
}
float ScaleX = 1;
float ScaleY = 1;
float TransX = 0;
float TransY = 0;
//Lookup the uniforms and apply a transform to the texture map
//Used for the UV viewer
if (matTexture.Type == STGenericMatTexture.TextureType.Diffuse)
{
if (ValueParams.ContainsKey("ColorUVScaleU"))
ScaleX = ValueParams["ColorUVScaleU"].Value;
if (ValueParams.ContainsKey("ColorUVScaleV"))
ScaleY = ValueParams["ColorUVScaleV"].Value;
if (ValueParams.ContainsKey("ColorUVTranslateU"))
TransX = ValueParams["ColorUVTranslateU"].Value;
if (ValueParams.ContainsKey("ColorUVTranslateV"))
TransY = ValueParams["ColorUVTranslateV"].Value;
}
if (matTexture.Type == STGenericMatTexture.TextureType.Normal)
{
}
matTexture.Transform.Scale = new OpenTK.Vector2(ScaleX, ScaleY);
matTexture.Transform.Translate = new OpenTK.Vector2(TransX, TransY);
}
}
}
public class GFLXTextureMap : STGenericMatTexture
{
public TextureMap gflxTextureMap;
public override STGenericTexture GetTexture()
{
foreach (var bntx in PluginRuntime.bntxContainers)
{
if (bntx.Textures.ContainsKey(Name))
return bntx.Textures[Name];
}
return base.GetTexture();
}
}
public class GFLXBone : STBone
{
public Bone Bone;
public GFLXModel ParentModel;
public bool HasSkinning => Bone.RigidCheck == null;
public GFLXBone(GFLXModel parent, Bone bone) : base(parent.Skeleton)
{
ParentModel = parent;
Bone = bone;
Text = bone.Name;
parentIndex = bone.Parent;
if (bone.Translation != null)
{
position = new float[3]
{ bone.Translation.X,
bone.Translation.Y,
bone.Translation.Z
};
}
if (bone.Rotation != null)
{
rotation = new float[4]
{ bone.Rotation.X,
bone.Rotation.Y,
bone.Rotation.Z,
1.0f,
};
}
if (bone.Scale != null)
{
scale = new float[3]
{ bone.Scale.X,
bone.Scale.Y,
bone.Scale.Z
};
}
}
}
public class GFLXColorParam
{
private MatColor Param;
public GFLXColorParam(MatColor param)
{
Param = param;
}
public string Name
{
get { return Param.Name; }
set { Param.Name = value; }
}
public OpenTK.Vector3 Value
{
get { return new OpenTK.Vector3(
Param.Color.R,
Param.Color.G,
Param.Color.B);
}
set
{
var vec3 = value;
Param.Color.R = vec3.X;
Param.Color.G = vec3.Y;
Param.Color.B = vec3.Z;
}
}
}
public class GFLXValueParam
{
private MatFloat Param;
public GFLXValueParam(MatFloat param) {
Param = param;
}
public string Name
{
get { return Param.Name; }
set { Param.Name = value; }
}
public float Value
{
get { return Param.Value; }
set { Param.Value = value; }
}
}
public class GFLXSwitchParam
{
private MatSwitch Param;
public GFLXSwitchParam(MatSwitch param)
{
Param = param;
}
public string Name
{
get { return Param.Name; }
set { Param.Name = value; }
}
public bool Value
{
get { return Param.Value; }
set { Param.Value = value; }
}
}
}

View File

@ -0,0 +1,276 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace FirstPlugin.GFMDLStructs
{
public enum VertexType
{
Position = 0,
Normal = 1,
Binormal = 2,
UV1 = 3,
UV2 = 4,
UV3 = 5,
UV4 = 6,
Color1 = 7,
Color2 = 8,
Color3 = 9,
Color4 = 10,
BoneID = 11,
BoneWeight = 12,
Tangents = 13,
Unknown2 = 14,
}
public enum BufferFormat : uint
{
Float = 0,
HalfFloat = 1,
Byte = 3,
Short = 5,
BytesAsFloat = 8,
}
public class Model
{
public uint Version { get; set; }
public BoundingBox Bounding { get; set; }
public IList<string> TextureNames { get; set; }
public IList<string> ShaderNames { get; set; }
public IList<UnknownEmpty> Unknown { get; set; }
public IList<string> MaterialNames { get; set; }
public IList<Material> Materials { get; set; }
public IList<Group> Groups { get; set; }
public IList<Mesh> Meshes { get; set; }
public IList<Bone> Bones { get; set; }
public IList<CollisionGroup> CollisionGroups { get; set; }
}
public class Material
{
public string Name { get; set; }
public string ShaderGroup { get; set; }
public int RenderLayer { get; set; }
public byte Unknown1 { get; set; }
public byte Unknown2 { get; set; }
public int Parameter1 { get; set; }
public int Parameter2 { get; set; }
public int Parameter3 { get; set; }
public int Parameter4 { get; set; }
public int Parameter5 { get; set; }
public int Parameter6 { get; set; }
public IList<TextureMap> TextureMaps { get; set; }
public IList<MatSwitch> Switches { get; set; }
public IList<MatFloat> Values { get; set; }
public IList<MatColor> Colors { get; set; }
public byte Unknown3 { get; set; }
public byte Unknown4 { get; set; }
public byte Unknown5 { get; set; }
public byte Unknown6 { get; set; }
public byte Unknown7 { get; set; }
public MaterialCommon Common { get; set; }
public void Export(string name)
{
string json = JsonConvert.SerializeObject(this, Formatting.Indented);
System.IO.File.WriteAllText($"mat_{name}.json", json);
}
public static Material Replace(string filePath)
{
string json = System.IO.File.ReadAllText(filePath);
return JsonConvert.DeserializeObject<Material>(json);
}
}
public class TextureMap
{
public string Sampler { get; set; }
public uint Index { get; set; }
public TextureParams Params { get; set; }
}
public class TextureParams
{
public uint Unknown1 { get; set; }
public uint Unknown2 { get; set; }
public uint Unknown3 { get; set; }
public uint Unknown4 { get; set; }
public uint Unknown5 { get; set; }
public uint Unknown6 { get; set; }
public uint Unknown7 { get; set; }
public uint Unknown8 { get; set; }
public float lodBias { get; set; }
}
public class MatInt
{
public string Name { get; set; }
public int Value { get; set; }
}
public class MatFloat
{
public string Name { get; set; }
public float Value { get; set; }
}
public class MatColor
{
public string Name { get; set; }
public ColorRGB32 Color { get; set; }
}
public class MatSwitch
{
public string Name { get; set; }
public bool Value { get; set; }
}
public class MaterialCommon
{
public IList<MatSwitch> Switches { get; set; }
public IList<MatInt> Values { get; set; }
public IList<MatColor> Colors { get; set; }
}
public class UnknownEmpty
{
public uint Zero { get; set; }
}
public class Group
{
public uint BoneIndex { get; set; }
public uint MeshIndex { get; set; }
public BoundingBox Bounding { get; set; }
public uint Layer { get; set; }
}
public class Mesh
{
public IList<MeshPolygon> Polygons { get; set; }
public IList<MeshAttribute> Attributes { get; set; }
public IList<byte> Data { get; set; }
public void SetData(byte[] data)
{
if (Data == null)
Data = new List<byte>();
Data.Clear();
for (int i = 0; i < data.Length; i++)
Data.Add(data[i]);
}
}
public class MeshPolygon
{
public uint MaterialIndex { get; set; }
public IList<ushort> Faces { get; set; }
}
public class MeshAttribute
{
public uint VertexType { get; set; }
public uint BufferFormat { get; set; }
public uint ElementCount { get; set; }
}
public class Bone
{
public string Name { get; set; }
public uint BoneType { get; set; }
public int Parent { get; set; }
public uint Zero { get; set; }
public bool Visible { get; set; }
public Vector3 Scale { get; set; }
public Vector3 Rotation { get; set; }
public Vector3 Translation { get; set; }
public Vector3 RadiusStart { get; set; }
public Vector3 RadiusEnd { get; set; }
public BoneRigidData RigidCheck { get; set; }
}
public class BoneRigidData
{
public uint Unknown1 { get; set; }
}
public class CollisionGroup
{
public uint BoneIndex { get; set; }
public uint Unknown1 { get; set; }
public IList<uint> BoneChildren { get; set; }
public BoundingBox Bounding { get; set; }
}
public class BoundingBox
{
public float MinX { get; set; }
public float MinY { get; set; }
public float MinZ { get; set; }
public float MaxX { get; set; }
public float MaxY { get; set; }
public float MaxZ { get; set; }
}
public class Vector3
{
public float X { get; set; }
public float Y { get; set; }
public float Z { get; set; }
public Vector3() { }
public Vector3(float x, float y, float z) {
X = x; Y = y; Z = z;
}
}
public class ColorRGB32
{
public float R { get; set; }
public float G { get; set; }
public float B { get; set; }
public ColorRGB32() { }
public ColorRGB32(float r, float g, float b) {
R = r; G = g; B = b;
}
}
public class Vector4
{
public float X { get; set; }
public float Y { get; set; }
public float Z { get; set; }
public float W { get; set; }
public Vector4() { }
public Vector4(float x, float y, float z, float w) {
X = x; Y = y; Z = z; W = w;
}
}
}

View File

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FirstPlugin.GFMDLStructs;
namespace FirstPlugin
{
public class GfbmdlImportSettings
{
public List<MeshSetting> MeshSettings = new List<MeshSetting>();
public class MeshSetting
{
public bool FlipUVsVertical { get; set; }
public bool HasNormals { get; set; }
public bool HasBitangents { get; set; }
public bool HasTangents { get; set; }
public bool HasTexCoord1 { get; set; }
public bool HasTexCoord2 { get; set; }
public bool HasTexCoord3 { get; set; }
public bool HasTexCoord4 { get; set; }
public bool HasColor1 { get; set; }
public bool HasColor2 { get; set; }
public bool HasColor3 { get; set; }
public bool HasColor4 { get; set; }
public bool HasBoneIndices { get; set; }
public bool HasWeights { get; set; }
public BufferFormat PositionFormat { get; set; } = BufferFormat.Float;
public BufferFormat NormalFormat { get; set; } = BufferFormat.HalfFloat;
public BufferFormat BitangentnFormat { get; set; } = BufferFormat.HalfFloat;
public BufferFormat TexCoord1Format { get; set; } = BufferFormat.Float;
public BufferFormat TexCoord2Format { get; set; } = BufferFormat.Float;
public BufferFormat TexCoord3Format { get; set; } = BufferFormat.Float;
public BufferFormat TexCoord4Format { get; set; } = BufferFormat.Float;
public BufferFormat Color1Format { get; set; } = BufferFormat.Byte;
public BufferFormat Color2Format { get; set; } = BufferFormat.Byte;
public BufferFormat Color3Format { get; set; } = BufferFormat.Byte;
public BufferFormat Color4Format { get; set; } = BufferFormat.Byte;
public BufferFormat BoneIndexFormat { get; set; } = BufferFormat.Byte;
public BufferFormat BoneWeightFormat { get; set; } = BufferFormat.BytesAsFloat;
public BufferFormat TangentsFormat { get; set; } = BufferFormat.HalfFloat;
public string Material { get; set; }
public string MaterialFile { get; set; }
}
}
}

View File

@ -233,7 +233,7 @@
<Compile Include="FileFormats\NLG\NLG_Common.cs" />
<Compile Include="FileFormats\NLG\NLG_NLOC.cs" />
<Compile Include="FileFormats\NLG\NLOC_Wrapper.cs" />
<Compile Include="FileFormats\NLG\NLG_PCK.cs" />
<Compile Include="FileFormats\Audio\Archives\PCK.cs" />
<Compile Include="FileFormats\NLG\PunchOutWii\PO_DICT.cs" />
<Compile Include="FileFormats\Archives\VIBS.cs" />
<Compile Include="FileFormats\Audio\Archives\AudioCommon.cs" />
@ -358,16 +358,21 @@
<Compile Include="FileFormats\NLG\PunchOutWii\PO_VertexAttribute.cs" />
<Compile Include="FileFormats\Pikmin1\MOD.cs" />
<Compile Include="FileFormats\Pikmin1\TXE.cs" />
<Compile Include="FileFormats\Pokemon\GFBANIM\FlatBuffers\gfbanim.cs" />
<Compile Include="FileFormats\Pokemon\GFBANIM\GFBANM.cs" />
<Compile Include="FileFormats\Pokemon\GFBANMCFG\GFBANMCFG.cs" />
<Compile Include="FileFormats\Pokemon\GFBANMCFG\FlatBuffers\gfbanmcfg.cs" />
<Compile Include="FileFormats\Pokemon\GFBMDL\FlatBuffers\gfbmdl.cs" />
<Compile Include="FileFormats\Pokemon\GFBMDL\GFBMDL.cs" />
<Compile Include="FileFormats\Pokemon\GFBMDL\GFLXModel.cs" />
<Compile Include="FileFormats\Pokemon\GFBMDL\GFLXMeshBufferHelper.cs" />
<Compile Include="FileFormats\Pokemon\GFBPMCATALOG\FlatBuffers\gfbpmcatalog.cs" />
<Compile Include="FileFormats\Pokemon\PokemonTable.cs" />
<Compile Include="FileFormats\Pokemon\GFLX\FlatBufferHelper.cs" />
<Compile Include="FileFormats\Pokemon\GFLX\GFBANIM\FlatBuffers\gfbanim.cs" />
<Compile Include="FileFormats\Pokemon\GFLX\GFBANIM\GfbanimKeyFrameLoader.cs" />
<Compile Include="FileFormats\Pokemon\GFLX\GFBANIM\GFBANM.cs" />
<Compile Include="FileFormats\Pokemon\GFLX\GFBANMCFG\GFBANMCFG.cs" />
<Compile Include="FileFormats\Pokemon\GFLX\GFBANMCFG\FlatBuffers\gfbanmcfg.cs" />
<Compile Include="FileFormats\Pokemon\GFLX\GFBMDL\FlatBuffers\BufferToStruct.cs" />
<Compile Include="FileFormats\Pokemon\GFLX\GFBMDL\FlatBuffers\gfbmdl.cs" />
<Compile Include="FileFormats\Pokemon\GFLX\GFBMDL\GFBMDL.cs" />
<Compile Include="FileFormats\Pokemon\GFLX\GFBMDL\GFLXModel.cs" />
<Compile Include="FileFormats\Pokemon\GFLX\GFBMDL\GFLXMeshBufferHelper.cs" />
<Compile Include="FileFormats\Pokemon\GFLX\GFBMDL\GfbmdlImportSettings.cs" />
<Compile Include="FileFormats\Pokemon\GFLX\GFBMDL\GFMDLStructs.cs" />
<Compile Include="FileFormats\Pokemon\GFLX\GFBPMCATALOG\FlatBuffers\gfbpmcatalog.cs" />
<Compile Include="FileFormats\Pokemon\GFLX\PokemonTable.cs" />
<Compile Include="FileFormats\Rom\3DS\NCSDStructs.cs" />
<Compile Include="FileFormats\Rom\3DS\NCSD.cs" />
<Compile Include="FileFormats\Rom\3DS\RomFS.cs" />
@ -392,6 +397,12 @@
<Compile Include="GL\LM3_Renderer.cs" />
<Compile Include="GL\PunchOutWii_Renderer.cs" />
<Compile Include="GL\Strikers_Renderer.cs" />
<Compile Include="GUI\BFLYT\Editor\PaneAnimationController.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="GUI\BFLYT\Editor\PaneAnimationController.Designer.cs">
<DependentUpon>PaneAnimationController.cs</DependentUpon>
</Compile>
<Compile Include="GUI\GFBMDL\GFLXMaterialEditor.cs">
<SubType>UserControl</SubType>
</Compile>
@ -404,6 +415,18 @@
<Compile Include="GUI\GFBMDL\GFLXMaterialParamEditor.Designer.cs">
<DependentUpon>GFLXMaterialParamEditor.cs</DependentUpon>
</Compile>
<Compile Include="GUI\GFBMDL\GFLXMeshEditor.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="GUI\GFBMDL\GFLXMeshEditor.Designer.cs">
<DependentUpon>GFLXMeshEditor.cs</DependentUpon>
</Compile>
<Compile Include="GUI\GFBMDL\GFLXModelImporter.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GUI\GFBMDL\GFLXModelImporter.Designer.cs">
<DependentUpon>GFLXModelImporter.cs</DependentUpon>
</Compile>
<Compile Include="GUI\Pokemon\PokemonLoaderSwSh.cs">
<SubType>Form</SubType>
</Compile>
@ -441,7 +464,7 @@
<DependentUpon>LayoutAnimEditor.cs</DependentUpon>
</Compile>
<Compile Include="GUI\BFLYT\Animations\Basic\LayoutAnimEditorBasic.cs">
<SubType>Form</SubType>
<SubType>UserControl</SubType>
</Compile>
<Compile Include="GUI\BFLYT\Animations\Basic\LayoutAnimEditorBasic.Designer.cs">
<DependentUpon>LayoutAnimEditorBasic.cs</DependentUpon>
@ -670,7 +693,7 @@
<Compile Include="GUI\BMD\BMDModelImportSettings.Designer.cs">
<DependentUpon>BMDModelImportSettings.cs</DependentUpon>
</Compile>
<Compile Include="FileFormats\Pokemon\GFBMDL\GFLXMesh.cs" />
<Compile Include="FileFormats\Pokemon\GFLX\GFBMDL\GFLXMesh.cs" />
<Compile Include="FileFormats\GMX\GMX.cs" />
<Compile Include="FileFormats\Hashes\SAHT.cs" />
<Compile Include="FileFormats\MKAGPDX\MKAGPDX_Model.cs" />
@ -1441,12 +1464,21 @@
<EmbeddedResource Include="GUI\AttributeEditor.resx">
<DependentUpon>AttributeEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\BFLYT\Editor\PaneAnimationController.resx">
<DependentUpon>PaneAnimationController.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\GFBMDL\GFLXMaterialEditor.resx">
<DependentUpon>GFLXMaterialEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\GFBMDL\GFLXMaterialParamEditor.resx">
<DependentUpon>GFLXMaterialParamEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\GFBMDL\GFLXMeshEditor.resx">
<DependentUpon>GFLXMeshEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\GFBMDL\GFLXModelImporter.resx">
<DependentUpon>GFLXModelImporter.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\Pokemon\PokemonLoaderSwSh.resx">
<DependentUpon>PokemonLoaderSwSh.cs</DependentUpon>
</EmbeddedResource>
@ -1940,6 +1972,7 @@
<ItemGroup>
<Folder Include="FileFormats\EvemtFlow\" />
<Folder Include="FileFormats\NLG\Common\" />
<Folder Include="FileFormats\Pokemon\GFL2\" />
<Folder Include="GUI\Byaml\MuuntEditor\Renderables\" />
</ItemGroup>
<ItemGroup>

View File

@ -15,6 +15,8 @@ namespace FirstPlugin
{
public class GFBMDL_Render : AbstractGlDrawable, IMeshContainer
{
public GFBMDL GfbmdlFile;
public List<STGenericObject> Meshes { get; set; } = new List<STGenericObject>();
public Matrix4 ModelTransform = Matrix4.Identity;
@ -399,7 +401,7 @@ namespace FirstPlugin
shader.EnableVertexAttributes();
foreach (GFLXMesh shp in Meshes)
{
if (shp.Checked)
if (shp.Checked && shp.AnimationController.IsVisible)
DrawModel(control, shp, shader);
}
shader.DisableVertexAttributes();

View File

@ -80,10 +80,9 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.splitContainer1);
this.Name = "LayoutAnimEditorBasic";
this.Text = "LayoutAnimEditorBasic";
this.Size = new System.Drawing.Size(800, 450);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();

View File

@ -12,7 +12,7 @@ using Toolbox.Library;
namespace LayoutBXLYT
{
public partial class LayoutAnimEditorBasic : LayoutDocked
public partial class LayoutAnimEditorBasic : UserControl
{
private BxlytHeader ParentLayout;
private BxlanHeader ActiveAnim;
@ -54,10 +54,19 @@ namespace LayoutBXLYT
}
}
public void LoadAnimationEntry(BxlanHeader bxlan, BxlanPaiEntry entry)
{
ActiveAnim = bxlan;
LoadAnimationEntry(entry, null);
}
private void LoadAnimationEntry(BxlanPaiEntry entry, TreeNode root)
{
var nodeEntry = new GroupAnimWrapper(entry.Name) { Tag = entry };
root.Nodes.Add(nodeEntry);
if (root != null)
root.Nodes.Add(nodeEntry);
else
treeView1.Nodes.Add(nodeEntry);
for (int i = 0; i < entry.Tags.Count; i++)
{

View File

@ -0,0 +1,147 @@
namespace LayoutBXLYT
{
partial class PaneAnimationController
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.stFlowLayoutPanel1 = new Toolbox.Library.Forms.STFlowLayoutPanel();
this.stDropDownPanel1 = new Toolbox.Library.Forms.STDropDownPanel();
this.listViewCustom1 = new Toolbox.Library.Forms.ListViewCustom();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.stDropDownPanel2 = new Toolbox.Library.Forms.STDropDownPanel();
this.stPanel1 = new Toolbox.Library.Forms.STPanel();
this.stFlowLayoutPanel1.SuspendLayout();
this.stDropDownPanel1.SuspendLayout();
this.stDropDownPanel2.SuspendLayout();
this.SuspendLayout();
//
// stFlowLayoutPanel1
//
this.stFlowLayoutPanel1.Controls.Add(this.stDropDownPanel1);
this.stFlowLayoutPanel1.Controls.Add(this.stDropDownPanel2);
this.stFlowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.stFlowLayoutPanel1.FixedHeight = false;
this.stFlowLayoutPanel1.FixedWidth = true;
this.stFlowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.stFlowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
this.stFlowLayoutPanel1.Name = "stFlowLayoutPanel1";
this.stFlowLayoutPanel1.Size = new System.Drawing.Size(348, 599);
this.stFlowLayoutPanel1.TabIndex = 0;
//
// stDropDownPanel1
//
this.stDropDownPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.stDropDownPanel1.Controls.Add(this.listViewCustom1);
this.stDropDownPanel1.ExpandedHeight = 0;
this.stDropDownPanel1.IsExpanded = true;
this.stDropDownPanel1.Location = new System.Drawing.Point(0, 0);
this.stDropDownPanel1.Margin = new System.Windows.Forms.Padding(0);
this.stDropDownPanel1.Name = "stDropDownPanel1";
this.stDropDownPanel1.PanelName = "Animation References";
this.stDropDownPanel1.PanelValueName = "";
this.stDropDownPanel1.SetIcon = null;
this.stDropDownPanel1.SetIconAlphaColor = System.Drawing.SystemColors.Control;
this.stDropDownPanel1.SetIconColor = System.Drawing.SystemColors.Control;
this.stDropDownPanel1.Size = new System.Drawing.Size(348, 195);
this.stDropDownPanel1.TabIndex = 0;
//
// listViewCustom1
//
this.listViewCustom1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listViewCustom1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.listViewCustom1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1});
this.listViewCustom1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.listViewCustom1.HideSelection = false;
this.listViewCustom1.Location = new System.Drawing.Point(3, 26);
this.listViewCustom1.Name = "listViewCustom1";
this.listViewCustom1.OwnerDraw = true;
this.listViewCustom1.Size = new System.Drawing.Size(342, 158);
this.listViewCustom1.TabIndex = 1;
this.listViewCustom1.UseCompatibleStateImageBehavior = false;
this.listViewCustom1.View = System.Windows.Forms.View.Details;
this.listViewCustom1.SelectedIndexChanged += new System.EventHandler(this.listViewCustom1_SelectedIndexChanged);
//
// columnHeader1
//
this.columnHeader1.Width = 342;
//
// stDropDownPanel2
//
this.stDropDownPanel2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.stDropDownPanel2.Controls.Add(this.stPanel1);
this.stDropDownPanel2.ExpandedHeight = 0;
this.stDropDownPanel2.IsExpanded = true;
this.stDropDownPanel2.Location = new System.Drawing.Point(0, 195);
this.stDropDownPanel2.Margin = new System.Windows.Forms.Padding(0);
this.stDropDownPanel2.Name = "stDropDownPanel2";
this.stDropDownPanel2.PanelName = "Animation Data";
this.stDropDownPanel2.PanelValueName = "";
this.stDropDownPanel2.SetIcon = null;
this.stDropDownPanel2.SetIconAlphaColor = System.Drawing.SystemColors.Control;
this.stDropDownPanel2.SetIconColor = System.Drawing.SystemColors.Control;
this.stDropDownPanel2.Size = new System.Drawing.Size(348, 404);
this.stDropDownPanel2.TabIndex = 2;
//
// stPanel1
//
this.stPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.stPanel1.Location = new System.Drawing.Point(3, 25);
this.stPanel1.Name = "stPanel1";
this.stPanel1.Size = new System.Drawing.Size(345, 385);
this.stPanel1.TabIndex = 1;
//
// PaneAnimationController
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.stFlowLayoutPanel1);
this.Name = "PaneAnimationController";
this.Size = new System.Drawing.Size(348, 599);
this.stFlowLayoutPanel1.ResumeLayout(false);
this.stDropDownPanel1.ResumeLayout(false);
this.stDropDownPanel1.PerformLayout();
this.stDropDownPanel2.ResumeLayout(false);
this.stDropDownPanel2.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private Toolbox.Library.Forms.STFlowLayoutPanel stFlowLayoutPanel1;
private Toolbox.Library.Forms.STDropDownPanel stDropDownPanel1;
private Toolbox.Library.Forms.ListViewCustom listViewCustom1;
private System.Windows.Forms.ColumnHeader columnHeader1;
private Toolbox.Library.Forms.STDropDownPanel stDropDownPanel2;
private Toolbox.Library.Forms.STPanel stPanel1;
}
}

View File

@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Toolbox.Library;
namespace LayoutBXLYT
{
public partial class PaneAnimationController : UserControl
{
private PaneEditor ParentEditor;
private LayoutAnimEditorBasic AnimEditor;
public PaneAnimationController()
{
InitializeComponent();
AnimEditor = new LayoutAnimEditorBasic();
AnimEditor.Dock = DockStyle.Fill;
stPanel1.Controls.Add(AnimEditor);
stDropDownPanel1.ResetColors();
stDropDownPanel2.ResetColors();
}
public void LoadPane(BasePane pane, PaneEditor paneEditor)
{
ParentEditor = paneEditor;
var animations = ParentEditor.GetAnimations();
var material = pane.TryGetActiveMaterial();
string matName = material != null ? material.Name : "";
listViewCustom1.Items.Clear();
var archive = pane.LayoutFile.FileInfo.IFileInfo.ArchiveParent;
if (archive != null)
{
foreach (var file in archive.Files) {
if (Utils.GetExtension(file.FileName) == ".bflan" &&
!animations.Any(x => x.FileName == file.FileName))
{
if (BxlanHeader.ContainsEntry(file.FileData, new string[2] { pane.Name, matName }))
listViewCustom1.Items.Add(new ListViewItem(file.FileName) { Tag = file });
}
}
}
for (int i = 0; i < animations?.Count; i++) {
if (animations[i].ContainsEntry(pane.Name) || animations[i].ContainsEntry(matName))
{
listViewCustom1.Items.Add(new ListViewItem(animations[i].FileName) { Tag = animations[i] });
}
}
LayoutAnimEditorBasic editor = new LayoutAnimEditorBasic();
stPanel1.Controls.Add(editor);
}
private void listViewCustom1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listViewCustom1.SelectedIndices.Count > 0)
{
var item = listViewCustom1.SelectedItems[0];
BxlanHeader bxlan = null;
if (item.Tag is ArchiveFileInfo) {
var fileFormat = ((ArchiveFileInfo)item.Tag).OpenFile();
bxlan = ((BXLAN)fileFormat).BxlanHeader;
}
else {
bxlan = (BxlanHeader)item.Tag;
}
if (bxlan == null) return;
for (int i = 0; i < bxlan.AnimationInfo.Entries.Count; i++)
if (bxlan.AnimationInfo.Entries[i].Name == item.Text)
AnimEditor.LoadAnimationEntry(bxlan, bxlan.AnimationInfo.Entries[i]);
}
}
}
}

View File

@ -28,40 +28,45 @@
/// </summary>
private void InitializeComponent()
{
this.stPanel3 = new Toolbox.Library.Forms.STPanel();
this.stPanel2 = new Toolbox.Library.Forms.STPanel();
this.stPanel4 = new Toolbox.Library.Forms.STPanel();
this.miniToolStrip = new Toolbox.Library.Forms.STToolStrip();
this.stToolStrip1 = new Toolbox.Library.Forms.STToolStrip();
this.stPanel1 = new Toolbox.Library.Forms.STPanel();
this.stPanel3.SuspendLayout();
this.stPanel2.SuspendLayout();
this.stPanel4.SuspendLayout();
this.SuspendLayout();
//
// stPanel3
// stPanel4
//
this.stPanel3.Controls.Add(this.stPanel2);
this.stPanel3.Controls.Add(this.stPanel1);
this.stPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
this.stPanel3.Location = new System.Drawing.Point(0, 0);
this.stPanel3.Name = "stPanel3";
this.stPanel3.Size = new System.Drawing.Size(411, 288);
this.stPanel3.TabIndex = 2;
this.stPanel4.Controls.Add(this.stToolStrip1);
this.stPanel4.Dock = System.Windows.Forms.DockStyle.Top;
this.stPanel4.Location = new System.Drawing.Point(0, 0);
this.stPanel4.Name = "stPanel4";
this.stPanel4.Size = new System.Drawing.Size(462, 31);
this.stPanel4.TabIndex = 2;
//
// stPanel2
// miniToolStrip
//
this.stPanel2.Controls.Add(this.stToolStrip1);
this.stPanel2.Dock = System.Windows.Forms.DockStyle.Top;
this.stPanel2.Location = new System.Drawing.Point(0, 0);
this.stPanel2.Name = "stPanel2";
this.stPanel2.Size = new System.Drawing.Size(411, 27);
this.stPanel2.TabIndex = 0;
this.miniToolStrip.AccessibleName = "New item selection";
this.miniToolStrip.AccessibleRole = System.Windows.Forms.AccessibleRole.ButtonDropDown;
this.miniToolStrip.AutoSize = false;
this.miniToolStrip.CanOverflow = false;
this.miniToolStrip.Dock = System.Windows.Forms.DockStyle.None;
this.miniToolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
this.miniToolStrip.HighlightSelectedTab = false;
this.miniToolStrip.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow;
this.miniToolStrip.Location = new System.Drawing.Point(0, 0);
this.miniToolStrip.Name = "miniToolStrip";
this.miniToolStrip.Size = new System.Drawing.Size(411, 0);
this.miniToolStrip.TabIndex = 0;
//
// stToolStrip1
//
this.stToolStrip1.Dock = System.Windows.Forms.DockStyle.Fill;
this.stToolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
this.stToolStrip1.HighlightSelectedTab = false;
this.stToolStrip1.Location = new System.Drawing.Point(0, 0);
this.stToolStrip1.Name = "stToolStrip1";
this.stToolStrip1.Size = new System.Drawing.Size(411, 25);
this.stToolStrip1.Size = new System.Drawing.Size(462, 31);
this.stToolStrip1.TabIndex = 0;
this.stToolStrip1.Text = "stToolStrip1";
//
@ -70,29 +75,29 @@
this.stPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.stPanel1.Location = new System.Drawing.Point(3, 26);
this.stPanel1.Location = new System.Drawing.Point(0, 31);
this.stPanel1.Name = "stPanel1";
this.stPanel1.Size = new System.Drawing.Size(411, 262);
this.stPanel1.Size = new System.Drawing.Size(462, 298);
this.stPanel1.TabIndex = 1;
//
// PaneEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(411, 288);
this.Controls.Add(this.stPanel3);
this.ClientSize = new System.Drawing.Size(462, 324);
this.Controls.Add(this.stPanel4);
this.Controls.Add(this.stPanel1);
this.Name = "PaneEditor";
this.stPanel3.ResumeLayout(false);
this.stPanel2.ResumeLayout(false);
this.stPanel2.PerformLayout();
this.stPanel4.ResumeLayout(false);
this.stPanel4.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private Toolbox.Library.Forms.STPanel stPanel1;
private Toolbox.Library.Forms.STPanel stPanel2;
private Toolbox.Library.Forms.STPanel stPanel3;
private Toolbox.Library.Forms.STPanel stPanel4;
private Toolbox.Library.Forms.STToolStrip miniToolStrip;
private Toolbox.Library.Forms.STToolStrip stToolStrip1;
private Toolbox.Library.Forms.STPanel stPanel1;
}
}

View File

@ -21,6 +21,8 @@ namespace LayoutBXLYT
InitializeComponent();
stToolStrip1.HighlightSelectedTab = true;
stToolStrip1.ItemClicked += tabMenu_SelectedIndexChanged;
stToolStrip1.CanOverflow = false;
}
public Dictionary<string, STGenericTexture> GetTextures()
@ -95,6 +97,11 @@ namespace LayoutBXLYT
((BasePaneEditor)editor).RefreshEditor();
}
public List<BxlanHeader> GetAnimations()
{
return ParentEditor.AnimationFiles;
}
public void LoadMaterial(BxlytMaterial material, LayoutEditor parentEditor)
{
ActiveMaterial = material;
@ -159,6 +166,7 @@ namespace LayoutBXLYT
}
AddTab("User Data", LoadUserData);
AddTab("Anims", LoadAnimationData);
int tabIndex;
if (pane is IPicturePane)
@ -206,6 +214,13 @@ namespace LayoutBXLYT
Runtime.LayoutEditor.NullPaneTabIndex = tabIndex;
}
public void LoadAnimationData(object sender, EventArgs e)
{
UpdateTabIndex();
var animEditor = GetActiveEditor<PaneAnimationController>();
animEditor.LoadPane(ActivePane, this);
}
private void LoadUserData(object sender, EventArgs e)
{
UpdateTabIndex();
@ -340,5 +355,10 @@ namespace LayoutBXLYT
private void tabMenu_SelectedIndexChanged(object sender, EventArgs e) {
}
private void stToolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
}
}
}

View File

@ -120,7 +120,7 @@
<metadata name="stToolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="stToolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="miniToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -431,10 +431,14 @@ namespace LayoutBXLYT
public void ShowBxlanEditor(BxlanHeader bxlan)
{
LayoutDocked dock = new LayoutDocked();
LayoutAnimEditorBasic editor = new LayoutAnimEditorBasic();
editor.LoadAnim(bxlan, ActiveLayout);
editor.OnPropertyChanged += AnimPropertyChanged;
editor.Show(this);
editor.Dock = DockStyle.Fill;
dock.Controls.Add(editor);
dock.Show(this);
/* if (LayoutAnimEditor != null) {
LayoutAnimEditor.LoadFile(bxlan.GetGenericAnimation());

File diff suppressed because it is too large Load Diff

View File

@ -18,11 +18,22 @@ namespace FirstPlugin.Forms
private ImageList TextureIconList;
private TextEditor JsonTextEditor;
public GFLXMaterialEditor()
{
InitializeComponent();
JsonTextEditor = new TextEditor();
JsonTextEditor.Dock = DockStyle.Fill;
JsonTextEditor.IsJson = true;
stPanel7.Controls.Add(JsonTextEditor);
stTabControl1.myBackColor = FormThemes.BaseTheme.FormBackColor;
stTabControl2.myBackColor = FormThemes.BaseTheme.FormBackColor;
stPanel6.BackColor = FormThemes.BaseTheme.ListViewBackColor;
TextureIconList = new ImageList()
{
ColorDepth = ColorDepth.Depth32Bit,
@ -35,20 +46,27 @@ namespace FirstPlugin.Forms
stDropDownPanel1.ResetColors();
stDropDownPanel2.ResetColors();
uvViewport1.UseGrid = false;
ResetSliders();
}
private void ResetSliders()
{
barSlider1.SetTheme();
barSlider2.SetTheme();
barSlider3.SetTheme();
barSlider4.SetTheme();
param1CB.SetTheme();
param2CB.SetTheme();
param4CB.SetTheme();
param3CB.SetTheme();
barSlider1.Value = 0;
barSlider2.Value = 0;
barSlider3.Value = 0;
barSlider4.Value = 0;
param1CB.Value = 0;
param2CB.Value = 0;
param4CB.Value = 0;
param3CB.Value = 0;
translateXUD.Value = 0;
translateYUD.Value = 0;
scaleXUD.Value = 1;
scaleYUD.Value = 1;
}
public void LoadMaterial(GFLXMaterialData materialData)
@ -107,40 +125,69 @@ namespace FirstPlugin.Forms
if (listViewCustom1.SelectedIndices.Count > 0) {
int index = listViewCustom1.SelectedIndices[0];
var tex = MaterialData.TextureMaps[index];
var gflxTex = ((GFLXTextureMap)tex).gflxTextureMap;
stTextBox1.Text = tex.Name;
stTextBox2.Text = tex.SamplerName;
uvViewport1.ActiveTextureMap = tex;
foreach (var bntx in PluginRuntime.bntxContainers) {
if (bntx.Textures.ContainsKey(tex.Name))
UpdateTexturePreview(bntx.Textures[tex.Name]);
translateXUD.Value = tex.Transform.Translate.X;
translateYUD.Value = tex.Transform.Translate.Y;
scaleXUD.Value = tex.Transform.Scale.X;
scaleYUD.Value = tex.Transform.Scale.Y;
if (gflxTex.Params != null)
{
param1CB.Value = gflxTex.Params.Unknown1;
param2CB.Value = gflxTex.Params.Unknown2;
param3CB.Value = gflxTex.Params.Unknown3;
param4CB.Value = gflxTex.Params.Unknown4;
param5CB.Value = gflxTex.Params.Unknown5;
param6CB.Value = gflxTex.Params.Unknown6;
param7CB.Value = gflxTex.Params.Unknown7;
param8CB.Value = gflxTex.Params.Unknown8;
param9CB.Value = gflxTex.Params.lodBias;
}
if (tex.Type == STGenericMatTexture.TextureType.Diffuse) {
transformParamTB.Text = "ColorUV";
}
else
transformParamTB.Text = "";
//Load mapped meshes
uvViewport1.ActiveObjects.Clear();
foreach (var mesh in MaterialData.ParentModel.GenericMeshes)
{
foreach (var poly in mesh.PolygonGroups)
{
if (poly.Material == MaterialData)
uvViewport1.ActiveObjects.Add(mesh);
}
}
uvViewport1.UpdateViewport();
}
else
{
ResetSliders();
pictureBoxCustom1.Image = null;
transformParamTB.Text = "";
uvViewport1.ActiveTextureMap = null;
uvViewport1.UpdateViewport();
}
}
private void UpdateTexturePreview(STGenericTexture texture)
private void barSlider7_Scroll(object sender, ScrollEventArgs e)
{
Thread Thread = new Thread((ThreadStart)(() =>
}
private void stTabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (stTabControl1.SelectedIndex == 2)
{
Bitmap image = null;
try {
image = texture.GetBitmap();
}
catch {
image = Properties.Resources.TextureError;
}
pictureBoxCustom1.Invoke((MethodInvoker)delegate {
// Running on the UI thread
pictureBoxCustom1.Image = image;
});
}));
Thread.Start();
var text = MaterialData.ConvertToJson();
JsonTextEditor.FillEditor(text);
}
}
}
}

View File

@ -117,212 +117,4 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="pictureBoxCustom1.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAlgAAAJYCAMAAACJuGjuAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAADAFBMVEXMzMzNzc3Ozs7Pz8/Q0NDR0dHS
0tLT09PU1NTV1dXW1tbX19fY2NjZ2dna2trb29vc3Nzd3d3e3t7f39/g4ODh4eHi4uLj4+Pk5OTl5eXm
5ubn5+fo6Ojp6enq6urr6+vs7Ozt7e3u7u7v7+/w8PDx8fHy8vLz8/P09PT19fX29vb39/f4+Pj5+fn6
+vr7+/v8/Pz9/f3+/v7///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACDTbOhAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAGXRF
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
</value>
</data>
</root>

View File

@ -0,0 +1,140 @@
namespace FirstPlugin.Forms
{
partial class GFLXMeshEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.materialCB = new Toolbox.Library.Forms.STComboBox();
this.stLabel1 = new Toolbox.Library.Forms.STLabel();
this.stFlowLayoutPanel1 = new Toolbox.Library.Forms.STFlowLayoutPanel();
this.stDropDownPanel1 = new Toolbox.Library.Forms.STDropDownPanel();
this.polyGroupCB = new Toolbox.Library.Forms.STComboBox();
this.stLabel2 = new Toolbox.Library.Forms.STLabel();
this.stFlowLayoutPanel1.SuspendLayout();
this.stDropDownPanel1.SuspendLayout();
this.SuspendLayout();
//
// materialCB
//
this.materialCB.BorderColor = System.Drawing.Color.Empty;
this.materialCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.materialCB.ButtonColor = System.Drawing.Color.Empty;
this.materialCB.FormattingEnabled = true;
this.materialCB.IsReadOnly = false;
this.materialCB.Location = new System.Drawing.Point(96, 68);
this.materialCB.Name = "materialCB";
this.materialCB.Size = new System.Drawing.Size(139, 21);
this.materialCB.TabIndex = 0;
this.materialCB.SelectedIndexChanged += new System.EventHandler(this.materialCB_SelectedIndexChanged);
//
// stLabel1
//
this.stLabel1.AutoSize = true;
this.stLabel1.Location = new System.Drawing.Point(16, 68);
this.stLabel1.Name = "stLabel1";
this.stLabel1.Size = new System.Drawing.Size(47, 13);
this.stLabel1.TabIndex = 1;
this.stLabel1.Text = "Material:";
//
// stFlowLayoutPanel1
//
this.stFlowLayoutPanel1.Controls.Add(this.stDropDownPanel1);
this.stFlowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.stFlowLayoutPanel1.FixedHeight = false;
this.stFlowLayoutPanel1.FixedWidth = true;
this.stFlowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.stFlowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
this.stFlowLayoutPanel1.Name = "stFlowLayoutPanel1";
this.stFlowLayoutPanel1.Size = new System.Drawing.Size(440, 404);
this.stFlowLayoutPanel1.TabIndex = 2;
//
// stDropDownPanel1
//
this.stDropDownPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.stDropDownPanel1.Controls.Add(this.stLabel2);
this.stDropDownPanel1.Controls.Add(this.polyGroupCB);
this.stDropDownPanel1.Controls.Add(this.stLabel1);
this.stDropDownPanel1.Controls.Add(this.materialCB);
this.stDropDownPanel1.ExpandedHeight = 0;
this.stDropDownPanel1.IsExpanded = true;
this.stDropDownPanel1.Location = new System.Drawing.Point(0, 0);
this.stDropDownPanel1.Margin = new System.Windows.Forms.Padding(0);
this.stDropDownPanel1.Name = "stDropDownPanel1";
this.stDropDownPanel1.PanelName = "Polygon Group";
this.stDropDownPanel1.PanelValueName = "";
this.stDropDownPanel1.SetIcon = null;
this.stDropDownPanel1.SetIconAlphaColor = System.Drawing.SystemColors.Control;
this.stDropDownPanel1.SetIconColor = System.Drawing.SystemColors.Control;
this.stDropDownPanel1.Size = new System.Drawing.Size(440, 164);
this.stDropDownPanel1.TabIndex = 0;
//
// polyGroupCB
//
this.polyGroupCB.BorderColor = System.Drawing.Color.Empty;
this.polyGroupCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.polyGroupCB.ButtonColor = System.Drawing.Color.Empty;
this.polyGroupCB.FormattingEnabled = true;
this.polyGroupCB.IsReadOnly = false;
this.polyGroupCB.Location = new System.Drawing.Point(96, 38);
this.polyGroupCB.Name = "polyGroupCB";
this.polyGroupCB.Size = new System.Drawing.Size(139, 21);
this.polyGroupCB.TabIndex = 2;
this.polyGroupCB.SelectedIndexChanged += new System.EventHandler(this.polyGroupCB_SelectedIndexChanged);
//
// stLabel2
//
this.stLabel2.AutoSize = true;
this.stLabel2.Location = new System.Drawing.Point(16, 38);
this.stLabel2.Name = "stLabel2";
this.stLabel2.Size = new System.Drawing.Size(39, 13);
this.stLabel2.TabIndex = 3;
this.stLabel2.Text = "Group:";
//
// GFLXMeshEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.stFlowLayoutPanel1);
this.Name = "GFLXMeshEditor";
this.Size = new System.Drawing.Size(440, 404);
this.stFlowLayoutPanel1.ResumeLayout(false);
this.stDropDownPanel1.ResumeLayout(false);
this.stDropDownPanel1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private Toolbox.Library.Forms.STComboBox materialCB;
private Toolbox.Library.Forms.STLabel stLabel1;
private Toolbox.Library.Forms.STFlowLayoutPanel stFlowLayoutPanel1;
private Toolbox.Library.Forms.STDropDownPanel stDropDownPanel1;
private Toolbox.Library.Forms.STLabel stLabel2;
private Toolbox.Library.Forms.STComboBox polyGroupCB;
}
}

View File

@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FirstPlugin.Forms
{
public partial class GFLXMeshEditor : UserControl
{
private bool Loaded = false;
private GFLXMesh ActiveMesh;
public GFLXMeshEditor()
{
InitializeComponent();
stDropDownPanel1.ResetColors();
}
public void LoadMesh(GFLXMesh mesh)
{
polyGroupCB.Items.Clear();
materialCB.Items.Clear();
ActiveMesh = mesh;
Loaded = false;
var materials = mesh.ParentModel.GenericMaterials;
for (int i = 0; i < materials.Count; i++)
materialCB.Items.Add(materials[i].Text);
for (int i = 0; i < mesh.PolygonGroups.Count; i++) {
polyGroupCB.Items.Add($"{i}");
}
polyGroupCB.SelectedIndex = 0;
Loaded = true;
}
private void polyGroupCB_SelectedIndexChanged(object sender, EventArgs e)
{
int index = polyGroupCB.SelectedIndex;
if (index >= 0)
{
var poly = ActiveMesh.PolygonGroups[index];
var mat = ActiveMesh.ParentModel.GenericMaterials[poly.MaterialIndex];
materialCB.SelectedItem = mat.Text;
}
}
private void materialCB_SelectedIndexChanged(object sender, EventArgs e) {
if (!Loaded) return;
int index = polyGroupCB.SelectedIndex;
if (index >= 0)
{
var poly = ActiveMesh.PolygonGroups[index];
var materials = ActiveMesh.ParentModel.GenericMaterials;
var mappedMat = materials.First(x => x.Text == materialCB.GetSelectedText());
if (mappedMat != null) {
var matIndex = materials.IndexOf(mappedMat);
poly.MaterialIndex = matIndex;
ActiveMesh.MeshData.Polygons[index].MaterialIndex = (uint)matIndex;
Toolbox.Library.LibraryGUI.UpdateViewport();
}
}
}
}
}

View File

@ -0,0 +1,600 @@
namespace FirstPlugin.Forms
{
partial class GFLXModelImporter
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.presetCB = new Toolbox.Library.Forms.STComboBox();
this.stLabel1 = new Toolbox.Library.Forms.STLabel();
this.chkUseNormals = new Toolbox.Library.Forms.STCheckBox();
this.chkHasUv1 = new Toolbox.Library.Forms.STCheckBox();
this.chkUseBoneIndex = new Toolbox.Library.Forms.STCheckBox();
this.chkUseColor1 = new Toolbox.Library.Forms.STCheckBox();
this.normalFormatCB = new Toolbox.Library.Forms.STComboBox();
this.uv0FormatCB = new Toolbox.Library.Forms.STComboBox();
this.boneFormatCB = new Toolbox.Library.Forms.STComboBox();
this.color0FormatCB = new Toolbox.Library.Forms.STComboBox();
this.uv1FormatCB = new Toolbox.Library.Forms.STComboBox();
this.chkHasUv2 = new Toolbox.Library.Forms.STCheckBox();
this.color1FormatCB = new Toolbox.Library.Forms.STComboBox();
this.chkUseColor2 = new Toolbox.Library.Forms.STCheckBox();
this.bitangentFormatCB = new Toolbox.Library.Forms.STComboBox();
this.chkBitangents = new Toolbox.Library.Forms.STCheckBox();
this.positionFormatCB = new Toolbox.Library.Forms.STComboBox();
this.stCheckBox8 = new Toolbox.Library.Forms.STCheckBox();
this.stLabel2 = new Toolbox.Library.Forms.STLabel();
this.materiialPresetCB = new Toolbox.Library.Forms.STComboBox();
this.stButton1 = new Toolbox.Library.Forms.STButton();
this.listViewCustom1 = new Toolbox.Library.Forms.ListViewCustom();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.weightFormatCB = new Toolbox.Library.Forms.STComboBox();
this.stPanel1 = new Toolbox.Library.Forms.STPanel();
this.tangentFormatCB = new Toolbox.Library.Forms.STComboBox();
this.chkTangents = new Toolbox.Library.Forms.STCheckBox();
this.chkUseBoneWeights = new Toolbox.Library.Forms.STCheckBox();
this.stLabel3 = new Toolbox.Library.Forms.STLabel();
this.stLabel4 = new Toolbox.Library.Forms.STLabel();
this.rotateModel90YUD = new Toolbox.Library.Forms.NumericUpDownFloat();
this.stLabel5 = new Toolbox.Library.Forms.STLabel();
this.stPanel2 = new Toolbox.Library.Forms.STPanel();
this.chkMatchAttributes = new Toolbox.Library.Forms.STCheckBox();
this.chkUseOriginalBones = new Toolbox.Library.Forms.STCheckBox();
this.stCheckBox7 = new Toolbox.Library.Forms.STCheckBox();
this.stButton2 = new Toolbox.Library.Forms.STButton();
this.contentContainer.SuspendLayout();
this.stPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.rotateModel90YUD)).BeginInit();
this.stPanel2.SuspendLayout();
this.SuspendLayout();
//
// contentContainer
//
this.contentContainer.Controls.Add(this.stButton2);
this.contentContainer.Controls.Add(this.stPanel2);
this.contentContainer.Controls.Add(this.stPanel1);
this.contentContainer.Controls.Add(this.listViewCustom1);
this.contentContainer.Size = new System.Drawing.Size(605, 601);
this.contentContainer.Controls.SetChildIndex(this.listViewCustom1, 0);
this.contentContainer.Controls.SetChildIndex(this.stPanel1, 0);
this.contentContainer.Controls.SetChildIndex(this.stPanel2, 0);
this.contentContainer.Controls.SetChildIndex(this.stButton2, 0);
//
// presetCB
//
this.presetCB.BorderColor = System.Drawing.Color.Empty;
this.presetCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.presetCB.ButtonColor = System.Drawing.Color.Empty;
this.presetCB.FormattingEnabled = true;
this.presetCB.IsReadOnly = false;
this.presetCB.Location = new System.Drawing.Point(153, 42);
this.presetCB.Name = "presetCB";
this.presetCB.Size = new System.Drawing.Size(120, 21);
this.presetCB.TabIndex = 11;
//
// stLabel1
//
this.stLabel1.AutoSize = true;
this.stLabel1.Location = new System.Drawing.Point(13, 45);
this.stLabel1.Name = "stLabel1";
this.stLabel1.Size = new System.Drawing.Size(40, 13);
this.stLabel1.TabIndex = 12;
this.stLabel1.Text = "Preset:";
//
// chkUseNormals
//
this.chkUseNormals.AutoSize = true;
this.chkUseNormals.Location = new System.Drawing.Point(12, 104);
this.chkUseNormals.Name = "chkUseNormals";
this.chkUseNormals.Size = new System.Drawing.Size(86, 17);
this.chkUseNormals.TabIndex = 14;
this.chkUseNormals.Text = "Use Normals";
this.chkUseNormals.UseVisualStyleBackColor = true;
this.chkUseNormals.CheckedChanged += new System.EventHandler(this.ApplySettings);
//
// chkHasUv1
//
this.chkHasUv1.AutoSize = true;
this.chkHasUv1.Location = new System.Drawing.Point(12, 187);
this.chkHasUv1.Name = "chkHasUv1";
this.chkHasUv1.Size = new System.Drawing.Size(114, 17);
this.chkHasUv1.TabIndex = 15;
this.chkHasUv1.Text = "Use UV Channel 1";
this.chkHasUv1.UseVisualStyleBackColor = true;
this.chkHasUv1.CheckedChanged += new System.EventHandler(this.ApplySettings);
//
// chkUseBoneIndex
//
this.chkUseBoneIndex.AutoSize = true;
this.chkUseBoneIndex.Location = new System.Drawing.Point(12, 301);
this.chkUseBoneIndex.Name = "chkUseBoneIndex";
this.chkUseBoneIndex.Size = new System.Drawing.Size(110, 17);
this.chkUseBoneIndex.TabIndex = 16;
this.chkUseBoneIndex.Text = "Use Bone Indices";
this.chkUseBoneIndex.UseVisualStyleBackColor = true;
this.chkUseBoneIndex.CheckedChanged += new System.EventHandler(this.ApplySettings);
//
// chkUseColor1
//
this.chkUseColor1.AutoSize = true;
this.chkUseColor1.Location = new System.Drawing.Point(12, 247);
this.chkUseColor1.Name = "chkUseColor1";
this.chkUseColor1.Size = new System.Drawing.Size(123, 17);
this.chkUseColor1.TabIndex = 17;
this.chkUseColor1.Text = "Use Color Channel 1";
this.chkUseColor1.UseVisualStyleBackColor = true;
this.chkUseColor1.CheckedChanged += new System.EventHandler(this.ApplySettings);
//
// normalFormatCB
//
this.normalFormatCB.BorderColor = System.Drawing.Color.Empty;
this.normalFormatCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.normalFormatCB.ButtonColor = System.Drawing.Color.Empty;
this.normalFormatCB.FormattingEnabled = true;
this.normalFormatCB.IsReadOnly = false;
this.normalFormatCB.Location = new System.Drawing.Point(147, 102);
this.normalFormatCB.Name = "normalFormatCB";
this.normalFormatCB.Size = new System.Drawing.Size(131, 21);
this.normalFormatCB.TabIndex = 18;
this.normalFormatCB.SelectedIndexChanged += new System.EventHandler(this.ApplySettings);
//
// uv0FormatCB
//
this.uv0FormatCB.BorderColor = System.Drawing.Color.Empty;
this.uv0FormatCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.uv0FormatCB.ButtonColor = System.Drawing.Color.Empty;
this.uv0FormatCB.FormattingEnabled = true;
this.uv0FormatCB.IsReadOnly = false;
this.uv0FormatCB.Location = new System.Drawing.Point(147, 183);
this.uv0FormatCB.Name = "uv0FormatCB";
this.uv0FormatCB.Size = new System.Drawing.Size(131, 21);
this.uv0FormatCB.TabIndex = 19;
this.uv0FormatCB.SelectedIndexChanged += new System.EventHandler(this.ApplySettings);
//
// boneFormatCB
//
this.boneFormatCB.BorderColor = System.Drawing.Color.Empty;
this.boneFormatCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.boneFormatCB.ButtonColor = System.Drawing.Color.Empty;
this.boneFormatCB.FormattingEnabled = true;
this.boneFormatCB.IsReadOnly = false;
this.boneFormatCB.Location = new System.Drawing.Point(143, 297);
this.boneFormatCB.Name = "boneFormatCB";
this.boneFormatCB.Size = new System.Drawing.Size(133, 21);
this.boneFormatCB.TabIndex = 21;
this.boneFormatCB.SelectedIndexChanged += new System.EventHandler(this.ApplySettings);
//
// color0FormatCB
//
this.color0FormatCB.BorderColor = System.Drawing.Color.Empty;
this.color0FormatCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.color0FormatCB.ButtonColor = System.Drawing.Color.Empty;
this.color0FormatCB.FormattingEnabled = true;
this.color0FormatCB.IsReadOnly = false;
this.color0FormatCB.Location = new System.Drawing.Point(145, 245);
this.color0FormatCB.Name = "color0FormatCB";
this.color0FormatCB.Size = new System.Drawing.Size(131, 21);
this.color0FormatCB.TabIndex = 20;
this.color0FormatCB.SelectedIndexChanged += new System.EventHandler(this.ApplySettings);
//
// uv1FormatCB
//
this.uv1FormatCB.BorderColor = System.Drawing.Color.Empty;
this.uv1FormatCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.uv1FormatCB.ButtonColor = System.Drawing.Color.Empty;
this.uv1FormatCB.FormattingEnabled = true;
this.uv1FormatCB.IsReadOnly = false;
this.uv1FormatCB.Location = new System.Drawing.Point(147, 210);
this.uv1FormatCB.Name = "uv1FormatCB";
this.uv1FormatCB.Size = new System.Drawing.Size(131, 21);
this.uv1FormatCB.TabIndex = 23;
this.uv1FormatCB.SelectedIndexChanged += new System.EventHandler(this.ApplySettings);
//
// chkHasUv2
//
this.chkHasUv2.AutoSize = true;
this.chkHasUv2.Location = new System.Drawing.Point(12, 214);
this.chkHasUv2.Name = "chkHasUv2";
this.chkHasUv2.Size = new System.Drawing.Size(114, 17);
this.chkHasUv2.TabIndex = 22;
this.chkHasUv2.Text = "Use UV Channel 2";
this.chkHasUv2.UseVisualStyleBackColor = true;
this.chkHasUv2.CheckedChanged += new System.EventHandler(this.ApplySettings);
//
// color1FormatCB
//
this.color1FormatCB.BorderColor = System.Drawing.Color.Empty;
this.color1FormatCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.color1FormatCB.ButtonColor = System.Drawing.Color.Empty;
this.color1FormatCB.FormattingEnabled = true;
this.color1FormatCB.IsReadOnly = false;
this.color1FormatCB.Location = new System.Drawing.Point(145, 272);
this.color1FormatCB.Name = "color1FormatCB";
this.color1FormatCB.Size = new System.Drawing.Size(131, 21);
this.color1FormatCB.TabIndex = 25;
this.color1FormatCB.SelectedIndexChanged += new System.EventHandler(this.ApplySettings);
//
// chkUseColor2
//
this.chkUseColor2.AutoSize = true;
this.chkUseColor2.Location = new System.Drawing.Point(12, 274);
this.chkUseColor2.Name = "chkUseColor2";
this.chkUseColor2.Size = new System.Drawing.Size(123, 17);
this.chkUseColor2.TabIndex = 24;
this.chkUseColor2.Text = "Use Color Channel 2";
this.chkUseColor2.UseVisualStyleBackColor = true;
this.chkUseColor2.CheckedChanged += new System.EventHandler(this.ApplySettings);
//
// bitangentFormatCB
//
this.bitangentFormatCB.BorderColor = System.Drawing.Color.Empty;
this.bitangentFormatCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.bitangentFormatCB.ButtonColor = System.Drawing.Color.Empty;
this.bitangentFormatCB.FormattingEnabled = true;
this.bitangentFormatCB.IsReadOnly = false;
this.bitangentFormatCB.Location = new System.Drawing.Point(147, 129);
this.bitangentFormatCB.Name = "bitangentFormatCB";
this.bitangentFormatCB.Size = new System.Drawing.Size(131, 21);
this.bitangentFormatCB.TabIndex = 27;
this.bitangentFormatCB.SelectedIndexChanged += new System.EventHandler(this.ApplySettings);
//
// chkBitangents
//
this.chkBitangents.AutoSize = true;
this.chkBitangents.Location = new System.Drawing.Point(12, 131);
this.chkBitangents.Name = "chkBitangents";
this.chkBitangents.Size = new System.Drawing.Size(98, 17);
this.chkBitangents.TabIndex = 26;
this.chkBitangents.Text = "Use Bitangents";
this.chkBitangents.UseVisualStyleBackColor = true;
this.chkBitangents.CheckedChanged += new System.EventHandler(this.ApplySettings);
//
// positionFormatCB
//
this.positionFormatCB.BorderColor = System.Drawing.Color.Empty;
this.positionFormatCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.positionFormatCB.ButtonColor = System.Drawing.Color.Empty;
this.positionFormatCB.FormattingEnabled = true;
this.positionFormatCB.IsReadOnly = false;
this.positionFormatCB.Location = new System.Drawing.Point(147, 75);
this.positionFormatCB.Name = "positionFormatCB";
this.positionFormatCB.Size = new System.Drawing.Size(131, 21);
this.positionFormatCB.TabIndex = 29;
this.positionFormatCB.SelectedIndexChanged += new System.EventHandler(this.ApplySettings);
//
// stCheckBox8
//
this.stCheckBox8.AutoSize = true;
this.stCheckBox8.Checked = true;
this.stCheckBox8.CheckState = System.Windows.Forms.CheckState.Checked;
this.stCheckBox8.Enabled = false;
this.stCheckBox8.Location = new System.Drawing.Point(12, 77);
this.stCheckBox8.Name = "stCheckBox8";
this.stCheckBox8.Size = new System.Drawing.Size(63, 17);
this.stCheckBox8.TabIndex = 28;
this.stCheckBox8.Text = "Position";
this.stCheckBox8.UseVisualStyleBackColor = true;
//
// stLabel2
//
this.stLabel2.AutoSize = true;
this.stLabel2.Location = new System.Drawing.Point(9, 39);
this.stLabel2.Name = "stLabel2";
this.stLabel2.Size = new System.Drawing.Size(47, 13);
this.stLabel2.TabIndex = 31;
this.stLabel2.Text = "Material:";
//
// materiialPresetCB
//
this.materiialPresetCB.BorderColor = System.Drawing.Color.Empty;
this.materiialPresetCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.materiialPresetCB.ButtonColor = System.Drawing.Color.Empty;
this.materiialPresetCB.FormattingEnabled = true;
this.materiialPresetCB.IsReadOnly = false;
this.materiialPresetCB.Location = new System.Drawing.Point(145, 36);
this.materiialPresetCB.Name = "materiialPresetCB";
this.materiialPresetCB.Size = new System.Drawing.Size(131, 21);
this.materiialPresetCB.TabIndex = 32;
this.materiialPresetCB.SelectedIndexChanged += new System.EventHandler(this.ApplySettings);
//
// stButton1
//
this.stButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.stButton1.Location = new System.Drawing.Point(282, 34);
this.stButton1.Name = "stButton1";
this.stButton1.Size = new System.Drawing.Size(31, 23);
this.stButton1.TabIndex = 33;
this.stButton1.Text = "+";
this.stButton1.UseVisualStyleBackColor = false;
this.stButton1.Click += new System.EventHandler(this.stButton1_Click);
//
// listViewCustom1
//
this.listViewCustom1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.listViewCustom1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1});
this.listViewCustom1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.listViewCustom1.HideSelection = false;
this.listViewCustom1.Location = new System.Drawing.Point(5, 31);
this.listViewCustom1.Name = "listViewCustom1";
this.listViewCustom1.OwnerDraw = true;
this.listViewCustom1.Size = new System.Drawing.Size(208, 499);
this.listViewCustom1.TabIndex = 34;
this.listViewCustom1.UseCompatibleStateImageBehavior = false;
this.listViewCustom1.View = System.Windows.Forms.View.Details;
this.listViewCustom1.SelectedIndexChanged += new System.EventHandler(this.listViewCustom1_SelectedIndexChanged);
//
// columnHeader1
//
this.columnHeader1.Width = 202;
//
// weightFormatCB
//
this.weightFormatCB.BorderColor = System.Drawing.Color.Empty;
this.weightFormatCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.weightFormatCB.ButtonColor = System.Drawing.Color.Empty;
this.weightFormatCB.FormattingEnabled = true;
this.weightFormatCB.IsReadOnly = false;
this.weightFormatCB.Location = new System.Drawing.Point(143, 324);
this.weightFormatCB.Name = "weightFormatCB";
this.weightFormatCB.Size = new System.Drawing.Size(135, 21);
this.weightFormatCB.TabIndex = 35;
this.weightFormatCB.SelectedIndexChanged += new System.EventHandler(this.ApplySettings);
//
// stPanel1
//
this.stPanel1.Controls.Add(this.tangentFormatCB);
this.stPanel1.Controls.Add(this.chkTangents);
this.stPanel1.Controls.Add(this.chkUseBoneWeights);
this.stPanel1.Controls.Add(this.stLabel2);
this.stPanel1.Controls.Add(this.stLabel3);
this.stPanel1.Controls.Add(this.weightFormatCB);
this.stPanel1.Controls.Add(this.chkUseNormals);
this.stPanel1.Controls.Add(this.chkHasUv1);
this.stPanel1.Controls.Add(this.stButton1);
this.stPanel1.Controls.Add(this.chkUseBoneIndex);
this.stPanel1.Controls.Add(this.materiialPresetCB);
this.stPanel1.Controls.Add(this.chkUseColor1);
this.stPanel1.Controls.Add(this.normalFormatCB);
this.stPanel1.Controls.Add(this.positionFormatCB);
this.stPanel1.Controls.Add(this.uv0FormatCB);
this.stPanel1.Controls.Add(this.stCheckBox8);
this.stPanel1.Controls.Add(this.color0FormatCB);
this.stPanel1.Controls.Add(this.bitangentFormatCB);
this.stPanel1.Controls.Add(this.boneFormatCB);
this.stPanel1.Controls.Add(this.chkBitangents);
this.stPanel1.Controls.Add(this.chkHasUv2);
this.stPanel1.Controls.Add(this.color1FormatCB);
this.stPanel1.Controls.Add(this.uv1FormatCB);
this.stPanel1.Controls.Add(this.chkUseColor2);
this.stPanel1.Location = new System.Drawing.Point(219, 206);
this.stPanel1.Name = "stPanel1";
this.stPanel1.Size = new System.Drawing.Size(378, 356);
this.stPanel1.TabIndex = 36;
//
// tangentFormatCB
//
this.tangentFormatCB.BorderColor = System.Drawing.Color.Empty;
this.tangentFormatCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.tangentFormatCB.ButtonColor = System.Drawing.Color.Empty;
this.tangentFormatCB.FormattingEnabled = true;
this.tangentFormatCB.IsReadOnly = false;
this.tangentFormatCB.Location = new System.Drawing.Point(147, 156);
this.tangentFormatCB.Name = "tangentFormatCB";
this.tangentFormatCB.Size = new System.Drawing.Size(131, 21);
this.tangentFormatCB.TabIndex = 40;
this.tangentFormatCB.SelectedIndexChanged += new System.EventHandler(this.ApplySettings);
//
// chkTangents
//
this.chkTangents.AutoSize = true;
this.chkTangents.Location = new System.Drawing.Point(12, 158);
this.chkTangents.Name = "chkTangents";
this.chkTangents.Size = new System.Drawing.Size(93, 17);
this.chkTangents.TabIndex = 39;
this.chkTangents.Text = "Use Tangents";
this.chkTangents.UseVisualStyleBackColor = true;
this.chkTangents.CheckedChanged += new System.EventHandler(this.ApplySettings);
//
// chkUseBoneWeights
//
this.chkUseBoneWeights.AutoSize = true;
this.chkUseBoneWeights.Location = new System.Drawing.Point(12, 328);
this.chkUseBoneWeights.Name = "chkUseBoneWeights";
this.chkUseBoneWeights.Size = new System.Drawing.Size(115, 17);
this.chkUseBoneWeights.TabIndex = 38;
this.chkUseBoneWeights.Text = "Use Bone Weights";
this.chkUseBoneWeights.UseVisualStyleBackColor = true;
this.chkUseBoneWeights.CheckedChanged += new System.EventHandler(this.ApplySettings);
//
// stLabel3
//
this.stLabel3.AutoSize = true;
this.stLabel3.Location = new System.Drawing.Point(140, 10);
this.stLabel3.Name = "stLabel3";
this.stLabel3.Size = new System.Drawing.Size(77, 13);
this.stLabel3.TabIndex = 37;
this.stLabel3.Text = "Mesh Settings:";
//
// stLabel4
//
this.stLabel4.AutoSize = true;
this.stLabel4.Location = new System.Drawing.Point(137, 11);
this.stLabel4.Name = "stLabel4";
this.stLabel4.Size = new System.Drawing.Size(81, 13);
this.stLabel4.TabIndex = 38;
this.stLabel4.Text = "Global Settings:";
//
// rotateModel90YUD
//
this.rotateModel90YUD.DecimalPlaces = 5;
this.rotateModel90YUD.Increment = new decimal(new int[] {
5,
0,
0,
196608});
this.rotateModel90YUD.Location = new System.Drawing.Point(153, 75);
this.rotateModel90YUD.Maximum = new decimal(new int[] {
1000000000,
0,
0,
0});
this.rotateModel90YUD.Minimum = new decimal(new int[] {
100000000,
0,
0,
-2147483648});
this.rotateModel90YUD.Name = "rotateModel90YUD";
this.rotateModel90YUD.Size = new System.Drawing.Size(120, 20);
this.rotateModel90YUD.TabIndex = 39;
this.rotateModel90YUD.ValueChanged += new System.EventHandler(this.numericUpDownFloat1_ValueChanged);
//
// stLabel5
//
this.stLabel5.AutoSize = true;
this.stLabel5.Location = new System.Drawing.Point(13, 77);
this.stLabel5.Name = "stLabel5";
this.stLabel5.Size = new System.Drawing.Size(52, 13);
this.stLabel5.TabIndex = 40;
this.stLabel5.Text = "Rotate Y:";
//
// stPanel2
//
this.stPanel2.Controls.Add(this.chkMatchAttributes);
this.stPanel2.Controls.Add(this.chkUseOriginalBones);
this.stPanel2.Controls.Add(this.stCheckBox7);
this.stPanel2.Controls.Add(this.stLabel1);
this.stPanel2.Controls.Add(this.presetCB);
this.stPanel2.Controls.Add(this.stLabel5);
this.stPanel2.Controls.Add(this.stLabel4);
this.stPanel2.Controls.Add(this.rotateModel90YUD);
this.stPanel2.Location = new System.Drawing.Point(222, 31);
this.stPanel2.Name = "stPanel2";
this.stPanel2.Size = new System.Drawing.Size(375, 169);
this.stPanel2.TabIndex = 41;
//
// chkMatchAttributes
//
this.chkMatchAttributes.AutoSize = true;
this.chkMatchAttributes.Location = new System.Drawing.Point(9, 111);
this.chkMatchAttributes.Name = "chkMatchAttributes";
this.chkMatchAttributes.Size = new System.Drawing.Size(141, 17);
this.chkMatchAttributes.TabIndex = 44;
this.chkMatchAttributes.Text = "Match Original Attributes";
this.chkMatchAttributes.UseVisualStyleBackColor = true;
this.chkMatchAttributes.CheckedChanged += new System.EventHandler(this.chkMatchAttributes_CheckedChanged);
//
// chkUseOriginalBones
//
this.chkUseOriginalBones.AutoSize = true;
this.chkUseOriginalBones.Checked = true;
this.chkUseOriginalBones.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkUseOriginalBones.Location = new System.Drawing.Point(157, 134);
this.chkUseOriginalBones.Name = "chkUseOriginalBones";
this.chkUseOriginalBones.Size = new System.Drawing.Size(116, 17);
this.chkUseOriginalBones.TabIndex = 43;
this.chkUseOriginalBones.Text = "Use Original Bones";
this.chkUseOriginalBones.UseVisualStyleBackColor = true;
//
// stCheckBox7
//
this.stCheckBox7.AutoSize = true;
this.stCheckBox7.Location = new System.Drawing.Point(157, 111);
this.stCheckBox7.Name = "stCheckBox7";
this.stCheckBox7.Size = new System.Drawing.Size(103, 17);
this.stCheckBox7.TabIndex = 41;
this.stCheckBox7.Text = "Flip UVs Vertical";
this.stCheckBox7.UseVisualStyleBackColor = true;
//
// stButton2
//
this.stButton2.DialogResult = System.Windows.Forms.DialogResult.OK;
this.stButton2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.stButton2.Location = new System.Drawing.Point(522, 568);
this.stButton2.Name = "stButton2";
this.stButton2.Size = new System.Drawing.Size(75, 23);
this.stButton2.TabIndex = 42;
this.stButton2.Text = "Ok";
this.stButton2.UseVisualStyleBackColor = false;
//
// GFLXModelImporter
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(611, 605);
this.Name = "GFLXModelImporter";
this.Text = "GFBMDL Importer";
this.contentContainer.ResumeLayout(false);
this.stPanel1.ResumeLayout(false);
this.stPanel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.rotateModel90YUD)).EndInit();
this.stPanel2.ResumeLayout(false);
this.stPanel2.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private Toolbox.Library.Forms.STComboBox presetCB;
private Toolbox.Library.Forms.STLabel stLabel1;
private Toolbox.Library.Forms.STComboBox boneFormatCB;
private Toolbox.Library.Forms.STComboBox color0FormatCB;
private Toolbox.Library.Forms.STComboBox uv0FormatCB;
private Toolbox.Library.Forms.STComboBox normalFormatCB;
private Toolbox.Library.Forms.STCheckBox chkUseColor1;
private Toolbox.Library.Forms.STCheckBox chkUseBoneIndex;
private Toolbox.Library.Forms.STCheckBox chkHasUv1;
private Toolbox.Library.Forms.STCheckBox chkUseNormals;
private Toolbox.Library.Forms.STComboBox bitangentFormatCB;
private Toolbox.Library.Forms.STCheckBox chkBitangents;
private Toolbox.Library.Forms.STComboBox color1FormatCB;
private Toolbox.Library.Forms.STCheckBox chkUseColor2;
private Toolbox.Library.Forms.STComboBox uv1FormatCB;
private Toolbox.Library.Forms.STCheckBox chkHasUv2;
private Toolbox.Library.Forms.STComboBox positionFormatCB;
private Toolbox.Library.Forms.STCheckBox stCheckBox8;
private Toolbox.Library.Forms.STButton stButton1;
private Toolbox.Library.Forms.STComboBox materiialPresetCB;
private Toolbox.Library.Forms.STLabel stLabel2;
private Toolbox.Library.Forms.ListViewCustom listViewCustom1;
private System.Windows.Forms.ColumnHeader columnHeader1;
private Toolbox.Library.Forms.STComboBox weightFormatCB;
private Toolbox.Library.Forms.STLabel stLabel4;
private Toolbox.Library.Forms.STPanel stPanel1;
private Toolbox.Library.Forms.STLabel stLabel3;
private Toolbox.Library.Forms.STLabel stLabel5;
private Toolbox.Library.Forms.NumericUpDownFloat rotateModel90YUD;
private Toolbox.Library.Forms.STCheckBox chkUseBoneWeights;
private Toolbox.Library.Forms.STPanel stPanel2;
private Toolbox.Library.Forms.STCheckBox stCheckBox7;
private Toolbox.Library.Forms.STCheckBox chkUseOriginalBones;
private Toolbox.Library.Forms.STButton stButton2;
private Toolbox.Library.Forms.STComboBox tangentFormatCB;
private Toolbox.Library.Forms.STCheckBox chkTangents;
private Toolbox.Library.Forms.STCheckBox chkMatchAttributes;
}
}

View File

@ -0,0 +1,345 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Toolbox.Library.Forms;
using Toolbox.Library;
using FirstPlugin.GFMDLStructs;
namespace FirstPlugin.Forms
{
public partial class GFLXModelImporter : STForm
{
public bool ImportNewBones => !chkUseOriginalBones.Checked;
private List<STGenericObject> Meshes;
private List<GFLXMesh> OriginalMeshes;
public GfbmdlImportSettings Settings = new GfbmdlImportSettings();
private bool Loaded = false;
public int RotationY => (int)rotateModel90YUD.Value;
public GFLXModelImporter()
{
InitializeComponent();
presetCB.Items.Add("Optimal");
presetCB.SelectedIndex = 0;
stPanel1.BackColor = FormThemes.BaseTheme.TextEditorBackColor;
stPanel2.BackColor = FormThemes.BaseTheme.TextEditorBackColor;
CanResize = false;
}
public void LoadMeshes(List<STGenericObject> meshes, List<STGenericMaterial> importedMats,
List<GFLXMaterialData> originalMaterials, List<GFLXMesh> originalMeshes)
{
Loaded = false;
Meshes = meshes;
OriginalMeshes = originalMeshes;
foreach (var mat in originalMaterials)
{
materiialPresetCB.Items.Add(mat.Text);
}
materiialPresetCB.SelectedIndex = 0;
listViewCustom1.Items.Clear();
for (int i = 0; i < meshes.Count; i++)
{
string material = originalMaterials[0].Text;
//Check if a material name matches one in the preset list
//Then auto match the preset
if (meshes[i].MaterialIndex < importedMats.Count &&
meshes[i].MaterialIndex > 0)
{
string importedMat = importedMats[meshes[i].MaterialIndex].Text;
if (materiialPresetCB.Items.Contains(importedMat))
material = importedMat;
}
Settings.MeshSettings.Add(new GfbmdlImportSettings.MeshSetting()
{
HasColor1 = meshes[i].HasVertColors,
HasColor2 = meshes[i].HasVertColors,
HasTexCoord1 = meshes[i].HasUv0,
HasTexCoord2 = meshes[i].HasUv1,
HasTexCoord3 = meshes[i].HasUv2,
HasNormals = meshes[i].HasNrm,
HasBoneIndices = meshes[i].HasIndices,
HasWeights = meshes[i].HasWeights,
HasBitangents = meshes[i].HasUv0,
Material = material,
});
listViewCustom1.Items.Add($"{meshes[i].ObjectName}");
}
SetDefaultFormats();
Loaded = true;
}
private void SetDefaultFormats()
{
positionFormatCB.LoadEnum(typeof(BufferFormat));
positionFormatCB.SelectedItem = BufferFormat.Float;
normalFormatCB.LoadEnum(typeof(BufferFormat));
normalFormatCB.SelectedItem = BufferFormat.HalfFloat;
bitangentFormatCB.LoadEnum(typeof(BufferFormat));
bitangentFormatCB.SelectedItem = BufferFormat.HalfFloat;
uv0FormatCB.LoadEnum(typeof(BufferFormat));
uv0FormatCB.SelectedItem = BufferFormat.Float;
uv1FormatCB.LoadEnum(typeof(BufferFormat));
uv1FormatCB.SelectedItem = BufferFormat.Float;
color0FormatCB.LoadEnum(typeof(BufferFormat));
color0FormatCB.SelectedItem = BufferFormat.Byte;
color1FormatCB.LoadEnum(typeof(BufferFormat));
color1FormatCB.SelectedItem = BufferFormat.Byte;
boneFormatCB.LoadEnum(typeof(BufferFormat));
boneFormatCB.SelectedItem = BufferFormat.Byte;
weightFormatCB.LoadEnum(typeof(BufferFormat));
weightFormatCB.SelectedItem = BufferFormat.BytesAsFloat;
tangentFormatCB.LoadEnum(typeof(BufferFormat));
tangentFormatCB.SelectedItem = BufferFormat.HalfFloat;
}
private void TryMatchOriginal()
{
if (OriginalMeshes == null || OriginalMeshes?.Count == 0)
return;
Loaded = false;
foreach (var mesh in Meshes)
{
var matchedMesh = (GFLXMesh)OriginalMeshes.FirstOrDefault(x => x.Text == mesh.ObjectName);
if (matchedMesh != null)
{
int index = Meshes.IndexOf(mesh);
var setting = Settings.MeshSettings[index];
foreach (var attribute in matchedMesh.MeshData.Attributes)
{
switch ((VertexType)attribute.VertexType)
{
case VertexType.Position:
setting.PositionFormat = (BufferFormat)attribute.BufferFormat;
break;
case VertexType.Normal:
setting.NormalFormat = (BufferFormat)attribute.BufferFormat;
setting.HasNormals = true;
break;
case VertexType.Color1:
setting.Color1Format = (BufferFormat)attribute.BufferFormat;
setting.HasColor1 = true;
break;
case VertexType.Color2:
setting.Color2Format = (BufferFormat)attribute.BufferFormat;
setting.HasColor2 = true;
break;
case VertexType.UV1:
setting.TexCoord1Format = (BufferFormat)attribute.BufferFormat;
setting.HasTexCoord1 = true;
break;
case VertexType.UV2:
setting.TexCoord2Format = (BufferFormat)attribute.BufferFormat;
setting.HasTexCoord2 = true;
break;
case VertexType.UV3:
setting.TexCoord3Format = (BufferFormat)attribute.BufferFormat;
setting.HasTexCoord3 = true;
break;
case VertexType.UV4:
setting.TexCoord4Format = (BufferFormat)attribute.BufferFormat;
setting.HasTexCoord4 = true;
break;
case VertexType.BoneWeight:
setting.BoneWeightFormat = (BufferFormat)attribute.BufferFormat;
if (mesh.vertices.FirstOrDefault().boneWeights.Count == 0)
{
//Fill weights with 1s
for (int v = 0; v < mesh.vertices.Count; v++)
{
for (int j = 0; j < 1; j++)
mesh.vertices[v].boneWeights.Add(1);
}
}
setting.HasWeights = true;
break;
case VertexType.BoneID:
setting.BoneIndexFormat = (BufferFormat)attribute.BufferFormat;
if (mesh.vertices.FirstOrDefault().boneNames.Count == 0)
{
//Fill indices with 1s
for (int v = 0; v < mesh.vertices.Count; v++)
{
for (int j = 0; j < 1; j++)
mesh.vertices[v].boneIds.Add(1);
}
}
setting.HasBoneIndices = true;
break;
case VertexType.Tangents:
setting.TangentsFormat = (BufferFormat)attribute.BufferFormat;
setting.HasTangents = true;
break;
case VertexType.Binormal:
setting.BitangentnFormat = (BufferFormat)attribute.BufferFormat;
setting.HasBitangents = true;
break;
}
}
}
}
Loaded = true;
}
private void listViewCustom1_SelectedIndexChanged(object sender, EventArgs e) {
if (!Loaded) return;
if (listViewCustom1.SelectedIndices.Count > 0)
{
Loaded = false;
int index = listViewCustom1.SelectedIndices[0];
var mesh = Meshes[index];
var settings = Settings.MeshSettings[index];
materiialPresetCB.SelectedItem = settings.Material;
UpdateSelectedMesh(settings);
Loaded = true;
}
}
private void ApplySettings(object sender, EventArgs e)
{
if (!Loaded) return;
var indices = listViewCustom1.SelectedIndices;
for (int i = 0; i < indices?.Count; i++)
{
int index = indices[i];
var mesh = Meshes[index];
var settings = Settings.MeshSettings[index];
settings.Material = materiialPresetCB.GetSelectedText();
settings.HasNormals = chkUseNormals.Checked;
settings.HasBitangents = chkBitangents.Checked;
settings.HasTexCoord1 = chkHasUv1.Checked;
settings.HasTexCoord2 = chkHasUv2.Checked;
settings.HasColor1 = chkUseColor1.Checked;
settings.HasColor2 = chkUseColor2.Checked;
settings.HasBoneIndices = chkUseBoneIndex.Checked;
settings.HasWeights = chkUseBoneWeights.Checked;
settings.HasTangents = chkTangents.Checked;
settings.PositionFormat = (BufferFormat)positionFormatCB.SelectedItem;
settings.NormalFormat = (BufferFormat)normalFormatCB.SelectedItem;
settings.BitangentnFormat = (BufferFormat)bitangentFormatCB.SelectedItem;
settings.TexCoord1Format = (BufferFormat)uv0FormatCB.SelectedItem;
settings.TexCoord2Format = (BufferFormat)uv1FormatCB.SelectedItem;
settings.Color1Format = (BufferFormat)color0FormatCB.SelectedItem;
settings.Color2Format = (BufferFormat)color1FormatCB.SelectedItem;
settings.BoneIndexFormat = (BufferFormat)boneFormatCB.SelectedItem;
settings.BoneWeightFormat = (BufferFormat)weightFormatCB.SelectedItem;
settings.TangentsFormat = (BufferFormat)tangentFormatCB.SelectedItem;
}
}
private void UpdateSelectedMesh(GfbmdlImportSettings.MeshSetting settings) {
chkUseNormals.Checked = settings.HasNormals;
chkBitangents.Checked = settings.HasBitangents;
chkHasUv1.Checked = settings.HasTexCoord1;
chkHasUv2.Checked = settings.HasTexCoord2;
chkUseColor1.Checked = settings.HasColor1;
chkUseColor2.Checked = settings.HasColor2;
chkUseBoneIndex.Checked = settings.HasBoneIndices;
chkUseBoneWeights.Checked = settings.HasWeights;
chkTangents.Checked = settings.HasTangents;
positionFormatCB.SelectedItem = settings.PositionFormat;
normalFormatCB.SelectedItem = settings.NormalFormat;
bitangentFormatCB.SelectedItem = settings.BitangentnFormat;
uv0FormatCB.SelectedItem = settings.TexCoord1Format;
uv1FormatCB.SelectedItem = settings.TexCoord2Format;
color0FormatCB.SelectedItem = settings.Color1Format;
color1FormatCB.SelectedItem = settings.Color2Format;
boneFormatCB.SelectedItem = settings.BoneIndexFormat;
weightFormatCB.SelectedItem = settings.BoneWeightFormat;
tangentFormatCB.SelectedItem = settings.TangentsFormat;
}
private void stButton1_Click(object sender, EventArgs e) {
if (!Loaded) return;
if (listViewCustom1.SelectedIndices.Count == 0) return;
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.json;";
ofd.DefaultExt = "json";
if (ofd.ShowDialog() == DialogResult.OK)
{
try {
Newtonsoft.Json.JsonConvert.DeserializeObject<Material>(
System.IO.File.ReadAllText(ofd.FileName));
}
catch (Exception ex)
{
STErrorDialog.Show("Failed to load material!", "GFBMDL Importer", ex.ToString());
return;
}
string name = System.IO.Path.GetFileNameWithoutExtension(ofd.FileName);
materiialPresetCB.Items.Add(name);
var indices = listViewCustom1.SelectedIndices;
for (int i = 0; i < indices?.Count; i++)
{
var settings = Settings.MeshSettings[indices[i]];
settings.MaterialFile = ofd.FileName;
settings.Material = name;
}
materiialPresetCB.SelectedItem = name;
}
}
private void chkMatchAttributes_CheckedChanged(object sender, EventArgs e) {
if (chkMatchAttributes.Checked)
{
TryMatchOriginal();
if (listViewCustom1.SelectedIndices.Count > 0)
{
int index = listViewCustom1.SelectedIndices[0];
UpdateSelectedMesh(Settings.MeshSettings[index]);
}
}
}
private void numericUpDownFloat1_ValueChanged(object sender, EventArgs e)
{
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -85,6 +85,8 @@ namespace FirstPlugin
tileModeCB.SelectedItem = GX2.GX2TileMode.MODE_DEFAULT;
formatComboBox.SelectedItem = GX2.GX2SurfaceFormat.T_BC1_SRGB;
MipmapNum.Maximum = 13;
IsLoaded = true;
}
@ -280,8 +282,8 @@ namespace FirstPlugin
SetupSettings(SelectedTexSettings);
MipmapNum.Maximum = STGenericTexture.GenerateTotalMipCount(
SelectedTexSettings.TexWidth, SelectedTexSettings.TexHeight) + 1;
// MipmapNum.Maximum = STGenericTexture.GenerateTotalMipCount(
// SelectedTexSettings.TexWidth, SelectedTexSettings.TexHeight) + 1;
//Force the mip counter to be the selected mip counter
//Some textures like bflim (used for UI) only have 1

View File

@ -392,7 +392,7 @@ namespace FirstPlugin
Formats.Add(typeof(IGA_PAK));
Formats.Add(typeof(MKAGPDX_Model));
Formats.Add(typeof(GFBMDL));
// Formats.Add(typeof(GFBANM));
// Formats.Add(typeof(GFBANM));
Formats.Add(typeof(GFBANMCFG));
Formats.Add(typeof(Turbo.Course_MapCamera_bin));
Formats.Add(typeof(SDF));
@ -443,7 +443,7 @@ namespace FirstPlugin
Formats.Add(typeof(PunchOutWii.PO_DICT));
Formats.Add(typeof(LM2_ARCADE_Model));
Formats.Add(typeof(NLG_NLOC));
Formats.Add(typeof(NLG_PCK));
Formats.Add(typeof(PCK));
Formats.Add(typeof(NLG.StrikersSAnim));

View File

@ -118,7 +118,7 @@ In the event that the tool cannot compile, check references. All the libraries u
- exelix for BYAML, SARC and KCL library.
- Syroot for helpful IO extensions and libraries.
- GDKChan for PICA shaders stuff used with BCRES, structs for BCRES, and some DDS decode methods.
- AboodXD for some foundation stuff with exelix's SARC library, Wii U (GPU7) and Switch (Tegra X1) textures swizzling, reading/converting uncompressed types for DDS, and documentation for GTX, XTX, and BNTX.
- AboodXD for some foundation stuff with exelix's SARC library, Wii U (GPU7) and Switch (Tegra X1) textures swizzling, reading/converting uncompressed types for DDS, and documentation for GTX, XTX, and BNTX. Library for Yaz0 made by AboodXD and helped port it to the tool.
- MelonSpeedruns for Switch Toolbox logo.
- BrawlBox team for brawl libraries used for BRRES parsing.
- Sage of Mirrors for SuperBMDLib.

View File

@ -5,6 +5,7 @@ using System.IO;
using System.IO.Compression;
using System.Threading.Tasks;
using Toolbox.Library.IO;
using System.Runtime.InteropServices;
namespace Toolbox.Library
{
@ -13,7 +14,7 @@ namespace Toolbox.Library
public int Alignment = 0;
public string[] Description { get; set; } = new string[] { "Yaz0" };
public string[] Extension { get; set; } = new string[] { "*.yaz0", "*.szs",};
public string[] Extension { get; set; } = new string[] { "*.yaz0", "*.szs", };
public override string ToString() { return "Yaz0"; }
@ -29,12 +30,250 @@ namespace Toolbox.Library
public Stream Decompress(Stream stream)
{
return new MemoryStream(EveryFileExplorer.YAZ0.Decompress(stream.ToArray()));
var comp = stream.ToBytes();
UInt32 decompressedSize = (uint)(comp[4] << 24 | comp[5] << 16 | comp[6] << 8 | comp[7]);
var data = Decompress(comp);
// var data = EveryFileExplorer.YAZ0.Decompress(comp);
// System.IO.File.WriteAllBytes("testYaz0.dec", data);
return new MemoryStream(data);
}
[DllImport("Lib/Yaz0.dll")]
static unsafe extern byte* decompress(byte* src, uint src_len, uint* dest_len);
[DllImport("Lib/Yaz0.dll")]
static unsafe extern byte* compress(byte* src, uint src_len, uint* dest_len, byte opt_compr);
[DllImport("Lib/Yaz0.dll")]
static unsafe extern void freePtr(void* ptr);
private unsafe byte[] Decompress(byte[] data)
{
return EveryFileExplorer.YAZ0.Decompress(data);
uint src_len = (uint)data.Length;
uint dest_len;
fixed (byte* inputPtr = data)
{
byte* outputPtr = decompress(inputPtr, src_len, &dest_len);
byte[] decomp = new byte[dest_len];
Marshal.Copy((IntPtr)outputPtr, decomp, 0, (int)dest_len);
freePtr(outputPtr);
return decomp;
}
}
public Stream Compress(Stream stream)
{
return new MemoryStream(EveryFileExplorer.YAZ0.Compress(stream.ToArray(),Runtime.Yaz0CompressionLevel, (uint)Alignment));
// return new MemoryStream(EveryFileExplorer.YAZ0.Compress(
// stream.ToArray(), Runtime.Yaz0CompressionLevel, (uint)Alignment));
var mem = new MemoryStream();
using (var writer = new FileWriter(mem, true))
{
writer.SetByteOrder(true);
writer.WriteSignature("Yaz0");
writer.Write((uint)stream.Length);
writer.Write((uint)Alignment);
writer.Write(0);
writer.Write(Compress(stream.ToArray(), (byte)Runtime.Yaz0CompressionLevel));
}
return mem;
}
public static unsafe byte[] Compress(byte[] src, byte opt_compr)
{
uint src_len = (uint)src.Length;
uint dest_len;
fixed (byte* inputPtr = src)
{
byte* outputPtr = compress(inputPtr, src_len, &dest_len, opt_compr);
byte[] comp = new byte[dest_len];
Marshal.Copy((IntPtr)outputPtr, comp, 0, (int)dest_len);
freePtr(outputPtr);
return comp;
}
Console.WriteLine($"opt_compr {opt_compr}");
uint range;
if (opt_compr == 0)
range = 0;
else if (opt_compr < 9)
range = (uint)(0x10e0 * opt_compr / 9 - 0x0e0);
else
range = 0x1000;
uint pos = 0;
uint src_end = (uint)src.Length;
byte[] dest = new byte[src_end + (src_end + 8) / 8];
uint dest_pos = 0;
uint code_byte_pos = 0;
ulong found = 0;
ulong found_len = 0;
uint delta;
int max_len = 0x111;
while (pos < src_end)
{
code_byte_pos = dest_pos;
dest[dest_pos] = 0; dest_pos++;
for (int i = 0; i < 8; i++)
{
if (pos >= src_end)
break;
found_len = 1;
if (range != 0)
{
// Going after speed here.
// Dunno if using a tuple is slower, so I don't want to risk it.
ulong search = compressionSearch(src, pos, max_len, range, src_end);
found = search >> 32;
found_len = search & 0xFFFFFFFF;
}
if (found_len > 2)
{
delta = (uint)(pos - found - 1);
if (found_len < 0x12)
{
dest[dest_pos] = (byte)(delta >> 8 | (found_len - 2) << 4); dest_pos++;
dest[dest_pos] = (byte)(delta & 0xFF); dest_pos++;
}
else
{
dest[dest_pos] = (byte)(delta >> 8); dest_pos++;
dest[dest_pos] = (byte)(delta & 0xFF); dest_pos++;
dest[dest_pos] = (byte)((found_len - 0x12) & 0xFF); dest_pos++;
}
pos += (uint)found_len;
}
else
{
dest[code_byte_pos] |= (byte)(1 << (7 - i));
dest[dest_pos] = src[pos]; dest_pos++; pos++;
}
}
}
byte[] result = new byte[dest_pos];
Array.Copy(dest, result, dest_pos);
return result;
}
public static ulong ReadULong(byte[] v, uint i)
{
int i1 = v[i] | (v[i + 1] << 8) | (v[i + 2] << 16) | (v[i + 3] << 24);
int i2 = v[i + 4] | (v[i + 5] << 8) | (v[i + 6] << 16) | (v[i + 7] << 24);
return (ulong)((uint)i1 | ((long)i2 << 32));
}
public static long IndexOfByte(byte[] src, byte v, uint i, uint c)
{
// https://stackoverflow.com/a/46678141
ulong t;
uint p, pEnd;
for (p = i; ((long)p & 7) != 0; c--, p++)
if (c == 0)
return -1;
else if (src[p] == v)
return p;
ulong r = v; r |= r << 8; r |= r << 16; r |= r << 32;
for (pEnd = (uint)(p + (c & ~7)); p < pEnd; p += 8)
{
t = ReadULong(src, p) ^ r;
t = (t - 0x0101010101010101) & ~t & 0x8080808080808080;
if (t != 0)
{
t &= (ulong)-(long)t;
return p + dbj8[t * 0x07EDD5E59A4E28C2 >> 58];
}
}
for (pEnd += c & 7; p < pEnd; p++)
if (src[p] == v)
return p;
return -1;
}
readonly static sbyte[] dbj8 =
{
7, -1, -1, -1, -1, 5, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 6, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 3, -1, -1, -1, -1, -1, -1, 1, -1, 2, 0, -1, -1,
};
public static unsafe long find(byte[] byteArray, byte byteToFind, uint start, uint length)
{
return Array.IndexOf(byteArray, byteToFind, (int)start, (int)length);
return IndexOfByte(byteArray, byteToFind, start, length);
}
public static ulong compressionSearch(byte[] src, uint pos, int max_len, uint range, uint src_end)
{
ulong found_len = 1;
ulong found = 0;
long search;
uint cmp_end, cmp1, cmp2;
byte c1;
uint len;
if (pos + 2 < src_end)
{
search = ((long)pos - (long)range);
if (search < 0)
search = 0;
cmp_end = (uint)(pos + max_len);
if (cmp_end > src_end)
cmp_end = src_end;
c1 = src[pos];
while (search < pos)
{
search = find(src, c1, (uint)search, (uint)(pos - search));
if (search < 0)
break;
cmp1 = (uint)(search + 1);
cmp2 = pos + 1;
while (cmp2 < cmp_end && src[cmp1] == src[cmp2])
{
cmp1++; cmp2++;
}
len = cmp2 - pos;
if (found_len < len)
{
found_len = len;
found = (uint)search;
if ((long)found_len == max_len)
break;
}
search++;
}
}
return (ulong)((found << 32) | found_len);
}
}
}

View File

@ -71,8 +71,7 @@ namespace Toolbox.Library
Flags |= PostProcessSteps.CalculateTangentSpace;
Flags |= PostProcessSteps.GenerateNormals;*/
scene = Importer.ImportFile(FileName, settings.GetFlags());
if (Utils.GetExtension(FileName) == ".dae")
@ -498,6 +497,11 @@ namespace Toolbox.Library
Name.Contains("Skl_Root") || Name.Contains("nw4f_root") ||
Name.Contains("skl_root") || Name.Contains("all_root") || Name.Contains("_root") || Name.Contains("Root");
if (DaeHelper.VisualSceneNodeTypes.ContainsKey(Name)) {
if (DaeHelper.VisualSceneNodeTypes[Name] == "JOINT")
IsBone = true;
}
//Root set saved by this tool
//Get our root manually as it's a child to this
bool IsRootSkeleton = Name == "skeleton_root";

View File

@ -26,6 +26,8 @@ namespace Toolbox.Library
public bool FlipTexCoordsVertical = true;
public bool OnlyExportRiggedBones = false;
public bool AddLeafBones = false;
public Version FileVersion = new Version();
public ProgramPreset Preset = ProgramPreset.NONE;

View File

@ -34,24 +34,28 @@
this.chkFlipUvsVertical = new Toolbox.Library.Forms.STCheckBox();
this.chkOldExporter = new Toolbox.Library.Forms.STCheckBox();
this.chkVertexColors = new Toolbox.Library.Forms.STCheckBox();
this.chkExportRiggedBonesOnly = new Toolbox.Library.Forms.STCheckBox();
this.contentContainer.SuspendLayout();
this.SuspendLayout();
//
// contentContainer
//
this.contentContainer.Controls.Add(this.chkExportRiggedBonesOnly);
this.contentContainer.Controls.Add(this.chkVertexColors);
this.contentContainer.Controls.Add(this.chkOldExporter);
this.contentContainer.Controls.Add(this.chkFlipUvsVertical);
this.contentContainer.Controls.Add(this.stButton2);
this.contentContainer.Controls.Add(this.stButton1);
this.contentContainer.Controls.Add(this.exportTexturesChkBox);
this.contentContainer.Size = new System.Drawing.Size(329, 173);
this.contentContainer.Size = new System.Drawing.Size(338, 267);
this.contentContainer.Paint += new System.Windows.Forms.PaintEventHandler(this.contentContainer_Paint);
this.contentContainer.Controls.SetChildIndex(this.exportTexturesChkBox, 0);
this.contentContainer.Controls.SetChildIndex(this.stButton1, 0);
this.contentContainer.Controls.SetChildIndex(this.stButton2, 0);
this.contentContainer.Controls.SetChildIndex(this.chkFlipUvsVertical, 0);
this.contentContainer.Controls.SetChildIndex(this.chkOldExporter, 0);
this.contentContainer.Controls.SetChildIndex(this.chkVertexColors, 0);
this.contentContainer.Controls.SetChildIndex(this.chkExportRiggedBonesOnly, 0);
//
// exportTexturesChkBox
//
@ -70,7 +74,7 @@
//
this.stButton1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.stButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.stButton1.Location = new System.Drawing.Point(244, 141);
this.stButton1.Location = new System.Drawing.Point(254, 235);
this.stButton1.Name = "stButton1";
this.stButton1.Size = new System.Drawing.Size(75, 23);
this.stButton1.TabIndex = 12;
@ -81,7 +85,7 @@
//
this.stButton2.DialogResult = System.Windows.Forms.DialogResult.OK;
this.stButton2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.stButton2.Location = new System.Drawing.Point(163, 141);
this.stButton2.Location = new System.Drawing.Point(173, 235);
this.stButton2.Name = "stButton2";
this.stButton2.Size = new System.Drawing.Size(75, 23);
this.stButton2.TabIndex = 13;
@ -91,7 +95,7 @@
// chkFlipUvsVertical
//
this.chkFlipUvsVertical.AutoSize = true;
this.chkFlipUvsVertical.Location = new System.Drawing.Point(23, 70);
this.chkFlipUvsVertical.Location = new System.Drawing.Point(22, 126);
this.chkFlipUvsVertical.Name = "chkFlipUvsVertical";
this.chkFlipUvsVertical.Size = new System.Drawing.Size(101, 17);
this.chkFlipUvsVertical.TabIndex = 14;
@ -102,7 +106,7 @@
// chkOldExporter
//
this.chkOldExporter.AutoSize = true;
this.chkOldExporter.Location = new System.Drawing.Point(23, 104);
this.chkOldExporter.Location = new System.Drawing.Point(22, 149);
this.chkOldExporter.Name = "chkOldExporter";
this.chkOldExporter.Size = new System.Drawing.Size(200, 17);
this.chkOldExporter.TabIndex = 15;
@ -115,7 +119,7 @@
this.chkVertexColors.AutoSize = true;
this.chkVertexColors.Checked = true;
this.chkVertexColors.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkVertexColors.Location = new System.Drawing.Point(132, 47);
this.chkVertexColors.Location = new System.Drawing.Point(23, 70);
this.chkVertexColors.Name = "chkVertexColors";
this.chkVertexColors.Size = new System.Drawing.Size(121, 17);
this.chkVertexColors.TabIndex = 16;
@ -123,11 +127,23 @@
this.chkVertexColors.UseVisualStyleBackColor = true;
this.chkVertexColors.CheckedChanged += new System.EventHandler(this.chkVertexColors_CheckedChanged);
//
// chkExportRiggedBonesOnly
//
this.chkExportRiggedBonesOnly.AutoSize = true;
this.chkExportRiggedBonesOnly.Enabled = false;
this.chkExportRiggedBonesOnly.Location = new System.Drawing.Point(23, 93);
this.chkExportRiggedBonesOnly.Name = "chkExportRiggedBonesOnly";
this.chkExportRiggedBonesOnly.Size = new System.Drawing.Size(150, 17);
this.chkExportRiggedBonesOnly.TabIndex = 17;
this.chkExportRiggedBonesOnly.Text = "Export Only Rigged Bones";
this.chkExportRiggedBonesOnly.UseVisualStyleBackColor = true;
this.chkExportRiggedBonesOnly.CheckedChanged += new System.EventHandler(this.chkExportRiggedBonesOnly_CheckedChanged);
//
// ExportModelSettings
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(335, 178);
this.ClientSize = new System.Drawing.Size(344, 272);
this.Name = "ExportModelSettings";
this.Text = "Export Settings";
this.contentContainer.ResumeLayout(false);
@ -144,5 +160,6 @@
private STCheckBox chkFlipUvsVertical;
protected STCheckBox chkOldExporter;
private STCheckBox chkVertexColors;
private STCheckBox chkExportRiggedBonesOnly;
}
}

View File

@ -37,5 +37,14 @@ namespace Toolbox.Library.Forms
private void chkVertexColors_CheckedChanged(object sender, EventArgs e) {
Settings.UseVertexColors = chkVertexColors.Checked;
}
private void chkExportRiggedBonesOnly_CheckedChanged(object sender, EventArgs e) {
Settings.OnlyExportRiggedBones = chkExportRiggedBonesOnly.Checked;
}
private void contentContainer_Paint(object sender, PaintEventArgs e)
{
}
}
}

View File

@ -94,6 +94,32 @@ namespace Toolbox.Library.Forms
}
}
private bool isJson;
public bool IsJson
{
get
{
return isJson;
}
set
{
isJson = true;
if (isJson)
{
scintilla1.Styles[Style.Json.Default].ForeColor = Color.Silver;
scintilla1.Styles[Style.Json.BlockComment].ForeColor = Color.FromArgb(0, 128, 0); // Green
scintilla1.Styles[Style.Json.LineComment].ForeColor = Color.FromArgb(0, 128, 0); // Green
scintilla1.Styles[Style.Json.Number].ForeColor = Color.Olive;
scintilla1.Styles[Style.Json.PropertyName].ForeColor = Color.Blue;
scintilla1.Styles[Style.Json.String].ForeColor = Color.FromArgb(163, 21, 21); // Red
scintilla1.Styles[Style.Json.StringEol].BackColor = Color.Pink;
scintilla1.Styles[Style.Json.Operator].ForeColor = Color.Purple;
scintilla1.Lexer = Lexer.Json;
}
}
}
private bool isYAML;
public bool IsYAML
{

View File

@ -0,0 +1,203 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using System.Drawing;
namespace Toolbox.Library.Forms
{
public class PickableUVMap : IPickable2DObject
{
public bool IsSelected { get; set; }
public bool IsHovered { get; set; }
public bool IsHit(float x, float y)
{
//Calcuate the total uv bounds
return false;
}
public void PickTranslate(float x, float y, float z)
{
}
public void PickScale(float x, float y, float z)
{
}
public void PickRotate(float x, float y, float z)
{
}
public void CalculateBoundry()
{
}
#region Draw UVs
public void DrawUVs(int PolygonGroupIndex, int UvChannelIndex, List<STGenericObject> genericObjects, STGenericMatTexture textureMap)
{
if (genericObjects.Count == 0) return;
foreach (var genericObject in genericObjects)
{
int divisions = 4;
int lineWidth = 1;
Color uvColor = Runtime.UVEditor.UVColor;
Color gridColor = Color.Black;
List<int> f = new List<int>();
int displayFaceSize = 0;
if (genericObject.lodMeshes.Count > 0)
{
f = genericObject.lodMeshes[0].getDisplayFace();
displayFaceSize = genericObject.lodMeshes[0].displayFaceSize;
}
if (genericObject.PolygonGroups.Count > 0)
{
if (PolygonGroupIndex == -1)
{
foreach (var group in genericObject.PolygonGroups)
{
f.AddRange(group.GetDisplayFace());
displayFaceSize += group.displayFaceSize;
}
}
else
{
if (genericObject.PolygonGroups.Count > PolygonGroupIndex)
{
f = genericObject.PolygonGroups[PolygonGroupIndex].GetDisplayFace();
displayFaceSize = genericObject.PolygonGroups[PolygonGroupIndex].displayFaceSize;
}
}
}
Console.WriteLine($"displayFaceSize {f.Count} {displayFaceSize} {genericObject.vertices.Count }");
for (int v = 0; v < displayFaceSize; v += 3)
{
if (displayFaceSize < 3 || genericObject.vertices.Count < 3)
return;
Vector2 v1 = new Vector2(0);
Vector2 v2 = new Vector2(0);
Vector2 v3 = new Vector2(0);
if (f.Count < v + 2)
continue;
if (UvChannelIndex == 0)
{
v1 = genericObject.vertices[f[v]].uv0;
v2 = genericObject.vertices[f[v + 1]].uv0;
v3 = genericObject.vertices[f[v + 2]].uv0;
}
if (UvChannelIndex == 1)
{
v1 = genericObject.vertices[f[v]].uv1;
v2 = genericObject.vertices[f[v + 1]].uv1;
v3 = genericObject.vertices[f[v + 2]].uv1;
}
if (UvChannelIndex == 2)
{
v1 = genericObject.vertices[f[v]].uv2;
v2 = genericObject.vertices[f[v + 1]].uv2;
v3 = genericObject.vertices[f[v + 2]].uv2;
}
v1 = new Vector2(v1.X, 1 - v1.Y);
v2 = new Vector2(v2.X, 1 - v2.Y);
v3 = new Vector2(v3.X, 1 - v3.Y);
DrawUVTriangleAndGrid(v1, v2, v3, divisions, uvColor, lineWidth, gridColor, textureMap);
}
}
}
private void DrawUVTriangleAndGrid(Vector2 v1, Vector2 v2, Vector2 v3, int divisions,
Color uvColor, int lineWidth, Color gridColor, STGenericMatTexture textureMap)
{
GL.UseProgram(0);
float bounds = 1;
Vector2 scaleUv = new Vector2(2);
Vector2 transUv = new Vector2(-1f);
if (textureMap != null && textureMap.Transform != null)
{
scaleUv *= textureMap.Transform.Scale;
transUv += textureMap.Transform.Translate;
}
//Disable textures so they don't affect color
GL.Disable(EnableCap.Texture2D);
DrawUvTriangle(v1, v2, v3, uvColor, scaleUv, transUv);
// Draw Grid
GL.Color3(gridColor);
GL.LineWidth(1);
// DrawHorizontalGrid(divisions, bounds, scaleUv);
// DrawVerticalGrid(divisions, bounds, scaleUv);
}
private static void DrawUvTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color uvColor, Vector2 scaleUv, Vector2 transUv)
{
GL.Color3(uvColor);
GL.Begin(PrimitiveType.Lines);
GL.LineWidth(3);
GL.Vertex2(v1 * scaleUv + transUv);
GL.Vertex2(v2 * scaleUv + transUv);
GL.End();
GL.Begin(PrimitiveType.Lines);
GL.LineWidth(3);
GL.Vertex2(v2 * scaleUv + transUv);
GL.Vertex2(v3 * scaleUv + transUv);
GL.End();
GL.Begin(PrimitiveType.Lines);
GL.LineWidth(3);
GL.Vertex2(v3 * scaleUv + transUv);
GL.Vertex2(v1 * scaleUv + transUv);
GL.End();
}
private static void DrawVerticalGrid(int divisions, float bounds, Vector2 scaleUv)
{
int verticalCount = divisions;
for (int i = 0; i < verticalCount * bounds; i++)
{
GL.Begin(PrimitiveType.Lines);
GL.Vertex2(new Vector2((1.0f / verticalCount) * i, -bounds) * scaleUv);
GL.Vertex2(new Vector2((1.0f / verticalCount) * i, bounds) * scaleUv);
GL.End();
}
}
private static void DrawHorizontalGrid(int divisions, float bounds, Vector2 scaleUv)
{
int horizontalCount = divisions;
for (int i = 0; i < horizontalCount * bounds; i++)
{
GL.Begin(PrimitiveType.Lines);
GL.Vertex2(new Vector2(-bounds, (1.0f / horizontalCount) * i) * scaleUv);
GL.Vertex2(new Vector2(bounds, (1.0f / horizontalCount) * i) * scaleUv);
GL.End();
}
}
#endregion
}
}

View File

@ -28,7 +28,6 @@
/// </summary>
private void InitializeComponent()
{
this.gL_ControlLegacy2D1 = new OpenTK.GLControl();
this.scaleYUD = new Toolbox.Library.Forms.NumericUpDownFloat();
this.transYUD = new Toolbox.Library.Forms.NumericUpDownFloat();
this.transXUD = new Toolbox.Library.Forms.NumericUpDownFloat();
@ -48,6 +47,7 @@
this.stButton1 = new Toolbox.Library.Forms.STButton();
this.splitter1 = new System.Windows.Forms.Splitter();
this.stPanel3 = new Toolbox.Library.Forms.STPanel();
this.uvViewport1 = new Toolbox.Library.Forms.UVViewport();
((System.ComponentModel.ISupportInitialize)(this.scaleYUD)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.transYUD)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.transXUD)).BeginInit();
@ -57,21 +57,6 @@
this.stPanel3.SuspendLayout();
this.SuspendLayout();
//
// gL_ControlLegacy2D1
//
this.gL_ControlLegacy2D1.BackColor = System.Drawing.Color.Black;
this.gL_ControlLegacy2D1.Dock = System.Windows.Forms.DockStyle.Fill;
this.gL_ControlLegacy2D1.Location = new System.Drawing.Point(0, 0);
this.gL_ControlLegacy2D1.Name = "gL_ControlLegacy2D1";
this.gL_ControlLegacy2D1.Size = new System.Drawing.Size(443, 454);
this.gL_ControlLegacy2D1.TabIndex = 2;
this.gL_ControlLegacy2D1.VSync = false;
this.gL_ControlLegacy2D1.Paint += new System.Windows.Forms.PaintEventHandler(this.gL_ControlLegacy2D1_Paint);
this.gL_ControlLegacy2D1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.gL_ControlLegacy2D1_MouseDown);
this.gL_ControlLegacy2D1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.gL_ControlLegacy2D1_MouseMove);
this.gL_ControlLegacy2D1.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.OnMouseWheel);
this.gL_ControlLegacy2D1.Resize += new System.EventHandler(this.gL_ControlLegacy2D1_Resize);
//
// scaleYUD
//
this.scaleYUD.DecimalPlaces = 5;
@ -209,6 +194,7 @@
this.drawableContainerCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.drawableContainerCB.ButtonColor = System.Drawing.Color.Empty;
this.drawableContainerCB.FormattingEnabled = true;
this.drawableContainerCB.IsReadOnly = false;
this.drawableContainerCB.Location = new System.Drawing.Point(294, 7);
this.drawableContainerCB.Name = "drawableContainerCB";
this.drawableContainerCB.Size = new System.Drawing.Size(146, 21);
@ -223,6 +209,7 @@
this.meshesCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.meshesCB.ButtonColor = System.Drawing.Color.Empty;
this.meshesCB.FormattingEnabled = true;
this.meshesCB.IsReadOnly = false;
this.meshesCB.Location = new System.Drawing.Point(294, 34);
this.meshesCB.Name = "meshesCB";
this.meshesCB.Size = new System.Drawing.Size(146, 21);
@ -280,6 +267,7 @@
this.textureCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.textureCB.ButtonColor = System.Drawing.Color.Empty;
this.textureCB.FormattingEnabled = true;
this.textureCB.IsReadOnly = false;
this.textureCB.Location = new System.Drawing.Point(446, 34);
this.textureCB.Name = "textureCB";
this.textureCB.Size = new System.Drawing.Size(156, 21);
@ -293,6 +281,7 @@
this.comboBox1.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.comboBox1.ButtonColor = System.Drawing.Color.Empty;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.IsReadOnly = false;
this.comboBox1.Location = new System.Drawing.Point(550, 7);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(52, 21);
@ -312,7 +301,7 @@
// btnApplyTransform
//
this.btnApplyTransform.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnApplyTransform.Location = new System.Drawing.Point(3, 138);
this.btnApplyTransform.Location = new System.Drawing.Point(6, 279);
this.btnApplyTransform.Name = "btnApplyTransform";
this.btnApplyTransform.Size = new System.Drawing.Size(119, 23);
this.btnApplyTransform.TabIndex = 9;
@ -357,13 +346,24 @@
//
// stPanel3
//
this.stPanel3.Controls.Add(this.gL_ControlLegacy2D1);
this.stPanel3.Controls.Add(this.uvViewport1);
this.stPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
this.stPanel3.Location = new System.Drawing.Point(162, 70);
this.stPanel3.Name = "stPanel3";
this.stPanel3.Size = new System.Drawing.Size(443, 454);
this.stPanel3.TabIndex = 5;
//
// uvViewport1
//
this.uvViewport1.ActiveTextureMap = null;
this.uvViewport1.Dock = System.Windows.Forms.DockStyle.Fill;
this.uvViewport1.Location = new System.Drawing.Point(0, 0);
this.uvViewport1.Name = "uvViewport1";
this.uvViewport1.Size = new System.Drawing.Size(443, 454);
this.uvViewport1.TabIndex = 0;
this.uvViewport1.UseGrid = false;
this.uvViewport1.UseOrtho = true;
//
// UVEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -391,7 +391,6 @@
private STPanel stPanel1;
private STLabel stLabel1;
private Toolbox.Library.Forms.STComboBox comboBox1;
private OpenTK.GLControl gL_ControlLegacy2D1;
private Toolbox.Library.Forms.STComboBox textureCB;
private STLabel stLabel2;
private NumericUpDownFloat scaleXUD;
@ -408,5 +407,6 @@
private STPanel stPanel3;
private STButton stButton1;
private STComboBox drawableContainerCB;
private UVViewport uvViewport1;
}
}

View File

@ -23,11 +23,13 @@ namespace Toolbox.Library.Forms
comboBox1.Items.Add(2);
comboBox1.SelectedIndex = 0;
barSlider1.Value = 0;
barSlider1.Value = barSlider1.Maximum;
}
public class ActiveTexture
{
public STGenericMatTexture MatTexture;
public Vector2 UVScale = new Vector2(1);
public Vector2 UVTranslate = new Vector2(0);
public float UVRotate = 0;
@ -46,7 +48,7 @@ namespace Toolbox.Library.Forms
}
public ActiveTexture activeTexture = new ActiveTexture();
public float brightness = 0.5f; //To see uv maps easier
public float brightness = 1.0f; //To see uv maps easier
public int UvChannelIndex = 0;
public List<STGenericObject> Objects = new List<STGenericObject>();
@ -58,10 +60,7 @@ namespace Toolbox.Library.Forms
{
List<STGenericObject> objects = new List<STGenericObject>();
for (int i = 0; i < Objects.Count; i++)
{
if (Objects[i].GetMaterial() == ActiveMaterial)
objects.Add(Objects[i]);
}
objects.Add(Objects[i]);
return objects;
}
@ -84,11 +83,11 @@ namespace Toolbox.Library.Forms
drawableContainerCB.SelectedIndex = 0;
}
public int texid;
bool IsSRTLoaded = false;
public void Reset()
{
barSlider1.Value = (int)(brightness * 100);
scaleXUD.Value = 1;
scaleYUD.Value = 1;
transXUD.Value = 0;
@ -110,212 +109,8 @@ namespace Toolbox.Library.Forms
meshesCB.SelectedIndex = 0;
}
public int texid;
public void DrawUVs(List<STGenericObject> genericObjects)
private void BindTexture()
{
foreach (var genericObject in genericObjects)
{
int divisions = 4;
int lineWidth = 1;
Color uvColor = Color.LightGreen;
Color gridColor = Color.Black;
List<int> f = new List<int>();
int displayFaceSize = 0;
if (genericObject.lodMeshes.Count > 0)
{
f = genericObject.lodMeshes[0].getDisplayFace();
displayFaceSize = genericObject.lodMeshes[0].displayFaceSize;
}
if (genericObject.PolygonGroups.Count > 0)
{
f = genericObject.PolygonGroups[0].GetDisplayFace();
displayFaceSize = genericObject.PolygonGroups[0].displayFaceSize;
}
for (int v = 0; v < displayFaceSize; v += 3)
{
if (displayFaceSize < 3 ||
genericObject.vertices.Count < 3)
return;
Vector2 v1 = new Vector2(0);
Vector2 v2 = new Vector2(0);
Vector2 v3 = new Vector2(0);
if (f.Count < v + 2)
continue;
if (UvChannelIndex == 0)
{
v1 = genericObject.vertices[f[v]].uv0;
v2 = genericObject.vertices[f[v + 1]].uv0;
v3 = genericObject.vertices[f[v + 2]].uv0;
}
if (UvChannelIndex == 1)
{
v1 = genericObject.vertices[f[v]].uv1;
v2 = genericObject.vertices[f[v + 1]].uv1;
v3 = genericObject.vertices[f[v + 2]].uv1;
}
if (UvChannelIndex == 2)
{
v1 = genericObject.vertices[f[v]].uv2;
v2 = genericObject.vertices[f[v + 1]].uv2;
v3 = genericObject.vertices[f[v + 2]].uv2;
}
v1 = new Vector2(v1.X, 1 - v1.Y);
v2 = new Vector2(v2.X, 1 - v2.Y);
v3 = new Vector2(v3.X, 1 - v3.Y);
DrawUVTriangleAndGrid(v1, v2, v3, divisions, uvColor, lineWidth, gridColor);
}
}
}
private void DrawUVTriangleAndGrid(Vector2 v1, Vector2 v2, Vector2 v3, int divisions,
Color uvColor, int lineWidth, Color gridColor)
{
GL.UseProgram(0);
float bounds = 1;
Vector2 scaleUv = activeTexture.UVScale * new Vector2(2);
Vector2 transUv = activeTexture.UVTranslate - new Vector2(1f);
//Disable textures so they don't affect color
GL.Disable(EnableCap.Texture2D);
DrawUvTriangle(v1, v2, v3, uvColor, scaleUv, transUv);
// Draw Grid
GL.Color3(gridColor);
// DrawHorizontalGrid(divisions, bounds, scaleUv);
// DrawVerticalGrid(divisions, bounds, scaleUv);
}
private static void DrawUvTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color uvColor, Vector2 scaleUv, Vector2 transUv)
{
GL.Color3(uvColor);
GL.Begin(PrimitiveType.Lines);
GL.LineWidth(3);
GL.Vertex2(v1 * scaleUv + transUv);
GL.Vertex2(v2 * scaleUv + transUv);
GL.End();
GL.Begin(PrimitiveType.Lines);
GL.LineWidth(3);
GL.Vertex2(v2 * scaleUv + transUv);
GL.Vertex2(v3 * scaleUv + transUv);
GL.End();
GL.Begin(PrimitiveType.Lines);
GL.LineWidth(3);
GL.Vertex2(v3 * scaleUv + transUv);
GL.Vertex2(v1 * scaleUv + transUv);
GL.End();
}
private void SetupRendering(float lineWidth)
{
// Go to 2D
GL.Viewport(0, 0, gL_ControlLegacy2D1.Width, gL_ControlLegacy2D1.Height);
GL.MatrixMode(MatrixMode.Projection);
GL.PushMatrix();
GL.LoadIdentity();
float aspect = (float)gL_ControlLegacy2D1.Width / (float)gL_ControlLegacy2D1.Height;
GL.Ortho(-aspect, aspect, -1, 1, -1, 1);
GL.MatrixMode(MatrixMode.Modelview);
GL.PushMatrix();
GL.LoadIdentity();
GL.LineWidth(lineWidth);
// Draw over everything
GL.Disable(EnableCap.DepthTest);
GL.Disable(EnableCap.CullFace);
}
private static void DrawVerticalGrid(int divisions, float bounds, Vector2 scaleUv)
{
int verticalCount = divisions;
for (int i = 0; i < verticalCount * bounds; i++)
{
GL.Begin(PrimitiveType.Lines);
GL.Vertex2(new Vector2((1.0f / verticalCount) * i, -bounds) * scaleUv);
GL.Vertex2(new Vector2((1.0f / verticalCount) * i, bounds) * scaleUv);
GL.End();
}
}
private static void DrawHorizontalGrid(int divisions, float bounds, Vector2 scaleUv)
{
int horizontalCount = divisions;
for (int i = 0; i < horizontalCount * bounds; i++)
{
GL.Begin(PrimitiveType.Lines);
GL.Vertex2(new Vector2(-bounds, (1.0f / horizontalCount) * i) * scaleUv);
GL.Vertex2(new Vector2(bounds, (1.0f / horizontalCount) * i) * scaleUv);
GL.End();
}
}
int PlaneSize = 1;
float PosX;
float PosY;
float ZoomValue = 1;
Point MouseDownPos;
private float FindHCF(float m, float n)
{
float temp, remainder;
if (m < n)
{
temp = m;
m = n;
n = temp;
}
while (true)
{
remainder = m % n;
if (remainder == 0)
return n;
else
m = n;
n = remainder;
}
}
private void gL_ControlLegacy2D1_Paint(object sender, PaintEventArgs e)
{
if (!Runtime.OpenTKInitialized)
return;
gL_ControlLegacy2D1.MakeCurrent();
SetupRendering(1);
GL.ClearColor(System.Drawing.Color.FromArgb(40, 40, 40));
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.Disable(EnableCap.Texture2D);
//This usually won't be seen unless the textures aren't repeating much
DrawBackdrop();
float PlaneScaleX = gL_ControlLegacy2D1.Width / 512;
float PlaneScaleY = gL_ControlLegacy2D1.Height / 512;
if (activeTexture.Width != 0 && activeTexture.Height != 0)
{
PlaneScaleX = (float)gL_ControlLegacy2D1.Width / (float)activeTexture.Width;
PlaneScaleY = (float)gL_ControlLegacy2D1.Height / (float)activeTexture.Height;
}
//Now do the plane with uvs
GL.PushMatrix();
GL.Scale(PlaneScaleY * ZoomValue, -PlaneScaleX * ZoomValue, 1);
GL.Translate(PosX, PosY, 0);
if (activeTexture.TextureIndex != -1)
{
//Draws a textured plan for our uvs to show on
@ -327,104 +122,7 @@ namespace Toolbox.Library.Forms
// GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)STGenericMatTexture.wrapmode[activeTexture.wrapModeT]);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)STGenericMatTexture.minfilter[activeTexture.MinFilter]);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)STGenericMatTexture.magfilter[activeTexture.MagFilter]);
}
//Params include Amount to repeat
DrawTexturedPlane(5);
if (ActiveObjects.Count > 0)
DrawUVs(ActiveObjects);
GL.UseProgram(0);
GL.PopMatrix();
gL_ControlLegacy2D1.SwapBuffers();
}
private void DrawTexturedPlane(float scale)
{
Vector2 scaleCenter = new Vector2(0.5f, 0.5f);
Vector2[] TexCoords = new Vector2[] {
new Vector2(1,1),
new Vector2(0,1),
new Vector2(0,0),
new Vector2(1,0),
};
Vector2[] Positions = new Vector2[] {
new Vector2(1,-1),
new Vector2(-1,-1),
new Vector2(-1,1),
new Vector2(1,1),
};
TexCoords[0] = (TexCoords[0] - scaleCenter) * scale + scaleCenter;
TexCoords[1] = (TexCoords[1] - scaleCenter) * scale + scaleCenter;
TexCoords[2] = (TexCoords[2] - scaleCenter) * scale + scaleCenter;
TexCoords[3] = (TexCoords[3] - scaleCenter) * scale + scaleCenter;
Positions[0] = Positions[0] * scale;
Positions[1] = Positions[1] * scale;
Positions[2] = Positions[2] * scale;
Positions[3] = Positions[3] * scale;
GL.Begin(PrimitiveType.Quads);
GL.Color3(brightness, brightness, brightness);
GL.TexCoord2(TexCoords[0]);
GL.Vertex2(Positions[0]);
GL.TexCoord2(TexCoords[1]);
GL.Vertex2(Positions[1]);
GL.TexCoord2(TexCoords[2]);
GL.Vertex2(Positions[2]);
GL.TexCoord2(TexCoords[3]);
GL.Vertex2(Positions[3]);
GL.End();
}
private void DrawBackdrop()
{
//Background
GL.Begin(PrimitiveType.Quads);
GL.Color3(Color.FromArgb(40, 40, 40));
GL.TexCoord2(1, 1);
GL.Vertex2(PlaneSize, -PlaneSize);
GL.TexCoord2(0, 1);
GL.Vertex2(-PlaneSize, -PlaneSize);
GL.TexCoord2(0, 0);
GL.Vertex2(-PlaneSize, PlaneSize);
GL.TexCoord2(1, 0);
GL.Vertex2(PlaneSize, PlaneSize);
GL.End();
}
private void OnMouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Delta > 0 && ZoomValue > 0) ZoomValue += 0.1f;
if (e.Delta < 0 && ZoomValue < 30 && ZoomValue > 0.1) ZoomValue -= 0.1f;
gL_ControlLegacy2D1.Invalidate();
}
private void gL_ControlLegacy2D1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
MouseDownPos = MousePosition;
}
}
private void gL_ControlLegacy2D1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
return;
Point temp = Control.MousePosition;
Point res = new Point(MouseDownPos.X - temp.X, MouseDownPos.Y - temp.Y);
PosX -= res.X * 0.001f;
PosY -= res.Y * 0.001f;
gL_ControlLegacy2D1.Invalidate();
MouseDownPos = temp;
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
@ -439,6 +137,8 @@ namespace Toolbox.Library.Forms
transXUD.Value = (decimal)activeTexture.UVTranslate.X;
transYUD.Value = (decimal)activeTexture.UVTranslate.Y;
uvViewport1.ActiveTextureMap = activeTexture.MatTexture;
var texture = Textures[activeTexture.TextureIndex];
if (texture.RenderableTex == null)
@ -448,7 +148,7 @@ namespace Toolbox.Library.Forms
activeTexture.Width = texture.Width;
activeTexture.Height = texture.Height;
gL_ControlLegacy2D1.Invalidate();
uvViewport1.UpdateViewport();
IsSRTLoaded = true;
}
@ -458,8 +158,8 @@ namespace Toolbox.Library.Forms
{
if (comboBox1.SelectedIndex >= 0)
{
UvChannelIndex = comboBox1.SelectedIndex;
gL_ControlLegacy2D1.Invalidate();
uvViewport1.UvChannelIndex = comboBox1.SelectedIndex;
uvViewport1.UpdateViewport();
}
}
@ -470,7 +170,8 @@ namespace Toolbox.Library.Forms
private void barSlider1_ValueChanged(object sender, EventArgs e)
{
brightness = (float)barSlider1.Value / 100;
gL_ControlLegacy2D1.Invalidate();
uvViewport1.Brightness = brightness;
uvViewport1.UpdateViewport();
}
private void OnNumbicValueSRT_ValueChanged(object sender, EventArgs e)
@ -494,18 +195,16 @@ namespace Toolbox.Library.Forms
transXUD.Value = 0;
transYUD.Value = 0;
gL_ControlLegacy2D1.Invalidate();
}
private void gL_ControlLegacy2D1_Resize(object sender, EventArgs e)
{
gL_ControlLegacy2D1.Invalidate();
uvViewport1.UpdateViewport();
}
private void meshesCB_SelectedIndexChanged(object sender, EventArgs e)
{
if (meshesCB.SelectedIndex >= 0)
{
uvViewport1.ActiveObjects.Clear();
uvViewport1.ActiveObjects.Add(Objects[meshesCB.SelectedIndex]);
ActiveMaterial = Materials[meshesCB.SelectedIndex];
ChannelTextures.Clear();
@ -521,6 +220,7 @@ namespace Toolbox.Library.Forms
Textures.Add(texture);
ActiveTexture tex = new ActiveTexture();
tex.MatTexture = texMap;
tex.TextureIndex = Textures.IndexOf(texture);
tex.Width = texture.Width;
tex.Height = texture.Height;
@ -564,9 +264,18 @@ namespace Toolbox.Library.Forms
for (int m = 0; m < ((IMeshContainer)container.Drawables[i]).Meshes.Count; m++)
{
var mesh = ((IMeshContainer)container.Drawables[i]).Meshes[m];
if (mesh.GetMaterial() != null)
Objects.Add(mesh);
if (mesh.PolygonGroups.Count > 0)
{
foreach (var group in mesh.PolygonGroups) {
var mat = group.Material;
if (mat != null && !Materials.Contains(mat))
Materials.Add(mat);
}
}
else if (mesh.GetMaterial() != null)
{
Objects.Add(mesh);
var mat = mesh.GetMaterial();
if (!Materials.Contains(mat))
{
@ -595,7 +304,7 @@ namespace Toolbox.Library.Forms
Reset();
Refresh();
gL_ControlLegacy2D1.Invalidate();
uvViewport1.UpdateViewport();
}
}
}

View File

@ -1,326 +0,0 @@
namespace Toolbox.Library.Forms.test
{
partial class UVEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.gL_ControlLegacy2D1 = new OpenTK.GLControl();
this.scaleYUD = new Toolbox.Library.Forms.NumericUpDownFloat();
this.transYUD = new Toolbox.Library.Forms.NumericUpDownFloat();
this.transXUD = new Toolbox.Library.Forms.NumericUpDownFloat();
this.stLabel4 = new Toolbox.Library.Forms.STLabel();
this.stLabel3 = new Toolbox.Library.Forms.STLabel();
this.scaleXUD = new Toolbox.Library.Forms.NumericUpDownFloat();
this.stPanel1 = new Toolbox.Library.Forms.STPanel();
this.barSlider1 = new ColorSlider.ColorSlider();
this.btnApplyTransform = new Toolbox.Library.Forms.STButton();
this.stLabel2 = new Toolbox.Library.Forms.STLabel();
this.comboBox2 = new Toolbox.Library.Forms.STComboBox();
this.comboBox1 = new Toolbox.Library.Forms.STComboBox();
this.stLabel1 = new Toolbox.Library.Forms.STLabel();
((System.ComponentModel.ISupportInitialize)(this.scaleYUD)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.transYUD)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.transXUD)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.scaleXUD)).BeginInit();
this.stPanel1.SuspendLayout();
this.SuspendLayout();
//
// gL_ControlLegacy2D1
//
this.gL_ControlLegacy2D1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.gL_ControlLegacy2D1.BackColor = System.Drawing.Color.Black;
this.gL_ControlLegacy2D1.Location = new System.Drawing.Point(0, 70);
this.gL_ControlLegacy2D1.Name = "gL_ControlLegacy2D1";
this.gL_ControlLegacy2D1.Size = new System.Drawing.Size(605, 454);
this.gL_ControlLegacy2D1.TabIndex = 2;
this.gL_ControlLegacy2D1.VSync = false;
this.gL_ControlLegacy2D1.Paint += new System.Windows.Forms.PaintEventHandler(this.gL_ControlLegacy2D1_Paint);
this.gL_ControlLegacy2D1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.gL_ControlLegacy2D1_MouseDown);
this.gL_ControlLegacy2D1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.gL_ControlLegacy2D1_MouseMove);
this.gL_ControlLegacy2D1.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.OnMouseWheel);
this.gL_ControlLegacy2D1.Resize += new System.EventHandler(this.gL_ControlLegacy2D1_Resize);
//
// scaleYUD
//
this.scaleYUD.DecimalPlaces = 5;
this.scaleYUD.Increment = new decimal(new int[] {
5,
0,
0,
196608});
this.scaleYUD.Location = new System.Drawing.Point(135, 43);
this.scaleYUD.Maximum = new decimal(new int[] {
1000000000,
0,
0,
0});
this.scaleYUD.Minimum = new decimal(new int[] {
100000000,
0,
0,
-2147483648});
this.scaleYUD.Name = "scaleYUD";
this.scaleYUD.Size = new System.Drawing.Size(64, 20);
this.scaleYUD.TabIndex = 8;
this.scaleYUD.ValueChanged += new System.EventHandler(this.OnNumbicValueSRT_ValueChanged);
//
// transYUD
//
this.transYUD.DecimalPlaces = 5;
this.transYUD.Increment = new decimal(new int[] {
5,
0,
0,
196608});
this.transYUD.Location = new System.Drawing.Point(360, 43);
this.transYUD.Maximum = new decimal(new int[] {
1000000000,
0,
0,
0});
this.transYUD.Minimum = new decimal(new int[] {
100000000,
0,
0,
-2147483648});
this.transYUD.Name = "transYUD";
this.transYUD.Size = new System.Drawing.Size(64, 20);
this.transYUD.TabIndex = 7;
this.transYUD.ValueChanged += new System.EventHandler(this.OnNumbicValueSRT_ValueChanged);
//
// transXUD
//
this.transXUD.DecimalPlaces = 5;
this.transXUD.Increment = new decimal(new int[] {
5,
0,
0,
196608});
this.transXUD.Location = new System.Drawing.Point(281, 43);
this.transXUD.Maximum = new decimal(new int[] {
1000000000,
0,
0,
0});
this.transXUD.Minimum = new decimal(new int[] {
100000000,
0,
0,
-2147483648});
this.transXUD.Name = "transXUD";
this.transXUD.Size = new System.Drawing.Size(64, 20);
this.transXUD.TabIndex = 6;
this.transXUD.ValueChanged += new System.EventHandler(this.OnNumbicValueSRT_ValueChanged);
//
// stLabel4
//
this.stLabel4.AutoSize = true;
this.stLabel4.Location = new System.Drawing.Point(205, 45);
this.stLabel4.Name = "stLabel4";
this.stLabel4.Size = new System.Drawing.Size(51, 13);
this.stLabel4.TabIndex = 5;
this.stLabel4.Text = "Translate";
//
// stLabel3
//
this.stLabel3.AutoSize = true;
this.stLabel3.Location = new System.Drawing.Point(25, 45);
this.stLabel3.Name = "stLabel3";
this.stLabel3.Size = new System.Drawing.Size(34, 13);
this.stLabel3.TabIndex = 4;
this.stLabel3.Text = "Scale";
//
// scaleXUD
//
this.scaleXUD.DecimalPlaces = 5;
this.scaleXUD.Increment = new decimal(new int[] {
5,
0,
0,
196608});
this.scaleXUD.Location = new System.Drawing.Point(65, 43);
this.scaleXUD.Maximum = new decimal(new int[] {
1000000000,
0,
0,
0});
this.scaleXUD.Minimum = new decimal(new int[] {
100000000,
0,
0,
-2147483648});
this.scaleXUD.Name = "scaleXUD";
this.scaleXUD.Size = new System.Drawing.Size(64, 20);
this.scaleXUD.TabIndex = 3;
this.scaleXUD.ValueChanged += new System.EventHandler(this.OnNumbicValueSRT_ValueChanged);
//
// stPanel1
//
this.stPanel1.Controls.Add(this.barSlider1);
this.stPanel1.Controls.Add(this.btnApplyTransform);
this.stPanel1.Controls.Add(this.scaleYUD);
this.stPanel1.Controls.Add(this.transYUD);
this.stPanel1.Controls.Add(this.stLabel2);
this.stPanel1.Controls.Add(this.transXUD);
this.stPanel1.Controls.Add(this.comboBox2);
this.stPanel1.Controls.Add(this.stLabel4);
this.stPanel1.Controls.Add(this.comboBox1);
this.stPanel1.Controls.Add(this.stLabel3);
this.stPanel1.Controls.Add(this.scaleXUD);
this.stPanel1.Controls.Add(this.stLabel1);
this.stPanel1.Dock = System.Windows.Forms.DockStyle.Top;
this.stPanel1.Location = new System.Drawing.Point(0, 0);
this.stPanel1.Name = "stPanel1";
this.stPanel1.Size = new System.Drawing.Size(605, 70);
this.stPanel1.TabIndex = 1;
//
// barSlider1
//
this.barSlider1.BarInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.barSlider1.BarPenColorBottom = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.barSlider1.BarPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.barSlider1.BorderRoundRectSize = new System.Drawing.Size(8, 8);
this.barSlider1.ElapsedInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
this.barSlider1.ElapsedPenColorBottom = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
this.barSlider1.ElapsedPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
this.barSlider1.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F);
this.barSlider1.ForeColor = System.Drawing.Color.White;
this.barSlider1.LargeChange = ((uint)(5u));
this.barSlider1.Location = new System.Drawing.Point(56, 7);
this.barSlider1.MouseEffects = false;
this.barSlider1.Name = "barSlider1";
this.barSlider1.ScaleDivisions = 10;
this.barSlider1.ScaleSubDivisions = 5;
this.barSlider1.ShowDivisionsText = true;
this.barSlider1.ShowSmallScale = false;
this.barSlider1.Size = new System.Drawing.Size(160, 25);
this.barSlider1.SmallChange = ((uint)(1u));
this.barSlider1.TabIndex = 17;
this.barSlider1.Text = "colorSlider1";
this.barSlider1.ThumbInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
this.barSlider1.ThumbPenColor = System.Drawing.Color.Silver;
this.barSlider1.ThumbRoundRectSize = new System.Drawing.Size(8, 8);
this.barSlider1.ThumbSize = new System.Drawing.Size(8, 8);
this.barSlider1.TickAdd = 0F;
this.barSlider1.TickColor = System.Drawing.Color.White;
this.barSlider1.TickDivide = 0F;
this.barSlider1.TickStyle = System.Windows.Forms.TickStyle.None;
this.barSlider1.Scroll += new System.Windows.Forms.ScrollEventHandler(this.barSlider1_Scroll);
//
// btnApplyTransform
//
this.btnApplyTransform.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnApplyTransform.Location = new System.Drawing.Point(430, 41);
this.btnApplyTransform.Name = "btnApplyTransform";
this.btnApplyTransform.Size = new System.Drawing.Size(119, 23);
this.btnApplyTransform.TabIndex = 9;
this.btnApplyTransform.Text = "Apply Transform";
this.btnApplyTransform.UseVisualStyleBackColor = false;
this.btnApplyTransform.Click += new System.EventHandler(this.btnApplyTransform_Click);
//
// stLabel2
//
this.stLabel2.AutoSize = true;
this.stLabel2.Location = new System.Drawing.Point(3, 13);
this.stLabel2.Name = "stLabel2";
this.stLabel2.Size = new System.Drawing.Size(56, 13);
this.stLabel2.TabIndex = 2;
this.stLabel2.Text = "Brightness";
//
// comboBox2
//
this.comboBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.comboBox2.BorderColor = System.Drawing.Color.Empty;
this.comboBox2.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.comboBox2.ButtonColor = System.Drawing.Color.Empty;
this.comboBox2.FormattingEnabled = true;
this.comboBox2.Location = new System.Drawing.Point(290, 7);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(166, 21);
this.comboBox2.TabIndex = 5;
this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
//
// comboBox1
//
this.comboBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.comboBox1.BorderColor = System.Drawing.Color.Empty;
this.comboBox1.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.comboBox1.ButtonColor = System.Drawing.Color.Empty;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(550, 7);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(52, 21);
this.comboBox1.TabIndex = 3;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// stLabel1
//
this.stLabel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.stLabel1.AutoSize = true;
this.stLabel1.Location = new System.Drawing.Point(462, 10);
this.stLabel1.Name = "stLabel1";
this.stLabel1.Size = new System.Drawing.Size(82, 13);
this.stLabel1.TabIndex = 4;
this.stLabel1.Text = "Active Channel:";
//
// UVEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.gL_ControlLegacy2D1);
this.Controls.Add(this.stPanel1);
this.Name = "UVEditor";
this.Size = new System.Drawing.Size(605, 524);
((System.ComponentModel.ISupportInitialize)(this.scaleYUD)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.transYUD)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.transXUD)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.scaleXUD)).EndInit();
this.stPanel1.ResumeLayout(false);
this.stPanel1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private STPanel stPanel1;
private STLabel stLabel1;
private Toolbox.Library.Forms.STComboBox comboBox1;
private OpenTK.GLControl gL_ControlLegacy2D1;
private Toolbox.Library.Forms.STComboBox comboBox2;
private STLabel stLabel2;
private NumericUpDownFloat scaleXUD;
private STLabel stLabel3;
private STLabel stLabel4;
private NumericUpDownFloat transXUD;
private NumericUpDownFloat transYUD;
private NumericUpDownFloat scaleYUD;
private STButton btnApplyTransform;
private ColorSlider.ColorSlider barSlider1;
}
}

View File

@ -1,532 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenTK;
using OpenTK.Graphics.OpenGL;
namespace Toolbox.Library.Forms.test
{
public partial class UVEditor : UserControl
{
public UVEditor()
{
InitializeComponent();
comboBox1.Items.Add(0);
comboBox1.Items.Add(1);
comboBox1.Items.Add(2);
comboBox1.SelectedIndex = 0;
barSlider1.Value = 0;
}
public class ActiveTexture
{
public Vector2 UVScale = new Vector2(1);
public Vector2 UVTranslate = new Vector2(0);
public float UVRotate = 0;
public STGenericTexture texture;
public int UvChannelIndex;
public int mapMode = 0;
public int wrapModeS = 1;
public int wrapModeT = 1;
public int minFilter = 3;
public int magFilter = 2;
public int mipDetail = 6;
public uint texWidth = 0;
public uint texHeight = 0;
}
public ActiveTexture activeTexture = new ActiveTexture();
public int brightness = 50; //To see uv maps easier
public int UvChannelIndex = 0;
public STGenericMaterial ActiveMaterial;
public List<STGenericObject> ActiveObjects = new List<STGenericObject>();
public List<ActiveTexture> Textures = new List<ActiveTexture>();
bool IsSRTLoaded = false;
public void Reset()
{
barSlider1.Value = brightness;
scaleXUD.Value = 1;
scaleYUD.Value = 1;
transXUD.Value = 0;
transYUD.Value = 0;
IsSRTLoaded = false;
comboBox2.Items.Clear();
if (RenderTools.defaultTex != null)
texid = RenderTools.defaultTex.RenderableTex.TexID;
foreach (var item in Textures)
comboBox2.Items.Add(item.texture.Text);
if (comboBox2.Items.Count > 0)
comboBox2.SelectedIndex = 0;
}
public int texid;
public void DrawUVs(List<STGenericObject> genericObjects)
{
foreach (var genericObject in genericObjects)
{
int divisions = 4;
int lineWidth = 1;
Color uvColor = Color.LightGreen;
Color gridColor = Color.Black;
List<int> f = genericObject.lodMeshes[0].getDisplayFace();
for (int v = 0; v < genericObject.lodMeshes[0].displayFaceSize; v += 3)
{
if (genericObject.lodMeshes[0].displayFaceSize < 3 ||
genericObject.vertices.Count < 3)
return;
Vector2 v1 = new Vector2(0);
Vector2 v2 = new Vector2(0);
Vector2 v3 = new Vector2(0);
if (UvChannelIndex == 0)
{
v1 = genericObject.vertices[f[v]].uv0;
v2 = genericObject.vertices[f[v + 1]].uv0;
v3 = genericObject.vertices[f[v + 2]].uv0;
}
if (UvChannelIndex == 1)
{
v1 = genericObject.vertices[f[v]].uv1;
v2 = genericObject.vertices[f[v + 1]].uv1;
v3 = genericObject.vertices[f[v + 2]].uv1;
}
if (UvChannelIndex == 2)
{
v1 = genericObject.vertices[f[v]].uv2;
v2 = genericObject.vertices[f[v + 1]].uv2;
v3 = genericObject.vertices[f[v + 2]].uv2;
}
v1 = new Vector2(v1.X, 1 - v1.Y);
v2 = new Vector2(v2.X, 1 - v2.Y);
v3 = new Vector2(v3.X, 1 - v3.Y);
DrawUVTriangleAndGrid(v1, v2, v3, divisions, uvColor, lineWidth, gridColor);
}
}
}
private void DrawUVTriangleAndGrid(Vector2 v1, Vector2 v2, Vector2 v3, int divisions,
Color uvColor, int lineWidth, Color gridColor)
{
GL.UseProgram(0);
float bounds = 1;
Vector2 scaleUv = activeTexture.UVScale * new Vector2(2);
Vector2 transUv = activeTexture.UVTranslate - new Vector2(1f);
//Disable textures so they don't affect color
GL.Disable(EnableCap.Texture2D);
DrawUvTriangle(v1, v2, v3, uvColor, scaleUv, transUv);
// Draw Grid
GL.Color3(gridColor);
// DrawHorizontalGrid(divisions, bounds, scaleUv);
// DrawVerticalGrid(divisions, bounds, scaleUv);
}
private static void DrawUvTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color uvColor, Vector2 scaleUv, Vector2 transUv)
{
GL.Color3(uvColor);
GL.Begin(PrimitiveType.Lines);
GL.LineWidth(3);
GL.Vertex2(v1 * scaleUv + transUv);
GL.Vertex2(v2 * scaleUv + transUv);
GL.End();
GL.Begin(PrimitiveType.Lines);
GL.LineWidth(3);
GL.Vertex2(v2 * scaleUv + transUv);
GL.Vertex2(v3 * scaleUv + transUv);
GL.End();
GL.Begin(PrimitiveType.Lines);
GL.LineWidth(3);
GL.Vertex2(v3 * scaleUv + transUv);
GL.Vertex2(v1 * scaleUv + transUv);
GL.End();
}
private void SetupRendering(float lineWidth)
{
// Go to 2D
GL.Viewport(0, 0, gL_ControlLegacy2D1.Width, gL_ControlLegacy2D1.Height);
GL.MatrixMode(MatrixMode.Projection);
GL.PushMatrix();
GL.LoadIdentity();
float aspect = (float)gL_ControlLegacy2D1.Width / (float)gL_ControlLegacy2D1.Height;
GL.Ortho(-aspect, aspect, -1, 1, -1, 1);
GL.MatrixMode(MatrixMode.Modelview);
GL.PushMatrix();
GL.LoadIdentity();
GL.LineWidth(lineWidth);
// Draw over everything
GL.Disable(EnableCap.DepthTest);
GL.Disable(EnableCap.CullFace);
}
private static void DrawVerticalGrid(int divisions, float bounds, Vector2 scaleUv)
{
int verticalCount = divisions;
for (int i = 0; i < verticalCount * bounds; i++)
{
GL.Begin(PrimitiveType.Lines);
GL.Vertex2(new Vector2((1.0f / verticalCount) * i, -bounds) * scaleUv);
GL.Vertex2(new Vector2((1.0f / verticalCount) * i, bounds) * scaleUv);
GL.End();
}
}
private static void DrawHorizontalGrid(int divisions, float bounds, Vector2 scaleUv)
{
int horizontalCount = divisions;
for (int i = 0; i < horizontalCount * bounds; i++)
{
GL.Begin(PrimitiveType.Lines);
GL.Vertex2(new Vector2(-bounds, (1.0f / horizontalCount) * i) * scaleUv);
GL.Vertex2(new Vector2(bounds, (1.0f / horizontalCount) * i) * scaleUv);
GL.End();
}
}
int PlaneSize = 1;
float PosX;
float PosY;
float ZoomValue = 1;
Point MouseDownPos;
private float FindHCF(float m, float n)
{
float temp, remainder;
if (m < n)
{
temp = m;
m = n;
n = temp;
}
while (true)
{
remainder = m % n;
if (remainder == 0)
return n;
else
m = n;
n = remainder;
}
}
private void gL_ControlLegacy2D1_Paint(object sender, PaintEventArgs e)
{
if (ActiveObjects.Count <= 0 || ActiveMaterial == null || Runtime.OpenTKInitialized == false)
return;
gL_ControlLegacy2D1.MakeCurrent();
SetupRendering(1);
GL.ClearColor(System.Drawing.Color.FromArgb(40, 40, 40));
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.Disable(EnableCap.Texture2D);
//This usually won't be seen unless the textures aren't repeating much
DrawBackdrop();
float PlaneScaleX = 0.5f;
float PlaneScaleY = 0.5f;
float HalfWidth = (float)gL_ControlLegacy2D1.Width / 2.0f;
float HalfHeight = (float)gL_ControlLegacy2D1.Height / 2.0f;
if (activeTexture.texWidth != 0 && activeTexture.texHeight != 0)
{
PlaneScaleX = (float)gL_ControlLegacy2D1.Width / (float)activeTexture.texWidth;
PlaneScaleY = (float)gL_ControlLegacy2D1.Height / (float)activeTexture.texHeight;
}
//Now do the plane with uvs
GL.PushMatrix();
GL.Scale(PlaneScaleY * ZoomValue, -PlaneScaleX * ZoomValue, 1);
GL.Translate(PosX, PosY, 0);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadIdentity();
GL.MatrixMode(MatrixMode.Texture);
GL.LoadIdentity();
bool UseBackground = true;
if (UseBackground)
{
float BrightnessAmount = (float)brightness / 100f;
int brightnessScale = (int)(BrightnessAmount * 255);
GL.PushAttrib(AttribMask.TextureBit);
var background = new GenericBitmapTexture(Properties.Resources.CheckerBackground);
background.LoadOpenGLTexture();
//Draws a textured plan for our uvs to show on
GL.Enable(EnableCap.Texture2D);
GL.BindTexture(TextureTarget.Texture2D, background.RenderableTex.TexID);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);
GL.Begin(PrimitiveType.Quads);
// GL.Color3(brightnessScale, brightnessScale, brightnessScale);
GL.TexCoord2(0.0f, 0.0f);
GL.Vertex2(-HalfWidth, -HalfHeight);
GL.TexCoord2(PlaneScaleX, 0.0f);
GL.Vertex2(HalfWidth, -HalfHeight);
GL.TexCoord2(PlaneScaleX, PlaneScaleY);
GL.Vertex2(HalfWidth, HalfHeight);
GL.TexCoord2(0.0f, PlaneScaleY);
GL.Vertex2(-HalfWidth, HalfHeight);
GL.End();
GL.PopAttrib();
}
if (activeTexture.texture != null)
{
// DrawTexturedPlane(1, activeTexture.texWidth, activeTexture.texHeight);
}
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadIdentity();
DrawUVs(ActiveObjects);
GL.PopMatrix();
gL_ControlLegacy2D1.SwapBuffers();
}
//Aspect ratio stuff from https://github.com/libertyernie/brawltools/blob/40d7431b1a01ef4a0411cd69e51411bd581e93e2/BrawlLib/System/Windows/Controls/TexCoordRenderer.cs
private void DrawTexturedPlane(float scale, uint TextureWidth, uint TextureHeight)
{
//Draws a textured plan for our uvs to show on
/* GL.Enable(EnableCap.Texture2D);
GL.BindTexture(TextureTarget.Texture2D, texid);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (float)STGenericMatTexture.wrapmode[activeTexture.wrapModeS]);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (float)STGenericMatTexture.wrapmode[activeTexture.wrapModeT]);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)STGenericMatTexture.minfilter[activeTexture.minFilter]);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)STGenericMatTexture.magfilter[activeTexture.magFilter]);
*/
float HalfWidth = (float)gL_ControlLegacy2D1.Width / 2.0f;
float HalfHeight = (float)gL_ControlLegacy2D1.Height / 2.0f;
Vector2 scaleCenter = new Vector2(0.5f, 0.5f);
float[] texCoord = new float[8];
float tAspect = (float)TextureWidth / TextureHeight;
float wAspect = (float)gL_ControlLegacy2D1.Width / gL_ControlLegacy2D1.Height;
Vector2 topLeft = new Vector2();
Vector2 bottomRight = new Vector2();
float xCorrect = 1.0f, yCorrect = 1.0f;
if (tAspect > wAspect)
{
//Texture is wider, use horizontal fit
//X touches the edges of the window, Y has top and bottom padding
texCoord[0] = texCoord[6] = 0.0f;
texCoord[2] = texCoord[4] = 1.0f;
texCoord[1] = texCoord[3] = (yCorrect = tAspect / wAspect) / 2.0f + 0.5f;
texCoord[5] = texCoord[7] = 1.0f - texCoord[1];
bottomRight = new Vector2(HalfWidth, (((float)gL_ControlLegacy2D1.Height - ((float)gL_ControlLegacy2D1.Width /
TextureWidth * TextureHeight)) / (float)gL_ControlLegacy2D1.Height / 2.0f - 0.5f) *
(float)gL_ControlLegacy2D1.Height);
topLeft = new Vector2(-HalfHeight, -bottomRight.Y);
}
else
{
//Window is wider, use vertical fit
//Y touches the edges of the window, X has left and right padding
texCoord[1] = texCoord[3] = 1.0f;
texCoord[5] = texCoord[7] = 0.0f;
//X
texCoord[2] = texCoord[4] = (xCorrect = wAspect / tAspect) / 2.0f + 0.5f;
texCoord[0] = texCoord[6] = 1.0f - texCoord[2];
bottomRight = new Vector2(1.0f - (((float)gL_ControlLegacy2D1.Width -
((float)gL_ControlLegacy2D1.Height / TextureHeight * TextureWidth)) / gL_ControlLegacy2D1.Width / 2.0f - 0.5f) *
(float)gL_ControlLegacy2D1.Width, -HalfHeight);
topLeft = new Vector2(-bottomRight.X, HalfHeight);
}
GL.Begin(PrimitiveType.Quads);
GL.TexCoord2(texCoord[0], texCoord[1]);
GL.Vertex2(-HalfWidth, -HalfHeight);
GL.TexCoord2(texCoord[2], texCoord[3]);
GL.Vertex2(HalfWidth, -HalfHeight);
GL.TexCoord2(texCoord[4], texCoord[5]);
GL.Vertex2(HalfWidth, HalfHeight);
GL.TexCoord2(texCoord[6], texCoord[7]);
GL.Vertex2(-HalfWidth, HalfHeight);
GL.End();
}
private void DrawBackdrop()
{
//Background
GL.Begin(PrimitiveType.Quads);
GL.Color3(Color.FromArgb(40, 40, 40));
GL.TexCoord2(1, 1);
GL.Vertex2(PlaneSize, -PlaneSize);
GL.TexCoord2(0, 1);
GL.Vertex2(-PlaneSize, -PlaneSize);
GL.TexCoord2(0, 0);
GL.Vertex2(-PlaneSize, PlaneSize);
GL.TexCoord2(1, 0);
GL.Vertex2(PlaneSize, PlaneSize);
GL.End();
}
private void OnMouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Delta > 0 && ZoomValue > 0) ZoomValue += 0.1f;
if (e.Delta < 0 && ZoomValue < 30 && ZoomValue > 0.1) ZoomValue -= 0.1f;
gL_ControlLegacy2D1.Invalidate();
}
private void gL_ControlLegacy2D1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
MouseDownPos = MousePosition;
}
}
private void gL_ControlLegacy2D1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
return;
Point temp = Control.MousePosition;
Point res = new Point(MouseDownPos.X - temp.X, MouseDownPos.Y - temp.Y);
PosX -= res.X * 0.001f;
PosY -= res.Y * 0.001f;
gL_ControlLegacy2D1.Invalidate();
MouseDownPos = temp;
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox2.SelectedIndex >= 0)
{
activeTexture = Textures[comboBox2.SelectedIndex];
UvChannelIndex = activeTexture.UvChannelIndex;
scaleXUD.Value = (decimal)activeTexture.UVScale.X;
scaleYUD.Value = (decimal)activeTexture.UVScale.Y;
transXUD.Value = (decimal)activeTexture.UVTranslate.X;
transYUD.Value = (decimal)activeTexture.UVTranslate.Y;
var texture = activeTexture.texture;
if (texture.RenderableTex == null)
texture.LoadOpenGLTexture();
texid = texture.RenderableTex.TexID;
activeTexture.texWidth = texture.Width;
activeTexture.texHeight = texture.Height;
gL_ControlLegacy2D1.Invalidate();
IsSRTLoaded = true;
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedIndex >= 0)
{
UvChannelIndex = comboBox1.SelectedIndex;
gL_ControlLegacy2D1.Invalidate();
}
}
private void OnNumbicValueSRT_ValueChanged(object sender, EventArgs e)
{
}
private void btnApplyTransform_Click(object sender, EventArgs e)
{
foreach (var shape in ActiveObjects)
{
Vector2 Scale = new Vector2((float)scaleXUD.Value, (float)scaleYUD.Value);
Vector2 Translate = new Vector2((float)transXUD.Value, (float)transYUD.Value);
shape.TransformUVs(Translate, Scale, UvChannelIndex);
}
scaleXUD.Value = 1;
scaleYUD.Value = 1;
transXUD.Value = 0;
transYUD.Value = 0;
gL_ControlLegacy2D1.Invalidate();
}
private void gL_ControlLegacy2D1_Resize(object sender, EventArgs e)
{
gL_ControlLegacy2D1.Invalidate();
}
private void stTrackBar1_Scroll(object sender, ScrollEventArgs e)
{
}
private void barSlider1_Scroll(object sender, ScrollEventArgs e)
{
brightness = barSlider1.Value;
gL_ControlLegacy2D1.Invalidate();
}
}
}

View File

@ -1,45 +0,0 @@
namespace Toolbox.Library.Forms
{
partial class UVEditorAdvanced
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// UVEditorAdvanced
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "UVEditorAdvanced";
this.Size = new System.Drawing.Size(444, 351);
this.ResumeLayout(false);
}
#endregion
}
}

View File

@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Toolbox.Library.Forms
{
public partial class UVEditorAdvanced : UserControl
{
public UVViewport Viewport;
public UVEditorAdvanced()
{
InitializeComponent();
Viewport = new UVViewport();
Viewport.Dock = DockStyle.Fill;
Controls.Add(Viewport);
}
}
}

View File

@ -44,9 +44,9 @@
// uvEditor1
//
this.uvEditor1.Dock = System.Windows.Forms.DockStyle.Fill;
this.uvEditor1.Location = new System.Drawing.Point(0, 25);
this.uvEditor1.Location = new System.Drawing.Point(0, 0);
this.uvEditor1.Name = "uvEditor1";
this.uvEditor1.Size = new System.Drawing.Size(595, 443);
this.uvEditor1.Size = new System.Drawing.Size(595, 468);
this.uvEditor1.TabIndex = 11;
//
// UVEditorForm

View File

@ -6,33 +6,125 @@ using System.Threading.Tasks;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using System.Drawing;
using Toolbox.Library.IO;
namespace Toolbox.Library.Forms
{
public class UVViewport : Viewport2D
{
public STGenericMatTexture ActiveTextureMap { get; set; }
public UVViewport()
{
}
public List<STGenericObject> ActiveObjects = new List<STGenericObject>();
/// <summary>
/// Selectes the group of polygons to display UVs for. -1 set to use all of them.
/// </summary>
public int PolygonGroupIndex = -1;
public int UvChannelIndex = 0;
public bool Repeat = true;
public float Brightness = 1.0f;
public PickableUVMap PickableUVMap = new PickableUVMap();
public override List<IPickable2DObject> GetPickableObjects()
{
return new List<IPickable2DObject>() { PickableUVMap };
}
public override void RenderSceme()
{
DrawTexturedPlane(1);
DrawUVs(ActiveObjects);
GL.PushMatrix();
Vector3 Scale = new Vector3(30, 30, 30);
//Scale the plane by aspect ratio
GL.PushMatrix();
bool useTextures = false;
if (ActiveTextureMap != null) {
var tex = ActiveTextureMap.GetTexture();
//Bind texture if not null
if (tex != null)
{
//Adjust scale via aspect ratio
if (Width > Height)
{
float aspect = (float)tex.Width / (float)tex.Height;
Console.WriteLine($"aspect w {aspect}");
Scale.X *= aspect;
}
else
{
float aspect = (float)tex.Height / (float)tex.Width;
Console.WriteLine($"aspect h {aspect}");
Scale.Y *= aspect;
}
if (tex.RenderableTex == null || !tex.RenderableTex.GLInitialized)
tex.LoadOpenGLTexture();
GL.Enable(EnableCap.Texture2D);
GL.BindTexture(TextureTarget.Texture2D, tex.RenderableTex.TexID);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (float)STGenericMatTexture.wrapmode[ActiveTextureMap.WrapModeS]);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (float)STGenericMatTexture.wrapmode[ActiveTextureMap.WrapModeT]);
// GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)STGenericMatTexture.wrapmode[activeTexture.wrapModeS]);
// GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)STGenericMatTexture.wrapmode[activeTexture.wrapModeT]);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)STGenericMatTexture.minfilter[ActiveTextureMap.MinFilter]);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)STGenericMatTexture.magfilter[ActiveTextureMap.MagFilter]);
useTextures = true;
}
}
GL.Scale(Scale);
if (useTextures)
{
GL.Enable(EnableCap.Texture2D);
if (Repeat)
{
DrawPlane(50, Color.FromArgb(128, 128,128));
DrawPlane(1, Color.White);
}
else
DrawPlane(1, Color.White);
}
else
{
DrawPlane(1, BackgroundColor.Lighten(40));
}
GL.Disable(EnableCap.Texture2D);
PickableUVMap.DrawUVs(PolygonGroupIndex, UvChannelIndex, ActiveObjects, ActiveTextureMap);
DrawPlane(1, Color.Black, true);
GL.PopMatrix();
}
private void DrawTexturedPlane(float scale)
private void DrawPlane(float scale, Color color, bool Outlines = false)
{
Vector2 scaleCenter = new Vector2(0.5f, 0.5f);
color = Color.FromArgb(
(byte)(color.R * Brightness),
(byte)(color.G * Brightness),
(byte)(color.B * Brightness));
Vector2[] TexCoords = new Vector2[] {
new Vector2(1,1),
new Vector2(0,1),
new Vector2(0,0),
new Vector2(1,0),
};
Vector2[] Positions = new Vector2[] {
new Vector2(1,-1),
new Vector2(-1,-1),
@ -49,149 +141,44 @@ namespace Toolbox.Library.Forms
Positions[2] = Positions[2] * scale;
Positions[3] = Positions[3] * scale;
GL.Begin(PrimitiveType.Quads);
GL.Color3(Brightness, Brightness, Brightness);
GL.TexCoord2(TexCoords[0]);
GL.Vertex2(Positions[0]);
GL.TexCoord2(TexCoords[1]);
GL.Vertex2(Positions[1]);
GL.TexCoord2(TexCoords[2]);
GL.Vertex2(Positions[2]);
GL.TexCoord2(TexCoords[3]);
GL.Vertex2(Positions[3]);
GL.End();
}
public void DrawUVs(List<STGenericObject> genericObjects)
{
if (genericObjects.Count == 0) return;
foreach (var genericObject in genericObjects)
if (Outlines)
{
int divisions = 4;
int lineWidth = 1;
Color uvColor = Color.LightGreen;
Color gridColor = Color.Black;
List<int> f = new List<int>();
int displayFaceSize = 0;
if (genericObject.lodMeshes.Count > 0)
{
f = genericObject.lodMeshes[0].getDisplayFace();
displayFaceSize = genericObject.lodMeshes[0].displayFaceSize;
}
if (genericObject.PolygonGroups.Count > 0)
{
foreach (var group in genericObject.PolygonGroups)
{
f.AddRange(genericObject.PolygonGroups[0].GetDisplayFace());
displayFaceSize += genericObject.PolygonGroups[0].displayFaceSize;
}
}
for (int v = 0; v < displayFaceSize; v += 3)
{
if (displayFaceSize < 3 || genericObject.vertices.Count < 3)
return;
Vector2 v1 = new Vector2(0);
Vector2 v2 = new Vector2(0);
Vector2 v3 = new Vector2(0);
if (f.Count < v + 2)
continue;
if (UvChannelIndex == 0)
{
v1 = genericObject.vertices[f[v]].uv0;
v2 = genericObject.vertices[f[v + 1]].uv0;
v3 = genericObject.vertices[f[v + 2]].uv0;
}
if (UvChannelIndex == 1)
{
v1 = genericObject.vertices[f[v]].uv1;
v2 = genericObject.vertices[f[v + 1]].uv1;
v3 = genericObject.vertices[f[v + 2]].uv1;
}
if (UvChannelIndex == 2)
{
v1 = genericObject.vertices[f[v]].uv2;
v2 = genericObject.vertices[f[v + 1]].uv2;
v3 = genericObject.vertices[f[v + 2]].uv2;
}
v1 = new Vector2(v1.X, 1 - v1.Y);
v2 = new Vector2(v2.X, 1 - v2.Y);
v3 = new Vector2(v3.X, 1 - v3.Y);
DrawUVTriangleAndGrid(v1, v2, v3, divisions, uvColor, lineWidth, gridColor);
}
}
}
private void DrawUVTriangleAndGrid(Vector2 v1, Vector2 v2, Vector2 v3, int divisions,
Color uvColor, int lineWidth, Color gridColor)
{
GL.UseProgram(0);
float bounds = 1;
Vector2 scaleUv = new Vector2(2);
Vector2 transUv = new Vector2(1f);
//Disable textures so they don't affect color
GL.Disable(EnableCap.Texture2D);
DrawUvTriangle(v1, v2, v3, uvColor, scaleUv, transUv);
// Draw Grid
GL.Color3(gridColor);
// DrawHorizontalGrid(divisions, bounds, scaleUv);
// DrawVerticalGrid(divisions, bounds, scaleUv);
}
private static void DrawUvTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color uvColor, Vector2 scaleUv, Vector2 transUv)
{
GL.Color3(uvColor);
GL.Begin(PrimitiveType.Lines);
GL.LineWidth(3);
GL.Vertex2(v1 * scaleUv + transUv);
GL.Vertex2(v2 * scaleUv + transUv);
GL.End();
GL.Begin(PrimitiveType.Lines);
GL.LineWidth(3);
GL.Vertex2(v2 * scaleUv + transUv);
GL.Vertex2(v3 * scaleUv + transUv);
GL.End();
GL.Begin(PrimitiveType.Lines);
GL.LineWidth(3);
GL.Vertex2(v3 * scaleUv + transUv);
GL.Vertex2(v1 * scaleUv + transUv);
GL.End();
}
private static void DrawVerticalGrid(int divisions, float bounds, Vector2 scaleUv)
{
int verticalCount = divisions;
for (int i = 0; i < verticalCount * bounds; i++)
{
GL.Begin(PrimitiveType.Lines);
GL.Vertex2(new Vector2((1.0f / verticalCount) * i, -bounds) * scaleUv);
GL.Vertex2(new Vector2((1.0f / verticalCount) * i, bounds) * scaleUv);
GL.LineWidth(1);
GL.Begin(PrimitiveType.LineLoop);
GL.Color3(color);
GL.Vertex2(Positions[0]);
GL.Vertex2(Positions[1]);
GL.Vertex2(Positions[2]);
GL.Vertex2(Positions[3]);
GL.End();
}
}
private static void DrawHorizontalGrid(int divisions, float bounds, Vector2 scaleUv)
{
int horizontalCount = divisions;
for (int i = 0; i < horizontalCount * bounds; i++)
else
{
GL.Begin(PrimitiveType.Lines);
GL.Vertex2(new Vector2(-bounds, (1.0f / horizontalCount) * i) * scaleUv);
GL.Vertex2(new Vector2(bounds, (1.0f / horizontalCount) * i) * scaleUv);
GL.Begin(PrimitiveType.Quads);
GL.Color3(color);
GL.TexCoord2(TexCoords[0]);
GL.Vertex2(Positions[0]);
GL.TexCoord2(TexCoords[1]);
GL.Vertex2(Positions[1]);
GL.TexCoord2(TexCoords[2]);
GL.Vertex2(Positions[2]);
GL.TexCoord2(TexCoords[3]);
GL.Vertex2(Positions[3]);
GL.End();
}
}
private void InitializeComponent()
{
this.SuspendLayout();
//
// UVViewport
//
this.Name = "UVViewport";
this.ResumeLayout(false);
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -278,7 +278,15 @@ namespace Toolbox.Library
if (vertices.Count < 3)
return;
List<int> f = lodMeshes[DisplayLODIndex].getDisplayFace();
List<int> f = new List<int>();
if (lodMeshes.Count > 0)
f = lodMeshes[DisplayLODIndex].getDisplayFace();
if (PolygonGroups.Count > 0)
{
foreach (var group in PolygonGroups)
f.AddRange(group.GetDisplayFace());
}
Vector3[] tanArray = new Vector3[vertices.Count];
Vector3[] bitanArray = new Vector3[vertices.Count];

View File

@ -18,6 +18,8 @@ namespace Toolbox.Library
public class STGenericPolygonGroup
{
public virtual STGenericMaterial Material { get; set; }
public int Offset { get; set; }
public int MaterialIndex { get; set; }
public int Index { get; set; }

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenTK.Graphics.OpenGL;
using OpenTK;
namespace Toolbox.Library
{
@ -29,6 +30,13 @@ namespace Toolbox.Library
NearestMipmapNearest,
}
public class STTextureTransform
{
public Vector2 Scale { get; set; }
public float Rotate { get; set; }
public Vector2 Translate { get; set; }
}
public class STGenericMatTexture
{
public int mapMode = 0;
@ -65,6 +73,8 @@ namespace Toolbox.Library
return null;
}
public virtual STTextureTransform Transform { get; set; }
public TextureType Type;
//An enum for the assumed texture type by sampler

View File

@ -29,6 +29,14 @@ namespace Toolbox.Library.IO
{
}
public void WriteHalfFloat(float v) {
Write((Syroot.IOExtension.Half)v);
}
public void Write(Syroot.IOExtension.Half v) {
Write(v.Raw);
}
public void Write(Syroot.Maths.Vector2F v)
{
Write(v.X);

View File

@ -0,0 +1,217 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Windows.Forms;
using Newtonsoft.Json;
namespace Toolbox.Library.IO
{
//Ported from https://github.com/kwsch/pkNX/blob/58b0597feaf53b35f5c4424e5ec357f82d99c9fa/pkNX.WinForms/Dumping/FlatBufferConverter.cs
//While i could use flat buffer c# generated code, it's a giant mess code wise
public static class FlatBufferConverter
{
static FlatBufferConverter()
{
if (!Directory.Exists(FlatPath))
return;
var files = Directory.GetFiles(FlatPath);
foreach (var f in files)
File.Delete(f);
}
public static string DeserializeToJson(Stream stream, string fbs)
{
var path = Path.GetTempFileName();
stream.ExportToFile(path);
return DeserializeToJson(path, fbs);
}
public static string DeserializeToJson(string path, string fbs)
{
GenerateJsonFromFile(path, fbs);
var text = ReadDeleteJsonFromFolder();
File.Delete(path);
return text;
}
public static T[] DeserializeFrom<T>(string[] files, string fbs)
{
var result = new T[files.Length];
for (int i = 0; i < result.Length; i++)
{
var file = files[i];
result[i] = DeserializeFrom<T>(file, fbs);
}
return result;
}
public static T DeserializeFrom<T>(Stream stream, string fbs)
{
var path = Path.GetTempFileName();
stream.ExportToFile(path);
var ret = DeserializeFrom<T>(path, fbs);
File.Delete(path);
return ret;
}
public static T DeserializeFrom<T>(string file, string fbs)
{
GenerateJsonFromFile(file, fbs);
var text = ReadDeleteJsonFromFolder();
var obj = JsonConvert.DeserializeObject<T>(text);
Debug.Assert(obj != null);
Debug.WriteLine($"Deserialized {Path.GetFileName(file)}");
return obj;
}
public static byte[][] SerializeFrom<T>(T[] obj, string fbs)
{
var result = new byte[obj.Length][];
for (int i = 0; i < result.Length; i++)
{
var file = obj[i];
result[i] = SerializeFrom(file, fbs);
}
return result;
}
public static byte[] SerializeFrom<T>(T obj, string fbs)
{
string log = GenerateBinFrom(obj, fbs);
var fileName = fbs + ".bin";
var data = ReadDelete(fileName);
Debug.Assert(data.Length != 0);
Debug.WriteLine($"Serialized to {fileName}");
return data;
}
private static string ReadDeleteJsonFromFolder()
{
var jsonPath = Directory.GetFiles(FlatPath, "*.json")[0];
var text = File.ReadAllText(jsonPath);
File.Delete(jsonPath);
return text;
}
private static byte[] ReadDelete(string fileName)
{
var filePath = Path.Combine(FlatPath, fileName);
if (!System.IO.File.Exists(filePath))
throw new Exception($"Failed to save binary. {log}");
var data = File.ReadAllBytes(filePath);
File.Delete(filePath);
return data;
}
private static void GenerateJsonFromFile(string file, string fbs)
{
var fbsName = fbs + ".fbs";
var fbsPath = Path.Combine(FlatPath, fbsName);
Directory.CreateDirectory(FlatPath);
if (!File.Exists(fbsPath))
File.WriteAllBytes(fbsPath, GetSchema(fbs));
var fileName = Path.GetFileName(file);
var filePath = Path.Combine(FlatPath, fileName);
File.Copy(file, filePath, true);
var args = GetArgumentsDeserialize(fileName, fbsName);
RunFlatC(args);
File.Delete(filePath);
}
private static string GenerateBinFrom<T>(T obj, string fbs)
{
var fbsName = fbs + ".fbs";
var jsonName = fbs + ".json";
var text = WriteJson(obj);
var jsonPath = Path.Combine(FlatPath, jsonName);
File.WriteAllText(jsonPath, text);
var args = GetArgumentsSerialize(jsonName, fbsName);
return RunFlatC(args);
}
public static string WriteJson<T>(T obj)
{
var serializer = new JsonSerializer();
using (var stringWriter = new StringWriter())
{
using (var writer = new JsonTextWriter(stringWriter)
{
QuoteName = false,
Formatting = Formatting.Indented,
IndentChar = ' ',
Indentation = 2
})
serializer.Serialize(writer, obj);
return stringWriter.ToString();
}
}
private static string log = "";
private static string RunFlatC(string args)
{
var fcp = Path.Combine(FlatPath, "flatc.exe");
if (!File.Exists(fcp))
File.WriteAllBytes(fcp, Properties.Resources.flatc);
var process = new Process
{
StartInfo = new ProcessStartInfo
{
WorkingDirectory = FlatPath,
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
FileName = "cmd.exe",
Arguments = $"/C flatc {args} & exit",
}
};
process.EnableRaisingEvents = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
process.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(process_OutputDataReceived);
process.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(process_ErrorDataReceived);
process.StartInfo.UseShellExecute = false;
process.Start();
process.BeginErrorReadLine();
process.BeginOutputReadLine();
process.WaitForExit();
return log;
}
private static void process_ErrorDataReceived(object sender, DataReceivedEventArgs e) {
if (e.Data != null) log = e.Data;
}
private static void process_OutputDataReceived(object sender, DataReceivedEventArgs e) {
if (e.Data != null) log = e.Data;
}
public static byte[] GetSchema(string name)
{
var obj = Properties.Resources.ResourceManager.GetObject(name);
if (!(obj is byte[] b))
throw new FileNotFoundException(nameof(name));
return b;
}
public static readonly string WorkingDirectory = Application.StartupPath;
public static readonly string FlatPath = Path.Combine(WorkingDirectory, "flatbuffers");
private static string GetArgumentsDeserialize(string file, string fbs) =>
$"-t {fbs} -- {file} --defaults-json --raw-binary";
private static string GetArgumentsSerialize(string file, string fbs) =>
$"-b {fbs} {file} --defaults-json";
}
}

View File

@ -27,7 +27,9 @@ namespace Toolbox.Library.IO
Cursor.Current = Cursors.WaitCursor;
FileFormat.FilePath = FileName;
if (FileFormat.IFileInfo.FileIsCompressed || FileFormat.IFileInfo.InArchive || Path.GetExtension(FileName) == ".szs")
string compressionLog = "";
if (FileFormat.IFileInfo.FileIsCompressed || FileFormat.IFileInfo.InArchive
|| Path.GetExtension(FileName) == ".szs" || Path.GetExtension(FileName) == ".sbfres")
{
//Todo find more optmial way to handle memory with files in archives
//Also make compression require streams
@ -45,16 +47,19 @@ namespace Toolbox.Library.IO
FileName,
EnableDialog);
FileFormat.IFileInfo.CompressedSize = (uint)finalStream.Length;
finalStream.ExportToFile(FileName);
compressionLog = finalStream.Item2;
Stream compressionStream = finalStream.Item1;
DetailsLog += "\n" + SatisfyFileTables(FileFormat, FileName, finalStream,
FileFormat.IFileInfo.CompressedSize = (uint)compressionStream.Length;
compressionStream.ExportToFile(FileName);
DetailsLog += "\n" + SatisfyFileTables(FileFormat, FileName, compressionStream,
FileFormat.IFileInfo.DecompressedSize,
FileFormat.IFileInfo.CompressedSize,
FileFormat.IFileInfo.FileIsCompressed);
finalStream.Flush();
finalStream.Close();
compressionStream.Flush();
compressionStream.Close();
}
else
{
@ -85,7 +90,10 @@ namespace Toolbox.Library.IO
}
}
MessageBox.Show($"File has been saved to {FileName}", "Save Notification");
if (compressionLog != string.Empty)
MessageBox.Show($"File has been saved to {FileName}. Compressed time: {compressionLog}", "Save Notification");
else
MessageBox.Show($"File has been saved to {FileName}", "Save Notification");
// STSaveLogDialog.Show($"File has been saved to {FileName}", "Save Notification", DetailsLog);
Cursor.Current = Cursors.Default;
@ -219,7 +227,10 @@ namespace Toolbox.Library.IO
uint DecompressedSize = (uint)data.Length;
Cursor.Current = Cursors.WaitCursor;
Stream FinalData = CompressFileFormat(CompressionFormat, new MemoryStream(data), FileIsCompressed, Alignment, FileName, EnableDialog);
var compressedData = CompressFileFormat(CompressionFormat, new MemoryStream(data), FileIsCompressed, Alignment, FileName, EnableDialog);
string compressionLog = compressedData.Item2;
Stream FinalData = compressedData.Item1;
FinalData.ExportToFile(FileName);
uint CompressedSize = (uint)FinalData.Length;
@ -268,7 +279,7 @@ namespace Toolbox.Library.IO
}
}
private static Stream CompressFileFormat(ICompressionFormat compressionFormat, Stream data, bool FileIsCompressed, int Alignment,
private static Tuple<Stream, string> CompressFileFormat(ICompressionFormat compressionFormat, Stream data, bool FileIsCompressed, int Alignment,
string FileName, bool EnableDialog = true)
{
string extension = Path.GetExtension(FileName);
@ -280,7 +291,7 @@ namespace Toolbox.Library.IO
}
if (compressionFormat == null)
return data;
return Tuple.Create(data, "");
bool CompressFile = false;
if (EnableDialog && FileIsCompressed)
@ -303,10 +314,18 @@ namespace Toolbox.Library.IO
if (compressionFormat is Yaz0)
((Yaz0)compressionFormat).Alignment = Alignment;
return compressionFormat.Compress(data);
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
var comp = compressionFormat.Compress(data);
sw.Stop();
TimeSpan ts = sw.Elapsed;
string message = string.Format("{0:D2}:{1:D2}:{2:D2}", ts.Minutes, ts.Seconds, ts.Milliseconds);
Console.WriteLine($"Compression Time : {message}");
return Tuple.Create(comp, message);
}
return data;
return Tuple.Create(data, "");
}
}

View File

@ -191,7 +191,7 @@ namespace Syroot.IOExtension
/// Gets the internally stored value to represent the instance.
/// </summary>
/// <remarks>Signed to get arithmetic rather than logical shifts.</remarks>
internal ushort Raw { get; private set; }
public ushort Raw { get; private set; }
// ---- OPERATORS ----------------------------------------------------------------------------------------------

View File

@ -41,7 +41,7 @@ namespace Toolbox.Library.Forms
}
private GLControl glControl1;
private Color BackgroundColor = Color.FromArgb(40, 40, 40);
public Color BackgroundColor = Color.FromArgb(40, 40, 40);
private List<IPickable2DObject> SelectedObjects = new List<IPickable2DObject>();
@ -64,6 +64,9 @@ namespace Toolbox.Library.Forms
public void UpdateViewport() {
if (!Runtime.OpenTKInitialized)
return;
glControl1.Invalidate();
}
@ -157,6 +160,8 @@ namespace Toolbox.Library.Forms
if (showSelectionBox)
{
GL.PushAttrib(AttribMask.DepthBufferBit);
GL.Disable(EnableCap.DepthTest);
GL.Begin(PrimitiveType.LineLoop);
GL.Color4(Color.Red);
@ -166,6 +171,8 @@ namespace Toolbox.Library.Forms
GL.Vertex2(SelectionBox.LeftPoint, SelectionBox.TopPoint);
GL.End();
GL.Enable(EnableCap.DepthTest);
GL.PopAttrib();
}
if (UseOrtho)
@ -202,7 +209,7 @@ namespace Toolbox.Library.Forms
showSelectionBox = true;
SelectionBox = new STRectangle(left, right, top, bottom);
SetupScene();
UpdateViewport();
}
public virtual void RenderSceme()
@ -389,10 +396,13 @@ namespace Toolbox.Library.Forms
if (mouseDown && !isPicked)
{
RenderEditor();
var temp = e.Location;
var curPos = OpenGLHelper.convertScreenToWorldCoords(temp.X, temp.Y);
var prevPos = OpenGLHelper.convertScreenToWorldCoords(pickOriginMouse.X, pickOriginMouse.Y);
GL.PopMatrix();
DrawSelectionBox(prevPos, curPos);
}
}

View File

@ -450,6 +450,16 @@ namespace Toolbox.Library.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
public static byte[] flatc {
get {
object obj = ResourceManager.GetObject("flatc", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
@ -470,6 +480,26 @@ namespace Toolbox.Library.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
public static byte[] gfbanm {
get {
object obj = ResourceManager.GetObject("gfbanm", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
public static byte[] gfbmdl {
get {
object obj = ResourceManager.GetObject("gfbmdl", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@ -418,4 +418,13 @@
<data name="MissingTexture" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\MissingTexture.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="flatc" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\flatc.exe;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="gfbmdl" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\FlatBuffers\gfbmdl.fbs;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="gfbanm" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\FlatBuffers\gfbanm.fbs;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>

View File

@ -23,15 +23,21 @@ namespace Toolbox.Library.Rendering
public Vector3 pos = new Vector3(0);
public Vector3 nrm = new Vector3(0);
public Vector4 col = new Vector4(1);
public Vector4 col2 = new Vector4(1);
public Vector2 uv0 = new Vector2(0);
public Vector2 uv1 = new Vector2(0);
public Vector2 uv2 = new Vector2(0);
public Vector2 uv3 = new Vector2(0);
public Vector4 tan = new Vector4(0);
public Vector4 bitan = new Vector4(0);
public List<int> boneIds = new List<int>();
public List<float> boneWeights = new List<float>();
public float normalW;
public List<string> boneNames = new List<string>();
public List<Bone> boneList = new List<Bone>();
@ -49,5 +55,7 @@ namespace Toolbox.Library.Rendering
//For vertex morphing
public Vector3 pos1 = new Vector3();
public Vector3 pos2 = new Vector3();
public List<Vector4> Unknowns = new List<Vector4>();
}
}

View File

@ -0,0 +1,210 @@
namespace Gfbanim;
union TriggerParams {
TriggerParameterInt , TriggerParameterFloat,
TriggerParameterByte, TriggerParameterString
}
union VectorTrack { FixedVectorTrack, DynamicVectorTrack, FramedVectorTrack }
union RotationTrack { FixedRotationTrack, DynamicRotationTrack, FramedRotationTrack }
union BooleanTrack { FixedBooleanTrack, DynamicBooleanTrack, FramedBooleanTrack }
union ValueTrack { FixedValueTrack, DynamicValueTrack, FramedValueTrack }
enum RotationFlags:ushort (bit_flags) {
Orientation = 0,
Data1,
Data2 = 3,
}
table Animation {
AnimConfig:Config;
Bones:BoneList;
Materials:MaterialList;
Groups:GroupList;
Triggers:TriggerList;
}
table TriggerList {
Triggers:[Trigger];
}
table Trigger {
Name:string;
FrameStart:int;
FrameEnd:int;
Parameter:TriggerParameter;
}
table TriggerParameter {
Name:string;
Params:TriggerParams;
}
table TriggerParameterInt {
Value:int;
}
table TriggerParameterFloat {
Value:float;
}
table TriggerParameterByte {
Value:byte;
}
table TriggerParameterString {
Value:string;
}
table BoneList {
Bones:[Bone];
Defaults:BoneDefaults;
}
table MaterialList {
Materials:[Material];
}
table GroupList {
Groups:[Group];
}
table Bone {
Name:string;
Scale:VectorTrack;
Rotate:RotationTrack;
Translate:VectorTrack;
ScaleFrames:FrameRanges;
RotationFrames:FrameRanges;
TranslationFrames:FrameRanges;
}
table BoneDefaults {
Unknown:uint;
Transform:[SRT];
}
table Material {
Name:string;
Switches:[MatSwitch];
Values:[MatValue];
Vectors:[MatVector];
}
table MatSwitch {
Name:string;
Value:BooleanTrack;
frameRanges:FrameRanges;
}
table MatValue {
Name:string;
Value:ValueTrack;
frameRanges:FrameRanges;
}
table MatVector {
Name:string;
Value:VectorTrack;
frameRanges:FrameRanges;
}
table Group {
Name:string;
Value:BooleanTrack;
}
table Config {
Unknown:uint;
KeyFrames:uint;
FramesPerSecond:uint;
}
table FixedVectorTrack {
Value:Vector3;
}
table DynamicVectorTrack {
Values:[Vector3];
}
table FramedVectorTrack {
Frames:[ushort];
Values:[Vector3];
}
table FixedRotationTrack {
Value:Rotation;
}
table DynamicRotationTrack {
Values:[Rotation];
}
table FramedRotationTrack {
Frames:[ushort];
Values:[Rotation];
}
table FixedBooleanTrack {
Value:byte;
}
table DynamicBooleanTrack {
Values:[ushort];
}
table FramedBooleanTrack {
Frames:[ushort];
Values:[ushort];
}
table FixedValueTrack {
Value:float;
}
table DynamicValueTrack {
Values:[float];
}
table FramedValueTrack {
Frames:[ushort];
Values:[float];
}
table FrameRanges {
StartFrames:[ushort];
EndFrames:[ushort];
}
struct Vector3 {
X:float;
Y:float;
Z:float;
}
struct Vector4 {
X:float;
Y:float;
Z:float;
W:float;
}
struct Rotation {
X:ushort;
Y:ushort;
Z:ushort;
}
struct SRT {
ScaleX:float;
ScaleY:float;
ScaleZ:float;
RotateX:float;
RotateY:float;
RotateZ:float;
RotateW:float;
TranslateX:float;
TranslateY:float;
TranslateZ:float;
}
root_type Animation;

View File

@ -0,0 +1,196 @@
namespace Gfbmdl;
enum BoneType : uint {
NoSkinning = 0,
HasSkinning = 1,
}
enum VertexType : uint {
Position = 0,
Normal = 1,
Binormal = 2,
UV1 = 3,
UV2 = 4,
UV3 = 5,
UV4 = 6,
Color1 = 7,
Color2 = 8,
Color3 = 9,
Color4 = 10,
BoneID = 11,
BoneWeight = 12,
}
enum BufferFormat : uint {
Float = 0,
HalfFloat = 1,
Byte = 3,
Short = 5,
BytesAsFloat = 8,
}
table Model {
Version:uint;
Bounding:BoundingBox;
TextureNames:[string];
ShaderNames:[string];
Unknown:[UnknownEmpty];
MaterialNames:[string];
Materials:[Material];
Groups:[Group];
Meshes:[Mesh];
Bones:[Bone];
CollisionGroups:[CollisionGroup];
}
table UnknownEmpty {
unk:uint;
}
table Material {
Name:string;
ShaderGroup:string;
RenderLayer:int;
Unknown1:ubyte;
Unknown2:ubyte;
Parameter1:int;
Parameter2:int;
Parameter3:int;
Parameter4:int;
Parameter5:int;
Parameter6:int;
TextureMaps:[TextureMap];
Switches:[MatSwitch];
Values:[MatFloat];
Colors:[MatColor];
Unknown3:ubyte;
Unknown4:ubyte;
Unknown5:ubyte;
Unknown6:ubyte;
Unknown7:ubyte;
Common:MaterialCommon;
}
table MaterialCommon {
Switches:[MatSwitch];
Values:[MatInt];
Colors:[MatColor];
}
table MatSwitch {
Name:string;
Value:bool;
}
table MatColor {
Name:string;
Color:ColorRGB32;
}
table MatInt {
Name:string;
Value:int;
}
table MatFloat {
Name:string;
Value:float;
}
table TextureMap {
Sampler:string;
Index:int;
Params:TextureMapping;
}
table TextureMapping {
Unknown1:uint;
Unknown2:uint;
Unknown3:uint;
Unknown4:uint;
Unknown5:uint;
Unknown6:uint;
Unknown7:uint;
Unknown8:uint;
lodBias:float;
}
table Group {
BoneIndex:uint;
MeshIndex:uint;
Bounding:BoundingBox;
Layer:uint;
}
table Mesh {
Polygons:[MeshPolygon];
Attributes:[MeshAttribute];
Data:[ubyte];
}
table MeshPolygon {
MaterialIndex:uint;
Faces:[ushort];
}
table MeshAttribute {
VertexType:uint;
BufferFormat:uint;
ElementCount:uint;
}
table Bone {
Name:string;
BoneType:uint;
Parent:int;
Zero:uint = 0;
Visible:bool;
Scale:Vector3;
Rotation:Vector3;
Translation:Vector3;
RadiusStart:Vector3;
RadiusEnd:Vector3;
RigidCheck:BoneRigidData;
}
struct BoneRigidData {
Unknown1:byte;
}
table CollisionGroup {
BoneIndex:uint;
Unknown1:uint;
BoneChildren:[uint];
Bounding:BoundingBox;
}
struct BoundingBox {
MinX:float;
MinY:float;
MinZ:float;
MaxX:float;
MaxY:float;
MaxZ:float;
}
struct Vector3 {
X:float;
Y:float;
Z:float;
}
struct ColorRGB32 {
R:float;
G:float;
B:float;
}
struct Vector4 {
X:float;
Y:float;
Z:float;
W:float;
}
root_type Model;

Binary file not shown.

View File

@ -20,7 +20,7 @@ namespace Toolbox.Library
public static bool EnableDragDrop = true;
public static bool UseSingleInstance = true;
public static bool UseSingleInstance = false;
public static bool UseDirectXTexDecoder = true;
public static bool DEVELOPER_DEBUG_MODE = false;
public static bool AlwaysCompressOnSave = false;
@ -38,6 +38,11 @@ namespace Toolbox.Library
public static string TpGamePath = "";
public static string BotwGamePath = "";
public class UVEditor
{
public static Color UVColor = Color.FromArgb(255, 128, 0);
}
public class SwitchKeys
{
public static string SwitchFolder = System.IO.Path.Combine(Environment.GetFolderPath(

View File

@ -99,6 +99,10 @@
<Private>False</Private>
</Reference>
<Reference Include="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Toolbox\Lib\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="ObjectListView">
<HintPath>..\Toolbox\Lib\ObjectListView.dll</HintPath>
<Private>False</Private>
@ -345,12 +349,7 @@
<DependentUpon>GenericTextureImporterList.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Editors\TextureImport\GenericTextureImporterSettings.cs" />
<Compile Include="Forms\Editors\UV\UVEditorAdvanced.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Forms\Editors\UV\UVEditorAdvanced.Designer.cs">
<DependentUpon>UVEditorAdvanced.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Editors\UV\PickableUVMap.cs" />
<Compile Include="Forms\Editors\UV\UVEditorForm.cs">
<SubType>Form</SubType>
</Compile>
@ -403,6 +402,7 @@
<Compile Include="IO\Extensions\StreamExport.cs" />
<Compile Include="IO\Extensions\UintExtension.cs" />
<Compile Include="IO\FileStreamStorage.cs" />
<Compile Include="IO\FlatBuffer\FlatBufferConverter.cs" />
<Compile Include="IO\FlatBuffer\FlatBufferParse.cs" />
<Compile Include="IO\HSVPixel.cs" />
<Compile Include="IO\IOComoon.cs" />
@ -684,12 +684,6 @@
<Compile Include="Forms\Animation\TimeLine.Designer.cs">
<DependentUpon>TimeLine.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Editors\UV\UVEditor2.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Forms\Editors\UV\UVEditor2.Designer.cs">
<DependentUpon>UVEditor2.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Extensions\MDICustom.cs" />
<Compile Include="Forms\Editors\Object Editor\ObjectEditor.cs">
<SubType>Form</SubType>
@ -1137,15 +1131,12 @@
<EmbeddedResource Include="Forms\Editors\UV\UVEditor.resx">
<DependentUpon>UVEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Editors\UV\UVEditor2.resx">
<DependentUpon>UVEditor2.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Editors\UV\UVEditorAdvanced.resx">
<DependentUpon>UVEditorAdvanced.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Editors\UV\UVEditorForm.resx">
<DependentUpon>UVEditorForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Editors\UV\UVViewport.resx">
<DependentUpon>UVViewport.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\SizeTables\FileTableViewTPHD.resx">
<DependentUpon>FileTableViewTPHD.cs</DependentUpon>
</EmbeddedResource>
@ -1216,6 +1207,8 @@
<None Include="Resources\FileBank.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\FlatBuffers\gfbanm.fbs" />
<None Include="Resources\FlatBuffers\gfbmdl.fbs" />
<None Include="Resources\Folder.png" />
</ItemGroup>
<ItemGroup>
@ -1519,6 +1512,9 @@
<ItemGroup>
<None Include="Resources\MissingTexture.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\flatc.exe" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>

BIN
Toolbox/Lib/yaz0.dll Normal file

Binary file not shown.

View File

@ -18,7 +18,6 @@ uniform mat4 mtxCam;
uniform mat4 mtxMdl;
uniform vec3 specLightDirection;
uniform vec3 difLightDirection;
uniform mat4 projMatrix;
uniform mat4 normalMatrix;
uniform mat4 modelViewMatrix;

View File

@ -124,6 +124,7 @@ void main()
f_texcoord1 = vUV1;
f_texcoord2 = vUV2;
tangent = vTangent;
binormal = vBinormal;
gl_Position = position;

View File

@ -115,22 +115,21 @@ void main()
vec4 objPos = vec4(vPosition.xyz, 1.0);
if (vBone.x != -1.0)
objPos = skin(vPosition, index);
objPos = skin(objPos.xyz, index);
if(vBone.x != -1.0)
normal = normalize((skinNRM(vNormal.xyz, index)).xyz);
vec4 position = mtxCam * mtxMdl * vec4(objPos.xyz, 1.0);
objPos = mtxMdl * vec4(objPos.xyz, 1.0);
vec4 position = mtxCam * objPos;
normal = vNormal;
vertexColor = vColor;
position = objPos;
f_texcoord0 = vUV0;
f_texcoord1 = vUV1;
f_texcoord2 = vUV2;
tangent = vTangent;
position = mtxCam * mtxMdl * vec4(vPosition.xyz, 1.0);
f_texcoord0.x *= ColorUVScaleU + ColorUVTranslateU;
f_texcoord0.y *= ColorUVScaleV + ColorUVTranslateV;

View File

@ -539,6 +539,9 @@
<Content Include="Lib\WeifenLuo.WinFormsUI.Docking.ThemeVS2015.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Lib\Yaz0.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="LZ4.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>