1
0
mirror of synced 2025-01-31 12:23:52 +01:00

Add option to hide specific bones

This commit is contained in:
KillzXGaming 2019-03-28 20:19:13 -04:00
parent 8cc5e13ace
commit a1606187b4
11 changed files with 201 additions and 174 deletions

Binary file not shown.

View File

@ -74,7 +74,6 @@ namespace Bfres.Structs
ContextMenuStrip.Items.Add(new ToolStripSeparator());
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Export Skeleton", null, ExportAction, Keys.Control | Keys.E));
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Replace Skeleton", null, ReplaceAction, Keys.Control | Keys.R));
ContextMenuStrip.Items.Add(new ToolStripSeparator());
}
public override void Replace(string FileName)
@ -225,6 +224,7 @@ namespace Bfres.Structs
{
ImageKey = "bone";
SelectedImageKey = "bone";
Checked = true;
ContextMenuStrip = new STContextMenuStrip();
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Rename", null, RenameAction, Keys.Control | Keys.I));

View File

@ -144,6 +144,8 @@ namespace Switch_Toolbox.Library.Forms
return true;
if (obj is STBone)
return true;
if (obj is STSkeleton)
return true;
if (obj is STGenericMaterial)
return true;
@ -246,14 +248,22 @@ namespace Switch_Toolbox.Library.Forms
}
bool UpdateViewport = false;
bool IsModelChecked = false;
private void treeViewCustom1_AfterCheck(object sender, TreeViewEventArgs e)
{
UpdateViewport = false;
if (e.Node is STGenericModel)
{
IsModelChecked = true;
CheckChildNodes(e.Node, e.Node.Checked);
}
else if (e.Node is STGenericObject && !IsModelChecked) {
UpdateViewport = true;
}
else if (e.Node is STBone && !IsModelChecked) {
UpdateViewport = true;
}
if (UpdateViewport)
LibraryGUI.Instance.UpdateViewport();
@ -277,7 +287,8 @@ namespace Switch_Toolbox.Library.Forms
{
e.DrawDefault = true;
bool IsCheckable = (e.Node is STGenericObject || e.Node is STGenericModel);
bool IsCheckable = (e.Node is STGenericObject || e.Node is STGenericModel
|| e.Node is STBone);
if (!IsCheckable)
TreeViewExtensions.HideCheckBox(e.Node);

View File

@ -0,0 +1,179 @@
using System.Drawing;
using System.Collections.Generic;
using System.Windows.Forms;
using OpenTK;
using OpenTK.Graphics.OpenGL;
namespace Switch_Toolbox.Library
{
public class STBone : TreeNodeCustom
{
private bool visbile = true;
public bool Visible
{
get
{
return visbile;
}
set
{
visbile = value;
}
}
public bool UseSegmentScaleCompensate;
public STSkeleton skeletonParent;
public BoneRotationType RotationType;
public ushort BillboardIndex;
public short RigidMatrixIndex;
public short SmoothMatrixIndex;
public float[] position = new float[] { 0, 0, 0 };
public float[] rotation = new float[] { 0, 0, 0 };
public float[] scale = new float[] { 1, 1, 1 };
public Vector3 pos = Vector3.Zero, sca = new Vector3(1f, 1f, 1f);
public Quaternion rot = Quaternion.FromMatrix(Matrix3.Zero);
public Matrix4 Transform, invert;
public Vector3 GetPosition()
{
return pos;
}
public Quaternion GetRotation()
{
return rot;
}
public Vector3 GetScale()
{
return sca;
}
public int GetIndex()
{
if (skeletonParent != null)
return skeletonParent.bones.IndexOf(this);
else
return -1;
}
public void ConvertToQuaternion()
{
if (RotationType == BoneRotationType.Quaternion)
return;
}
public void ConvertToEular()
{
if (RotationType == BoneRotationType.Euler)
return;
}
public override void OnClick(TreeView treeView)
{
}
public enum BoneRotationType
{
Euler,
Quaternion,
}
public int parentIndex
{
set
{
if (Parent != null) Parent.Nodes.Remove(this);
if (value > -1 && value < skeletonParent.bones.Count)
{
skeletonParent.bones[value].Nodes.Add(this);
}
}
get
{
if (Parent == null || !(Parent is STBone))
return -1;
return skeletonParent.bones.IndexOf((STBone)Parent);
}
}
public List<STBone> GetChildren()
{
List<STBone> l = new List<STBone>();
foreach (STBone b in skeletonParent.bones)
if (b.Parent == this)
l.Add(b);
return l;
}
public STBone(STSkeleton skl)
{
skeletonParent = skl;
ImageKey = "bone";
SelectedImageKey = "bone";
Checked = true;
}
public STBone()
{
ImageKey = "bone";
SelectedImageKey = "bone";
}
public Matrix4 CalculateSmoothMatrix()
{
Matrix4 mat4 = new Matrix4();
return Transform * invert;
}
public Matrix4 CalculateRigidMatrix()
{
Matrix4 mat4 = new Matrix4();
return mat4;
}
public void Render()
{
if (!Runtime.OpenTKInitialized || !Runtime.renderBones)
return;
Vector3 pos_c = Vector3.TransformPosition(Vector3.Zero, Transform);
if (IsSelected)
{
GL.Color3(Color.Red);
}
else
GL.Color3(Color.GreenYellow);
RenderTools.DrawCube(pos_c, 0.1f);
// now draw line between parent
GL.Color3(Color.LightBlue);
GL.LineWidth(2f);
GL.Begin(PrimitiveType.Lines);
if (Parent != null && Parent is STBone)
{
Vector3 pos_p = Vector3.TransformPosition(Vector3.Zero, ((STBone)Parent).Transform);
GL.Vertex3(pos_c);
GL.Color3(Color.Blue);
GL.Vertex3(pos_p);
}
GL.End();
}
}
}

View File

@ -87,6 +87,7 @@ namespace Switch_Toolbox.Library
foreach (STBone bn in bones)
{
if (bn.Checked)
bn.Render();
}
}
@ -98,6 +99,7 @@ namespace Switch_Toolbox.Library
foreach (STBone bn in bones)
{
if (bn.Checked)
bn.Render();
}
}
@ -243,6 +245,9 @@ namespace Switch_Toolbox.Library
foreach (STBone bn in bones)
{
if (!bn.Checked)
continue;
solidColorShaderProgram.SetVector4("boneColor", ColorUtility.ToVector4(boneColor));
solidColorShaderProgram.SetFloat("scale", Runtime.bonePointSize);
@ -493,173 +498,4 @@ namespace Switch_Toolbox.Library
return 0;
}
}
public class STBone : TreeNodeCustom
{
private bool visbile = true;
public bool Visible
{
get
{
return visbile;
}
set
{
visbile = value;
}
}
public bool UseSegmentScaleCompensate;
public STSkeleton skeletonParent;
public BoneRotationType RotationType;
public ushort BillboardIndex;
public short RigidMatrixIndex;
public short SmoothMatrixIndex;
public float[] position = new float[] { 0, 0, 0 };
public float[] rotation = new float[] { 0, 0, 0 };
public float[] scale = new float[] { 1, 1, 1 };
public Vector3 pos = Vector3.Zero, sca = new Vector3(1f, 1f, 1f);
public Quaternion rot = Quaternion.FromMatrix(Matrix3.Zero);
public Matrix4 Transform, invert;
public Vector3 GetPosition()
{
return pos;
}
public Quaternion GetRotation()
{
return rot;
}
public Vector3 GetScale()
{
return sca;
}
public int GetIndex()
{
if (skeletonParent != null)
return skeletonParent.bones.IndexOf(this);
else
return -1;
}
public void ConvertToQuaternion()
{
if (RotationType == BoneRotationType.Quaternion)
return;
}
public void ConvertToEular()
{
if (RotationType == BoneRotationType.Euler)
return;
}
public override void OnClick(TreeView treeView)
{
}
public enum BoneRotationType
{
Euler,
Quaternion,
}
public int parentIndex
{
set
{
if (Parent != null) Parent.Nodes.Remove(this);
if (value > -1 && value < skeletonParent.bones.Count)
{
skeletonParent.bones[value].Nodes.Add(this);
}
}
get
{
if (Parent == null || !(Parent is STBone))
return -1;
return skeletonParent.bones.IndexOf((STBone)Parent);
}
}
public List<STBone> GetChildren()
{
List<STBone> l = new List<STBone>();
foreach (STBone b in skeletonParent.bones)
if (b.Parent == this)
l.Add(b);
return l;
}
public STBone(STSkeleton skl)
{
skeletonParent = skl;
ImageKey = "bone";
SelectedImageKey = "bone";
}
public STBone()
{
ImageKey = "bone";
SelectedImageKey = "bone";
}
public Matrix4 CalculateSmoothMatrix()
{
Matrix4 mat4 = new Matrix4();
return Transform * invert;
}
public Matrix4 CalculateRigidMatrix()
{
Matrix4 mat4 = new Matrix4();
return mat4;
}
public void Render()
{
if (!Runtime.OpenTKInitialized || !Runtime.renderBones)
return;
Vector3 pos_c = Vector3.TransformPosition(Vector3.Zero, Transform);
if (IsSelected)
{
GL.Color3(Color.Red);
}
else
GL.Color3(Color.GreenYellow);
RenderTools.DrawCube(pos_c, 0.1f);
// now draw line between parent
GL.Color3(Color.LightBlue);
GL.LineWidth(2f);
GL.Begin(PrimitiveType.Lines);
if (Parent != null && Parent is STBone)
{
Vector3 pos_p = Vector3.TransformPosition(Vector3.Zero, ((STBone)Parent).Transform);
GL.Vertex3(pos_c);
GL.Color3(Color.Blue);
GL.Vertex3(pos_p);
}
GL.End();
}
}
}

View File

@ -435,6 +435,7 @@
<Compile Include="Generics\GenericObject.cs" />
<Compile Include="Generics\GenericTexture.cs" />
<Compile Include="Generics\RenderableTex.cs" />
<Compile Include="Generics\STBone.cs" />
<Compile Include="Generics\STGenericWrapper.cs" />
<Compile Include="Generics\TEX_FORMAT.cs" />
<Compile Include="Forms\Custom\ListViewCustom.cs">
@ -557,7 +558,7 @@
<Compile Include="Rendering\DrawableXyzLines.cs" />
<Compile Include="Rendering\RenderTools.cs" />
<Compile Include="Rendering\ScreenTriangle.cs" />
<Compile Include="Generics\Skeleton.cs" />
<Compile Include="Generics\STSkeleton.cs" />
<Compile Include="Rendering\RenderLib.cs" />
<Compile Include="Runtime.cs" />
<Compile Include="FormThemes.cs" />