Apply the kcl viewport to work better with bfres
This commit is contained in:
parent
29e9a0533d
commit
240cc5f0b3
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1090,10 +1090,8 @@ namespace Bfres.Structs
|
||||
if (VertexSkinCount == 1 && vtx.boneIds.Count > 0)
|
||||
boneId = vtx.boneIds[0];
|
||||
|
||||
Console.WriteLine("Old " + vtx.pos);
|
||||
vtx.pos = TransformLocal(vtx.pos, boneId, VertexSkinCount == 1);
|
||||
vtx.nrm = TransformLocal(vtx.nrm, boneId, VertexSkinCount == 1, false);
|
||||
Console.WriteLine("New " + vtx.pos);
|
||||
// vtx.pos = TransformLocal(vtx.pos, boneId, VertexSkinCount == 1);
|
||||
// vtx.nrm = TransformLocal(vtx.nrm, boneId, VertexSkinCount == 1, false);
|
||||
}
|
||||
//Console.WriteLine($"Weight count {vtx.boneWeights.Count}");
|
||||
//Console.WriteLine($"Index count {vtx.boneIds.Count}");
|
||||
|
@ -296,9 +296,21 @@ namespace FirstPlugin
|
||||
}
|
||||
if (fshp.VertexSkinCount == 0)
|
||||
{
|
||||
Matrix4 NoBindFix = model.Skeleton.bones[fshp.BoneIndex].Transform;
|
||||
v.pos = Vector3.TransformPosition(v.pos, NoBindFix);
|
||||
v.nrm = Vector3.TransformNormal(v.nrm, NoBindFix);
|
||||
try
|
||||
{
|
||||
if (model.Skeleton.bones.Count > 0) {
|
||||
Matrix4 NoBindFix = model.Skeleton.bones[fshp.BoneIndex].Transform;
|
||||
v.pos = Vector3.TransformPosition(v.pos, NoBindFix);
|
||||
v.nrm = Vector3.TransformNormal(v.nrm, NoBindFix);
|
||||
}
|
||||
}
|
||||
catch //Matrix failed. Print the coordinate data of the bone
|
||||
{
|
||||
Console.WriteLine(model.Skeleton.bones[fshp.BoneIndex].Text);
|
||||
Console.WriteLine(model.Skeleton.bones[fshp.BoneIndex].GetPosition());
|
||||
Console.WriteLine(model.Skeleton.bones[fshp.BoneIndex].GetRotation());
|
||||
Console.WriteLine(model.Skeleton.bones[fshp.BoneIndex].GetScale());
|
||||
}
|
||||
}
|
||||
fshp.vertices.Add(v);
|
||||
}
|
||||
|
@ -263,24 +263,38 @@ namespace FirstPlugin
|
||||
}
|
||||
}
|
||||
|
||||
Viewport viewport
|
||||
{
|
||||
get
|
||||
{
|
||||
var editor = LibraryGUI.Instance.GetObjectEditor();
|
||||
return editor.GetViewport();
|
||||
}
|
||||
set
|
||||
{
|
||||
var editor = LibraryGUI.Instance.GetObjectEditor();
|
||||
editor.LoadViewport(value);
|
||||
}
|
||||
}
|
||||
|
||||
public KCLRendering Renderer;
|
||||
bool IsLoaded = false;
|
||||
public override void OnClick(TreeView treeView)
|
||||
{
|
||||
Viewport editor = (Viewport)LibraryGUI.Instance.GetActiveContent(typeof(Viewport));
|
||||
|
||||
if (editor == null)
|
||||
if (viewport == null)
|
||||
{
|
||||
editor = new Viewport();
|
||||
LibraryGUI.Instance.LoadEditor(editor);
|
||||
viewport.Dock = DockStyle.Fill;
|
||||
viewport.AddDrawable(Renderer);
|
||||
viewport.LoadObjects();
|
||||
LibraryGUI.Instance.LoadEditor(viewport);
|
||||
}
|
||||
editor.Text = Text;
|
||||
editor.Dock = DockStyle.Fill;
|
||||
|
||||
viewport.Text = Text;
|
||||
|
||||
if (!IsLoaded)
|
||||
{
|
||||
editor.AddDrawable(Renderer);
|
||||
editor.LoadObjects();
|
||||
viewport.AddDrawable(Renderer);
|
||||
viewport.LoadObjects();
|
||||
}
|
||||
|
||||
IsLoaded = true;
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -146,7 +146,6 @@ namespace Switch_Toolbox.Library
|
||||
for (int i = 0; i < _meshChannels.Length; i++)
|
||||
{
|
||||
_meshChannels[i] = new MeshAnimationChannel();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -454,7 +453,6 @@ namespace Switch_Toolbox.Library
|
||||
{
|
||||
foreach (VertexWeight w in bn.VertexWeights)
|
||||
{
|
||||
// vertices[w.VertexID].pos = Vector3.TransformPosition(vertices[w.VertexID].pos, AssimpHelper.TKMatrix(bn.OffsetMatrix));
|
||||
vertices[w.VertexID].boneWeights.Add(w.Weight);
|
||||
vertices[w.VertexID].boneNames.Add(bn.Name);
|
||||
BoneNames.Add(bn.Name);
|
||||
|
@ -158,9 +158,14 @@ namespace Switch_Toolbox.Library
|
||||
|
||||
foreach (var tex in genericMat.TextureMaps)
|
||||
{
|
||||
TextureSlot slot = new TextureSlot();
|
||||
int index = Textures.FindIndex(r => r.Text.Equals(tex.Name));
|
||||
|
||||
string path = System.IO.Path.Combine(TexturePath, tex.Name + TextureExtension);
|
||||
|
||||
if (!File.Exists(path))
|
||||
throw new Exception("Texture not found to map");
|
||||
|
||||
TextureSlot slot = new TextureSlot();
|
||||
slot.FilePath = path;
|
||||
slot.UVIndex = 0;
|
||||
slot.Flags = 0;
|
||||
@ -192,22 +197,22 @@ namespace Switch_Toolbox.Library
|
||||
|
||||
if (tex.wrapModeS == 0)
|
||||
slot.WrapModeU = TextureWrapMode.Wrap;
|
||||
if (tex.wrapModeS == 1)
|
||||
else if (tex.wrapModeS == 1)
|
||||
slot.WrapModeU = TextureWrapMode.Mirror;
|
||||
if (tex.wrapModeS == 2)
|
||||
else if (tex.wrapModeS == 2)
|
||||
slot.WrapModeU = TextureWrapMode.Clamp;
|
||||
else
|
||||
slot.WrapModeU = TextureWrapMode.Wrap;
|
||||
|
||||
if (tex.wrapModeT == 0)
|
||||
slot.WrapModeV = TextureWrapMode.Wrap;
|
||||
if (tex.wrapModeT == 1)
|
||||
else if (tex.wrapModeT == 1)
|
||||
slot.WrapModeV = TextureWrapMode.Mirror;
|
||||
if (tex.wrapModeT == 2)
|
||||
else if (tex.wrapModeT == 2)
|
||||
slot.WrapModeV = TextureWrapMode.Clamp;
|
||||
else
|
||||
{
|
||||
slot.WrapModeU = TextureWrapMode.Wrap;
|
||||
slot.WrapModeV = TextureWrapMode.Wrap;
|
||||
}
|
||||
|
||||
|
||||
material.AddMaterialTexture(ref slot);
|
||||
}
|
||||
scene.Materials.Add(material);
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user