Add tool library
371
Switch_Toolbox_Library/FileFormats/ANIM.cs
Normal file
|
@ -0,0 +1,371 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using OpenTK;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public class ANIM
|
||||
{
|
||||
|
||||
private class AnimKey{
|
||||
public float input, output;
|
||||
public string intan, outtan;
|
||||
public float t1 = 0, w1 = 1;
|
||||
}
|
||||
|
||||
private class AnimData{
|
||||
public string type, input, output, preInfinity, postInfinity;
|
||||
public bool weighted = false;
|
||||
public List<AnimKey> keys = new List<AnimKey>();
|
||||
|
||||
public float getValue(int frame){
|
||||
AnimKey f1 = null, f2 = null;
|
||||
for (int i = 0; i < keys.Count-1; i++) {
|
||||
if ((keys [i].input-1 <= frame && keys [i + 1].input-1 >= frame)) {
|
||||
f1 = keys [i];
|
||||
f2 = keys [i + 1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (f1 == null) {
|
||||
if (keys.Count <= 1) {
|
||||
return keys [0].output;
|
||||
} else {
|
||||
f1 = keys [keys.Count - 2];
|
||||
f2 = keys [keys.Count - 1];
|
||||
}
|
||||
}
|
||||
|
||||
return Animation.Hermite (frame+1, f1.input, f2.input, weighted ? f1.t1 : 0, weighted ? f2.t1 : 0, f1.output, f2.output);
|
||||
}
|
||||
}
|
||||
|
||||
private class AnimBone{
|
||||
public string name;
|
||||
public List<AnimData> atts = new List<AnimData>();
|
||||
}
|
||||
|
||||
public static Animation read(string filename, STSkeleton vbn){
|
||||
StreamReader reader = File.OpenText(filename);
|
||||
string line;
|
||||
|
||||
bool isHeader = true;
|
||||
|
||||
string angularUnit, linearUnit, timeUnit;
|
||||
int startTime = 0;
|
||||
int endTime = 0;
|
||||
List<AnimBone> bones = new List<AnimBone>();
|
||||
Animation.KeyNode current = null;
|
||||
Animation.KeyFrame att = new Animation.KeyFrame();
|
||||
bool inKeys = false;
|
||||
string type = "";
|
||||
|
||||
Animation a = new Animation(filename);
|
||||
|
||||
while ((line = reader.ReadLine()) != null) {
|
||||
string[] args = line.Replace (";", "").TrimStart().Split (' ');
|
||||
|
||||
if (isHeader) {
|
||||
if (args [0].Equals ("anim"))
|
||||
isHeader = false;
|
||||
else if (args [0].Equals ("angularUnit"))
|
||||
angularUnit = args [1];
|
||||
else if (args [0].Equals ("endTime"))
|
||||
endTime = (int)Math.Ceiling(float.Parse (args [1]));
|
||||
else if (args [0].Equals ("startTime"))
|
||||
startTime = (int)Math.Ceiling(float.Parse (args [1]));
|
||||
}
|
||||
|
||||
if (!isHeader) {
|
||||
|
||||
if (inKeys) {
|
||||
if(args[0].Equals("}")){
|
||||
inKeys = false;
|
||||
continue;
|
||||
}
|
||||
Animation.KeyFrame k = new Animation.KeyFrame ();
|
||||
//att.keys.Add (k);
|
||||
if (type.Contains("translate"))
|
||||
{
|
||||
if (type.Contains("X")) current.XPOS.Keys.Add(k);
|
||||
if (type.Contains("Y")) current.YPOS.Keys.Add(k);
|
||||
if (type.Contains("Z")) current.ZPOS.Keys.Add(k);
|
||||
}
|
||||
if (type.Contains("rotate"))
|
||||
{
|
||||
if (type.Contains("X")) current.XROT.Keys.Add(k);
|
||||
if (type.Contains("Y")) current.YROT.Keys.Add(k);
|
||||
if (type.Contains("Z")) current.ZROT.Keys.Add(k);
|
||||
}
|
||||
if (type.Contains("scale"))
|
||||
{
|
||||
if (type.Contains("X")) current.XSCA.Keys.Add(k);
|
||||
if (type.Contains("Y")) current.YSCA.Keys.Add(k);
|
||||
if (type.Contains("Z")) current.ZSCA.Keys.Add(k);
|
||||
}
|
||||
k.Frame = float.Parse (args [0])-1;
|
||||
k.Value = float.Parse (args [1]);
|
||||
if (type.Contains("rotate"))
|
||||
{
|
||||
k.Value *= (float)(Math.PI / 180f);
|
||||
}
|
||||
//k.intan = (args [2]);
|
||||
//k.outtan = (args [3]);
|
||||
if (args.Length > 7 && att.Weighted)
|
||||
{
|
||||
k.In = float.Parse(args[7]) * (float)(Math.PI / 180f);
|
||||
k.Out = float.Parse(args[8]) * (float)(Math.PI / 180f);
|
||||
}
|
||||
}
|
||||
|
||||
if (args [0].Equals ("anim")) {
|
||||
inKeys = false;
|
||||
if (args.Length == 5) {
|
||||
//TODO: finish this type
|
||||
// can be name of attribute
|
||||
}
|
||||
if (args.Length == 7) {
|
||||
// see of the bone of this attribute exists
|
||||
current = null;
|
||||
foreach (Animation.KeyNode b in a.Bones)
|
||||
if (b.Text.Equals (args [3])) {
|
||||
current = b;
|
||||
break;
|
||||
}
|
||||
if (current == null) {
|
||||
current = new Animation.KeyNode (args[3]);
|
||||
current.RotType = Animation.RotationType.EULER;
|
||||
a.Bones.Add (current);
|
||||
}
|
||||
current.Text = args [3];
|
||||
|
||||
att = new Animation.KeyFrame();
|
||||
att.InterType = Animation.InterpolationType.HERMITE;
|
||||
type = args [2];
|
||||
//current.Nodes.Add (att);
|
||||
|
||||
// row child attribute aren't needed here
|
||||
}
|
||||
}
|
||||
|
||||
/*if (args [0].Equals ("input"))
|
||||
att.input = args [1];
|
||||
if (args [0].Equals ("output"))
|
||||
att.output = args [1];
|
||||
if (args [0].Equals ("preInfinity"))
|
||||
att.preInfinity = args [1];
|
||||
if (args [0].Equals ("postInfinity"))
|
||||
att.postInfinity = args [1];*/
|
||||
if (args[0].Equals("weighted"))
|
||||
att.Weighted = args[1].Equals("1");
|
||||
|
||||
|
||||
// begining keys section
|
||||
if (args [0].Contains ("keys")) {
|
||||
inKeys = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
a.FrameCount = endTime-1;
|
||||
|
||||
reader.Close();
|
||||
return a;
|
||||
}
|
||||
|
||||
public static void CreateANIM(string fname, Animation a, STSkeleton vbn)
|
||||
{
|
||||
using (System.IO.StreamWriter file = new System.IO.StreamWriter(@fname))
|
||||
{
|
||||
file.WriteLine("animVersion 1.1;");
|
||||
file.WriteLine("mayaVersion 2014 x64;\ntimeUnit ntscf;\nlinearUnit cm;\nangularUnit deg;\nstartTime 1;\nendTime " + (a.FrameCount+1) + ";");
|
||||
|
||||
a.SetFrame(a.FrameCount - 1); //from last frame
|
||||
for (int li = 0; li < a.FrameCount; ++li) //go through each frame with nextFrame
|
||||
a.NextFrame(vbn);
|
||||
a.NextFrame(vbn); //go on first frame
|
||||
|
||||
int i = 0;
|
||||
|
||||
// writing node attributes
|
||||
foreach (STBone b in vbn.getBoneTreeOrder())
|
||||
{
|
||||
i = vbn.boneIndex(b.Text);
|
||||
|
||||
if (a.HasBone(b.Text))
|
||||
{
|
||||
// write the bone attributes
|
||||
// count the attributes
|
||||
Animation.KeyNode n = a.GetBone(b.Text);
|
||||
int ac = 0;
|
||||
|
||||
|
||||
if (n.XPOS.HasAnimation())
|
||||
{
|
||||
file.WriteLine("anim translate.translateX translateX " + b.Text + " 0 0 " + (ac++) + ";");
|
||||
writeKey(file, n.XPOS, n, a.Size(), "translateX");
|
||||
file.WriteLine("}");
|
||||
}
|
||||
if (n.YPOS.HasAnimation())
|
||||
{
|
||||
file.WriteLine("anim translate.translateY translateY " + b.Text + " 0 0 " + (ac++) + ";");
|
||||
writeKey(file, n.YPOS, n, a.Size(), "translateY");
|
||||
file.WriteLine("}");
|
||||
}
|
||||
if (n.ZPOS.HasAnimation())
|
||||
{
|
||||
file.WriteLine("anim translate.translateZ translateZ " + b.Text + " 0 0 " + (ac++) + ";");
|
||||
writeKey(file, n.ZPOS, n, a.Size(), "translateZ");
|
||||
file.WriteLine("}");
|
||||
}
|
||||
if (n.XROT.HasAnimation())
|
||||
{
|
||||
file.WriteLine("anim rotate.rotateX rotateX " + b.Text + " 0 0 " + (ac++) + ";");
|
||||
writeKey(file, n.XROT, n, a.Size(), "rotateX");
|
||||
file.WriteLine("}");
|
||||
}
|
||||
if (n.YROT.HasAnimation())
|
||||
{
|
||||
file.WriteLine("anim rotate.rotateY rotateY " + b.Text + " 0 0 " + (ac++) + ";");
|
||||
writeKey(file, n.YROT, n, a.Size(), "rotateY");
|
||||
file.WriteLine("}");
|
||||
}
|
||||
if (n.ZROT.HasAnimation())
|
||||
{
|
||||
file.WriteLine("anim rotate.rotateZ rotateZ " + b.Text + " 0 0 " + (ac++) + ";");
|
||||
writeKey(file, n.ZROT, n, a.Size(), "rotateZ");
|
||||
file.WriteLine("}");
|
||||
}
|
||||
|
||||
if (n.XSCA.HasAnimation())
|
||||
{
|
||||
file.WriteLine("anim scale.scaleX scaleX " + b.Text + " 0 0 " + (ac++) + ";");
|
||||
writeKey(file, n.XSCA, n, a.Size(), "scaleX");
|
||||
file.WriteLine("}");
|
||||
}
|
||||
if (n.YSCA.HasAnimation())
|
||||
{
|
||||
file.WriteLine("anim scale.scaleY scaleY " + b.Text + " 0 0 " + (ac++) + ";");
|
||||
writeKey(file, n.YSCA, n, a.Size(), "scaleY");
|
||||
file.WriteLine("}");
|
||||
}
|
||||
if (n.ZSCA.HasAnimation())
|
||||
{
|
||||
file.WriteLine("anim scale.scaleZ scaleZ " + b.Text + " 0 0 " + (ac++) + ";");
|
||||
writeKey(file, n.ZSCA, n, a.Size(), "scaleZ");
|
||||
file.WriteLine("}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
file.WriteLine("anim " + b.Text + " 0 0 0;");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeKey(StreamWriter file, Animation.KeyGroup keys, Animation.KeyNode rt, int size, string type)
|
||||
{
|
||||
|
||||
file.WriteLine("animData {\n input time;\n output linear;\n weighted 1;\n preInfinity constant;\n postInfinity constant;\n keys {");
|
||||
|
||||
if (((Animation.KeyFrame)keys.Keys[0]).InterType == Animation.InterpolationType.CONSTANT)
|
||||
size = 1;
|
||||
|
||||
int f = 1;
|
||||
foreach (Animation.KeyFrame key in keys.Keys)
|
||||
{
|
||||
float v = 0;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case "translateX":
|
||||
v = key.Value;
|
||||
break;
|
||||
case "translateY":
|
||||
v = key.Value;
|
||||
break;
|
||||
case "translateZ":
|
||||
v = key.Value;
|
||||
break;
|
||||
case "rotateX":
|
||||
if (rt.RotType == Animation.RotationType.EULER)
|
||||
v = key.Value * (float)(180f / Math.PI);
|
||||
if (rt.RotType == Animation.RotationType.QUATERNION)
|
||||
{
|
||||
Quaternion q = new Quaternion(rt.XROT.GetValue(key.Frame), rt.YROT.GetValue(key.Frame), rt.ZROT.GetValue(key.Frame), rt.WROT.GetValue(key.Frame));
|
||||
v = quattoeul(q).X * (float)(180f / Math.PI);
|
||||
}
|
||||
break;
|
||||
case "rotateY":
|
||||
if (rt.RotType == Animation.RotationType.EULER)
|
||||
v = key.Value * (float)(180f / Math.PI);
|
||||
if (rt.RotType == Animation.RotationType.QUATERNION)
|
||||
{
|
||||
Quaternion q = new Quaternion(rt.XROT.GetValue(key.Frame), rt.YROT.GetValue(key.Frame), rt.ZROT.GetValue(key.Frame), rt.WROT.GetValue(key.Frame));
|
||||
v = quattoeul(q).Y * (float)(180f / Math.PI);
|
||||
}
|
||||
break;
|
||||
case "rotateZ":
|
||||
if (rt.RotType == Animation.RotationType.EULER)
|
||||
v = key.Value * (float)(180f / Math.PI);
|
||||
if (rt.RotType == Animation.RotationType.QUATERNION)
|
||||
{
|
||||
Quaternion q = new Quaternion(rt.XROT.GetValue(key.Frame), rt.YROT.GetValue(key.Frame), rt.ZROT.GetValue(key.Frame), rt.WROT.GetValue(key.Frame));
|
||||
v = quattoeul(q).Z * (float)(180f / Math.PI);
|
||||
}
|
||||
break;
|
||||
case "scaleX":
|
||||
v = key.Value;
|
||||
break;
|
||||
case "scaleY":
|
||||
v = key.Value;
|
||||
break;
|
||||
case "scaleZ":
|
||||
v = key.Value;
|
||||
break;
|
||||
}
|
||||
|
||||
file.WriteLine(" " + (key.Frame + 1) + " {0:N6} fixed fixed 1 1 0 " + key.In * (float)(180f/Math.PI) + " 1 " + key.In * (float)(180f / Math.PI) + " 1;", v);
|
||||
}
|
||||
|
||||
file.WriteLine(" }");
|
||||
}
|
||||
public static Vector3 quattoeul(Quaternion q){
|
||||
float sqw = q.W * q.W;
|
||||
float sqx = q.X * q.X;
|
||||
float sqy = q.Y * q.Y;
|
||||
float sqz = q.Z * q.Z;
|
||||
|
||||
float normal = (float)Math.Sqrt (sqw + sqx + sqy + sqz);
|
||||
float pole_result = (q.X * q.Z) + (q.Y * q.W);
|
||||
|
||||
if (pole_result > (0.5 * normal)){
|
||||
float ry = (float)Math.PI / 2;
|
||||
float rz = 0;
|
||||
float rx = 2 * (float)Math.Atan2(q.X, q.W);
|
||||
return new Vector3(rx, ry, rz);
|
||||
}
|
||||
if (pole_result < (-0.5 * normal)){
|
||||
float ry = (float)Math.PI/2;
|
||||
float rz = 0;
|
||||
float rx = -2 * (float)Math.Atan2(q.X, q.W);
|
||||
return new Vector3(rx, ry, rz);
|
||||
}
|
||||
|
||||
float r11 = 2*(q.X*q.Y + q.W*q.Z);
|
||||
float r12 = sqw + sqx - sqy - sqz;
|
||||
float r21 = -2*(q.X*q.Z - q.W*q.Y);
|
||||
float r31 = 2*(q.Y*q.Z + q.W*q.X);
|
||||
float r32 = sqw - sqx - sqy + sqz;
|
||||
|
||||
float frx = (float)Math.Atan2( r31, r32 );
|
||||
float fry = (float)Math.Asin ( r21 );
|
||||
float frz = (float)Math.Atan2( r11, r12 );
|
||||
return new Vector3(frx, fry, frz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
611
Switch_Toolbox_Library/FileFormats/Assimp/Assimp.cs
Normal file
|
@ -0,0 +1,611 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Assimp;
|
||||
using Assimp.Configs;
|
||||
using OpenTK;
|
||||
using Switch_Toolbox.Library.Rendering;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public class AssimpData
|
||||
{
|
||||
public Scene scene;
|
||||
private Vector3 m_sceneCenter, m_sceneMin, m_sceneMax;
|
||||
|
||||
public List<STGenericObject> objects = new List<STGenericObject>();
|
||||
public List<STGenericMaterial> materials = new List<STGenericMaterial>();
|
||||
|
||||
public AssimpContext Importer = new AssimpContext();
|
||||
|
||||
public string[] GetSupportedImportFormats()
|
||||
{
|
||||
return Importer.GetSupportedImportFormats();
|
||||
}
|
||||
|
||||
public AssimpData()
|
||||
{
|
||||
}
|
||||
public void LoadFile(string FileName)
|
||||
{
|
||||
AssimpContext Importer = new AssimpContext();
|
||||
|
||||
scene = Importer.ImportFile(FileName, PostProcessSteps.Triangulate | PostProcessSteps.JoinIdenticalVertices
|
||||
| PostProcessSteps.FlipUVs | PostProcessSteps.ValidateDataStructure |
|
||||
PostProcessSteps.CalculateTangentSpace | PostProcessSteps.GenerateNormals);
|
||||
LoadMeshes();
|
||||
}
|
||||
public void processNode()
|
||||
{
|
||||
Matrix4x4 identity = Matrix4x4.Identity;
|
||||
if (scene.RootNode != null)
|
||||
{
|
||||
BuildNode(scene.RootNode, ref identity);
|
||||
}
|
||||
else
|
||||
{
|
||||
int Index = 0;
|
||||
foreach (Mesh msh in scene.Meshes)
|
||||
{
|
||||
objects.Add(CreateGenericObject(msh, Index, Matrix4.Identity));
|
||||
Index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void BuildNode(Node node, ref Matrix4x4 rootTransform)
|
||||
{
|
||||
Matrix4x4 trafo = node.Transform;
|
||||
Matrix4x4 world = trafo * rootTransform;
|
||||
Matrix4 worldTK = TKMatrix(world);
|
||||
|
||||
if (node.HasMeshes)
|
||||
{
|
||||
foreach (int index in node.MeshIndices)
|
||||
{
|
||||
objects.Add(CreateGenericObject(scene.Meshes[index], index, worldTK));
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < node.ChildCount; i++)
|
||||
{
|
||||
BuildNode(node.Children[i], ref world);
|
||||
}
|
||||
}
|
||||
public void LoadMeshes()
|
||||
{
|
||||
objects.Clear();
|
||||
processNode();
|
||||
if (scene.HasMaterials)
|
||||
{
|
||||
foreach (Material mat in scene.Materials)
|
||||
{
|
||||
Console.WriteLine(mat.Name + " TEST");
|
||||
materials.Add(CreateGenericMaterial(mat));
|
||||
}
|
||||
}
|
||||
}
|
||||
void CopyNodesWithMeshes()
|
||||
{
|
||||
|
||||
}
|
||||
public STGenericMaterial CreateGenericMaterial(Material material)
|
||||
{
|
||||
STGenericMaterial mat = new STGenericMaterial();
|
||||
mat.Text = material.Name;
|
||||
|
||||
TextureSlot tex;
|
||||
if (material.GetMaterialTexture(TextureType.Diffuse, 0, out tex))
|
||||
mat.TextureMaps.Add(CreateTextureSlot(tex, TextureType.Diffuse));
|
||||
if (material.GetMaterialTexture(TextureType.Normals, 1, out tex))
|
||||
mat.TextureMaps.Add(CreateTextureSlot(tex, TextureType.Normals));
|
||||
if (material.GetMaterialTexture(TextureType.Specular, 1, out tex))
|
||||
mat.TextureMaps.Add(CreateTextureSlot(tex, TextureType.Specular));
|
||||
return mat;
|
||||
}
|
||||
private STGenericMatTexture CreateTextureSlot(TextureSlot tex, TextureType type)
|
||||
{
|
||||
var matTex = new STGenericMatTexture();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case TextureType.Diffuse:
|
||||
matTex.Type = STGenericMatTexture.TextureType.Diffuse;
|
||||
break;
|
||||
case TextureType.Normals:
|
||||
matTex.Type = STGenericMatTexture.TextureType.Normal;
|
||||
break;
|
||||
case TextureType.Lightmap:
|
||||
matTex.Type = STGenericMatTexture.TextureType.Light;
|
||||
break;
|
||||
case TextureType.Emissive:
|
||||
matTex.Type = STGenericMatTexture.TextureType.Emission;
|
||||
break;
|
||||
case TextureType.Specular:
|
||||
matTex.Type = STGenericMatTexture.TextureType.Specular;
|
||||
break;
|
||||
case TextureType.Shininess:
|
||||
matTex.Type = STGenericMatTexture.TextureType.Metalness;
|
||||
break;
|
||||
case TextureType.Opacity:
|
||||
matTex.Type = STGenericMatTexture.TextureType.Transparency;
|
||||
break;
|
||||
case TextureType.Displacement:
|
||||
break;
|
||||
default:
|
||||
matTex.Type = STGenericMatTexture.TextureType.Unknown;
|
||||
break;
|
||||
}
|
||||
|
||||
matTex.Name = System.IO.Path.GetFileNameWithoutExtension(tex.FilePath);
|
||||
matTex.wrapModeS = SetWrapMode(tex.WrapModeU);
|
||||
matTex.wrapModeT = SetWrapMode(tex.WrapModeV);
|
||||
|
||||
return matTex;
|
||||
}
|
||||
private int SetWrapMode(TextureWrapMode wrap)
|
||||
{
|
||||
switch (wrap)
|
||||
{
|
||||
case TextureWrapMode.Wrap:
|
||||
return 0;
|
||||
case TextureWrapMode.Mirror:
|
||||
return 1;
|
||||
case TextureWrapMode.Clamp:
|
||||
return 2;
|
||||
case TextureWrapMode.Decal:
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public STGenericObject CreateGenericObject(Mesh msh, int Index, Matrix4 transform)
|
||||
{
|
||||
STGenericObject obj = new STGenericObject();
|
||||
|
||||
Console.WriteLine(msh.MaterialIndex);
|
||||
if (msh.MaterialIndex != -1)
|
||||
obj.MaterialIndex = msh.MaterialIndex;
|
||||
else
|
||||
scene.Materials.Add(new Material() { Name = msh.Name });
|
||||
|
||||
if (scene.Materials[msh.MaterialIndex].Name == "")
|
||||
scene.Materials[msh.MaterialIndex].Name = msh.Name;
|
||||
|
||||
obj.HasPos = msh.HasVertices;
|
||||
obj.HasNrm = msh.HasNormals;
|
||||
obj.HasUv0 = msh.HasTextureCoords(0);
|
||||
obj.HasUv1 = msh.HasTextureCoords(1);
|
||||
obj.HasUv2 = msh.HasTextureCoords(2);
|
||||
obj.HasIndices = msh.HasBones;
|
||||
if (msh.HasBones)
|
||||
obj.HasWeights = msh.Bones[0].HasVertexWeights;
|
||||
|
||||
obj.HasTans = msh.HasTangentBasis;
|
||||
obj.HasBitans = msh.HasTangentBasis;
|
||||
obj.HasVertColors = msh.HasVertexColors(0);
|
||||
obj.ObjectName = msh.Name;
|
||||
obj.boneList = GetBoneList(msh);
|
||||
obj.MaxSkinInfluenceCount = GetVertexSkinCount(msh);
|
||||
|
||||
GenericObject.LOD_Mesh lod = new GenericObject.LOD_Mesh();
|
||||
lod.faces = GetFaces(msh);
|
||||
lod.IndexFormat = STIndexFormat.UInt16;
|
||||
lod.PrimitiveType = STPolygonType.Triangle;
|
||||
lod.GenerateSubMesh();
|
||||
obj.lodMeshes.Add(lod);
|
||||
obj.vertices = GetVertices(msh, transform);
|
||||
obj.VertexBufferIndex = Index;
|
||||
|
||||
return obj;
|
||||
}
|
||||
int NodeIndex;
|
||||
public void SaveFromModel(GenericModel model, string FileName)
|
||||
{
|
||||
Scene scene = new Scene();
|
||||
scene.RootNode = new Node("Root");
|
||||
|
||||
Node modelNode = new Node(model.Text);
|
||||
scene.RootNode.Children.Add(modelNode);
|
||||
|
||||
int MeshIndex = 0;
|
||||
foreach (var obj in model.Nodes[0].Nodes)
|
||||
{
|
||||
var genericObj = (STGenericObject)obj;
|
||||
|
||||
Node groupNode = new Node(genericObj.Text);
|
||||
|
||||
|
||||
Mesh mesh = new Mesh(genericObj.Text, PrimitiveType.Triangle);
|
||||
|
||||
List<Vector3D> textureCoords0 = new List<Vector3D>();
|
||||
List<Vector3D> textureCoords1 = new List<Vector3D>();
|
||||
List<Vector3D> textureCoords2 = new List<Vector3D>();
|
||||
List<Color4D> vertexColors = new List<Color4D>();
|
||||
foreach (Vertex v in genericObj.vertices)
|
||||
{
|
||||
mesh.Vertices.Add(new Vector3D(v.pos.X, v.pos.Y, v.pos.Z));
|
||||
mesh.Normals.Add(new Vector3D(v.nrm.X, v.nrm.Y, v.nrm.Z));
|
||||
textureCoords0.Add(new Vector3D(v.uv0.X, v.uv0.Y, 0));
|
||||
textureCoords1.Add(new Vector3D(v.uv1.X, v.uv1.Y, 0));
|
||||
textureCoords2.Add(new Vector3D(v.uv2.X, v.uv2.Y, 0));
|
||||
vertexColors.Add(new Color4D(v.col.X, v.col.Y, v.col.Z, v.col.W));
|
||||
mesh.TextureCoordinateChannels[0] = textureCoords0;
|
||||
mesh.TextureCoordinateChannels[1] = textureCoords1;
|
||||
mesh.TextureCoordinateChannels[2] = textureCoords2;
|
||||
mesh.VertexColorChannels[0] = vertexColors;
|
||||
}
|
||||
|
||||
List<int> faces = genericObj.lodMeshes[genericObj.DisplayLODIndex].faces;
|
||||
for (int f = 0; f < faces.Count; f++)
|
||||
mesh.Faces.Add(new Face(new int[] { faces[f++], faces[f++], faces[f] }));
|
||||
|
||||
Console.WriteLine(genericObj.faces.Count);
|
||||
Console.WriteLine(genericObj.vertices.Count);
|
||||
Console.WriteLine(genericObj.Text);
|
||||
|
||||
mesh.MaterialIndex = genericObj.MaterialIndex;
|
||||
|
||||
mesh.TextureCoordinateChannels.SetValue(textureCoords0, 0);
|
||||
groupNode.MeshIndices.Add(scene.Meshes.Count);
|
||||
|
||||
|
||||
scene.Meshes.Add(mesh);
|
||||
|
||||
MeshIndex++;
|
||||
modelNode.Children.Add(groupNode);
|
||||
}
|
||||
foreach (var mat in model.Nodes[1].Nodes)
|
||||
{
|
||||
var genericMat = (STGenericMaterial)mat;
|
||||
|
||||
Material material = new Material();
|
||||
material.Name = genericMat.Name;
|
||||
|
||||
foreach (var tex in genericMat.TextureMaps)
|
||||
{
|
||||
TextureSlot slot = new TextureSlot();
|
||||
slot.FilePath = tex.Name;
|
||||
|
||||
if (tex.Type == STGenericMatTexture.TextureType.Diffuse)
|
||||
slot.TextureType = TextureType.Diffuse;
|
||||
else if (tex.Type == STGenericMatTexture.TextureType.Normal)
|
||||
slot.TextureType = TextureType.Normals;
|
||||
else if (tex.Type == STGenericMatTexture.TextureType.Specular)
|
||||
slot.TextureType = TextureType.Specular;
|
||||
else if (tex.Type == STGenericMatTexture.TextureType.Emission)
|
||||
slot.TextureType = TextureType.Emissive;
|
||||
else if (tex.Type == STGenericMatTexture.TextureType.Light)
|
||||
{
|
||||
slot.Mapping = TextureMapping.FromUV - 1;
|
||||
slot.TextureType = TextureType.Lightmap;
|
||||
}
|
||||
else if (tex.Type == STGenericMatTexture.TextureType.Shadow)
|
||||
{
|
||||
slot.Mapping = TextureMapping.FromUV - 1;
|
||||
slot.TextureType = TextureType.Ambient;
|
||||
}
|
||||
else
|
||||
slot.TextureType = TextureType.Unknown;
|
||||
|
||||
if (tex.wrapModeS == 0)
|
||||
slot.WrapModeU = TextureWrapMode.Wrap;
|
||||
if (tex.wrapModeS == 1)
|
||||
slot.WrapModeU = TextureWrapMode.Mirror;
|
||||
if (tex.wrapModeS == 2)
|
||||
slot.WrapModeU = TextureWrapMode.Clamp;
|
||||
if (tex.wrapModeT == 0)
|
||||
slot.WrapModeU = TextureWrapMode.Wrap;
|
||||
if (tex.wrapModeT == 1)
|
||||
slot.WrapModeU = TextureWrapMode.Mirror;
|
||||
if (tex.wrapModeT == 2)
|
||||
slot.WrapModeU = TextureWrapMode.Clamp;
|
||||
|
||||
material.AddMaterialTexture(ref slot);
|
||||
}
|
||||
scene.Materials.Add(material);
|
||||
}
|
||||
|
||||
using (var v = new AssimpContext())
|
||||
{
|
||||
string ext = System.IO.Path.GetExtension(FileName);
|
||||
|
||||
string formatID = "obj";
|
||||
if (ext == ".obj")
|
||||
formatID = "obj";
|
||||
if (ext == ".fbx")
|
||||
formatID = "fbx";
|
||||
if (ext == ".dae")
|
||||
formatID = "dae";
|
||||
|
||||
Console.WriteLine(ext);
|
||||
Console.WriteLine(formatID);
|
||||
|
||||
bool Exported = v.ExportFile(scene, FileName, formatID);
|
||||
|
||||
if (Exported)
|
||||
System.Windows.Forms.MessageBox.Show($"Exported {FileName} Successfuly!");
|
||||
else
|
||||
System.Windows.Forms.MessageBox.Show($"Failed to export {FileName}!");
|
||||
}
|
||||
}
|
||||
public void SaveFromObject(List<Vertex> vertices, List<int> faces, string MeshName, string FileName)
|
||||
{
|
||||
Scene scene = new Scene();
|
||||
scene.RootNode = new Node("Root");
|
||||
|
||||
Mesh mesh = new Mesh(MeshName, PrimitiveType.Triangle);
|
||||
|
||||
List<Vector3D> textureCoords0 = new List<Vector3D>();
|
||||
List<Vector3D> textureCoords1 = new List<Vector3D>();
|
||||
List<Vector3D> textureCoords2 = new List<Vector3D>();
|
||||
List<Color4D> vertexColors = new List<Color4D>();
|
||||
|
||||
foreach (Vertex v in vertices)
|
||||
{
|
||||
mesh.Vertices.Add(new Vector3D(v.pos.X, v.pos.Y, v.pos.Z));
|
||||
mesh.Normals.Add(new Vector3D(v.nrm.X, v.nrm.Y, v.nrm.Z));
|
||||
textureCoords0.Add(new Vector3D(v.uv0.X, v.uv0.Y, 0));
|
||||
textureCoords1.Add(new Vector3D(v.uv1.X, v.uv1.Y, 0));
|
||||
textureCoords2.Add(new Vector3D(v.uv2.X, v.uv2.Y, 0));
|
||||
vertexColors.Add(new Color4D(v.col.X, v.col.Y, v.col.Z, v.col.W));
|
||||
mesh.TextureCoordinateChannels[0] = textureCoords0;
|
||||
mesh.TextureCoordinateChannels[1] = textureCoords1;
|
||||
mesh.TextureCoordinateChannels[2] = textureCoords2;
|
||||
mesh.VertexColorChannels[0] = vertexColors;
|
||||
}
|
||||
for (int f = 0; f < faces.Count; f++)
|
||||
{
|
||||
mesh.Faces.Add(new Face(new int[] { faces[f++], faces[f++], faces[f] }));
|
||||
}
|
||||
mesh.MaterialIndex = 0;
|
||||
|
||||
mesh.TextureCoordinateChannels.SetValue(textureCoords0, 0);
|
||||
scene.Meshes.Add(mesh);
|
||||
scene.RootNode.MeshIndices.Add(0);
|
||||
|
||||
Material material = new Material();
|
||||
material.Name = "NewMaterial";
|
||||
scene.Materials.Add(material);
|
||||
|
||||
using (var v = new AssimpContext())
|
||||
{
|
||||
v.ExportFile(scene, FileName, "obj");
|
||||
}
|
||||
}
|
||||
public List<int> GetFaces(Mesh msh)
|
||||
{
|
||||
List<int> faces = new List<int>();
|
||||
|
||||
if (msh.HasFaces)
|
||||
{
|
||||
foreach (Face f in msh.Faces)
|
||||
{
|
||||
if (f.HasIndices)
|
||||
{
|
||||
foreach (int indx in f.Indices)
|
||||
faces.Add(indx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return faces;
|
||||
}
|
||||
public List<string> GetBoneList(Mesh msh)
|
||||
{
|
||||
List<string> bones = new List<string>();
|
||||
foreach (Bone b in msh.Bones)
|
||||
{
|
||||
if (!bones.Contains(b.Name))
|
||||
bones.Add(b.Name);
|
||||
}
|
||||
return bones;
|
||||
}
|
||||
public int GetVertexSkinCount(Mesh msh)
|
||||
{
|
||||
|
||||
List<int> indciesTotal = new List<int>();
|
||||
|
||||
var blendIndexes = new List<List<int>>();
|
||||
var blendWeights = new List<List<float>>();
|
||||
|
||||
int i;
|
||||
for (i = 0; i < msh.VertexCount; i++)
|
||||
{
|
||||
blendIndexes.Add(new List<int>());
|
||||
blendWeights.Add(new List<float>());
|
||||
}
|
||||
|
||||
foreach (var bone in msh.Bones)
|
||||
{
|
||||
var bi = msh.Bones.IndexOf(bone);
|
||||
foreach (var vw in bone.VertexWeights)
|
||||
{
|
||||
blendIndexes[vw.VertexID].Add(bi);
|
||||
blendWeights[vw.VertexID].Add(vw.Weight);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Bone b in msh.Bones)
|
||||
Console.WriteLine(b.VertexWeights.Count);
|
||||
|
||||
if (msh.HasBones)
|
||||
return msh.Bones.Max(b => b.VertexWeightCount);
|
||||
|
||||
return 0;
|
||||
}
|
||||
public List<Vertex> GetVertices(Mesh msh, Matrix4 transform)
|
||||
{
|
||||
List<Vertex> vertices = new List<Vertex>();
|
||||
for (int v = 0; v < msh.VertexCount; v++)
|
||||
{
|
||||
Vertex vert = new Vertex();
|
||||
|
||||
if (msh.HasVertices)
|
||||
vert.pos = Vector3.TransformPosition(FromVector(msh.Vertices[v]), transform);
|
||||
if (msh.HasNormals)
|
||||
vert.nrm = Vector3.TransformNormal(FromVector(msh.Normals[v]), transform);
|
||||
if (msh.HasTextureCoords(0))
|
||||
vert.uv0 = new Vector2(msh.TextureCoordinateChannels[0][v].X, msh.TextureCoordinateChannels[0][v].Y);
|
||||
if (msh.HasTextureCoords(1))
|
||||
vert.uv1 = new Vector2(msh.TextureCoordinateChannels[1][v].X, msh.TextureCoordinateChannels[1][v].Y);
|
||||
if (msh.HasTextureCoords(2))
|
||||
vert.uv2 = new Vector2(msh.TextureCoordinateChannels[2][v].X, msh.TextureCoordinateChannels[2][v].Y);
|
||||
if (msh.HasTangentBasis)
|
||||
vert.tan = new Vector4(msh.Tangents[v].X, msh.Tangents[v].Y, msh.Tangents[v].Z, 1);
|
||||
if (msh.HasVertexColors(0))
|
||||
vert.col = new Vector4(msh.VertexColorChannels[0][v].R, msh.VertexColorChannels[0][v].G, msh.VertexColorChannels[0][v].B, msh.VertexColorChannels[0][v].A);
|
||||
if (msh.HasTangentBasis)
|
||||
vert.bitan = new Vector4(msh.BiTangents[v].X, msh.BiTangents[v].Y, msh.BiTangents[v].Z, 1);
|
||||
if (msh.HasBones)
|
||||
{
|
||||
foreach (Bone bn in msh.Bones)
|
||||
{
|
||||
/* Vertex.Bone bone = new Vertex.Bone();
|
||||
bone.Name = bn.Name;
|
||||
bone.HasWeights = bn.HasVertexWeights;
|
||||
|
||||
if (bn.HasVertexWeights)
|
||||
{
|
||||
foreach (VertexWeight w in bn.VertexWeights)
|
||||
bone.weights.Add(new Vertex.BoneWeight() { weight = w.Weight });
|
||||
}
|
||||
vert.boneList.Add(bone);*/
|
||||
}
|
||||
}
|
||||
vertices.Add(vert);
|
||||
}
|
||||
|
||||
return vertices;
|
||||
}
|
||||
private Vector3 FromVector(Vector3D vec)
|
||||
{
|
||||
Vector3 v;
|
||||
v.X = vec.X;
|
||||
v.Y = vec.Y;
|
||||
v.Z = vec.Z;
|
||||
return v;
|
||||
}
|
||||
public static OpenTK.Matrix4 TKMatrix(Assimp.Matrix4x4 input)
|
||||
{
|
||||
return new OpenTK.Matrix4(input.A1, input.B1, input.C1, input.D1,
|
||||
input.A2, input.B2, input.C2, input.D2,
|
||||
input.A3, input.B3, input.C3, input.D3,
|
||||
input.A4, input.B4, input.C4, input.D4);
|
||||
}
|
||||
public static OpenTK.Matrix4 TKMatrix2(Assimp.Matrix4x4 matOut)
|
||||
{
|
||||
var matIn = new OpenTK.Matrix4();
|
||||
|
||||
matOut.A1 = matIn.M11;
|
||||
matOut.B1 = matIn.M12;
|
||||
matOut.C1 = matIn.M13;
|
||||
matOut.D1 = matIn.M14;
|
||||
|
||||
//Y
|
||||
matOut.A2 = matIn.M21;
|
||||
matOut.B2 = matIn.M22;
|
||||
matOut.C2 = matIn.M23;
|
||||
matOut.D2 = matIn.M24;
|
||||
|
||||
//Z
|
||||
matOut.A3 = matIn.M31;
|
||||
matOut.B3 = matIn.M32;
|
||||
matOut.C3 = matIn.M33;
|
||||
matOut.D3 = matIn.M34;
|
||||
|
||||
//Translation
|
||||
matOut.A4 = matIn.M41;
|
||||
matOut.B4 = matIn.M42;
|
||||
matOut.C4 = matIn.M43;
|
||||
matOut.D4 = matIn.M44;
|
||||
|
||||
return matIn;
|
||||
}
|
||||
|
||||
private Matrix4 FromAssimpMatrix(Matrix4x4 mat)
|
||||
{
|
||||
Vector3D scaling;
|
||||
Vector3D tranlation;
|
||||
Assimp.Quaternion rot;
|
||||
mat.Decompose(out scaling, out rot, out tranlation);
|
||||
|
||||
Console.WriteLine($"rotQ " + rot);
|
||||
|
||||
Matrix4 positionMat = Matrix4.CreateTranslation(FromVector(tranlation));
|
||||
Matrix4 rotQ = Matrix4.CreateFromQuaternion(TKQuaternion(rot));
|
||||
Matrix4 scaleMat = Matrix4.CreateScale(FromVector(scaling));
|
||||
Matrix4 matrixFinal = scaleMat * rotQ * positionMat;
|
||||
|
||||
return matrixFinal;
|
||||
}
|
||||
private OpenTK.Quaternion TKQuaternion(Assimp.Quaternion rot)
|
||||
{
|
||||
OpenTK.Quaternion quat = new OpenTK.Quaternion();
|
||||
quat.X = rot.X;
|
||||
quat.Y = rot.Y;
|
||||
quat.Z = rot.Z;
|
||||
quat.W = rot.W;
|
||||
return quat;
|
||||
}
|
||||
private Matrix4 FromMatrix(Matrix4x4 mat)
|
||||
{
|
||||
Matrix4 m = new Matrix4();
|
||||
m.M11 = mat.A1;
|
||||
m.M12 = mat.A2;
|
||||
m.M13 = mat.A3;
|
||||
m.M14 = mat.A4;
|
||||
m.M21 = mat.B1;
|
||||
m.M22 = mat.B2;
|
||||
m.M23 = mat.B3;
|
||||
m.M24 = mat.B4;
|
||||
m.M31 = mat.C1;
|
||||
m.M32 = mat.C2;
|
||||
m.M33 = mat.C3;
|
||||
m.M34 = mat.C4;
|
||||
m.M41 = mat.D1;
|
||||
m.M42 = mat.D2;
|
||||
m.M43 = mat.D3;
|
||||
m.M44 = mat.D4;
|
||||
return m;
|
||||
}
|
||||
|
||||
public static Vector3 ToEulerAngles(Assimp.Quaternion q)
|
||||
{
|
||||
float PI = (float)Math.PI;
|
||||
// Store the Euler angles in radians
|
||||
Vector3 pitchYawRoll = new Vector3();
|
||||
|
||||
double sqw = q.W * q.W;
|
||||
double sqx = q.X * q.X;
|
||||
double sqy = q.Y * q.Y;
|
||||
double sqz = q.Z * q.Z;
|
||||
|
||||
// If quaternion is normalised the unit is one, otherwise it is the correction factor
|
||||
double unit = sqx + sqy + sqz + sqw;
|
||||
double test = q.X * q.Y + q.Z * q.W;
|
||||
|
||||
if (test > 0.499f * unit)
|
||||
{
|
||||
// Singularity at north pole
|
||||
pitchYawRoll.Y = 2f * (float)Math.Atan2(q.X, q.W); // Yaw
|
||||
pitchYawRoll.X = PI * 0.5f; // Pitch
|
||||
pitchYawRoll.Z = 0f; // Roll
|
||||
return pitchYawRoll;
|
||||
}
|
||||
else if (test < -0.499f * unit)
|
||||
{
|
||||
// Singularity at south pole
|
||||
pitchYawRoll.Y = -2f * (float)Math.Atan2(q.X, q.W); // Yaw
|
||||
pitchYawRoll.X = -PI * 0.5f; // Pitch
|
||||
pitchYawRoll.Z = 0f; // Roll
|
||||
return pitchYawRoll;
|
||||
}
|
||||
pitchYawRoll.Y = (float)Math.Atan2(2 * q.Y * q.W - 2 * q.X * q.Z, sqx - sqy - sqz + sqw); // Yaw
|
||||
pitchYawRoll.X = (float)Math.Asin(2 * test / unit); // Pitch
|
||||
pitchYawRoll.Z = (float)Math.Atan2(2 * q.X * q.W - 2 * q.Y * q.Z, -sqx + sqy - sqz + sqw); // Roll
|
||||
return pitchYawRoll;
|
||||
}
|
||||
}
|
||||
}
|
52
Switch_Toolbox_Library/FileFormats/Assimp/AssimpHelper.cs
Normal file
|
@ -0,0 +1,52 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Assimp;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public class AssimpHelper
|
||||
{
|
||||
public static void ToNumerics(Matrix4x4 matIn, out System.Numerics.Matrix4x4 matOut)
|
||||
{
|
||||
//Assimp matrices are column vector, so X,Y,Z axes are columns 1-3 and 4th column is translation.
|
||||
//Columns => Rows to make it compatible with numerics
|
||||
matOut = new System.Numerics.Matrix4x4(matIn.A1, matIn.B1, matIn.C1, matIn.D1, //X
|
||||
matIn.A2, matIn.B2, matIn.C2, matIn.D2, //Y
|
||||
matIn.A3, matIn.B3, matIn.C3, matIn.D3, //Z
|
||||
matIn.A4, matIn.B4, matIn.C4, matIn.D4); //Translation
|
||||
}
|
||||
|
||||
public static void FromNumerics(System.Numerics.Matrix4x4 matIn, out Matrix4x4 matOut)
|
||||
{
|
||||
//Numerics matrix are row vector, so X,Y,Z axes are rows 1-3 and 4th row is translation.
|
||||
//Rows => Columns to make it compatible with assimp
|
||||
|
||||
//X
|
||||
matOut.A1 = matIn.M11;
|
||||
matOut.B1 = matIn.M12;
|
||||
matOut.C1 = matIn.M13;
|
||||
matOut.D1 = matIn.M14;
|
||||
|
||||
//Y
|
||||
matOut.A2 = matIn.M21;
|
||||
matOut.B2 = matIn.M22;
|
||||
matOut.C2 = matIn.M23;
|
||||
matOut.D2 = matIn.M24;
|
||||
|
||||
//Z
|
||||
matOut.A3 = matIn.M31;
|
||||
matOut.B3 = matIn.M32;
|
||||
matOut.C3 = matIn.M33;
|
||||
matOut.D3 = matIn.M34;
|
||||
|
||||
//Translation
|
||||
matOut.A4 = matIn.M41;
|
||||
matOut.B4 = matIn.M42;
|
||||
matOut.C4 = matIn.M43;
|
||||
matOut.D4 = matIn.M44;
|
||||
}
|
||||
}
|
||||
}
|
13
Switch_Toolbox_Library/FileFormats/CSV.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CsvHelper;
|
||||
using System.IO;
|
||||
using Switch_Toolbox.Library.Rendering;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
|
||||
}
|
348
Switch_Toolbox_Library/FileFormats/DDS.cs
Normal file
|
@ -0,0 +1,348 @@
|
|||
using System;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Drawing;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Syroot.BinaryData;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using Switch_Toolbox.Library;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public class DDS
|
||||
{
|
||||
public Header header;
|
||||
public DX10Header DX10header;
|
||||
public class Header
|
||||
{
|
||||
public uint size = 0x7C;
|
||||
public uint flags = 0x00000000;
|
||||
public uint height = 0;
|
||||
public uint width = 0;
|
||||
public uint pitchOrLinearSize = 0;
|
||||
public uint depth = 0;
|
||||
public uint mipmapCount = 0;
|
||||
public uint[] reserved1 = new uint[11];
|
||||
public DDS_PixelFormat ddspf = new DDS_PixelFormat();
|
||||
public class DDS_PixelFormat
|
||||
{
|
||||
public uint size = 0x20;
|
||||
public uint flags = 0x00000000;
|
||||
public string fourCC;
|
||||
public uint RGBBitCount = 0;
|
||||
public uint RBitMask = 0x00000000;
|
||||
public uint GBitMask = 0x00000000;
|
||||
public uint BBitMask = 0x00000000;
|
||||
public uint ABitMask = 0x00000000;
|
||||
}
|
||||
public uint caps = 0;
|
||||
public uint caps2 = 0;
|
||||
public uint caps3 = 0;
|
||||
public uint caps4 = 0;
|
||||
public uint reserved2 = 0;
|
||||
}
|
||||
public class DX10Header
|
||||
{
|
||||
public DXGI_FORMAT DXGI_Format;
|
||||
public uint ResourceDim;
|
||||
public uint miscFlag;
|
||||
public uint arrayFlag;
|
||||
public uint miscFlags2;
|
||||
|
||||
}
|
||||
public byte[] bdata;
|
||||
public List<byte[]> mipmaps = new List<byte[]>();
|
||||
|
||||
public enum DXGI_FORMAT : uint
|
||||
{
|
||||
DXGI_FORMAT_UNKNOWN = 0,
|
||||
DXGI_FORMAT_R32G32B32A32_TYPELESS = 1,
|
||||
DXGI_FORMAT_R32G32B32A32_FLOAT = 2,
|
||||
DXGI_FORMAT_R32G32B32A32_UINT = 3,
|
||||
DXGI_FORMAT_R32G32B32A32_SINT = 4,
|
||||
DXGI_FORMAT_R32G32B32_TYPELESS = 5,
|
||||
DXGI_FORMAT_R32G32B32_FLOAT = 6,
|
||||
DXGI_FORMAT_R32G32B32_UINT = 7,
|
||||
DXGI_FORMAT_R32G32B32_SINT = 8,
|
||||
DXGI_FORMAT_R16G16B16A16_TYPELESS = 9,
|
||||
DXGI_FORMAT_R16G16B16A16_FLOAT = 10,
|
||||
DXGI_FORMAT_R16G16B16A16_UNORM = 11,
|
||||
DXGI_FORMAT_R16G16B16A16_UINT = 12,
|
||||
DXGI_FORMAT_R16G16B16A16_SNORM = 13,
|
||||
DXGI_FORMAT_R16G16B16A16_SINT = 14,
|
||||
DXGI_FORMAT_R32G32_TYPELESS = 15,
|
||||
DXGI_FORMAT_R32G32_FLOAT = 16,
|
||||
DXGI_FORMAT_R32G32_UINT = 17,
|
||||
DXGI_FORMAT_R32G32_SINT = 18,
|
||||
DXGI_FORMAT_R32G8X24_TYPELESS = 19,
|
||||
DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20,
|
||||
DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21,
|
||||
DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22,
|
||||
DXGI_FORMAT_R10G10B10A2_TYPELESS = 23,
|
||||
DXGI_FORMAT_R10G10B10A2_UNORM = 24,
|
||||
DXGI_FORMAT_R10G10B10A2_UINT = 25,
|
||||
DXGI_FORMAT_R11G11B10_FLOAT = 26,
|
||||
DXGI_FORMAT_R8G8B8A8_TYPELESS = 27,
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM = 28,
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29,
|
||||
DXGI_FORMAT_R8G8B8A8_UINT = 30,
|
||||
DXGI_FORMAT_R8G8B8A8_SNORM = 31,
|
||||
DXGI_FORMAT_R8G8B8A8_SINT = 32,
|
||||
DXGI_FORMAT_R16G16_TYPELESS = 33,
|
||||
DXGI_FORMAT_R16G16_FLOAT = 34,
|
||||
DXGI_FORMAT_R16G16_UNORM = 35,
|
||||
DXGI_FORMAT_R16G16_UINT = 36,
|
||||
DXGI_FORMAT_R16G16_SNORM = 37,
|
||||
DXGI_FORMAT_R16G16_SINT = 38,
|
||||
DXGI_FORMAT_R32_TYPELESS = 39,
|
||||
DXGI_FORMAT_D32_FLOAT = 40,
|
||||
DXGI_FORMAT_R32_FLOAT = 41,
|
||||
DXGI_FORMAT_R32_UINT = 42,
|
||||
DXGI_FORMAT_R32_SINT = 43,
|
||||
DXGI_FORMAT_R24G8_TYPELESS = 44,
|
||||
DXGI_FORMAT_D24_UNORM_S8_UINT = 45,
|
||||
DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46,
|
||||
DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47,
|
||||
DXGI_FORMAT_R8G8_TYPELESS = 48,
|
||||
DXGI_FORMAT_R8G8_UNORM = 49,
|
||||
DXGI_FORMAT_R8G8_UINT = 50,
|
||||
DXGI_FORMAT_R8G8_SNORM = 51,
|
||||
DXGI_FORMAT_R8G8_SINT = 52,
|
||||
DXGI_FORMAT_R16_TYPELESS = 53,
|
||||
DXGI_FORMAT_R16_FLOAT = 54,
|
||||
DXGI_FORMAT_D16_UNORM = 55,
|
||||
DXGI_FORMAT_R16_UNORM = 56,
|
||||
DXGI_FORMAT_R16_UINT = 57,
|
||||
DXGI_FORMAT_R16_SNORM = 58,
|
||||
DXGI_FORMAT_R16_SINT = 59,
|
||||
DXGI_FORMAT_R8_TYPELESS = 60,
|
||||
DXGI_FORMAT_R8_UNORM = 61,
|
||||
DXGI_FORMAT_R8_UINT = 62,
|
||||
DXGI_FORMAT_R8_SNORM = 63,
|
||||
DXGI_FORMAT_R8_SINT = 64,
|
||||
DXGI_FORMAT_A8_UNORM = 65,
|
||||
DXGI_FORMAT_R1_UNORM = 66,
|
||||
DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67,
|
||||
DXGI_FORMAT_R8G8_B8G8_UNORM = 68,
|
||||
DXGI_FORMAT_G8R8_G8B8_UNORM = 69,
|
||||
DXGI_FORMAT_BC1_TYPELESS = 70,
|
||||
DXGI_FORMAT_BC1_UNORM = 71,
|
||||
DXGI_FORMAT_BC1_UNORM_SRGB = 72,
|
||||
DXGI_FORMAT_BC2_TYPELESS = 73,
|
||||
DXGI_FORMAT_BC2_UNORM = 74,
|
||||
DXGI_FORMAT_BC2_UNORM_SRGB = 75,
|
||||
DXGI_FORMAT_BC3_TYPELESS = 76,
|
||||
DXGI_FORMAT_BC3_UNORM = 77,
|
||||
DXGI_FORMAT_BC3_UNORM_SRGB = 78,
|
||||
DXGI_FORMAT_BC4_TYPELESS = 79,
|
||||
DXGI_FORMAT_BC4_UNORM = 80,
|
||||
DXGI_FORMAT_BC4_SNORM = 81,
|
||||
DXGI_FORMAT_BC5_TYPELESS = 82,
|
||||
DXGI_FORMAT_BC5_UNORM = 83,
|
||||
DXGI_FORMAT_BC5_SNORM = 84,
|
||||
DXGI_FORMAT_B5G6R5_UNORM = 85,
|
||||
DXGI_FORMAT_B5G5R5A1_UNORM = 86,
|
||||
DXGI_FORMAT_B8G8R8A8_UNORM = 87,
|
||||
DXGI_FORMAT_B8G8R8X8_UNORM = 88,
|
||||
DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
|
||||
DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
|
||||
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
|
||||
DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
|
||||
DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
|
||||
DXGI_FORMAT_BC6H_TYPELESS = 94,
|
||||
DXGI_FORMAT_BC6H_UF16 = 95,
|
||||
DXGI_FORMAT_BC6H_SF16 = 96,
|
||||
DXGI_FORMAT_BC7_TYPELESS = 97,
|
||||
DXGI_FORMAT_BC7_UNORM = 98,
|
||||
DXGI_FORMAT_BC7_UNORM_SRGB = 99,
|
||||
DXGI_FORMAT_AYUV = 100,
|
||||
DXGI_FORMAT_Y410 = 101,
|
||||
DXGI_FORMAT_Y416 = 102,
|
||||
DXGI_FORMAT_NV12 = 103,
|
||||
DXGI_FORMAT_P010 = 104,
|
||||
DXGI_FORMAT_P016 = 105,
|
||||
DXGI_FORMAT_420_OPAQUE = 106,
|
||||
DXGI_FORMAT_YUY2 = 107,
|
||||
DXGI_FORMAT_Y210 = 108,
|
||||
DXGI_FORMAT_Y216 = 109,
|
||||
DXGI_FORMAT_NV11 = 110,
|
||||
DXGI_FORMAT_AI44 = 111,
|
||||
DXGI_FORMAT_IA44 = 112,
|
||||
DXGI_FORMAT_P8 = 113,
|
||||
DXGI_FORMAT_A8P8 = 114,
|
||||
DXGI_FORMAT_B4G4R4A4_UNORM = 115,
|
||||
DXGI_FORMAT_P208 = 130,
|
||||
DXGI_FORMAT_V208 = 131,
|
||||
DXGI_FORMAT_V408 = 132,
|
||||
DXGI_FORMAT_FORCE_UINT = 0xFFFFFFFF
|
||||
}
|
||||
public DDS()
|
||||
{
|
||||
|
||||
}
|
||||
public DDS(byte[] data)
|
||||
{
|
||||
BinaryDataReader reader = new BinaryDataReader(new MemoryStream(data));
|
||||
Load(reader);
|
||||
}
|
||||
public DDS(string FileName)
|
||||
{
|
||||
BinaryDataReader reader = new BinaryDataReader(new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read));
|
||||
|
||||
Load(reader);
|
||||
}
|
||||
public void Load(BinaryDataReader reader)
|
||||
{
|
||||
reader.Seek(0);
|
||||
string Magic = reader.ReadString(4);
|
||||
Console.WriteLine(Magic);
|
||||
if (Magic != "DDS ")
|
||||
{
|
||||
MessageBox.Show("The file does not appear to be a valid DDS file.");
|
||||
}
|
||||
|
||||
header = new Header();
|
||||
header.size = reader.ReadUInt32();
|
||||
header.flags = reader.ReadUInt32();
|
||||
header.height = reader.ReadUInt32();
|
||||
header.width = reader.ReadUInt32();
|
||||
|
||||
|
||||
header.pitchOrLinearSize = reader.ReadUInt32();
|
||||
header.depth = reader.ReadUInt32();
|
||||
header.mipmapCount = reader.ReadUInt32();
|
||||
header.reserved1 = new uint[11];
|
||||
for (int i = 0; i < 11; ++i)
|
||||
header.reserved1[i] = reader.ReadUInt32();
|
||||
|
||||
header.ddspf.size = reader.ReadUInt32();
|
||||
header.ddspf.flags = reader.ReadUInt32();
|
||||
header.ddspf.fourCC = reader.ReadString(4);
|
||||
header.ddspf.RGBBitCount = reader.ReadUInt32();
|
||||
header.ddspf.RBitMask = reader.ReadUInt32();
|
||||
header.ddspf.GBitMask = reader.ReadUInt32();
|
||||
header.ddspf.BBitMask = reader.ReadUInt32();
|
||||
header.ddspf.ABitMask = reader.ReadUInt32();
|
||||
|
||||
header.caps = reader.ReadUInt32();
|
||||
header.caps2 = reader.ReadUInt32();
|
||||
header.caps3 = reader.ReadUInt32();
|
||||
header.caps4 = reader.ReadUInt32();
|
||||
header.reserved2 = reader.ReadUInt32();
|
||||
|
||||
int DX10HeaderSize = 0;
|
||||
if (header.ddspf.fourCC == "DX10")
|
||||
{
|
||||
DX10HeaderSize = 20;
|
||||
ReadDX10Header(reader);
|
||||
}
|
||||
|
||||
reader.TemporarySeek((int)(4 + header.size + DX10HeaderSize), SeekOrigin.Begin);
|
||||
bdata = reader.ReadBytes((int)(reader.BaseStream.Length - reader.Position));
|
||||
|
||||
|
||||
|
||||
|
||||
reader.Dispose();
|
||||
reader.Close();
|
||||
}
|
||||
private void ReadDX10Header(BinaryDataReader reader)
|
||||
{
|
||||
DX10header = new DX10Header();
|
||||
DX10header.DXGI_Format = reader.ReadEnum<DXGI_FORMAT>(true);
|
||||
DX10header.ResourceDim = reader.ReadUInt32();
|
||||
DX10header.miscFlag = reader.ReadUInt32();
|
||||
DX10header.arrayFlag = reader.ReadUInt32();
|
||||
DX10header.miscFlags2 = reader.ReadUInt32();
|
||||
}
|
||||
public void Save(DDS dds, string FileName, List<byte[]> data = null, bool IsDX10 = false)
|
||||
{
|
||||
BinaryDataWriter writer = new BinaryDataWriter(new FileStream(FileName, FileMode.Create, FileAccess.Write, FileShare.Write));
|
||||
writer.Write(Encoding.ASCII.GetBytes("DDS "));
|
||||
writer.Write(header.size);
|
||||
writer.Write(header.flags);
|
||||
writer.Write(header.height);
|
||||
writer.Write(header.width);
|
||||
|
||||
|
||||
|
||||
writer.Write(header.pitchOrLinearSize);
|
||||
writer.Write(header.depth);
|
||||
writer.Write(header.mipmapCount);
|
||||
for (int i = 0; i < 11; ++i)
|
||||
writer.Write(header.reserved1[i]);
|
||||
|
||||
writer.Write(header.ddspf.size);
|
||||
writer.Write(header.ddspf.flags);
|
||||
writer.Write(header.ddspf.fourCC);
|
||||
writer.Write(header.ddspf.RGBBitCount);
|
||||
writer.Write(header.ddspf.RBitMask);
|
||||
writer.Write(header.ddspf.GBitMask);
|
||||
writer.Write(header.ddspf.BBitMask);
|
||||
writer.Write(header.ddspf.ABitMask);
|
||||
writer.Write(header.caps);
|
||||
writer.Write(header.caps2);
|
||||
writer.Write(header.caps3);
|
||||
writer.Write(header.caps4);
|
||||
writer.Write(header.reserved2);
|
||||
|
||||
if (IsDX10)
|
||||
{
|
||||
WriteDX10Header(writer);
|
||||
}
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
foreach (byte[] mip in data)
|
||||
{
|
||||
writer.Write(mip);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write(bdata);
|
||||
}
|
||||
|
||||
writer.Flush();
|
||||
}
|
||||
private void WriteDX10Header(BinaryDataWriter writer)
|
||||
{
|
||||
if (DX10header == null)
|
||||
DX10header = new DX10Header();
|
||||
|
||||
writer.Write((uint)DX10header.DXGI_Format);
|
||||
writer.Write(DX10header.ResourceDim);
|
||||
writer.Write(DX10header.miscFlag);
|
||||
writer.Write(DX10header.arrayFlag);
|
||||
writer.Write(DX10header.miscFlags2);
|
||||
}
|
||||
public static byte[] CompressBC1Block(byte[] data, int Width, int Height)
|
||||
{
|
||||
byte[] image = new byte[0];
|
||||
|
||||
return image;
|
||||
}
|
||||
public static void ToRGBA(byte[] data, int Width, int Height, int bpp, int compSel)
|
||||
{
|
||||
int Size = Width * Height * 4;
|
||||
|
||||
byte[] result = new byte[Size];
|
||||
|
||||
for (int Y = 0; Y < Height; Y++)
|
||||
{
|
||||
for (int X = 0; X < Width; X++)
|
||||
{
|
||||
int pos = (Y * Width + X) * bpp;
|
||||
int pos_ = (Y * Width + X) * 4;
|
||||
|
||||
int pixel = 0;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
528
Switch_Toolbox_Library/FileFormats/DDS_Decompress.cs
Normal file
|
@ -0,0 +1,528 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
using Switch_Toolbox.Library;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public class DDS_Decompress
|
||||
{
|
||||
//Huge thanks to gdkchan and AbooodXD for the method of decomp BC5/BC4.
|
||||
|
||||
//Todo. Add these to DDS code and add in methods to compress and decode more formats
|
||||
//BC7 also needs to be decompressed properly since OpenTK can't decompress those
|
||||
|
||||
//BC4 actually breaks a bit with artifacts so i'll need to go back and fix
|
||||
|
||||
private static byte[] BCnDecodeTile(byte[] Input, int Offset, bool IsBC1)
|
||||
{
|
||||
Color[] CLUT = new Color[4];
|
||||
|
||||
int c0 = Get16(Input, Offset + 0);
|
||||
int c1 = Get16(Input, Offset + 2);
|
||||
|
||||
CLUT[0] = DecodeRGB565(c0);
|
||||
CLUT[1] = DecodeRGB565(c1);
|
||||
CLUT[2] = CalculateCLUT2(CLUT[0], CLUT[1], c0, c1, IsBC1);
|
||||
CLUT[3] = CalculateCLUT3(CLUT[0], CLUT[1], c0, c1, IsBC1);
|
||||
|
||||
int Indices = Get32(Input, Offset + 4);
|
||||
|
||||
int IdxShift = 0;
|
||||
|
||||
byte[] Output = new byte[4 * 4 * 4];
|
||||
|
||||
int OOffset = 0;
|
||||
|
||||
for (int TY = 0; TY < 4; TY++)
|
||||
{
|
||||
for (int TX = 0; TX < 4; TX++)
|
||||
{
|
||||
int Idx = (Indices >> IdxShift) & 3;
|
||||
|
||||
IdxShift += 2;
|
||||
|
||||
Color Pixel = CLUT[Idx];
|
||||
|
||||
Output[OOffset + 0] = Pixel.B;
|
||||
Output[OOffset + 1] = Pixel.G;
|
||||
Output[OOffset + 2] = Pixel.R;
|
||||
Output[OOffset + 3] = Pixel.A;
|
||||
|
||||
OOffset += 4;
|
||||
}
|
||||
}
|
||||
return Output;
|
||||
}
|
||||
private static Color DecodeRGB565(int Value)
|
||||
{
|
||||
int B = ((Value >> 0) & 0x1f) << 3;
|
||||
int G = ((Value >> 5) & 0x3f) << 2;
|
||||
int R = ((Value >> 11) & 0x1f) << 3;
|
||||
|
||||
return Color.FromArgb(
|
||||
R | (R >> 5),
|
||||
G | (G >> 6),
|
||||
B | (B >> 5));
|
||||
}
|
||||
private static Color CalculateCLUT2(Color C0, Color C1, int c0, int c1, bool IsBC1)
|
||||
{
|
||||
if (c0 > c1 || !IsBC1)
|
||||
{
|
||||
return Color.FromArgb(
|
||||
(2 * C0.R + C1.R) / 3,
|
||||
(2 * C0.G + C1.G) / 3,
|
||||
(2 * C0.B + C1.B) / 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Color.FromArgb(
|
||||
(C0.R + C1.R) / 2,
|
||||
(C0.G + C1.G) / 2,
|
||||
(C0.B + C1.B) / 2);
|
||||
}
|
||||
}
|
||||
private static Color CalculateCLUT3(Color C0, Color C1, int c0, int c1, bool IsBC1)
|
||||
{
|
||||
if (c0 > c1 || !IsBC1)
|
||||
{
|
||||
return
|
||||
Color.FromArgb(
|
||||
(2 * C1.R + C0.R) / 3,
|
||||
(2 * C1.G + C0.G) / 3,
|
||||
(2 * C1.B + C0.B) / 3);
|
||||
}
|
||||
|
||||
return Color.Transparent;
|
||||
}
|
||||
public static Bitmap DecompressBC1(Byte[] data, int width, int height, bool IsSRGB)
|
||||
{
|
||||
int W = (width + 3) / 4;
|
||||
int H = (height + 3) / 4;
|
||||
|
||||
byte[] Output = new byte[W * H * 64];
|
||||
|
||||
for (int Y = 0; Y < H; Y++)
|
||||
{
|
||||
for (int X = 0; X < W; X++)
|
||||
{
|
||||
int IOffs = (Y * W + X) * 8;
|
||||
|
||||
byte[] Tile = BCnDecodeTile(data, IOffs, true);
|
||||
|
||||
int TOffset = 0;
|
||||
|
||||
for (int TY = 0; TY < 4; TY++)
|
||||
{
|
||||
for (int TX = 0; TX < 4; TX++)
|
||||
{
|
||||
int OOffset = (X * 4 + TX + (Y * 4 + TY) * W * 4) * 4;
|
||||
|
||||
Output[OOffset + 0] = Tile[TOffset + 0];
|
||||
Output[OOffset + 1] = Tile[TOffset + 1];
|
||||
Output[OOffset + 2] = Tile[TOffset + 2];
|
||||
Output[OOffset + 3] = Tile[TOffset + 3];
|
||||
|
||||
TOffset += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return BitmapExtension.GetBitmap(Output, W * 4, H * 4);
|
||||
}
|
||||
public static Bitmap DecompressBC3(Byte[] data, int width, int height, bool IsSRGB)
|
||||
{
|
||||
int W = (width + 3) / 4;
|
||||
int H = (height + 3) / 4;
|
||||
|
||||
byte[] Output = new byte[W * H * 64];
|
||||
|
||||
for (int Y = 0; Y < H; Y++)
|
||||
{
|
||||
for (int X = 0; X < W; X++)
|
||||
{
|
||||
int IOffs = (Y * W + X) * 16;
|
||||
|
||||
byte[] Tile = BCnDecodeTile(data, IOffs + 8, false);
|
||||
|
||||
byte[] Alpha = new byte[8];
|
||||
|
||||
Alpha[0] = data[IOffs + 0];
|
||||
Alpha[1] = data[IOffs + 1];
|
||||
|
||||
CalculateBC3Alpha(Alpha);
|
||||
|
||||
int AlphaLow = Get32(data, IOffs + 2);
|
||||
int AlphaHigh = Get16(data, IOffs + 6);
|
||||
|
||||
ulong AlphaCh = (uint)AlphaLow | (ulong)AlphaHigh << 32;
|
||||
|
||||
int TOffset = 0;
|
||||
|
||||
for (int TY = 0; TY < 4; TY++)
|
||||
{
|
||||
for (int TX = 0; TX < 4; TX++)
|
||||
{
|
||||
int OOffset = (X * 4 + TX + (Y * 4 + TY) * W * 4) * 4;
|
||||
|
||||
byte AlphaPx = Alpha[(AlphaCh >> (TY * 12 + TX * 3)) & 7];
|
||||
|
||||
Output[OOffset + 0] = Tile[TOffset + 0];
|
||||
Output[OOffset + 1] = Tile[TOffset + 1];
|
||||
Output[OOffset + 2] = Tile[TOffset + 2];
|
||||
Output[OOffset + 3] = AlphaPx;
|
||||
|
||||
TOffset += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return BitmapExtension.GetBitmap(Output, W * 4, H * 4);
|
||||
}
|
||||
|
||||
public static Bitmap DecompressBC4(Byte[] data, int width, int height, bool IsSNORM)
|
||||
{
|
||||
int W = (width + 3) / 4;
|
||||
int H = (height + 3) / 4;
|
||||
|
||||
byte[] Output = new byte[W * H * 64];
|
||||
|
||||
for (int Y = 0; Y < H; Y++)
|
||||
{
|
||||
for (int X = 0; X < W; X++)
|
||||
{
|
||||
int IOffs = (Y * W + X) * 8;
|
||||
|
||||
byte[] Red = new byte[8];
|
||||
|
||||
Red[0] = data[IOffs + 0];
|
||||
Red[1] = data[IOffs + 1];
|
||||
|
||||
CalculateBC3Alpha(Red);
|
||||
|
||||
int RedLow = Get32(data, IOffs + 2);
|
||||
int RedHigh = Get16(data, IOffs + 6);
|
||||
|
||||
ulong RedCh = (uint)RedLow | (ulong)RedHigh << 32;
|
||||
|
||||
int TOffset = 0;
|
||||
int TW = Math.Min(width - X * 4, 4);
|
||||
int TH = Math.Min(height - Y * 4, 4);
|
||||
|
||||
for (int TY = 0; TY < 4; TY++)
|
||||
{
|
||||
for (int TX = 0; TX < 4; TX++)
|
||||
{
|
||||
int OOffset = (X * 4 + TX + (Y * 4 + TY) * W * 4) * 4;
|
||||
|
||||
byte RedPx = Red[(RedCh >> (TY * 12 + TX * 3)) & 7];
|
||||
|
||||
Output[OOffset + 0] = RedPx;
|
||||
Output[OOffset + 1] = RedPx;
|
||||
Output[OOffset + 2] = RedPx;
|
||||
Output[OOffset + 3] = 255;
|
||||
|
||||
TOffset += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return BitmapExtension.GetBitmap(Output, W * 4, H * 4);
|
||||
}
|
||||
public static byte[] DecompressBC5(Byte[] data, int width, int height, bool IsSNORM, bool IsByteArray)
|
||||
{
|
||||
int W = (width + 3) / 4;
|
||||
int H = (height + 3) / 4;
|
||||
|
||||
|
||||
byte[] Output = new byte[W * H * 64];
|
||||
|
||||
for (int Y = 0; Y < H; Y++)
|
||||
{
|
||||
for (int X = 0; X < W; X++)
|
||||
|
||||
{
|
||||
int IOffs = (Y * W + X) * 16;
|
||||
byte[] Red = new byte[8];
|
||||
byte[] Green = new byte[8];
|
||||
|
||||
Red[0] = data[IOffs + 0];
|
||||
Red[1] = data[IOffs + 1];
|
||||
|
||||
Green[0] = data[IOffs + 8];
|
||||
Green[1] = data[IOffs + 9];
|
||||
|
||||
if (IsSNORM == true)
|
||||
{
|
||||
CalculateBC3AlphaS(Red);
|
||||
CalculateBC3AlphaS(Green);
|
||||
}
|
||||
else
|
||||
{
|
||||
CalculateBC3Alpha(Red);
|
||||
CalculateBC3Alpha(Green);
|
||||
}
|
||||
|
||||
int RedLow = Get32(data, IOffs + 2);
|
||||
int RedHigh = Get16(data, IOffs + 6);
|
||||
|
||||
int GreenLow = Get32(data, IOffs + 10);
|
||||
int GreenHigh = Get16(data, IOffs + 14);
|
||||
|
||||
ulong RedCh = (uint)RedLow | (ulong)RedHigh << 32;
|
||||
ulong GreenCh = (uint)GreenLow | (ulong)GreenHigh << 32;
|
||||
|
||||
int TW = Math.Min(width - X * 4, 4);
|
||||
int TH = Math.Min(height - Y * 4, 4);
|
||||
|
||||
|
||||
if (IsSNORM == true)
|
||||
{
|
||||
for (int TY = 0; TY < TH; TY++)
|
||||
{
|
||||
for (int TX = 0; TX < TW; TX++)
|
||||
{
|
||||
|
||||
int Shift = TY * 12 + TX * 3;
|
||||
int OOffset = ((Y * 4 + TY) * width + (X * 4 + TX)) * 4;
|
||||
|
||||
byte RedPx = Red[(RedCh >> Shift) & 7];
|
||||
byte GreenPx = Green[(GreenCh >> Shift) & 7];
|
||||
|
||||
if (IsSNORM == true)
|
||||
{
|
||||
RedPx += 0x80;
|
||||
GreenPx += 0x80;
|
||||
}
|
||||
|
||||
float NX = (RedPx / 255f) * 2 - 1;
|
||||
float NY = (GreenPx / 255f) * 2 - 1;
|
||||
float NZ = (float)Math.Sqrt(1 - (NX * NX + NY * NY));
|
||||
|
||||
Output[OOffset + 0] = Clamp((NX + 1) * 0.5f);
|
||||
Output[OOffset + 1] = Clamp((NY + 1) * 0.5f);
|
||||
Output[OOffset + 2] = Clamp((NZ + 1) * 0.5f);
|
||||
Output[OOffset + 3] = 0xff;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int TY = 0; TY < TH; TY++)
|
||||
{
|
||||
for (int TX = 0; TX < TW; TX++)
|
||||
{
|
||||
|
||||
int Shift = TY * 12 + TX * 3;
|
||||
int OOffset = ((Y * 4 + TY) * width + (X * 4 + TX)) * 4;
|
||||
|
||||
byte RedPx = Red[(RedCh >> Shift) & 7];
|
||||
byte GreenPx = Green[(GreenCh >> Shift) & 7];
|
||||
|
||||
Output[OOffset + 0] = RedPx;
|
||||
Output[OOffset + 1] = GreenPx;
|
||||
Output[OOffset + 2] = 255;
|
||||
Output[OOffset + 3] = 255;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Output;
|
||||
}
|
||||
public static Bitmap DecompressBC5(Byte[] data, int width, int height, bool IsSNORM)
|
||||
{
|
||||
int W = (width + 3) / 4;
|
||||
int H = (height + 3) / 4;
|
||||
|
||||
|
||||
byte[] Output = new byte[W * H * 64];
|
||||
|
||||
for (int Y = 0; Y < H; Y++)
|
||||
{
|
||||
for (int X = 0; X < W; X++)
|
||||
|
||||
{
|
||||
int IOffs = (Y * W + X) * 16;
|
||||
byte[] Red = new byte[8];
|
||||
byte[] Green = new byte[8];
|
||||
|
||||
Red[0] = data[IOffs + 0];
|
||||
Red[1] = data[IOffs + 1];
|
||||
|
||||
Green[0] = data[IOffs + 8];
|
||||
Green[1] = data[IOffs + 9];
|
||||
|
||||
if (IsSNORM == true)
|
||||
{
|
||||
CalculateBC3AlphaS(Red);
|
||||
CalculateBC3AlphaS(Green);
|
||||
}
|
||||
else
|
||||
{
|
||||
CalculateBC3Alpha(Red);
|
||||
CalculateBC3Alpha(Green);
|
||||
}
|
||||
|
||||
int RedLow = Get32(data, IOffs + 2);
|
||||
int RedHigh = Get16(data, IOffs + 6);
|
||||
|
||||
int GreenLow = Get32(data, IOffs + 10);
|
||||
int GreenHigh = Get16(data, IOffs + 14);
|
||||
|
||||
ulong RedCh = (uint)RedLow | (ulong)RedHigh << 32;
|
||||
ulong GreenCh = (uint)GreenLow | (ulong)GreenHigh << 32;
|
||||
|
||||
int TW = Math.Min(width - X * 4, 4);
|
||||
int TH = Math.Min(height - Y * 4, 4);
|
||||
|
||||
|
||||
if (IsSNORM == true)
|
||||
{
|
||||
for (int TY = 0; TY < TH; TY++)
|
||||
{
|
||||
for (int TX = 0; TX < TW; TX++)
|
||||
{
|
||||
|
||||
int Shift = TY * 12 + TX * 3;
|
||||
int OOffset = ((Y * 4 + TY) * width + (X * 4 + TX)) * 4;
|
||||
|
||||
byte RedPx = Red[(RedCh >> Shift) & 7];
|
||||
byte GreenPx = Green[(GreenCh >> Shift) & 7];
|
||||
|
||||
if (IsSNORM == true)
|
||||
{
|
||||
RedPx += 0x80;
|
||||
GreenPx += 0x80;
|
||||
}
|
||||
|
||||
float NX = (RedPx / 255f) * 2 - 1;
|
||||
float NY = (GreenPx / 255f) * 2 - 1;
|
||||
float NZ = (float)Math.Sqrt(1 - (NX * NX + NY * NY));
|
||||
|
||||
Output[OOffset + 0] = Clamp((NZ + 1) * 0.5f);
|
||||
Output[OOffset + 1] = Clamp((NY + 1) * 0.5f);
|
||||
Output[OOffset + 2] = Clamp((NX + 1) * 0.5f);
|
||||
Output[OOffset + 3] = 0xff;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int TY = 0; TY < TH; TY++)
|
||||
{
|
||||
for (int TX = 0; TX < TW; TX++)
|
||||
{
|
||||
|
||||
int Shift = TY * 12 + TX * 3;
|
||||
int OOffset = ((Y * 4 + TY) * width + (X * 4 + TX)) * 4;
|
||||
|
||||
byte RedPx = Red[(RedCh >> Shift) & 7];
|
||||
byte GreenPx = Green[(GreenCh >> Shift) & 7];
|
||||
|
||||
Output[OOffset + 0] = 255;
|
||||
Output[OOffset + 1] = GreenPx;
|
||||
Output[OOffset + 2] = RedPx;
|
||||
Output[OOffset + 3] = 255;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return BitmapExtension.GetBitmap(Output, W * 4, H * 4);
|
||||
}
|
||||
|
||||
public static int Get16(byte[] Data, int Address)
|
||||
{
|
||||
return
|
||||
Data[Address + 0] << 0 |
|
||||
Data[Address + 1] << 8;
|
||||
}
|
||||
|
||||
public static int Get32(byte[] Data, int Address)
|
||||
{
|
||||
return
|
||||
Data[Address + 0] << 0 |
|
||||
Data[Address + 1] << 8 |
|
||||
Data[Address + 2] << 16 |
|
||||
Data[Address + 3] << 24;
|
||||
}
|
||||
|
||||
private static byte Clamp(float Value)
|
||||
{
|
||||
if (Value > 1)
|
||||
{
|
||||
return 0xff;
|
||||
}
|
||||
else if (Value < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (byte)(Value * 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
private static void CalculateBC3Alpha(byte[] Alpha)
|
||||
{
|
||||
for (int i = 2; i < 8; i++)
|
||||
{
|
||||
if (Alpha[0] > Alpha[1])
|
||||
{
|
||||
Alpha[i] = (byte)(((8 - i) * Alpha[0] + (i - 1) * Alpha[1]) / 7);
|
||||
}
|
||||
else if (i < 6)
|
||||
{
|
||||
Alpha[i] = (byte)(((6 - i) * Alpha[0] + (i - 1) * Alpha[1]) / 7);
|
||||
}
|
||||
else if (i == 6)
|
||||
{
|
||||
Alpha[i] = 0;
|
||||
}
|
||||
else /* i == 7 */
|
||||
{
|
||||
Alpha[i] = 0xff;
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void CalculateBC3AlphaS(byte[] Alpha)
|
||||
{
|
||||
for (int i = 2; i < 8; i++)
|
||||
{
|
||||
if ((sbyte)Alpha[0] > (sbyte)Alpha[1])
|
||||
{
|
||||
Alpha[i] = (byte)(((8 - i) * (sbyte)Alpha[0] + (i - 1) * (sbyte)Alpha[1]) / 7);
|
||||
}
|
||||
else if (i < 6)
|
||||
{
|
||||
Alpha[i] = (byte)(((6 - i) * (sbyte)Alpha[0] + (i - 1) * (sbyte)Alpha[1]) / 7);
|
||||
}
|
||||
else if (i == 6)
|
||||
{
|
||||
Alpha[i] = 0x80;
|
||||
}
|
||||
else /* i == 7 */
|
||||
{
|
||||
Alpha[i] = 0x7f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] DecodeBC7(int X, int Y, int block)
|
||||
{
|
||||
byte[] result = null;
|
||||
|
||||
//Alright so BC7 decompression as multple modes
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
84
Switch_Toolbox_Library/FileFormats/DDS_PixelDecode.cs
Normal file
|
@ -0,0 +1,84 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public class DDS_PixelDecode
|
||||
{
|
||||
public static Bitmap DecodeR8G8(Byte[] data, int width, int height)
|
||||
{
|
||||
byte[] Output = new byte[width * height * 4];
|
||||
|
||||
int OOffset = 0;
|
||||
|
||||
int W = (width + 3) / 4;
|
||||
int H = (height + 3) / 4;
|
||||
|
||||
for (int Y = 0; Y < H; Y++)
|
||||
{
|
||||
for (int X = 0; X < W; X++)
|
||||
{
|
||||
int IOffs = (Y * W + X) * 2;
|
||||
|
||||
Output[OOffset + 1] = data[IOffs + 1];
|
||||
Output[OOffset + 2] = data[IOffs + 0];
|
||||
Output[OOffset + 3] = 0xff;
|
||||
|
||||
OOffset += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return BitmapExtension.GetBitmap(Output, width, height);
|
||||
}
|
||||
public static Bitmap DecodeR8G8B8A8(Byte[] data, int width, int height)
|
||||
{
|
||||
byte[] Output = new byte[width * height * 4];
|
||||
|
||||
int OOffset = 0;
|
||||
|
||||
for (int Y = 0; Y < height; Y++)
|
||||
{
|
||||
for (int X = 0; X < width; X++)
|
||||
{
|
||||
int IOffs = OOffset;
|
||||
|
||||
Output[OOffset + 0] = data[IOffs + 2];
|
||||
Output[OOffset + 1] = data[IOffs + 1];
|
||||
Output[OOffset + 2] = data[IOffs + 0];
|
||||
Output[OOffset + 3] = data[IOffs + 3];
|
||||
|
||||
OOffset += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return BitmapExtension.GetBitmap(Output, width, height);
|
||||
}
|
||||
public static byte[] EncodeR8G8B8A8(Byte[] data, int width, int height, int Offset)
|
||||
{
|
||||
byte[] Output = new byte[width * height * 4];
|
||||
|
||||
int OOffset = 0;
|
||||
|
||||
for (int Y = 0; Y < height; Y++)
|
||||
{
|
||||
for (int X = 0; X < width; X++)
|
||||
{
|
||||
int IOffs = (X * 4 + X + (Y * 4 + Y) * width * 4) * 4;
|
||||
|
||||
Output[OOffset + 0] = data[IOffs + 2];
|
||||
Output[OOffset + 1] = data[IOffs + 1];
|
||||
Output[OOffset + 2] = data[IOffs + 0];
|
||||
Output[OOffset + 3] = data[IOffs + 3];
|
||||
|
||||
OOffset += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return Output;
|
||||
}
|
||||
}
|
||||
}
|
3
Switch_Toolbox_Library/FodyWeavers.xml
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Weavers>
|
||||
</Weavers>
|
292
Switch_Toolbox_Library/GUI Custom/BitmapCustom.cs
Normal file
|
@ -0,0 +1,292 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public class BitmapExtension
|
||||
{
|
||||
public BitmapExtension()
|
||||
{
|
||||
|
||||
}
|
||||
public static Bitmap GetBitmap(byte[] Buffer, int Width, int Height, PixelFormat pixelFormat = PixelFormat.Format32bppArgb)
|
||||
{
|
||||
|
||||
Rectangle Rect = new Rectangle(0, 0, Width, Height);
|
||||
|
||||
Bitmap Img = new Bitmap(Width, Height, pixelFormat);
|
||||
|
||||
BitmapData ImgData = Img.LockBits(Rect, ImageLockMode.WriteOnly, Img.PixelFormat);
|
||||
|
||||
if (Buffer.Length > ImgData.Stride * Img.Height)
|
||||
throw new Exception($"Invalid Buffer Length ({Buffer.Length})!!!");
|
||||
|
||||
Marshal.Copy(Buffer, 0, ImgData.Scan0, Buffer.Length);
|
||||
|
||||
Img.UnlockBits(ImgData);
|
||||
|
||||
return Img;
|
||||
}
|
||||
public class ColorSwapFilter
|
||||
{
|
||||
private ColorSwapType swapType = ColorSwapType.FixDDS;
|
||||
public ColorSwapType SwapType
|
||||
{
|
||||
get { return swapType; }
|
||||
set { swapType = value; }
|
||||
}
|
||||
|
||||
private Red compRed = Red.Red;
|
||||
public Red CompRed
|
||||
{
|
||||
get { return compRed; }
|
||||
set { compRed = value; }
|
||||
}
|
||||
private Green comGreen = Green.Green;
|
||||
public Green CompGreen
|
||||
{
|
||||
get { return comGreen; }
|
||||
set { comGreen = value; }
|
||||
}
|
||||
private Blue compBlue = Blue.Blue;
|
||||
public Blue CompBlue
|
||||
{
|
||||
get { return compBlue; }
|
||||
set { compBlue = value; }
|
||||
}
|
||||
private Alpha compAlpha = Alpha.Alpha;
|
||||
public Alpha CompAlpha
|
||||
{
|
||||
get { return compAlpha; }
|
||||
set { compAlpha = value; }
|
||||
}
|
||||
|
||||
private bool swapHalfColorValues = false;
|
||||
public bool SwapHalfColorValues
|
||||
{
|
||||
get { return swapHalfColorValues; }
|
||||
set { swapHalfColorValues = value; }
|
||||
}
|
||||
|
||||
|
||||
private bool invertColorsWhenSwapping = false;
|
||||
public bool InvertColorsWhenSwapping
|
||||
{
|
||||
get { return invertColorsWhenSwapping; }
|
||||
set { invertColorsWhenSwapping = value; }
|
||||
}
|
||||
|
||||
public enum Red
|
||||
{
|
||||
Red,
|
||||
Green,
|
||||
Blue,
|
||||
Alpha,
|
||||
One,
|
||||
Zero,
|
||||
}
|
||||
public enum Green
|
||||
{
|
||||
Red,
|
||||
Green,
|
||||
Blue,
|
||||
Alpha,
|
||||
One,
|
||||
Zero,
|
||||
}
|
||||
public enum Blue
|
||||
{
|
||||
Red,
|
||||
Green,
|
||||
Blue,
|
||||
Alpha,
|
||||
One,
|
||||
Zero,
|
||||
}
|
||||
public enum Alpha
|
||||
{
|
||||
Red,
|
||||
Green,
|
||||
Blue,
|
||||
Alpha,
|
||||
One,
|
||||
Zero,
|
||||
}
|
||||
|
||||
public enum ColorSwapType
|
||||
{
|
||||
FixDDS,
|
||||
}
|
||||
}
|
||||
public static Bitmap SwapRGB(Bitmap bitmap, ColorSwapFilter swapFilterData)
|
||||
{
|
||||
BitmapData sourceData = bitmap.LockBits
|
||||
(new Rectangle(0, 0, bitmap.Width, bitmap.Height),
|
||||
ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||
|
||||
byte[] resultBuffer = new byte[sourceData.Stride * sourceData.Height];
|
||||
Marshal.Copy(sourceData.Scan0, resultBuffer, 0, resultBuffer.Length);
|
||||
bitmap.UnlockBits(sourceData);
|
||||
|
||||
byte sourceBlue = 0, resultBlue = 0,
|
||||
sourceGreen = 0, resultGreen = 0,
|
||||
sourceRed = 0, resultRed = 0,
|
||||
sourceAlpha = 0, resultAlpha = 0;
|
||||
byte byte2 = 2, maxValue = 255;
|
||||
|
||||
for (int k = 0; k < resultBuffer.Length; k += 4)
|
||||
{
|
||||
sourceBlue = resultBuffer[k];
|
||||
sourceGreen = resultBuffer[k + 1];
|
||||
sourceRed = resultBuffer[k + 2];
|
||||
sourceAlpha = resultBuffer[k + 3];
|
||||
|
||||
|
||||
|
||||
switch (swapFilterData.SwapType)
|
||||
{
|
||||
case ColorSwapFilter.ColorSwapType.FixDDS:
|
||||
{
|
||||
resultBlue = sourceRed;
|
||||
resultRed = sourceBlue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (swapFilterData.CompRed)
|
||||
{
|
||||
case ColorSwapFilter.Red.Red:
|
||||
resultRed = sourceRed;
|
||||
break;
|
||||
case ColorSwapFilter.Red.Green:
|
||||
resultRed = sourceGreen;
|
||||
break;
|
||||
case ColorSwapFilter.Red.Blue:
|
||||
resultRed = sourceBlue;
|
||||
break;
|
||||
case ColorSwapFilter.Red.Alpha:
|
||||
resultRed = sourceAlpha;
|
||||
break;
|
||||
case ColorSwapFilter.Red.One:
|
||||
resultRed = 255;
|
||||
break;
|
||||
case ColorSwapFilter.Red.Zero:
|
||||
resultRed = 0;
|
||||
break;
|
||||
}
|
||||
switch (swapFilterData.CompGreen)
|
||||
{
|
||||
case ColorSwapFilter.Green.Red:
|
||||
resultGreen = sourceRed;
|
||||
break;
|
||||
case ColorSwapFilter.Green.Green:
|
||||
resultGreen = sourceGreen;
|
||||
break;
|
||||
case ColorSwapFilter.Green.Blue:
|
||||
resultGreen = sourceBlue;
|
||||
break;
|
||||
case ColorSwapFilter.Green.Alpha:
|
||||
resultGreen = sourceAlpha;
|
||||
break;
|
||||
case ColorSwapFilter.Green.One:
|
||||
resultGreen = 255;
|
||||
break;
|
||||
case ColorSwapFilter.Green.Zero:
|
||||
resultGreen = 0;
|
||||
break;
|
||||
}
|
||||
switch (swapFilterData.CompBlue)
|
||||
{
|
||||
case ColorSwapFilter.Blue.Red:
|
||||
resultBlue = sourceRed;
|
||||
break;
|
||||
case ColorSwapFilter.Blue.Green:
|
||||
resultBlue = sourceGreen;
|
||||
break;
|
||||
case ColorSwapFilter.Blue.Blue:
|
||||
resultBlue = sourceBlue;
|
||||
break;
|
||||
case ColorSwapFilter.Blue.Alpha:
|
||||
resultBlue = sourceAlpha;
|
||||
break;
|
||||
case ColorSwapFilter.Blue.One:
|
||||
resultBlue = 255;
|
||||
break;
|
||||
case ColorSwapFilter.Blue.Zero:
|
||||
resultBlue = 0;
|
||||
break;
|
||||
}
|
||||
switch (swapFilterData.CompAlpha)
|
||||
{
|
||||
case ColorSwapFilter.Alpha.Red:
|
||||
resultAlpha = sourceRed;
|
||||
break;
|
||||
case ColorSwapFilter.Alpha.Green:
|
||||
resultAlpha = sourceGreen;
|
||||
break;
|
||||
case ColorSwapFilter.Alpha.Blue:
|
||||
resultAlpha = sourceBlue;
|
||||
break;
|
||||
case ColorSwapFilter.Alpha.Alpha:
|
||||
resultAlpha = sourceAlpha;
|
||||
break;
|
||||
case ColorSwapFilter.Alpha.One:
|
||||
resultAlpha = 255;
|
||||
break;
|
||||
case ColorSwapFilter.Alpha.Zero:
|
||||
resultAlpha = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
resultBuffer[k] = resultBlue;
|
||||
resultBuffer[k + 1] = resultGreen;
|
||||
resultBuffer[k + 2] = resultRed;
|
||||
resultBuffer[k + 3] = resultAlpha;
|
||||
}
|
||||
|
||||
|
||||
Bitmap resultBitmap = new Bitmap(bitmap.Width, bitmap.Height,
|
||||
PixelFormat.Format32bppArgb);
|
||||
|
||||
BitmapData resultData = resultBitmap.LockBits
|
||||
(new Rectangle(0, 0, resultBitmap.Width, resultBitmap.Height),
|
||||
ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
|
||||
|
||||
Marshal.Copy(resultBuffer, 0, resultData.Scan0, resultBuffer.Length);
|
||||
resultBitmap.UnlockBits(resultData);
|
||||
|
||||
bitmap.Dispose();
|
||||
return resultBitmap;
|
||||
|
||||
}
|
||||
public static byte[] ImageToByte(Bitmap bitmap)
|
||||
{
|
||||
BitmapData bmpdata = null;
|
||||
|
||||
try
|
||||
{
|
||||
bmpdata = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, bitmap.PixelFormat);
|
||||
int numbytes = bmpdata.Stride * bitmap.Height;
|
||||
byte[] bytedata = new byte[numbytes];
|
||||
IntPtr ptr = bmpdata.Scan0;
|
||||
|
||||
Marshal.Copy(ptr, bytedata, 0, numbytes);
|
||||
|
||||
return bytedata;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (bmpdata != null)
|
||||
bitmap.UnlockBits(bmpdata);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
142
Switch_Toolbox_Library/GUI Custom/ContextMenuStripDark.cs
Normal file
|
@ -0,0 +1,142 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace Switch_Toolbox.Library.Forms
|
||||
{
|
||||
public class ToolStripItemDark : ToolStripMenuItem
|
||||
{
|
||||
public ToolStripItemDark()
|
||||
{
|
||||
}
|
||||
public ToolStripItemDark(string Name)
|
||||
{
|
||||
this.Text = Name;
|
||||
this.ForeColor = Color.FromArgb(255, 255, 255);
|
||||
}
|
||||
}
|
||||
public class ContextMenuStripDark : MenuStrip
|
||||
{
|
||||
private static Color titlebarColor = Color.FromArgb(33, 33, 33);
|
||||
private static Color titlebarColorWhite = Color.FromArgb(255, 255, 255);
|
||||
|
||||
public ContextMenuStripDark()
|
||||
{
|
||||
this.BackColor = titlebarColor;
|
||||
this.ForeColor = Color.FromArgb(255, 255, 255);
|
||||
|
||||
this.Renderer = new ToolStripProfessionalRenderer(new ColorTable());
|
||||
|
||||
}
|
||||
public class ColorTable : ProfessionalColorTable
|
||||
{
|
||||
public override Color ToolStripDropDownBackground
|
||||
{
|
||||
get
|
||||
{
|
||||
return titlebarColor;
|
||||
}
|
||||
}
|
||||
|
||||
public override Color ImageMarginGradientBegin
|
||||
{
|
||||
get
|
||||
{
|
||||
return titlebarColor;
|
||||
}
|
||||
}
|
||||
|
||||
public override Color ImageMarginGradientMiddle
|
||||
{
|
||||
get
|
||||
{
|
||||
return titlebarColor;
|
||||
}
|
||||
}
|
||||
|
||||
public override Color ImageMarginGradientEnd
|
||||
{
|
||||
get
|
||||
{
|
||||
return titlebarColor;
|
||||
}
|
||||
}
|
||||
|
||||
public override Color MenuBorder
|
||||
{
|
||||
get
|
||||
{
|
||||
return Color.White;
|
||||
}
|
||||
}
|
||||
|
||||
public override Color MenuItemBorder
|
||||
{
|
||||
get
|
||||
{
|
||||
return Color.Black;
|
||||
}
|
||||
}
|
||||
|
||||
public override Color MenuItemSelected
|
||||
{
|
||||
get
|
||||
{
|
||||
return Color.FromArgb(80, 80, 80);
|
||||
}
|
||||
}
|
||||
|
||||
public override Color MenuStripGradientBegin
|
||||
{
|
||||
get
|
||||
{
|
||||
return titlebarColor;
|
||||
}
|
||||
}
|
||||
|
||||
public override Color MenuStripGradientEnd
|
||||
{
|
||||
get
|
||||
{
|
||||
return titlebarColor;
|
||||
}
|
||||
}
|
||||
|
||||
public override Color MenuItemSelectedGradientBegin
|
||||
{
|
||||
get
|
||||
{
|
||||
return Color.FromArgb(80, 80, 80);
|
||||
}
|
||||
}
|
||||
|
||||
public override Color MenuItemSelectedGradientEnd
|
||||
{
|
||||
get
|
||||
{
|
||||
return Color.FromArgb(80, 80, 80);
|
||||
}
|
||||
}
|
||||
|
||||
public override Color MenuItemPressedGradientBegin
|
||||
{
|
||||
get
|
||||
{
|
||||
return titlebarColor;
|
||||
}
|
||||
}
|
||||
|
||||
public override Color MenuItemPressedGradientEnd
|
||||
{
|
||||
get
|
||||
{
|
||||
return titlebarColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
19
Switch_Toolbox_Library/GUI Custom/DockContentCustom.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
using WeifenLuo.WinFormsUI.ThemeVS2015;
|
||||
|
||||
namespace Switch_Toolbox.Library.Forms
|
||||
{
|
||||
public class DockPanelCustom : DockPanel
|
||||
{
|
||||
public DockPanelCustom()
|
||||
{
|
||||
var theme = new VS2015DarkTheme();
|
||||
this.Theme = theme;
|
||||
}
|
||||
}
|
||||
}
|
18
Switch_Toolbox_Library/GUI Custom/DockContentST.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public class DockContentST : DockContent
|
||||
{
|
||||
public DockContentST()
|
||||
{
|
||||
BackColor = Color.FromArgb(33, 33, 33);
|
||||
}
|
||||
}
|
||||
}
|
20
Switch_Toolbox_Library/GUI Custom/EditorInterface.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
class FileEditor : UserControl
|
||||
{
|
||||
void OpenFile()
|
||||
{
|
||||
}
|
||||
void SaveFile()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
21
Switch_Toolbox_Library/GUI Custom/ListViewCustom.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Switch_Toolbox.Library.Forms
|
||||
{
|
||||
[ToolboxItem(true)]
|
||||
[ToolboxBitmap(typeof(ListView))]
|
||||
public class ListViewCustom : ListView
|
||||
{
|
||||
public ListViewCustom()
|
||||
{
|
||||
this.DoubleBuffered = true;
|
||||
}
|
||||
}
|
||||
}
|
143
Switch_Toolbox_Library/GUI Custom/MinMaxButton.cs
Normal file
|
@ -0,0 +1,143 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Switch_Toolbox.Library.Forms
|
||||
{
|
||||
public class MinMaxButton : System.Windows.Forms.Button
|
||||
{
|
||||
Color clr1;
|
||||
private Color color = Color.Gray;
|
||||
private Color m_hovercolor = Color.FromArgb(180, 200, 240);
|
||||
private Color clickcolor = Color.FromArgb(160, 180, 200);
|
||||
private int textX = 6;
|
||||
private int textY = -20;
|
||||
private String text = "_";
|
||||
|
||||
public enum CustomFormState
|
||||
{
|
||||
Normal,
|
||||
Maximize
|
||||
}
|
||||
|
||||
CustomFormState _customFormState;
|
||||
|
||||
public CustomFormState CFormState
|
||||
{
|
||||
get { return _customFormState; }
|
||||
set { _customFormState = value; Invalidate(); }
|
||||
}
|
||||
|
||||
|
||||
public String DisplayText
|
||||
{
|
||||
get { return text; }
|
||||
set { text = value; Invalidate(); }
|
||||
}
|
||||
public Color BZBackColor
|
||||
{
|
||||
get { return color; }
|
||||
set { color = value; Invalidate(); }
|
||||
}
|
||||
|
||||
public Color MouseHoverColor
|
||||
{
|
||||
get { return m_hovercolor; }
|
||||
set { m_hovercolor = value; Invalidate(); }
|
||||
}
|
||||
|
||||
public Color MouseClickColor1
|
||||
{
|
||||
get { return clickcolor; }
|
||||
set { clickcolor = value; Invalidate(); }
|
||||
}
|
||||
|
||||
|
||||
public int TextLocation_X
|
||||
{
|
||||
get { return textX; }
|
||||
set { textX = value; Invalidate(); }
|
||||
}
|
||||
public int TextLocation_Y
|
||||
{
|
||||
get { return textY; }
|
||||
set { textY = value; Invalidate(); }
|
||||
}
|
||||
|
||||
public MinMaxButton()
|
||||
{
|
||||
this.Size = new System.Drawing.Size(31, 24);
|
||||
this.ForeColor = Color.White;
|
||||
this.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.Text = "_";
|
||||
text = this.Text;
|
||||
}
|
||||
|
||||
//method mouse enter
|
||||
protected override void OnMouseEnter(EventArgs e)
|
||||
{
|
||||
base.OnMouseEnter(e);
|
||||
clr1 = color;
|
||||
color = m_hovercolor;
|
||||
}
|
||||
//method mouse leave
|
||||
protected override void OnMouseLeave(EventArgs e)
|
||||
{
|
||||
base.OnMouseLeave(e);
|
||||
color = clr1;
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs mevent)
|
||||
{
|
||||
base.OnMouseDown(mevent);
|
||||
color = clickcolor;
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseEventArgs mevent)
|
||||
{
|
||||
base.OnMouseUp(mevent);
|
||||
color = clr1;
|
||||
}
|
||||
|
||||
|
||||
protected override void OnPaint(PaintEventArgs pe)
|
||||
{
|
||||
base.OnPaint(pe);
|
||||
|
||||
switch (_customFormState)
|
||||
{
|
||||
case CustomFormState.Normal:
|
||||
pe.Graphics.FillRectangle(new SolidBrush(color), ClientRectangle);
|
||||
|
||||
//draw and fill thw rectangles of maximized window
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
pe.Graphics.DrawRectangle(new Pen(this.ForeColor), textX + i + 1, textY, 10, 10);
|
||||
pe.Graphics.FillRectangle(new SolidBrush(this.ForeColor), textX + 1, textY - 1, 12, 4);
|
||||
}
|
||||
break;
|
||||
|
||||
case CustomFormState.Maximize:
|
||||
pe.Graphics.FillRectangle(new SolidBrush(color), ClientRectangle);
|
||||
|
||||
//draw and fill thw rectangles of maximized window
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
pe.Graphics.DrawRectangle(new Pen(this.ForeColor), textX + 5, textY, 8, 8);
|
||||
pe.Graphics.FillRectangle(new SolidBrush(this.ForeColor), textX + 5, textY - 1, 9, 4);
|
||||
|
||||
pe.Graphics.DrawRectangle(new Pen(this.ForeColor), textX + 2, textY + 5, 8, 8);
|
||||
pe.Graphics.FillRectangle(new SolidBrush(this.ForeColor), textX + 2, textY + 4, 9, 4);
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
24
Switch_Toolbox_Library/GUI Custom/NumericUpDownFloat.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Switch_Toolbox.Library.Forms
|
||||
{
|
||||
public class NumericUpDownFloat : NumericUpDown
|
||||
{
|
||||
public NumericUpDownFloat()
|
||||
{
|
||||
Maximum = 1000000000;
|
||||
Minimum = -100000000;
|
||||
DecimalPlaces = 5;
|
||||
Increment = 0.005m;
|
||||
|
||||
BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
ForeColor = Color.White;
|
||||
}
|
||||
}
|
||||
}
|
18
Switch_Toolbox_Library/GUI Custom/NumericUpDownInt.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Switch_Toolbox.Library.Forms
|
||||
{
|
||||
public class NumericUpDownInt : NumericUpDown
|
||||
{
|
||||
public NumericUpDownInt()
|
||||
{
|
||||
Maximum = 2147483647;
|
||||
Minimum = -2147483648;
|
||||
}
|
||||
}
|
||||
}
|
18
Switch_Toolbox_Library/GUI Custom/NumericUpDownUint.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Switch_Toolbox.Library.Forms
|
||||
{
|
||||
public class NumericUpDownUint : NumericUpDown
|
||||
{
|
||||
public NumericUpDownUint()
|
||||
{
|
||||
Maximum = 2147483647;
|
||||
Minimum = 0;
|
||||
}
|
||||
}
|
||||
}
|
34
Switch_Toolbox_Library/GUI Custom/PictureBoxCustom.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Switch_Toolbox.Library.Forms
|
||||
{
|
||||
public class PictureBoxCustom : PictureBox
|
||||
{
|
||||
public PictureBoxCustom()
|
||||
{
|
||||
this.BackgroundImage = GetCheckerBackground();
|
||||
this.BackColor = Color.Transparent;
|
||||
this.SizeMode = PictureBoxSizeMode.Zoom;
|
||||
|
||||
}
|
||||
public Image GetCheckerBackground()
|
||||
{
|
||||
return Properties.Resources.CheckerBackground;
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs pe)
|
||||
{
|
||||
pe.Graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
|
||||
pe.Graphics.PixelOffsetMode = PixelOffsetMode.Half;
|
||||
base.OnPaint(pe);
|
||||
}
|
||||
}
|
||||
}
|
157
Switch_Toolbox_Library/GUI Custom/TreeViewCustom.cs
Normal file
|
@ -0,0 +1,157 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public abstract class TreeNodeCustom : TreeNode
|
||||
{
|
||||
public abstract void OnClick(TreeView treeview);
|
||||
|
||||
public TreeNodeCustom()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class TreeViewCustom : TreeView
|
||||
{
|
||||
private readonly Dictionary<int, TreeNode> _treeNodes = new Dictionary<int, TreeNode>();
|
||||
|
||||
public TreeViewCustom()
|
||||
{
|
||||
ReloadImages();
|
||||
this.ForeColor = Color.White;
|
||||
}
|
||||
public int ImageWidth = 21;
|
||||
public int ImageHeight = 21;
|
||||
public void ReloadImages()
|
||||
{
|
||||
ImageList imgList = new ImageList();
|
||||
imgList.ColorDepth = ColorDepth.Depth32Bit;
|
||||
imgList.ImageSize = new Size(ImageWidth, ImageHeight);
|
||||
imgList.Images.Add("folder", Properties.Resources.Folder);
|
||||
imgList.Images.Add("resource", Properties.Resources.Folder);
|
||||
imgList.Images.Add("Texture", Properties.Resources.Texture);
|
||||
imgList.Images.Add("fileBlank", Properties.Resources.FileBlank);
|
||||
imgList.Images.Add("bfres", Properties.Resources.Bfres);
|
||||
imgList.Images.Add("byaml", Properties.Resources.Byaml);
|
||||
imgList.Images.Add("aamp", Properties.Resources.Aamp);
|
||||
imgList.Images.Add("bntx", Properties.Resources.Bntx);
|
||||
imgList.Images.Add("bfsha", Properties.Resources.Bfsha);
|
||||
imgList.Images.Add("bnsh", Properties.Resources.Bnsh);
|
||||
imgList.Images.Add("mesh", Properties.Resources.mesh);
|
||||
imgList.Images.Add("skeletonAnimation", Properties.Resources.skeletonAnimation);
|
||||
imgList.Images.Add("bone", Properties.Resources.Bone);
|
||||
imgList.Images.Add("bfwav", Properties.Resources.Music1);
|
||||
imgList.Images.Add("bfstp", Properties.Resources.Music2);
|
||||
imgList.Images.Add("material", Properties.Resources.materialSphere);
|
||||
imgList.Images.Add("model", Properties.Resources.model);
|
||||
imgList.Images.Add("skeleton", Properties.Resources.skeleton);
|
||||
|
||||
this.ImageList = imgList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the TreeView with items.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Item type</typeparam>
|
||||
/// <param name="items">Collection of items</param>
|
||||
/// <param name="getId">Function to parse Id value from item object</param>
|
||||
/// <param name="getParentId">Function to parse parentId value from item object</param>
|
||||
/// <param name="getDisplayName">Function to parse display name
|
||||
/// value from item object. This is used as node text.</param>
|
||||
public void LoadItems<T>(IEnumerable<T> items, Func<T, int> getId,
|
||||
Func<T, int?> getParentId, Func<T, string> getDisplayName)
|
||||
{
|
||||
// Clear view and internal dictionary
|
||||
Nodes.Clear();
|
||||
_treeNodes.Clear();
|
||||
|
||||
// Load internal dictionary with nodes
|
||||
foreach (var item in items)
|
||||
{
|
||||
var id = getId(item);
|
||||
var displayName = getDisplayName(item);
|
||||
var node = new TreeNode
|
||||
{
|
||||
Name = id.ToString(),
|
||||
Text = displayName,
|
||||
Tag = item
|
||||
};
|
||||
_treeNodes.Add(getId(item), node);
|
||||
}
|
||||
|
||||
// Create hierarchy and load into view
|
||||
foreach (var id in _treeNodes.Keys)
|
||||
{
|
||||
var node = GetNode(id);
|
||||
var obj = (T)node.Tag;
|
||||
var parentId = getParentId(obj);
|
||||
if (parentId.HasValue)
|
||||
{
|
||||
var parentNode = GetNode(parentId.Value);
|
||||
parentNode.Nodes.Add(node);
|
||||
}
|
||||
else
|
||||
{
|
||||
Nodes.Add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Retrieve TreeNode by Id.
|
||||
/// Useful when you want to select a specific node.
|
||||
/// </summary>
|
||||
/// <param name="id">Item id</param>
|
||||
public TreeNode GetNode(int id)
|
||||
{
|
||||
return _treeNodes[id];
|
||||
}
|
||||
|
||||
}
|
||||
public static class TreeViewExtensions
|
||||
{
|
||||
private const int TVIF_STATE = 0x8;
|
||||
private const int TVIS_STATEIMAGEMASK = 0xF000;
|
||||
private const int TV_FIRST = 0x1100;
|
||||
private const int TVM_SETITEM = TV_FIRST + 63;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Auto)]
|
||||
private struct TVITEM
|
||||
{
|
||||
public int mask;
|
||||
public IntPtr hItem;
|
||||
public int state;
|
||||
public int stateMask;
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string lpszText;
|
||||
public int cchTextMax;
|
||||
public int iImage;
|
||||
public int iSelectedImage;
|
||||
public int cChildren;
|
||||
public IntPtr lParam;
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam,
|
||||
ref TVITEM lParam);
|
||||
|
||||
/// <summary>
|
||||
/// Hides the checkbox for the specified node on a TreeView control.
|
||||
/// </summary>
|
||||
public static void HideCheckBox(this TreeNode node)
|
||||
{
|
||||
TVITEM tvi = new TVITEM();
|
||||
tvi.hItem = node.Handle;
|
||||
tvi.mask = TVIF_STATE;
|
||||
tvi.stateMask = TVIS_STATEIMAGEMASK;
|
||||
tvi.state = 0;
|
||||
SendMessage(node.TreeView.Handle, TVM_SETITEM, IntPtr.Zero, ref tvi);
|
||||
}
|
||||
}
|
||||
}
|
19
Switch_Toolbox_Library/GUI.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
using GL_Core;
|
||||
using System.Windows.Forms;
|
||||
using GL_Core.Cameras;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public class LibraryGUI
|
||||
{
|
||||
|
||||
}
|
||||
}
|
129
Switch_Toolbox_Library/GUI/AnimationPanel.Designer.cs
generated
Normal file
|
@ -0,0 +1,129 @@
|
|||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
partial class AnimationPanel
|
||||
{
|
||||
/// <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.animationPlayBtn = new System.Windows.Forms.Button();
|
||||
this.currentFrameUpDown = new System.Windows.Forms.NumericUpDown();
|
||||
this.totalFrame = new System.Windows.Forms.NumericUpDown();
|
||||
this.animationTrackBar = new System.Windows.Forms.TrackBar();
|
||||
((System.ComponentModel.ISupportInitialize)(this.currentFrameUpDown)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.totalFrame)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.animationTrackBar)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// animationPlayBtn
|
||||
//
|
||||
this.animationPlayBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.animationPlayBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.animationPlayBtn.ForeColor = System.Drawing.Color.White;
|
||||
this.animationPlayBtn.Location = new System.Drawing.Point(12, 12);
|
||||
this.animationPlayBtn.Name = "animationPlayBtn";
|
||||
this.animationPlayBtn.Size = new System.Drawing.Size(231, 47);
|
||||
this.animationPlayBtn.TabIndex = 0;
|
||||
this.animationPlayBtn.Text = "Play";
|
||||
this.animationPlayBtn.UseVisualStyleBackColor = false;
|
||||
this.animationPlayBtn.Click += new System.EventHandler(this.animationPlayBtn_Click);
|
||||
//
|
||||
// currentFrameUpDown
|
||||
//
|
||||
this.currentFrameUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.currentFrameUpDown.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.currentFrameUpDown.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.currentFrameUpDown.ForeColor = System.Drawing.Color.White;
|
||||
this.currentFrameUpDown.Location = new System.Drawing.Point(452, 21);
|
||||
this.currentFrameUpDown.Maximum = new decimal(new int[] {
|
||||
-1981284353,
|
||||
-1966660860,
|
||||
0,
|
||||
0});
|
||||
this.currentFrameUpDown.Name = "currentFrameUpDown";
|
||||
this.currentFrameUpDown.Size = new System.Drawing.Size(60, 16);
|
||||
this.currentFrameUpDown.TabIndex = 1;
|
||||
this.currentFrameUpDown.ValueChanged += new System.EventHandler(this.currentFrameUpDown_ValueChanged);
|
||||
//
|
||||
// totalFrame
|
||||
//
|
||||
this.totalFrame.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.totalFrame.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.totalFrame.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.totalFrame.ForeColor = System.Drawing.Color.White;
|
||||
this.totalFrame.Location = new System.Drawing.Point(530, 21);
|
||||
this.totalFrame.Maximum = new decimal(new int[] {
|
||||
-1981284353,
|
||||
-1966660860,
|
||||
0,
|
||||
0});
|
||||
this.totalFrame.Name = "totalFrame";
|
||||
this.totalFrame.Size = new System.Drawing.Size(60, 16);
|
||||
this.totalFrame.TabIndex = 2;
|
||||
this.totalFrame.ValueChanged += new System.EventHandler(this.totalFrame_ValueChanged);
|
||||
//
|
||||
// animationTrackBar
|
||||
//
|
||||
this.animationTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.animationTrackBar.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(33)))), ((int)(((byte)(33)))), ((int)(((byte)(33)))));
|
||||
this.animationTrackBar.Location = new System.Drawing.Point(249, 12);
|
||||
this.animationTrackBar.Name = "animationTrackBar";
|
||||
this.animationTrackBar.Size = new System.Drawing.Size(197, 45);
|
||||
this.animationTrackBar.TabIndex = 3;
|
||||
this.animationTrackBar.Scroll += new System.EventHandler(this.animationTrackBar_Scroll);
|
||||
this.animationTrackBar.ValueChanged += new System.EventHandler(this.animationTrackBar_ValueChanged);
|
||||
//
|
||||
// AnimationPanel
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(33)))), ((int)(((byte)(33)))), ((int)(((byte)(33)))));
|
||||
this.ClientSize = new System.Drawing.Size(602, 69);
|
||||
this.Controls.Add(this.animationTrackBar);
|
||||
this.Controls.Add(this.totalFrame);
|
||||
this.Controls.Add(this.currentFrameUpDown);
|
||||
this.Controls.Add(this.animationPlayBtn);
|
||||
this.Name = "AnimationPanel";
|
||||
this.Text = "AnimationPanel";
|
||||
this.Click += new System.EventHandler(this.AnimationPanel_Click);
|
||||
this.Enter += new System.EventHandler(this.AnimationPanel_Enter);
|
||||
this.Leave += new System.EventHandler(this.AnimationPanel_Leave);
|
||||
((System.ComponentModel.ISupportInitialize)(this.currentFrameUpDown)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.totalFrame)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.animationTrackBar)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button animationPlayBtn;
|
||||
private System.Windows.Forms.NumericUpDown currentFrameUpDown;
|
||||
private System.Windows.Forms.NumericUpDown totalFrame;
|
||||
private System.Windows.Forms.TrackBar animationTrackBar;
|
||||
}
|
||||
}
|
285
Switch_Toolbox_Library/GUI/AnimationPanel.cs
Normal file
|
@ -0,0 +1,285 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
//Thanks to forge! Based on
|
||||
// https://github.com/jam1garner/Smash-Forge/blob/52844da94c7bed830d841e0d7e5d49c3f2c69471/Smash%20Forge/GUI/ModelViewport.cs
|
||||
|
||||
public partial class AnimationPanel : UserControl
|
||||
{
|
||||
private static AnimationPanel _instance;
|
||||
public static AnimationPanel Instance { get { return _instance == null ? _instance = new AnimationPanel() : _instance; } }
|
||||
|
||||
//Animation Functions
|
||||
public int AnimationSpeed = 60;
|
||||
public float Frame = 0;
|
||||
public bool isPlaying;
|
||||
private bool isOpen = true;
|
||||
private Thread renderThread;
|
||||
private GL_Core.GL_ControlModern gL_ControlModern1;
|
||||
private bool renderThreadIsUpdating = false;
|
||||
|
||||
private Animation currentAnimation;
|
||||
public Animation CurrentAnimation
|
||||
{
|
||||
get
|
||||
{
|
||||
return currentAnimation;
|
||||
}
|
||||
set
|
||||
{
|
||||
ResetModels();
|
||||
/* currentAnimation = value;
|
||||
totalFrame.Value = value.FrameCount;
|
||||
animationTrackBar.TickFrequency = 1;
|
||||
animationTrackBar.SetRange(0, (int)value.FrameCount);
|
||||
currentFrameUpDown.Value = 1;
|
||||
currentFrameUpDown.Value = 0;*/
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetModels()
|
||||
{
|
||||
foreach (var drawable in Runtime.abstractGlDrawables)
|
||||
{
|
||||
if (drawable is STSkeleton)
|
||||
{
|
||||
((STSkeleton)drawable).reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AnimationPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public static Stopwatch directUVTimeStopWatch = new Stopwatch();
|
||||
|
||||
private void animationPlayBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
isPlaying = !isPlaying;
|
||||
animationPlayBtn.Text = isPlaying ? "Pause" : "Play";
|
||||
|
||||
if (isPlaying)
|
||||
directUVTimeStopWatch.Start();
|
||||
else
|
||||
directUVTimeStopWatch.Stop();
|
||||
}
|
||||
|
||||
private void totalFrame_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (currentAnimation == null) return;
|
||||
if (totalFrame.Value < 1)
|
||||
{
|
||||
totalFrame.Value = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currentAnimation.Tag is Animation)
|
||||
((Animation)currentAnimation.Tag).FrameCount = (int)totalFrame.Value;
|
||||
currentAnimation.FrameCount = (int)totalFrame.Value;
|
||||
animationTrackBar.Value = 0;
|
||||
animationTrackBar.SetRange(0, currentAnimation.FrameCount);
|
||||
}
|
||||
}
|
||||
private GL_Core.GL_ControlModern GetViewport()
|
||||
{
|
||||
Form form1 = Application.OpenForms[0];
|
||||
foreach (Control control in form1.Controls)
|
||||
{
|
||||
if (control is DockPanel)
|
||||
{
|
||||
foreach (DockContent ctrl in ((DockPanel)control).Contents)
|
||||
{
|
||||
foreach (Control controls in ctrl.Controls)
|
||||
{
|
||||
if (controls is GL_Core.GL_ControlModern)
|
||||
{
|
||||
return (GL_Core.GL_ControlModern)controls;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void UpdateViewport()
|
||||
{
|
||||
if (Viewport.Instance.gL_ControlModern1.InvokeRequired)
|
||||
{
|
||||
Viewport.Instance.gL_ControlModern1.Invoke((MethodInvoker)delegate {
|
||||
// Running on the UI thread
|
||||
Viewport.Instance.gL_ControlModern1.Invalidate();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Viewport.Instance.gL_ControlModern1.Invalidate();
|
||||
}
|
||||
}
|
||||
private void RenderAndAnimationLoop()
|
||||
{
|
||||
if (IsDisposed)
|
||||
return;
|
||||
|
||||
// TODO: We don't really need two timers.
|
||||
Stopwatch renderStopwatch = Stopwatch.StartNew();
|
||||
Stopwatch animationStopwatch = Stopwatch.StartNew();
|
||||
|
||||
// Wait for UI to load before triggering paint events.
|
||||
int waitTimeMs = 500;
|
||||
Thread.Sleep(waitTimeMs);
|
||||
|
||||
UpdateViewport();
|
||||
|
||||
int frameUpdateInterval = 5;
|
||||
int animationUpdateInterval = 16;
|
||||
|
||||
while (isOpen)
|
||||
{
|
||||
// Always refresh the viewport when animations are playing.
|
||||
if (renderThreadIsUpdating || isPlaying)
|
||||
{
|
||||
if (renderStopwatch.ElapsedMilliseconds > frameUpdateInterval)
|
||||
{
|
||||
UpdateViewport();
|
||||
renderStopwatch.Restart();
|
||||
}
|
||||
|
||||
if (animationStopwatch.ElapsedMilliseconds > animationUpdateInterval)
|
||||
{
|
||||
UpdateAnimationFrame();
|
||||
animationStopwatch.Restart();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Avoid wasting the CPU if we don't need to render anything.
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void UpdateAnimationFrame()
|
||||
{
|
||||
if (isPlaying)
|
||||
{
|
||||
if (currentFrameUpDown.InvokeRequired)
|
||||
{
|
||||
this.currentFrameUpDown.Invoke((MethodInvoker)delegate {
|
||||
// Running on the UI thread
|
||||
if (currentFrameUpDown.Value == totalFrame.Value)
|
||||
currentFrameUpDown.Value = 0;
|
||||
else
|
||||
currentFrameUpDown.Value++;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currentFrameUpDown.Value == totalFrame.Value)
|
||||
currentFrameUpDown.Value = 0;
|
||||
else
|
||||
currentFrameUpDown.Value++;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void nextButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Loop the animation.
|
||||
if (currentFrameUpDown.Value == totalFrame.Value)
|
||||
currentFrameUpDown.Value = 0;
|
||||
else
|
||||
currentFrameUpDown.Value++;
|
||||
}
|
||||
private void prevButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (currentFrameUpDown.Value != 0)
|
||||
currentFrameUpDown.Value--;
|
||||
}
|
||||
|
||||
private void animationTrackBar_Scroll(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void animationTrackBar_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (animationTrackBar.Value > (int)totalFrame.Value)
|
||||
animationTrackBar.Value = 0;
|
||||
if (animationTrackBar.Value < 0)
|
||||
animationTrackBar.Value = (int)totalFrame.Value;
|
||||
currentFrameUpDown.Value = animationTrackBar.Value;
|
||||
|
||||
int currentFrame = animationTrackBar.Value;
|
||||
|
||||
SetAnimationsToFrame(currentFrame);
|
||||
|
||||
UpdateViewport();
|
||||
}
|
||||
private void SetAnimationsToFrame(int frameNum)
|
||||
{
|
||||
if (currentAnimation == null)
|
||||
return;
|
||||
|
||||
float animFrameNum = frameNum;
|
||||
foreach (var drawable in Runtime.abstractGlDrawables)
|
||||
{
|
||||
if (drawable is STSkeleton)
|
||||
{
|
||||
currentAnimation.SetFrame(animFrameNum);
|
||||
currentAnimation.NextFrame((STSkeleton)drawable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void currentFrameUpDown_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (currentFrameUpDown.Value > totalFrame.Value)
|
||||
currentFrameUpDown.Value = totalFrame.Value;
|
||||
|
||||
animationTrackBar.Value = (int)currentFrameUpDown.Value;
|
||||
}
|
||||
|
||||
private void AnimationPanel_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
isOpen = false;
|
||||
Dispose();
|
||||
}
|
||||
|
||||
private void AnimationPanel_Shown(object sender, EventArgs e)
|
||||
{
|
||||
// if (Viewport.Instance.gL_ControlModern1 != null)
|
||||
// Viewport.Instance.gL_ControlModern1.VSync = Runtime.enableVSync;
|
||||
|
||||
// renderThread = new Thread(new ThreadStart(RenderAndAnimationLoop));
|
||||
// renderThread.Start();
|
||||
}
|
||||
|
||||
private void AnimationPanel_Enter(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void AnimationPanel_Click(object sender, EventArgs e)
|
||||
{
|
||||
renderThreadIsUpdating = true;
|
||||
}
|
||||
|
||||
private void AnimationPanel_Leave(object sender, EventArgs e)
|
||||
{
|
||||
renderThreadIsUpdating = false;
|
||||
}
|
||||
}
|
||||
}
|
120
Switch_Toolbox_Library/GUI/AnimationPanel.resx
Normal 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>
|
203
Switch_Toolbox_Library/GUI/Assimp Settings.Designer.cs
generated
Normal file
|
@ -0,0 +1,203 @@
|
|||
namespace Switch_Toolbox.Library.GUI
|
||||
{
|
||||
partial class Assimp_Settings
|
||||
{
|
||||
/// <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.checkBox1 = new System.Windows.Forms.CheckBox();
|
||||
this.checkBox2 = new System.Windows.Forms.CheckBox();
|
||||
this.checkBox3 = new System.Windows.Forms.CheckBox();
|
||||
this.checkBox4 = new System.Windows.Forms.CheckBox();
|
||||
this.checkBox5 = new System.Windows.Forms.CheckBox();
|
||||
this.checkBox6 = new System.Windows.Forms.CheckBox();
|
||||
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
|
||||
this.checkBox7 = new System.Windows.Forms.CheckBox();
|
||||
this.checkBox8 = new System.Windows.Forms.CheckBox();
|
||||
this.checkBox9 = new System.Windows.Forms.CheckBox();
|
||||
this.checkBox10 = new System.Windows.Forms.CheckBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// checkBox1
|
||||
//
|
||||
this.checkBox1.AutoSize = true;
|
||||
this.checkBox1.ForeColor = System.Drawing.Color.White;
|
||||
this.checkBox1.Location = new System.Drawing.Point(14, 16);
|
||||
this.checkBox1.Name = "checkBox1";
|
||||
this.checkBox1.Size = new System.Drawing.Size(196, 17);
|
||||
this.checkBox1.TabIndex = 0;
|
||||
this.checkBox1.Text = "Generate Normals (if none are used)";
|
||||
this.checkBox1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBox2
|
||||
//
|
||||
this.checkBox2.AutoSize = true;
|
||||
this.checkBox2.ForeColor = System.Drawing.Color.White;
|
||||
this.checkBox2.Location = new System.Drawing.Point(14, 39);
|
||||
this.checkBox2.Name = "checkBox2";
|
||||
this.checkBox2.Size = new System.Drawing.Size(103, 17);
|
||||
this.checkBox2.TabIndex = 1;
|
||||
this.checkBox2.Text = "Smooth Normals";
|
||||
this.checkBox2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBox3
|
||||
//
|
||||
this.checkBox3.AutoSize = true;
|
||||
this.checkBox3.ForeColor = System.Drawing.Color.White;
|
||||
this.checkBox3.Location = new System.Drawing.Point(14, 62);
|
||||
this.checkBox3.Name = "checkBox3";
|
||||
this.checkBox3.Size = new System.Drawing.Size(173, 17);
|
||||
this.checkBox3.TabIndex = 2;
|
||||
this.checkBox3.Text = "Generate Tangents/Bitangents";
|
||||
this.checkBox3.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBox4
|
||||
//
|
||||
this.checkBox4.AutoSize = true;
|
||||
this.checkBox4.ForeColor = System.Drawing.Color.White;
|
||||
this.checkBox4.Location = new System.Drawing.Point(14, 85);
|
||||
this.checkBox4.Name = "checkBox4";
|
||||
this.checkBox4.Size = new System.Drawing.Size(65, 17);
|
||||
this.checkBox4.TabIndex = 3;
|
||||
this.checkBox4.Text = "Flip UVs";
|
||||
this.checkBox4.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBox5
|
||||
//
|
||||
this.checkBox5.AutoSize = true;
|
||||
this.checkBox5.ForeColor = System.Drawing.Color.White;
|
||||
this.checkBox5.Location = new System.Drawing.Point(14, 108);
|
||||
this.checkBox5.Name = "checkBox5";
|
||||
this.checkBox5.Size = new System.Drawing.Size(65, 17);
|
||||
this.checkBox5.TabIndex = 4;
|
||||
this.checkBox5.Text = "Flip UVs";
|
||||
this.checkBox5.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBox6
|
||||
//
|
||||
this.checkBox6.AutoSize = true;
|
||||
this.checkBox6.ForeColor = System.Drawing.Color.White;
|
||||
this.checkBox6.Location = new System.Drawing.Point(14, 131);
|
||||
this.checkBox6.Name = "checkBox6";
|
||||
this.checkBox6.Size = new System.Drawing.Size(113, 17);
|
||||
this.checkBox6.TabIndex = 5;
|
||||
this.checkBox6.Text = "Limit bone weights";
|
||||
this.checkBox6.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDown1
|
||||
//
|
||||
this.numericUpDown1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.numericUpDown1.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.numericUpDown1.ForeColor = System.Drawing.Color.White;
|
||||
this.numericUpDown1.Location = new System.Drawing.Point(137, 130);
|
||||
this.numericUpDown1.Name = "numericUpDown1";
|
||||
this.numericUpDown1.Size = new System.Drawing.Size(120, 16);
|
||||
this.numericUpDown1.TabIndex = 6;
|
||||
//
|
||||
// checkBox7
|
||||
//
|
||||
this.checkBox7.AutoSize = true;
|
||||
this.checkBox7.ForeColor = System.Drawing.Color.White;
|
||||
this.checkBox7.Location = new System.Drawing.Point(14, 154);
|
||||
this.checkBox7.Name = "checkBox7";
|
||||
this.checkBox7.Size = new System.Drawing.Size(130, 17);
|
||||
this.checkBox7.TabIndex = 7;
|
||||
this.checkBox7.Text = "PreTransform Vertices";
|
||||
this.checkBox7.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBox8
|
||||
//
|
||||
this.checkBox8.AutoSize = true;
|
||||
this.checkBox8.ForeColor = System.Drawing.Color.White;
|
||||
this.checkBox8.Location = new System.Drawing.Point(14, 177);
|
||||
this.checkBox8.Name = "checkBox8";
|
||||
this.checkBox8.Size = new System.Drawing.Size(79, 17);
|
||||
this.checkBox8.TabIndex = 8;
|
||||
this.checkBox8.Text = "Triangulate";
|
||||
this.checkBox8.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBox9
|
||||
//
|
||||
this.checkBox9.AutoSize = true;
|
||||
this.checkBox9.ForeColor = System.Drawing.Color.White;
|
||||
this.checkBox9.Location = new System.Drawing.Point(14, 200);
|
||||
this.checkBox9.Name = "checkBox9";
|
||||
this.checkBox9.Size = new System.Drawing.Size(121, 17);
|
||||
this.checkBox9.TabIndex = 9;
|
||||
this.checkBox9.Text = "Join Duped Vertices";
|
||||
this.checkBox9.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBox10
|
||||
//
|
||||
this.checkBox10.AutoSize = true;
|
||||
this.checkBox10.ForeColor = System.Drawing.Color.White;
|
||||
this.checkBox10.Location = new System.Drawing.Point(14, 223);
|
||||
this.checkBox10.Name = "checkBox10";
|
||||
this.checkBox10.Size = new System.Drawing.Size(109, 17);
|
||||
this.checkBox10.TabIndex = 10;
|
||||
this.checkBox10.Text = "Make left handed";
|
||||
this.checkBox10.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// Assimp_Settings
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
|
||||
this.Controls.Add(this.checkBox10);
|
||||
this.Controls.Add(this.checkBox9);
|
||||
this.Controls.Add(this.checkBox8);
|
||||
this.Controls.Add(this.checkBox7);
|
||||
this.Controls.Add(this.numericUpDown1);
|
||||
this.Controls.Add(this.checkBox6);
|
||||
this.Controls.Add(this.checkBox5);
|
||||
this.Controls.Add(this.checkBox4);
|
||||
this.Controls.Add(this.checkBox3);
|
||||
this.Controls.Add(this.checkBox2);
|
||||
this.Controls.Add(this.checkBox1);
|
||||
this.Name = "Assimp_Settings";
|
||||
this.Size = new System.Drawing.Size(297, 422);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.CheckBox checkBox1;
|
||||
private System.Windows.Forms.CheckBox checkBox2;
|
||||
private System.Windows.Forms.CheckBox checkBox3;
|
||||
private System.Windows.Forms.CheckBox checkBox4;
|
||||
private System.Windows.Forms.CheckBox checkBox5;
|
||||
private System.Windows.Forms.CheckBox checkBox6;
|
||||
private System.Windows.Forms.NumericUpDown numericUpDown1;
|
||||
private System.Windows.Forms.CheckBox checkBox7;
|
||||
private System.Windows.Forms.CheckBox checkBox8;
|
||||
private System.Windows.Forms.CheckBox checkBox9;
|
||||
private System.Windows.Forms.CheckBox checkBox10;
|
||||
}
|
||||
}
|
20
Switch_Toolbox_Library/GUI/Assimp Settings.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
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 Switch_Toolbox.Library.GUI
|
||||
{
|
||||
public partial class Assimp_Settings : UserControl
|
||||
{
|
||||
public Assimp_Settings()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
120
Switch_Toolbox_Library/GUI/Assimp Settings.resx
Normal 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>
|
121
Switch_Toolbox_Library/GUI/AssimpMeshSelector.Designer.cs
generated
Normal file
|
@ -0,0 +1,121 @@
|
|||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
partial class AssimpMeshSelector
|
||||
{
|
||||
/// <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.listView1 = new System.Windows.Forms.ListView();
|
||||
this.CancelBtn = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.OkBtn = new System.Windows.Forms.Button();
|
||||
this.Meshes = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// listView1
|
||||
//
|
||||
this.listView1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.Meshes});
|
||||
this.listView1.ForeColor = System.Drawing.Color.White;
|
||||
this.listView1.FullRowSelect = true;
|
||||
this.listView1.Location = new System.Drawing.Point(1, 29);
|
||||
this.listView1.Name = "listView1";
|
||||
this.listView1.OwnerDraw = true;
|
||||
this.listView1.Size = new System.Drawing.Size(325, 320);
|
||||
this.listView1.TabIndex = 0;
|
||||
this.listView1.UseCompatibleStateImageBehavior = false;
|
||||
this.listView1.View = System.Windows.Forms.View.Details;
|
||||
this.listView1.DrawColumnHeader += new System.Windows.Forms.DrawListViewColumnHeaderEventHandler(this.listView1_DrawColumnHeader);
|
||||
this.listView1.DrawSubItem += new System.Windows.Forms.DrawListViewSubItemEventHandler(this.listView1_DrawSubItem);
|
||||
this.listView1.DoubleClick += new System.EventHandler(this.listView1_DoubleClick);
|
||||
//
|
||||
// CancelBtn
|
||||
//
|
||||
this.CancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.CancelBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.CancelBtn.ForeColor = System.Drawing.Color.White;
|
||||
this.CancelBtn.Location = new System.Drawing.Point(12, 369);
|
||||
this.CancelBtn.Name = "CancelBtn";
|
||||
this.CancelBtn.Size = new System.Drawing.Size(75, 23);
|
||||
this.CancelBtn.TabIndex = 2;
|
||||
this.CancelBtn.Text = "Cancel";
|
||||
this.CancelBtn.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.ForeColor = System.Drawing.Color.White;
|
||||
this.label1.Location = new System.Drawing.Point(12, 9);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(201, 13);
|
||||
this.label1.TabIndex = 3;
|
||||
this.label1.Text = "Select the mesh you want to replace with";
|
||||
//
|
||||
// OkBtn
|
||||
//
|
||||
this.OkBtn.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.OkBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.OkBtn.ForeColor = System.Drawing.Color.White;
|
||||
this.OkBtn.Location = new System.Drawing.Point(239, 369);
|
||||
this.OkBtn.Name = "OkBtn";
|
||||
this.OkBtn.Size = new System.Drawing.Size(75, 23);
|
||||
this.OkBtn.TabIndex = 4;
|
||||
this.OkBtn.Text = "Ok";
|
||||
this.OkBtn.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// Meshes
|
||||
//
|
||||
this.Meshes.Text = "Meshes";
|
||||
this.Meshes.Width = 321;
|
||||
//
|
||||
// AssimpMeshSelector
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.ClientSize = new System.Drawing.Size(329, 404);
|
||||
this.Controls.Add(this.OkBtn);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.CancelBtn);
|
||||
this.Controls.Add(this.listView1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.Name = "AssimpMeshSelector";
|
||||
this.Text = "AssimpMeshSelector";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ListView listView1;
|
||||
private System.Windows.Forms.Button CancelBtn;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Button OkBtn;
|
||||
private System.Windows.Forms.ColumnHeader Meshes;
|
||||
}
|
||||
}
|
72
Switch_Toolbox_Library/GUI/AssimpMeshSelector.cs
Normal file
|
@ -0,0 +1,72 @@
|
|||
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 Assimp;
|
||||
using Switch_Toolbox.Library.Rendering;
|
||||
using OpenTK;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public partial class AssimpMeshSelector : Form
|
||||
{
|
||||
public AssimpMeshSelector()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
AssimpData assimp;
|
||||
int index;
|
||||
public void LoadMeshes(AssimpData a, int i)
|
||||
{
|
||||
assimp = a;
|
||||
index = i;
|
||||
|
||||
foreach (Mesh msh in assimp.scene.Meshes)
|
||||
{
|
||||
listView1.Items.Add(msh.Name);
|
||||
}
|
||||
}
|
||||
public GenericObject GetSelectedMesh()
|
||||
{
|
||||
assimp.processNode();
|
||||
foreach (Mesh msh in assimp.scene.Meshes)
|
||||
{
|
||||
if (msh.Name == listView1.SelectedItems[0].Text)
|
||||
return assimp.CreateGenericObject(msh, index, Matrix4.Identity);
|
||||
}
|
||||
throw new Exception("This shouldn't happen???");
|
||||
}
|
||||
|
||||
private void listView1_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
private void listView1_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
|
||||
{
|
||||
using (SolidBrush backBrush = new SolidBrush(Color.FromArgb(50, 50, 50)))
|
||||
{
|
||||
e.Graphics.FillRectangle(backBrush, e.Bounds);
|
||||
}
|
||||
using (SolidBrush foreBrush = new SolidBrush(Color.FromArgb(255, 255, 255)))
|
||||
{
|
||||
e.Graphics.DrawString(e.Header.Text, e.Font, foreBrush, e.Bounds);
|
||||
}
|
||||
}
|
||||
|
||||
private void listView1_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
|
||||
{
|
||||
e.DrawDefault = true;
|
||||
if ((e.ItemIndex % 2) == 1)
|
||||
{
|
||||
e.Item.BackColor = Color.FromArgb(50, 50, 50);
|
||||
e.Item.UseItemStyleForSubItems = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
Switch_Toolbox_Library/GUI/AssimpMeshSelector.resx
Normal 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>
|
94
Switch_Toolbox_Library/GUI/Dialogs/RenameDialog.Designer.cs
generated
Normal file
|
@ -0,0 +1,94 @@
|
|||
namespace Switch_Toolbox.Library.Forms
|
||||
{
|
||||
partial class RenameDialog
|
||||
{
|
||||
/// <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.textBox1 = new System.Windows.Forms.TextBox();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
this.textBox1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.textBox1.ForeColor = System.Drawing.Color.White;
|
||||
this.textBox1.Location = new System.Drawing.Point(12, 12);
|
||||
this.textBox1.Name = "textBox1";
|
||||
this.textBox1.Size = new System.Drawing.Size(314, 20);
|
||||
this.textBox1.TabIndex = 0;
|
||||
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.button1.ForeColor = System.Drawing.Color.White;
|
||||
this.button1.Location = new System.Drawing.Point(256, 38);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(70, 23);
|
||||
this.button1.TabIndex = 2;
|
||||
this.button1.Text = "Cancel";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.button2.ForeColor = System.Drawing.Color.White;
|
||||
this.button2.Location = new System.Drawing.Point(176, 38);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(74, 23);
|
||||
this.button2.TabIndex = 3;
|
||||
this.button2.Text = "Ok";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// TextDialog
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.ClientSize = new System.Drawing.Size(338, 73);
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.textBox1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.Name = "TextDialog";
|
||||
this.Text = "Rename";
|
||||
this.Load += new System.EventHandler(this.RenameDialog_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public System.Windows.Forms.TextBox textBox1;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Button button2;
|
||||
}
|
||||
}
|
98
Switch_Toolbox_Library/GUI/Dialogs/RenameDialog.cs
Normal file
|
@ -0,0 +1,98 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Switch_Toolbox.Library.Forms
|
||||
{
|
||||
public partial class RenameDialog : Form
|
||||
{
|
||||
public RenameDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public void SetString(string Default)
|
||||
{
|
||||
textBox1.Text = Default;
|
||||
button2.Select();
|
||||
}
|
||||
//If used as a treeview filter
|
||||
public TreeViewCustom treeView;
|
||||
public TreeViewCustom _fieldsTreeCache;
|
||||
|
||||
public void LoadTree(TreeViewCustom t)
|
||||
{
|
||||
treeView = t;
|
||||
|
||||
_fieldsTreeCache = new TreeViewCustom();
|
||||
foreach (TreeNode originalNode in treeView.Nodes)
|
||||
{
|
||||
TreeNode newNode = new TreeNode(originalNode.Text);
|
||||
newNode.Tag = originalNode.Tag;
|
||||
_fieldsTreeCache.Nodes.Add(newNode);
|
||||
IterateTreeNodes(originalNode, newNode, _fieldsTreeCache);
|
||||
}
|
||||
}
|
||||
private void IterateTreeNodes(TreeNode originalNode, TreeNode rootNode, TreeView treeView2)
|
||||
{
|
||||
foreach (TreeNode childNode in originalNode.Nodes)
|
||||
{
|
||||
TreeNode newNode = new TreeNode(childNode.Text);
|
||||
newNode.Tag = childNode.Tag;
|
||||
treeView2.SelectedNode = rootNode;
|
||||
treeView2.SelectedNode.Nodes.Add(newNode);
|
||||
IterateTreeNodes(childNode, newNode, treeView2);
|
||||
}
|
||||
}
|
||||
private void RenameDialog_Load(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void textBox1_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (treeView != null)
|
||||
{
|
||||
if (textBox1.Text == String.Empty)
|
||||
{
|
||||
Console.WriteLine("Resetting tree");
|
||||
|
||||
treeView.Nodes.Clear();
|
||||
foreach (TreeNode originalNode in _fieldsTreeCache.Nodes)
|
||||
{
|
||||
TreeNode newNode = new TreeNode(originalNode.Text);
|
||||
newNode.Tag = originalNode.Tag;
|
||||
treeView.Nodes.Add(newNode);
|
||||
IterateTreeNodes(originalNode, newNode, treeView);
|
||||
}
|
||||
}
|
||||
|
||||
//blocks repainting tree till all objects loaded
|
||||
this.treeView.BeginUpdate();
|
||||
this.treeView.Nodes.Clear();
|
||||
if (this.textBox1.Text != string.Empty)
|
||||
{
|
||||
foreach (TreeNode _parentNode in _fieldsTreeCache.Nodes)
|
||||
{
|
||||
foreach (TreeNode _childNode in _parentNode.Nodes)
|
||||
{
|
||||
if (_childNode.Text.StartsWith(this.textBox1.Text))
|
||||
{
|
||||
this.treeView.Nodes.Add((TreeNode)_childNode.Clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (TreeNode _node in this._fieldsTreeCache.Nodes)
|
||||
{
|
||||
treeView.Nodes.Add((TreeNode)_node.Clone());
|
||||
}
|
||||
}
|
||||
//enables redrawing tree after all objects have been added
|
||||
this.treeView.EndUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
Switch_Toolbox_Library/GUI/Dialogs/RenameDialog.resx
Normal 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>
|
336
Switch_Toolbox_Library/GUI/FolderSelectDialog.cs
Normal file
|
@ -0,0 +1,336 @@
|
|||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
|
||||
namespace System.Windows.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// Wraps System.Windows.Forms.OpenFileDialog to make it present
|
||||
/// a vista-style dialog.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Browsable(false)]
|
||||
[DesignTimeVisible(false)]
|
||||
public partial class FolderSelectDialog : Component
|
||||
{
|
||||
// Wrapped dialog
|
||||
System.Windows.Forms.OpenFileDialog ofd = null;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public FolderSelectDialog()
|
||||
{
|
||||
ofd = new System.Windows.Forms.OpenFileDialog();
|
||||
|
||||
ofd.Filter = "Folders|\n";
|
||||
ofd.AddExtension = false;
|
||||
ofd.CheckFileExists = false;
|
||||
ofd.DereferenceLinks = true;
|
||||
ofd.Multiselect = false;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the initial folder to be selected. A null value selects the current directory.
|
||||
/// </summary>
|
||||
public string InitialDirectory
|
||||
{
|
||||
get { return ofd.InitialDirectory; }
|
||||
set { ofd.InitialDirectory = value == null || value.Length == 0 ? Environment.CurrentDirectory : value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the title to show in the dialog
|
||||
/// </summary>
|
||||
public string Title
|
||||
{
|
||||
get { return ofd.Title; }
|
||||
set { ofd.Title = value == null ? "Select a folder" : value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the selected folder
|
||||
/// </summary>
|
||||
public string SelectedPath
|
||||
{
|
||||
get { return ofd.FileName; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Shows the dialog
|
||||
/// </summary>
|
||||
/// <returns>DialogResult.OK if user presses OK, else DialogResult.Cancel</returns>
|
||||
public DialogResult ShowDialog()
|
||||
{
|
||||
return ShowDialog(IntPtr.Zero);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the dialog
|
||||
/// </summary>
|
||||
/// <param name="hWndOwner">Handle of the control to be parent</param>
|
||||
/// <returns>DialogResult.OK if user presses OK, else DialogResult.Cancel</returns>
|
||||
public DialogResult ShowDialog(IntPtr hWndOwner)
|
||||
{
|
||||
bool flag = false;
|
||||
|
||||
if (Environment.OSVersion.Version.Major >= 6)
|
||||
{
|
||||
var r = new Reflector("System.Windows.Forms");
|
||||
|
||||
uint num = 0;
|
||||
Type typeIFileDialog = r.GetType("FileDialogNative.IFileDialog");
|
||||
object dialog = r.Call(ofd, "CreateVistaDialog");
|
||||
r.Call(ofd, "OnBeforeVistaDialog", dialog);
|
||||
|
||||
uint options = (uint)r.CallAs(typeof(System.Windows.Forms.FileDialog), ofd, "GetOptions");
|
||||
options |= (uint)r.GetEnum("FileDialogNative.FOS", "FOS_PICKFOLDERS");
|
||||
r.CallAs(typeIFileDialog, dialog, "SetOptions", options);
|
||||
|
||||
object pfde = r.New("FileDialog.VistaDialogEvents", ofd);
|
||||
object[] parameters = new object[] { pfde, num };
|
||||
r.CallAs2(typeIFileDialog, dialog, "Advise", parameters);
|
||||
num = (uint)parameters[1];
|
||||
try
|
||||
{
|
||||
int num2 = (int)r.CallAs(typeIFileDialog, dialog, "Show", hWndOwner);
|
||||
flag = 0 == num2;
|
||||
}
|
||||
finally
|
||||
{
|
||||
r.CallAs(typeIFileDialog, dialog, "Unadvise", num);
|
||||
GC.KeepAlive(pfde);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var fbd = new FolderBrowserDialog();
|
||||
fbd.Description = this.Title;
|
||||
fbd.SelectedPath = this.InitialDirectory;
|
||||
fbd.ShowNewFolderButton = false;
|
||||
if (fbd.ShowDialog(new WindowWrapper(hWndOwner)) != DialogResult.OK) return DialogResult.Cancel;
|
||||
ofd.FileName = fbd.SelectedPath;
|
||||
flag = true;
|
||||
}
|
||||
|
||||
return flag ? DialogResult.OK : DialogResult.Cancel;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates IWin32Window around an IntPtr
|
||||
/// </summary>
|
||||
public class WindowWrapper : System.Windows.Forms.IWin32Window
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="handle">Handle to wrap</param>
|
||||
public WindowWrapper(IntPtr handle)
|
||||
{
|
||||
_hwnd = handle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Original ptr
|
||||
/// </summary>
|
||||
public IntPtr Handle
|
||||
{
|
||||
get { return _hwnd; }
|
||||
}
|
||||
|
||||
private IntPtr _hwnd;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This class is from the Front-End for Dosbox and is used to present a 'vista' dialog box to select folders.
|
||||
/// Being able to use a vista style dialog box to select folders is much better then using the shell folder browser.
|
||||
/// http://code.google.com/p/fed/
|
||||
///
|
||||
/// Example:
|
||||
/// var r = new Reflector("System.Windows.Forms");
|
||||
/// </summary>
|
||||
public class Reflector
|
||||
{
|
||||
#region variables
|
||||
|
||||
string m_ns;
|
||||
Assembly m_asmb;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="ns">The namespace containing types to be used</param>
|
||||
public Reflector(string ns)
|
||||
: this(ns, ns)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="an">A specific assembly name (used if the assembly name does not tie exactly with the namespace)</param>
|
||||
/// <param name="ns">The namespace containing types to be used</param>
|
||||
public Reflector(string an, string ns)
|
||||
{
|
||||
m_ns = ns;
|
||||
m_asmb = null;
|
||||
foreach (AssemblyName aN in Assembly.GetExecutingAssembly().GetReferencedAssemblies())
|
||||
{
|
||||
if (aN.FullName.StartsWith(an))
|
||||
{
|
||||
m_asmb = Assembly.Load(aN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Return a Type instance for a type 'typeName'
|
||||
/// </summary>
|
||||
/// <param name="typeName">The name of the type</param>
|
||||
/// <returns>A type instance</returns>
|
||||
public Type GetType(string typeName)
|
||||
{
|
||||
Type type = null;
|
||||
string[] names = typeName.Split('.');
|
||||
|
||||
if (names.Length > 0)
|
||||
type = m_asmb.GetType(m_ns + "." + names[0]);
|
||||
|
||||
for (int i = 1; i < names.Length; ++i)
|
||||
{
|
||||
type = type.GetNestedType(names[i], BindingFlags.NonPublic);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new object of a named type passing along any params
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the type to create</param>
|
||||
/// <param name="parameters"></param>
|
||||
/// <returns>An instantiated type</returns>
|
||||
public object New(string name, params object[] parameters)
|
||||
{
|
||||
Type type = GetType(name);
|
||||
|
||||
ConstructorInfo[] ctorInfos = type.GetConstructors();
|
||||
foreach (ConstructorInfo ci in ctorInfos)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ci.Invoke(parameters);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calls method 'func' on object 'obj' passing parameters 'parameters'
|
||||
/// </summary>
|
||||
/// <param name="obj">The object on which to excute function 'func'</param>
|
||||
/// <param name="func">The function to execute</param>
|
||||
/// <param name="parameters">The parameters to pass to function 'func'</param>
|
||||
/// <returns>The result of the function invocation</returns>
|
||||
public object Call(object obj, string func, params object[] parameters)
|
||||
{
|
||||
return Call2(obj, func, parameters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calls method 'func' on object 'obj' passing parameters 'parameters'
|
||||
/// </summary>
|
||||
/// <param name="obj">The object on which to excute function 'func'</param>
|
||||
/// <param name="func">The function to execute</param>
|
||||
/// <param name="parameters">The parameters to pass to function 'func'</param>
|
||||
/// <returns>The result of the function invocation</returns>
|
||||
public object Call2(object obj, string func, object[] parameters)
|
||||
{
|
||||
return CallAs2(obj.GetType(), obj, func, parameters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calls method 'func' on object 'obj' which is of type 'type' passing parameters 'parameters'
|
||||
/// </summary>
|
||||
/// <param name="type">The type of 'obj'</param>
|
||||
/// <param name="obj">The object on which to excute function 'func'</param>
|
||||
/// <param name="func">The function to execute</param>
|
||||
/// <param name="parameters">The parameters to pass to function 'func'</param>
|
||||
/// <returns>The result of the function invocation</returns>
|
||||
public object CallAs(Type type, object obj, string func, params object[] parameters)
|
||||
{
|
||||
return CallAs2(type, obj, func, parameters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calls method 'func' on object 'obj' which is of type 'type' passing parameters 'parameters'
|
||||
/// </summary>
|
||||
/// <param name="type">The type of 'obj'</param>
|
||||
/// <param name="obj">The object on which to excute function 'func'</param>
|
||||
/// <param name="func">The function to execute</param>
|
||||
/// <param name="parameters">The parameters to pass to function 'func'</param>
|
||||
/// <returns>The result of the function invocation</returns>
|
||||
public object CallAs2(Type type, object obj, string func, object[] parameters)
|
||||
{
|
||||
MethodInfo methInfo = type.GetMethod(func, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
return methInfo.Invoke(obj, parameters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value of property 'prop' of object 'obj'
|
||||
/// </summary>
|
||||
/// <param name="obj">The object containing 'prop'</param>
|
||||
/// <param name="prop">The property name</param>
|
||||
/// <returns>The property value</returns>
|
||||
public object Get(object obj, string prop)
|
||||
{
|
||||
return GetAs(obj.GetType(), obj, prop);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value of property 'prop' of object 'obj' which has type 'type'
|
||||
/// </summary>
|
||||
/// <param name="type">The type of 'obj'</param>
|
||||
/// <param name="obj">The object containing 'prop'</param>
|
||||
/// <param name="prop">The property name</param>
|
||||
/// <returns>The property value</returns>
|
||||
public static object GetAs(Type type, object obj, string prop)
|
||||
{
|
||||
PropertyInfo propInfo = type.GetProperty(prop, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
return propInfo.GetValue(obj, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an enum value
|
||||
/// </summary>
|
||||
/// <param name="typeName">The name of enum type</param>
|
||||
/// <param name="name">The name of the value</param>
|
||||
/// <returns>The enum value</returns>
|
||||
public object GetEnum(string typeName, string name)
|
||||
{
|
||||
Type type = GetType(typeName);
|
||||
FieldInfo fieldInfo = type.GetField(name);
|
||||
return fieldInfo.GetValue(null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
158
Switch_Toolbox_Library/GUI/ObjectList.Designer.cs
generated
Normal file
|
@ -0,0 +1,158 @@
|
|||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
partial class ObjectList
|
||||
{
|
||||
/// <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.components = new System.ComponentModel.Container();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.contextMenuStripDark1 = new Switch_Toolbox.Library.Forms.ContextMenuStripDark();
|
||||
this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.smallToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mediumToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.largeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.searchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.treeView1 = new Switch_Toolbox.Library.TreeViewCustom();
|
||||
this.panel1.SuspendLayout();
|
||||
this.contextMenuStripDark1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
|
||||
this.panel1.Controls.Add(this.contextMenuStripDark1);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.panel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(358, 27);
|
||||
this.panel1.TabIndex = 2;
|
||||
//
|
||||
// contextMenuStripDark1
|
||||
//
|
||||
this.contextMenuStripDark1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(33)))), ((int)(((byte)(33)))), ((int)(((byte)(33)))));
|
||||
this.contextMenuStripDark1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
|
||||
this.contextMenuStripDark1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.settingsToolStripMenuItem,
|
||||
this.searchToolStripMenuItem});
|
||||
this.contextMenuStripDark1.Location = new System.Drawing.Point(0, 0);
|
||||
this.contextMenuStripDark1.Name = "contextMenuStripDark1";
|
||||
this.contextMenuStripDark1.Size = new System.Drawing.Size(358, 24);
|
||||
this.contextMenuStripDark1.TabIndex = 1;
|
||||
this.contextMenuStripDark1.Text = "contextMenuStripDark1";
|
||||
//
|
||||
// settingsToolStripMenuItem
|
||||
//
|
||||
this.settingsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.smallToolStripMenuItem,
|
||||
this.mediumToolStripMenuItem,
|
||||
this.largeToolStripMenuItem});
|
||||
this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem";
|
||||
this.settingsToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
|
||||
this.settingsToolStripMenuItem.Text = "View";
|
||||
//
|
||||
// smallToolStripMenuItem
|
||||
//
|
||||
this.smallToolStripMenuItem.ForeColor = System.Drawing.Color.White;
|
||||
this.smallToolStripMenuItem.Name = "smallToolStripMenuItem";
|
||||
this.smallToolStripMenuItem.Size = new System.Drawing.Size(119, 22);
|
||||
this.smallToolStripMenuItem.Text = "Small";
|
||||
this.smallToolStripMenuItem.Click += new System.EventHandler(this.smallToolStripMenuItem_Click);
|
||||
//
|
||||
// mediumToolStripMenuItem
|
||||
//
|
||||
this.mediumToolStripMenuItem.ForeColor = System.Drawing.Color.White;
|
||||
this.mediumToolStripMenuItem.Name = "mediumToolStripMenuItem";
|
||||
this.mediumToolStripMenuItem.Size = new System.Drawing.Size(119, 22);
|
||||
this.mediumToolStripMenuItem.Text = "Medium";
|
||||
this.mediumToolStripMenuItem.Click += new System.EventHandler(this.mediumToolStripMenuItem_Click);
|
||||
//
|
||||
// largeToolStripMenuItem
|
||||
//
|
||||
this.largeToolStripMenuItem.ForeColor = System.Drawing.Color.White;
|
||||
this.largeToolStripMenuItem.Name = "largeToolStripMenuItem";
|
||||
this.largeToolStripMenuItem.Size = new System.Drawing.Size(119, 22);
|
||||
this.largeToolStripMenuItem.Text = "Large";
|
||||
this.largeToolStripMenuItem.Click += new System.EventHandler(this.largeToolStripMenuItem_Click);
|
||||
//
|
||||
// searchToolStripMenuItem
|
||||
//
|
||||
this.searchToolStripMenuItem.Name = "searchToolStripMenuItem";
|
||||
this.searchToolStripMenuItem.Size = new System.Drawing.Size(54, 20);
|
||||
this.searchToolStripMenuItem.Text = "Search";
|
||||
this.searchToolStripMenuItem.Click += new System.EventHandler(this.searchToolStripMenuItem_Click);
|
||||
//
|
||||
// treeView1
|
||||
//
|
||||
this.treeView1.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.treeView1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
|
||||
this.treeView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.treeView1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.treeView1.ForeColor = System.Drawing.Color.White;
|
||||
this.treeView1.ImageIndex = 0;
|
||||
this.treeView1.Location = new System.Drawing.Point(0, 27);
|
||||
this.treeView1.Name = "treeView1";
|
||||
this.treeView1.SelectedImageIndex = 0;
|
||||
this.treeView1.Size = new System.Drawing.Size(358, 423);
|
||||
this.treeView1.TabIndex = 0;
|
||||
this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterCheck);
|
||||
this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
|
||||
this.treeView1.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.selectItem);
|
||||
//
|
||||
// ObjectList
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
|
||||
this.ClientSize = new System.Drawing.Size(358, 450);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.Controls.Add(this.treeView1);
|
||||
this.Name = "ObjectList";
|
||||
this.Text = "ObjectList";
|
||||
this.DockStateChanged += new System.EventHandler(this.ObjectList_DockStateChanged);
|
||||
this.Load += new System.EventHandler(this.ObjectList_Load);
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel1.PerformLayout();
|
||||
this.contextMenuStripDark1.ResumeLayout(false);
|
||||
this.contextMenuStripDark1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public Switch_Toolbox.Library.TreeViewCustom treeView1;
|
||||
private Forms.ContextMenuStripDark contextMenuStripDark1;
|
||||
private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem smallToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem mediumToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem largeToolStripMenuItem;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.ToolStripMenuItem searchToolStripMenuItem;
|
||||
}
|
||||
}
|
212
Switch_Toolbox_Library/GUI/ObjectList.cs
Normal file
|
@ -0,0 +1,212 @@
|
|||
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.Threading;
|
||||
using System.Windows.Forms;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
using System.Text.RegularExpressions;
|
||||
using Switch_Toolbox.Library.Rendering;
|
||||
using Switch_Toolbox.Library.Forms;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public partial class ObjectList : DockContent
|
||||
{
|
||||
Thread Thread;
|
||||
|
||||
public ObjectList()
|
||||
{
|
||||
InitializeComponent();
|
||||
ApplyThumbnailSetting(Runtime.thumbnailSize);
|
||||
// treeView1.Sort();
|
||||
}
|
||||
|
||||
private void selectItem(object sender, TreeNodeMouseClickEventArgs e)
|
||||
{
|
||||
if (e.Node is Animation)
|
||||
{
|
||||
string AnimName = e.Node.Text;
|
||||
AnimName = Regex.Match(AnimName, @"([A-Z][0-9][0-9])(.*)").Groups[0].ToString();
|
||||
if (AnimName.Length > 3)
|
||||
AnimName = AnimName.Substring(3);
|
||||
|
||||
Animation running = new Animation(AnimName);
|
||||
running.ReplaceMe((Animation)e.Node);
|
||||
running.Tag = e.Node;
|
||||
|
||||
Queue<TreeNode> NodeQueue = new Queue<TreeNode>();
|
||||
foreach (TreeNode n in treeView1.Nodes)
|
||||
{
|
||||
NodeQueue.Enqueue(n);
|
||||
}
|
||||
while (NodeQueue.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
TreeNode n = NodeQueue.Dequeue();
|
||||
string NodeName = Regex.Match(n.Text, @"([A-Z][0-9][0-9])(.*)").Groups[0].ToString();
|
||||
if (NodeName.Length <= 3)
|
||||
Console.WriteLine(NodeName);
|
||||
else
|
||||
NodeName = NodeName.Substring(3);
|
||||
if (n is Animation)
|
||||
{
|
||||
if (n == e.Node)
|
||||
continue;
|
||||
if (NodeName.Equals(AnimName))
|
||||
{
|
||||
running.Children.Add(n);
|
||||
}
|
||||
}
|
||||
if (n is AnimationGroupNode)
|
||||
{
|
||||
foreach (TreeNode tn in n.Nodes)
|
||||
NodeQueue.Enqueue(tn);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
AnimationPanel AnimationPanel = LoadAnimationPanel();
|
||||
|
||||
if (AnimationPanel != null)
|
||||
{
|
||||
AnimationPanel.CurrentAnimation = running;
|
||||
}
|
||||
}
|
||||
}
|
||||
public AnimationPanel LoadAnimationPanel()
|
||||
{
|
||||
Form form1 = Application.OpenForms[0];
|
||||
foreach (Control control in form1.Controls)
|
||||
{
|
||||
if (control is DockPanel)
|
||||
{
|
||||
foreach (DockContent ctrl in ((DockPanel)control).Contents)
|
||||
{
|
||||
if (ctrl is AnimationPanel)
|
||||
{
|
||||
// return (AnimationPanel)ctrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void ApplyThumbnailSetting(Runtime.ThumbnailSize size)
|
||||
{
|
||||
//Set default color
|
||||
smallToolStripMenuItem.BackColor = Color.FromArgb(33, 33, 33);
|
||||
mediumToolStripMenuItem.BackColor = Color.FromArgb(33, 33, 33);
|
||||
largeToolStripMenuItem.BackColor = Color.FromArgb(33, 33, 33);
|
||||
|
||||
switch (size)
|
||||
{
|
||||
case Runtime.ThumbnailSize.Small:
|
||||
treeView1.ImageHeight = 21;
|
||||
treeView1.ImageWidth = 21;
|
||||
smallToolStripMenuItem.BackColor = Color.FromArgb(80, 80, 80);
|
||||
break;
|
||||
case Runtime.ThumbnailSize.Medium:
|
||||
treeView1.ImageHeight = 27;
|
||||
treeView1.ImageWidth = 27;
|
||||
mediumToolStripMenuItem.BackColor = Color.FromArgb(80, 80, 80);
|
||||
break;
|
||||
case Runtime.ThumbnailSize.Large:
|
||||
treeView1.ImageHeight = 34;
|
||||
treeView1.ImageWidth = 34;
|
||||
largeToolStripMenuItem.BackColor = Color.FromArgb(80, 80, 80);
|
||||
break;
|
||||
}
|
||||
treeView1.ReloadImages();
|
||||
}
|
||||
|
||||
private void largeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Runtime.thumbnailSize = Runtime.ThumbnailSize.Large;
|
||||
ApplyThumbnailSetting(Runtime.thumbnailSize);
|
||||
}
|
||||
|
||||
private void mediumToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Runtime.thumbnailSize = Runtime.ThumbnailSize.Medium;
|
||||
ApplyThumbnailSetting(Runtime.thumbnailSize);
|
||||
}
|
||||
|
||||
private void smallToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Runtime.thumbnailSize = Runtime.ThumbnailSize.Small;
|
||||
ApplyThumbnailSetting(Runtime.thumbnailSize);
|
||||
}
|
||||
|
||||
protected override void OnFormClosing(FormClosingEventArgs e)
|
||||
{
|
||||
foreach (IFileFormat file in FileManager.GetFileFormats())
|
||||
{
|
||||
if (file.IsActive)
|
||||
{
|
||||
DialogResult dialogResult = MessageBox.Show("Are you sure you want to close this tab? Doing so may result in losing progress.", "", MessageBoxButtons.YesNo);
|
||||
if (dialogResult != DialogResult.Yes)
|
||||
{
|
||||
e.Cancel = true;
|
||||
base.OnFormClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
|
||||
{
|
||||
if (treeView1.SelectedNode is TreeNodeCustom)
|
||||
{
|
||||
((TreeNodeCustom)treeView1.SelectedNode).OnClick(treeView1);
|
||||
}
|
||||
if (treeView1.SelectedNode is STGenericObject)
|
||||
{
|
||||
((STGenericObject)treeView1.SelectedNode).OnClick(treeView1);
|
||||
}
|
||||
if (treeView1.SelectedNode is STGenericMaterial)
|
||||
{
|
||||
((STGenericMaterial)treeView1.SelectedNode).OnClick(treeView1);
|
||||
}
|
||||
|
||||
Viewport.Instance.UpdateViewport();
|
||||
}
|
||||
|
||||
private void ObjectList_DockStateChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void treeView1_AfterCheck(object sender, TreeViewEventArgs e)
|
||||
{
|
||||
Viewport.Instance.UpdateViewport();
|
||||
}
|
||||
|
||||
private void searchToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
return;
|
||||
|
||||
RenameDialog search = new RenameDialog();
|
||||
search.Text = "Search";
|
||||
search.LoadTree(treeView1);
|
||||
if (search.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
string NameLookup = search.textBox1.Text;
|
||||
}
|
||||
}
|
||||
|
||||
private void ObjectList_Load(object sender, EventArgs e)
|
||||
{
|
||||
// this.treeView1.DrawMode = TreeViewDrawMode.OwnerDrawText;
|
||||
}
|
||||
}
|
||||
}
|
126
Switch_Toolbox_Library/GUI/ObjectList.resx
Normal file
|
@ -0,0 +1,126 @@
|
|||
<?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>
|
||||
<metadata name="contextMenuStripDark1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="contextMenuStripDark1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
72
Switch_Toolbox_Library/GUI/ProgressBar.Designer.cs
generated
Normal file
|
@ -0,0 +1,72 @@
|
|||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
partial class ProgressBarWindow
|
||||
{
|
||||
/// <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.progressBar1 = new System.Windows.Forms.ProgressBar();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// progressBar1
|
||||
//
|
||||
this.progressBar1.Location = new System.Drawing.Point(12, 46);
|
||||
this.progressBar1.Name = "progressBar1";
|
||||
this.progressBar1.Size = new System.Drawing.Size(195, 23);
|
||||
this.progressBar1.TabIndex = 0;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(82, 30);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(0, 13);
|
||||
this.label1.TabIndex = 1;
|
||||
//
|
||||
// ProgressBarWindow
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(219, 81);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.progressBar1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.Name = "ProgressBarWindow";
|
||||
this.Text = "Progress";
|
||||
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.ProgressBar_FormClosed);
|
||||
this.Load += new System.EventHandler(this.ProgressBarWindow_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ProgressBar progressBar1;
|
||||
private System.Windows.Forms.Label label1;
|
||||
}
|
||||
}
|
49
Switch_Toolbox_Library/GUI/ProgressBar.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
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;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public partial class ProgressBarWindow : Form
|
||||
{
|
||||
public ProgressBarWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public int Value
|
||||
{
|
||||
set
|
||||
{
|
||||
progressBar1.Value = value;
|
||||
if (value >= 100)
|
||||
Close();
|
||||
progressBar1.Refresh();
|
||||
}
|
||||
}
|
||||
public string Task
|
||||
{
|
||||
set
|
||||
{
|
||||
label1.Text = value;
|
||||
label1.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private void ProgressBar_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void ProgressBarWindow_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
120
Switch_Toolbox_Library/GUI/ProgressBar.resx
Normal 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>
|
171
Switch_Toolbox_Library/GUI/Viewport.Designer.cs
generated
Normal file
|
@ -0,0 +1,171 @@
|
|||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
partial class Viewport
|
||||
{
|
||||
/// <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.gL_ControlModern1 = new GL_Core.GL_ControlModern();
|
||||
this.animationPanel1 = new Switch_Toolbox.Library.AnimationPanel();
|
||||
this.contextMenuStripDark1 = new Switch_Toolbox.Library.Forms.ContextMenuStripDark();
|
||||
this.shadingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.normalsShadingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.translateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.rotateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.scaleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.contextMenuStripDark1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// gL_ControlModern1
|
||||
//
|
||||
this.gL_ControlModern1.ActiveCamera = null;
|
||||
this.gL_ControlModern1.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_ControlModern1.BackColor = System.Drawing.Color.Black;
|
||||
this.gL_ControlModern1.CurrentShader = null;
|
||||
this.gL_ControlModern1.DisplayPolyCount = false;
|
||||
this.gL_ControlModern1.Location = new System.Drawing.Point(-3, 66);
|
||||
this.gL_ControlModern1.MainDrawable = null;
|
||||
this.gL_ControlModern1.Name = "gL_ControlModern1";
|
||||
this.gL_ControlModern1.Size = new System.Drawing.Size(791, 388);
|
||||
this.gL_ControlModern1.Stereoscopy = false;
|
||||
this.gL_ControlModern1.TabIndex = 0;
|
||||
this.gL_ControlModern1.VSync = false;
|
||||
//
|
||||
// animationPanel1
|
||||
//
|
||||
this.animationPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.animationPanel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(33)))), ((int)(((byte)(33)))), ((int)(((byte)(33)))));
|
||||
this.animationPanel1.CurrentAnimation = null;
|
||||
this.animationPanel1.Location = new System.Drawing.Point(-3, 450);
|
||||
this.animationPanel1.Name = "animationPanel1";
|
||||
this.animationPanel1.Size = new System.Drawing.Size(791, 69);
|
||||
this.animationPanel1.TabIndex = 1;
|
||||
//
|
||||
// contextMenuStripDark1
|
||||
//
|
||||
this.contextMenuStripDark1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(33)))), ((int)(((byte)(33)))), ((int)(((byte)(33)))));
|
||||
this.contextMenuStripDark1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
|
||||
this.contextMenuStripDark1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.shadingToolStripMenuItem,
|
||||
this.translateToolStripMenuItem,
|
||||
this.rotateToolStripMenuItem,
|
||||
this.scaleToolStripMenuItem});
|
||||
this.contextMenuStripDark1.Location = new System.Drawing.Point(0, 0);
|
||||
this.contextMenuStripDark1.Name = "contextMenuStripDark1";
|
||||
this.contextMenuStripDark1.Size = new System.Drawing.Size(781, 63);
|
||||
this.contextMenuStripDark1.TabIndex = 2;
|
||||
this.contextMenuStripDark1.Text = "contextMenuStripDark1";
|
||||
this.contextMenuStripDark1.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.contextMenuStripDark1_ItemClicked);
|
||||
//
|
||||
// shadingToolStripMenuItem
|
||||
//
|
||||
this.shadingToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {});
|
||||
this.shadingToolStripMenuItem.Image = global::Switch_Toolbox.Library.Properties.Resources.diffuseSphere;
|
||||
this.shadingToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
|
||||
this.shadingToolStripMenuItem.Name = "shadingToolStripMenuItem";
|
||||
this.shadingToolStripMenuItem.Size = new System.Drawing.Size(103, 59);
|
||||
this.shadingToolStripMenuItem.Text = "Default Shading";
|
||||
this.shadingToolStripMenuItem.TextDirection = System.Windows.Forms.ToolStripTextDirection.Horizontal;
|
||||
this.shadingToolStripMenuItem.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
|
||||
this.shadingToolStripMenuItem.DropDownItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.shadingToolStripMenuItem_DropDownItemClicked);
|
||||
//
|
||||
// normalsShadingToolStripMenuItem
|
||||
//
|
||||
this.normalsShadingToolStripMenuItem.ForeColor = System.Drawing.Color.White;
|
||||
this.normalsShadingToolStripMenuItem.Image = global::Switch_Toolbox.Library.Properties.Resources.normalsSphere;
|
||||
this.normalsShadingToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
|
||||
this.normalsShadingToolStripMenuItem.Name = "normalsShadingToolStripMenuItem";
|
||||
this.normalsShadingToolStripMenuItem.Size = new System.Drawing.Size(204, 46);
|
||||
this.normalsShadingToolStripMenuItem.Text = "Normals Shading";
|
||||
this.normalsShadingToolStripMenuItem.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
|
||||
//
|
||||
// translateToolStripMenuItem
|
||||
//
|
||||
this.translateToolStripMenuItem.Image = global::Switch_Toolbox.Library.Properties.Resources.translateGizmo;
|
||||
this.translateToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
|
||||
this.translateToolStripMenuItem.Name = "translateToolStripMenuItem";
|
||||
this.translateToolStripMenuItem.Size = new System.Drawing.Size(66, 59);
|
||||
this.translateToolStripMenuItem.Text = "Translate";
|
||||
this.translateToolStripMenuItem.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
|
||||
//
|
||||
// rotateToolStripMenuItem
|
||||
//
|
||||
this.rotateToolStripMenuItem.Image = global::Switch_Toolbox.Library.Properties.Resources.rotateGizmo;
|
||||
this.rotateToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
|
||||
this.rotateToolStripMenuItem.Name = "rotateToolStripMenuItem";
|
||||
this.rotateToolStripMenuItem.Size = new System.Drawing.Size(53, 59);
|
||||
this.rotateToolStripMenuItem.Text = "Rotate";
|
||||
this.rotateToolStripMenuItem.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
|
||||
//
|
||||
// scaleToolStripMenuItem
|
||||
//
|
||||
this.scaleToolStripMenuItem.Image = global::Switch_Toolbox.Library.Properties.Resources.scaleGizmo;
|
||||
this.scaleToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
|
||||
this.scaleToolStripMenuItem.Name = "scaleToolStripMenuItem";
|
||||
this.scaleToolStripMenuItem.Size = new System.Drawing.Size(52, 59);
|
||||
this.scaleToolStripMenuItem.Text = "Scale";
|
||||
this.scaleToolStripMenuItem.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
|
||||
//
|
||||
// Viewport
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.ClientSize = new System.Drawing.Size(781, 522);
|
||||
this.Controls.Add(this.animationPanel1);
|
||||
this.Controls.Add(this.gL_ControlModern1);
|
||||
this.Controls.Add(this.contextMenuStripDark1);
|
||||
this.DockAreas = ((WeifenLuo.WinFormsUI.Docking.DockAreas)((((((WeifenLuo.WinFormsUI.Docking.DockAreas.Float | WeifenLuo.WinFormsUI.Docking.DockAreas.DockLeft)
|
||||
| WeifenLuo.WinFormsUI.Docking.DockAreas.DockRight)
|
||||
| WeifenLuo.WinFormsUI.Docking.DockAreas.DockTop)
|
||||
| WeifenLuo.WinFormsUI.Docking.DockAreas.DockBottom)
|
||||
| WeifenLuo.WinFormsUI.Docking.DockAreas.Document)));
|
||||
this.MainMenuStrip = this.contextMenuStripDark1;
|
||||
this.Name = "Viewport";
|
||||
this.ShowHint = WeifenLuo.WinFormsUI.Docking.DockState.Unknown;
|
||||
this.Text = "Viewport";
|
||||
this.contextMenuStripDark1.ResumeLayout(false);
|
||||
this.contextMenuStripDark1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public GL_Core.GL_ControlModern gL_ControlModern1;
|
||||
private AnimationPanel animationPanel1;
|
||||
private Forms.ContextMenuStripDark contextMenuStripDark1;
|
||||
private System.Windows.Forms.ToolStripMenuItem shadingToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem translateToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem rotateToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem scaleToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem normalsShadingToolStripMenuItem;
|
||||
}
|
||||
}
|
125
Switch_Toolbox_Library/GUI/Viewport.cs
Normal file
|
@ -0,0 +1,125 @@
|
|||
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 GL_Core;
|
||||
using GL_Core.Public_Interfaces;
|
||||
using GL_Core.Cameras;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public partial class Viewport : DockContentST
|
||||
{
|
||||
public Viewport()
|
||||
{
|
||||
InitializeComponent();
|
||||
LoadViewportRuntimeValues();
|
||||
LoadShadingModes();
|
||||
}
|
||||
|
||||
public static Viewport Instance
|
||||
{
|
||||
get { return _instance != null ? _instance : (_instance = new Viewport()); }
|
||||
}
|
||||
private static Viewport _instance;
|
||||
|
||||
public GL_ControlLegacy GL_ControlLegacy;
|
||||
|
||||
public void UpdateViewport()
|
||||
{
|
||||
if (gL_ControlModern1 != null)
|
||||
gL_ControlModern1.Refresh();
|
||||
if (GL_ControlLegacy != null)
|
||||
GL_ControlLegacy.Refresh();
|
||||
}
|
||||
public void RenderToTexture()
|
||||
{
|
||||
if (gL_ControlModern1 == null)
|
||||
return;
|
||||
|
||||
int Framebuffer = 0;
|
||||
}
|
||||
private void LoadShadingModes()
|
||||
{
|
||||
foreach (var type in Enum.GetValues(typeof(Runtime.ViewportShading)).Cast<Runtime.ViewportShading>())
|
||||
{
|
||||
ToolStripMenuItem item = new ToolStripMenuItem();
|
||||
item.Text = $"Shading: {type.ToString()}";
|
||||
item.TextImageRelation = TextImageRelation.ImageAboveText;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case Runtime.ViewportShading.Default:
|
||||
item.Image = Properties.Resources.diffuseSphere;
|
||||
break;
|
||||
case Runtime.ViewportShading.Normal:
|
||||
item.Image = Properties.Resources.normalsSphere;
|
||||
break;
|
||||
case Runtime.ViewportShading.NormalMap:
|
||||
item.Image = Properties.Resources.normalMapSphere;
|
||||
break;
|
||||
}
|
||||
|
||||
shadingToolStripMenuItem.DropDownItems.Add(item);
|
||||
}
|
||||
}
|
||||
public void LoadViewportRuntimeValues()
|
||||
{
|
||||
switch (Runtime.cameraMovement)
|
||||
{
|
||||
case Runtime.CameraMovement.Inspect:
|
||||
gL_ControlModern1.ActiveCamera = new InspectCamera();
|
||||
break;
|
||||
case Runtime.CameraMovement.Walk:
|
||||
gL_ControlModern1.ActiveCamera = new WalkaroundCamera();
|
||||
break;
|
||||
}
|
||||
gL_ControlModern1.Stereoscopy = Runtime.stereoscopy;
|
||||
gL_ControlModern1.znear = Runtime.CameraNear;
|
||||
gL_ControlModern1.zfar = Runtime.CameraFar;
|
||||
gL_ControlModern1.DisplayPolyCount = Runtime.DisplayPolyCount;
|
||||
gL_ControlModern1.PolyCount = Runtime.PolyCount;
|
||||
gL_ControlModern1.VertCount = Runtime.VertCount;
|
||||
}
|
||||
public void SetupViewportRuntimeValues()
|
||||
{
|
||||
if (gL_ControlModern1.ActiveCamera is InspectCamera)
|
||||
Runtime.cameraMovement = Runtime.CameraMovement.Inspect;
|
||||
if (gL_ControlModern1.ActiveCamera is WalkaroundCamera)
|
||||
Runtime.cameraMovement = Runtime.CameraMovement.Walk;
|
||||
|
||||
Runtime.stereoscopy = gL_ControlModern1.Stereoscopy;
|
||||
Runtime.DisplayPolyCount = gL_ControlModern1.DisplayPolyCount;
|
||||
Runtime.PolyCount = gL_ControlModern1.PolyCount;
|
||||
Runtime.VertCount = gL_ControlModern1.VertCount;
|
||||
}
|
||||
|
||||
private void contextMenuStripDark1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void shadingToolStripMenuItem_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (ToolStripItem item in shadingToolStripMenuItem.DropDownItems)
|
||||
{
|
||||
if (item.Selected)
|
||||
{
|
||||
Runtime.viewportShading = (Runtime.ViewportShading)i;
|
||||
|
||||
shadingToolStripMenuItem.Text = item.Text;
|
||||
shadingToolStripMenuItem.Image = item.Image;
|
||||
|
||||
UpdateViewport();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
123
Switch_Toolbox_Library/GUI/Viewport.resx
Normal file
|
@ -0,0 +1,123 @@
|
|||
<?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>
|
||||
<metadata name="contextMenuStripDark1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
196
Switch_Toolbox_Library/IO/FileIO.cs
Normal file
|
@ -0,0 +1,196 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Syroot.BinaryData;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using OpenTK;
|
||||
|
||||
namespace Switch_Toolbox.Library.IO
|
||||
{
|
||||
public class STLibraryCompression
|
||||
{
|
||||
public class GZIP
|
||||
{
|
||||
public static byte[] Decompress(byte[] b)
|
||||
{
|
||||
using (MemoryStream mem = new MemoryStream())
|
||||
{
|
||||
using (GZipStream gzip = new GZipStream(new MemoryStream(b), CompressionMode.Decompress))
|
||||
{
|
||||
gzip.CopyTo(mem);
|
||||
mem.Write(b, 0, b.Length);
|
||||
}
|
||||
return mem.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] Compress(byte[] b)
|
||||
{
|
||||
using (MemoryStream mem = new MemoryStream())
|
||||
{
|
||||
using (GZipStream gzip = new GZipStream(mem,
|
||||
CompressionMode.Compress, true))
|
||||
{
|
||||
gzip.Write(b, 0, b.Length);
|
||||
}
|
||||
return mem.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class FileWriter : BinaryDataWriter
|
||||
{
|
||||
public FileWriter(Stream stream, bool leaveOpen = false)
|
||||
: base(stream, Encoding.ASCII, leaveOpen)
|
||||
{
|
||||
}
|
||||
|
||||
public FileWriter(string fileName)
|
||||
: this(new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.Write))
|
||||
{
|
||||
}
|
||||
public FileWriter(byte[] data)
|
||||
: this(new MemoryStream(data))
|
||||
{
|
||||
}
|
||||
public void Write(Syroot.Maths.Vector2F v)
|
||||
{
|
||||
Write(v.X);
|
||||
Write(v.Y);
|
||||
}
|
||||
public void Write(Syroot.Maths.Vector3F v)
|
||||
{
|
||||
Write(v.X);
|
||||
Write(v.Y);
|
||||
Write(v.Z);
|
||||
}
|
||||
public void Write(Syroot.Maths.Vector4F v)
|
||||
{
|
||||
Write(v.X);
|
||||
Write(v.Y);
|
||||
Write(v.Z);
|
||||
Write(v.W);
|
||||
}
|
||||
public void WriteSignature(string value)
|
||||
{
|
||||
Write(Encoding.ASCII.GetBytes(value));
|
||||
}
|
||||
}
|
||||
public class FileExt
|
||||
{
|
||||
public static Vector2 ToVec2(Syroot.Maths.Vector2F v)
|
||||
{
|
||||
return new Vector2(v.X, v.Y);
|
||||
}
|
||||
public static Vector3 ToVec3(Syroot.Maths.Vector3F v)
|
||||
{
|
||||
return new Vector3(v.X, v.Y, v.Z);
|
||||
}
|
||||
public static Vector4 ToVec4(Syroot.Maths.Vector4F v)
|
||||
{
|
||||
return new Vector4(v.X, v.Y, v.Z, v.W);
|
||||
}
|
||||
public static Vector2 ToVec2(float[] v)
|
||||
{
|
||||
return new Vector2(v[0], v[1]);
|
||||
}
|
||||
public static Vector3 ToVec3(float[] v)
|
||||
{
|
||||
return new Vector3(v[0], v[1], v[2]);
|
||||
}
|
||||
public static Vector4 ToVec4(float[] v)
|
||||
{
|
||||
return new Vector4(v[0], v[1], v[2], v[3]);
|
||||
}
|
||||
|
||||
|
||||
public static string DataToString(Syroot.Maths.Vector2F v)
|
||||
{
|
||||
return $"{v.X},{v.Y}";
|
||||
}
|
||||
public static string DataToString(Syroot.Maths.Vector3F v)
|
||||
{
|
||||
return $"{v.X},{v.Y},{v.Z}";
|
||||
}
|
||||
public static string DataToString(Syroot.Maths.Vector4F v)
|
||||
{
|
||||
return $"{v.X},{v.Y},{v.Z} {v.W}";
|
||||
}
|
||||
}
|
||||
public class FileReader : BinaryDataReader
|
||||
{
|
||||
public FileReader(Stream stream, bool leaveOpen = false)
|
||||
: base(stream, Encoding.ASCII, leaveOpen)
|
||||
{
|
||||
}
|
||||
|
||||
public FileReader(string fileName)
|
||||
: this(new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
}
|
||||
public FileReader(byte[] data)
|
||||
: this(new MemoryStream(data))
|
||||
{
|
||||
}
|
||||
public static byte[] DeflateZLIB(byte[] i)
|
||||
{
|
||||
MemoryStream output = new MemoryStream();
|
||||
output.WriteByte(0x78);
|
||||
output.WriteByte(0x9C);
|
||||
using (DeflateStream dstream = new DeflateStream(output, CompressionLevel.Optimal))
|
||||
{
|
||||
dstream.Write(i, 0, i.Length);
|
||||
}
|
||||
return output.ToArray();
|
||||
}
|
||||
public byte[] getSection(int offset, int size)
|
||||
{
|
||||
Seek(offset, SeekOrigin.Begin);
|
||||
return ReadBytes(size);
|
||||
}
|
||||
public Vector3 ReadVec3()
|
||||
{
|
||||
return new Vector3(ReadSingle(), ReadSingle(), ReadSingle());
|
||||
}
|
||||
public Syroot.Maths.Vector3F ReadVec3SY()
|
||||
{
|
||||
return new Syroot.Maths.Vector3F(ReadSingle(), ReadSingle(), ReadSingle());
|
||||
}
|
||||
public Vector2 ReadVec2()
|
||||
{
|
||||
return new Vector2(ReadSingle(), ReadSingle());
|
||||
}
|
||||
public Syroot.Maths.Vector2F ReadVec2SY()
|
||||
{
|
||||
return new Syroot.Maths.Vector2F(ReadSingle(), ReadSingle());
|
||||
}
|
||||
public static byte[] InflateZLIB(byte[] i)
|
||||
{
|
||||
var stream = new MemoryStream();
|
||||
var ms = new MemoryStream(i);
|
||||
ms.ReadByte();
|
||||
ms.ReadByte();
|
||||
var zlibStream = new DeflateStream(ms, CompressionMode.Decompress);
|
||||
byte[] buffer = new byte[4095];
|
||||
while (true)
|
||||
{
|
||||
int size = zlibStream.Read(buffer, 0, buffer.Length);
|
||||
if (size > 0)
|
||||
stream.Write(buffer, 0, buffer.Length);
|
||||
else
|
||||
break;
|
||||
}
|
||||
zlibStream.Close();
|
||||
return stream.ToArray();
|
||||
}
|
||||
public string ReadMagic(int Offset, int Length)
|
||||
{
|
||||
Seek(Offset, SeekOrigin.Begin);
|
||||
return ReadString(Length);
|
||||
}
|
||||
}
|
||||
}
|
26
Switch_Toolbox_Library/Imaging.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public class Imaging
|
||||
{
|
||||
public enum Channel
|
||||
{
|
||||
Red,
|
||||
Green,
|
||||
Blue,
|
||||
Alpha,
|
||||
Zero,
|
||||
One,
|
||||
}
|
||||
public static Bitmap GetLoadingImage()
|
||||
{
|
||||
return Properties.Resources.LoadingImage;
|
||||
}
|
||||
}
|
||||
}
|
27
Switch_Toolbox_Library/Interfaces/IArchiveFile.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public interface IArchiveFile
|
||||
{
|
||||
string[] Description { get; set; }
|
||||
string[] Extension { get; set; }
|
||||
string Magic { get; set; }
|
||||
string CompressionType { get; set; }
|
||||
bool FileIsCompressed { get; set; }
|
||||
bool FileIsEdited { get; set; }
|
||||
bool CanSave { get; set; }
|
||||
bool IsActive { get; set; }
|
||||
bool UseEditMenu { get; set; }
|
||||
byte[] Data { get; set; }
|
||||
string FileName { get; set; }
|
||||
TreeNode EditorRoot { get; set; }
|
||||
void Load();
|
||||
void Save();
|
||||
}
|
||||
}
|
32
Switch_Toolbox_Library/Interfaces/IFileFormat.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Switch_Toolbox.Library.IO;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public interface IFileFormat
|
||||
{
|
||||
string[] Description { get; set; }
|
||||
string[] Extension { get; set; }
|
||||
Type[] Types { get; } //Types hold menu extensions
|
||||
string Magic { get; set; }
|
||||
CompressionType CompressionType { get; set; }
|
||||
bool FileIsCompressed { get; set; }
|
||||
bool FileIsEdited { get; set; }
|
||||
bool CanSave { get; set; }
|
||||
bool IsActive { get; set; }
|
||||
bool UseEditMenu { get; set; }
|
||||
byte[] Data { get; set; }
|
||||
string FileName { get; set; }
|
||||
string FilePath { get; set; }
|
||||
TreeNode EditorRoot { get; set; }
|
||||
void Load();
|
||||
void Unload();
|
||||
byte[] Save();
|
||||
int Alignment { get; set; } //Alignment to save the file back. Also used for Yaz0 comp sometimes
|
||||
}
|
||||
}
|
25
Switch_Toolbox_Library/Interfaces/IMenuExtension.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Switch_Toolbox.Library.Forms;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
//Based on Exelix's menu ext
|
||||
public interface IMenuExtension
|
||||
{
|
||||
ToolStripItemDark[] FileMenuExtensions { get; }
|
||||
ToolStripItemDark[] ToolsMenuExtensions { get; }
|
||||
ToolStripItemDark[] TitleBarExtensions { get; }
|
||||
}
|
||||
public interface IFileMenuExtension
|
||||
{
|
||||
ToolStripItemDark[] NewFileMenuExtensions { get; }
|
||||
ToolStripItemDark[] CompressionMenuExtensions { get; }
|
||||
ToolStripItemDark[] ToolsMenuExtensions { get; }
|
||||
ToolStripItemDark[] TitleBarExtensions { get; }
|
||||
ToolStripItemDark[] ExperimentalMenuExtensions { get; }
|
||||
}
|
||||
}
|
25
Switch_Toolbox_Library/Interfaces/IPlugin.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Switch_Toolbox.Library;
|
||||
|
||||
namespace PluginContracts
|
||||
{
|
||||
public interface IPlugin
|
||||
{
|
||||
string Name { get; }
|
||||
string Author { get; }
|
||||
string Description { get; }
|
||||
string Version { get; }
|
||||
//List of types
|
||||
//IFileFormat
|
||||
Type[] Types { get; } //Types hold File extensions
|
||||
Form MainForm { get; set; }
|
||||
DockContentST DockedEditor { get; set; }
|
||||
void Load();
|
||||
void Unload();
|
||||
}
|
||||
}
|
58
Switch_Toolbox_Library/Plugin/FileFormat.cs
Normal file
|
@ -0,0 +1,58 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public class FileManager
|
||||
{
|
||||
public FileManager()
|
||||
{
|
||||
|
||||
}
|
||||
public static IFileMenuExtension[] GetMenuExtensions()
|
||||
{
|
||||
//Add plugin and main application menu extensions
|
||||
List<IFileMenuExtension> types = new List<IFileMenuExtension>();
|
||||
foreach (IFileFormat fileFormat in GetFileFormats())
|
||||
{
|
||||
foreach (Type T in fileFormat.Types)
|
||||
{
|
||||
Type[] interfaces_array = T.GetInterfaces();
|
||||
for (int i = 0; i < interfaces_array.Length; i++)
|
||||
{
|
||||
if (interfaces_array[i] == typeof(IFileMenuExtension))
|
||||
{
|
||||
types.Add((IFileMenuExtension)Activator.CreateInstance(T));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return types.ToArray();
|
||||
}
|
||||
public static IFileFormat[] GetFileFormats()
|
||||
{
|
||||
//Add plugin and main application file formats
|
||||
List<IFileFormat> types = new List<IFileFormat>();
|
||||
foreach (var plugin in GenericPluginLoader._Plugins)
|
||||
{
|
||||
foreach (Type T in plugin.Value.Types)
|
||||
{
|
||||
Type[] interfaces_array = T.GetInterfaces();
|
||||
for (int i = 0; i < interfaces_array.Length; i++)
|
||||
{
|
||||
if (interfaces_array[i] == typeof(IFileFormat))
|
||||
{
|
||||
types.Add((IFileFormat)Activator.CreateInstance(T));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return types.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
26
Switch_Toolbox_Library/Plugin/GenericPluginLoader.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using PluginContracts;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public static class GenericPluginLoader
|
||||
{
|
||||
public static Dictionary<string, IPlugin> _Plugins;
|
||||
|
||||
public static void LoadPlugin()
|
||||
{
|
||||
_Plugins = new Dictionary<string, IPlugin>();
|
||||
|
||||
ICollection<IPlugin> plugins = PluginLoader.LoadPlugins();
|
||||
foreach (var item in plugins)
|
||||
{
|
||||
_Plugins.Add(item.Name, item);
|
||||
}
|
||||
plugins.Clear();
|
||||
}
|
||||
}
|
||||
}
|
74
Switch_Toolbox_Library/Plugin/PluginLoader.cs
Normal file
|
@ -0,0 +1,74 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using PluginContracts;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public class PluginLoader
|
||||
{
|
||||
public Dictionary<string, IPlugin> _Plugins;
|
||||
|
||||
public PluginLoader()
|
||||
{
|
||||
|
||||
}
|
||||
public static ICollection<IPlugin> LoadPlugins()
|
||||
{
|
||||
string path = "Lib/Plugins";
|
||||
|
||||
string[] dllFileNames = null;
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
dllFileNames = Directory.GetFiles(path, "*.Plg.dll");
|
||||
}
|
||||
|
||||
ICollection<Assembly> assemblies = new List<Assembly>(dllFileNames.Length);
|
||||
foreach (string dllFile in dllFileNames)
|
||||
{
|
||||
AssemblyName an = AssemblyName.GetAssemblyName(dllFile);
|
||||
Assembly assembly = Assembly.Load(an);
|
||||
assemblies.Add(assembly);
|
||||
}
|
||||
|
||||
Type pluginType = typeof(IPlugin);
|
||||
ICollection<Type> pluginTypes = new List<Type>();
|
||||
foreach (Assembly assembly in assemblies)
|
||||
{
|
||||
if (assembly != null)
|
||||
{
|
||||
Type[] types = assembly.GetTypes();
|
||||
foreach (Type type in types)
|
||||
{
|
||||
if (type.IsInterface || type.IsAbstract)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type.GetInterface(pluginType.FullName) != null)
|
||||
{
|
||||
pluginTypes.Add(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ICollection<IPlugin> plugins = new List<IPlugin>(pluginTypes.Count);
|
||||
foreach (Type type in pluginTypes)
|
||||
{
|
||||
IPlugin plugin = (IPlugin)Activator.CreateInstance(type);
|
||||
plugins.Add(plugin);
|
||||
}
|
||||
assemblies.Clear();
|
||||
pluginTypes.Clear();
|
||||
|
||||
return plugins;
|
||||
}
|
||||
}
|
||||
}
|
36
Switch_Toolbox_Library/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Switch_Toolbox_Library")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Switch_Toolbox_Library")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("96820047-2a39-4e5a-bfa4-e84fff5c66cf")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
403
Switch_Toolbox_Library/Properties/Resources.Designer.cs
generated
Normal file
|
@ -0,0 +1,403 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Switch_Toolbox.Library.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Switch_Toolbox.Library.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Aamp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Aamp", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowMinimize_ {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowMinimize ", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Bfres {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Bfres", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Bfsha {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Bfsha", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Bnsh {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Bnsh", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Bntx {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Bntx", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Bone {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Bone", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Byaml {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Byaml", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap CheckerBackground {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("CheckerBackground", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap defaultDif {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("defaultDif", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap DefaultTexture {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("DefaultTexture", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] diffuseSDR {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("diffuseSDR", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap diffuseSphere {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("diffuseSphere", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap ErrorCheck {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ErrorCheck", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap FileBlank {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("FileBlank", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Folder {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Folder", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] InjectTexErrored {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("InjectTexErrored", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap LoadingImage {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("LoadingImage", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap materialSphere {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("materialSphere", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap mesh {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("mesh", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap model {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("model", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Music1 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Music1", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Music2 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Music2", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap normalMapSphere {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("normalMapSphere", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap normalsSphere {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("normalsSphere", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap rotateGizmo {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("rotateGizmo", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap scaleGizmo {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("scaleGizmo", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap skeleton {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("skeleton", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap skeletonAnimation {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("skeletonAnimation", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] specularSDR {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("specularSDR", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Texture {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Texture", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap TextureError {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("TextureError", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap translateGizmo {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("translateGizmo", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap UVPattern {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("UVPattern", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
223
Switch_Toolbox_Library/Properties/Resources.resx
Normal file
|
@ -0,0 +1,223 @@
|
|||
<?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>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="skeletonAnimation" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\skeletonAnimation.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="LoadingImage" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\LoadingImage.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="rotateGizmo" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\rotateGizmo.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="mesh" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\mesh.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Bone" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Bone.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Music1" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Music1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowMinimize " type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowMinimize .png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="model" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\model.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="scaleGizmo" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\scaleGizmo.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Folder" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Folder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Bfres" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Bfres.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="translateGizmo" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\translateGizmo.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="skeleton" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\skeleton.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="FileBlank" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\FileBank.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="materialSphere" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\materialSphere.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="specularSDR" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\specularSDR.gzip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="CheckerBackground" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\CheckerBackground.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Bntx" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Bntx.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Music2" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Music2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Texture" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Texture.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="DefaultTexture" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\DefaultTexture.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="UVPattern" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\UVPattern.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ErrorCheck" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ErrorCheck.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Bnsh" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Bnsh.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="diffuseSphere" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\diffuseSphere.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="InjectTexErrored" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\InjectTexErrored.dds;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="defaultDif" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\defaultDif.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="diffuseSDR" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\diffuseSDR.gzip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="Aamp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Aamp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Byaml" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Byaml.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Bfsha" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Bfsha.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="TextureError" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\TextureError.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="normalsSphere" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\normalsSphere.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="normalMapSphere" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\normalMapSphere.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
19
Switch_Toolbox_Library/PublicEnums.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public enum CompressionType
|
||||
{
|
||||
None,
|
||||
Yaz0,
|
||||
Zlib,
|
||||
Gzip,
|
||||
Lz4,
|
||||
Lz4f,
|
||||
Zstb,
|
||||
}
|
||||
}
|
108
Switch_Toolbox_Library/Rendering/OpenTKSharedResources.cs
Normal file
|
@ -0,0 +1,108 @@
|
|||
using System;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
using SFGraphics.GLObjects.Shaders;
|
||||
using Switch_Toolbox.Library;
|
||||
|
||||
namespace Smash_Forge.Rendering
|
||||
{
|
||||
public static class OpenTKSharedResources
|
||||
{
|
||||
public enum SharedResourceStatus
|
||||
{
|
||||
Initialized,
|
||||
Failed,
|
||||
Unitialized
|
||||
}
|
||||
|
||||
public static SharedResourceStatus SetupStatus
|
||||
{
|
||||
get { return setupStatus; }
|
||||
}
|
||||
private static SharedResourceStatus setupStatus = SharedResourceStatus.Unitialized;
|
||||
|
||||
// Keep a context around to avoid setting up after making each context.
|
||||
public static GameWindow dummyResourceWindow;
|
||||
|
||||
public static Dictionary<string, Shader> shaders = new Dictionary<string, Shader>();
|
||||
|
||||
private static DebugProc debugProc;
|
||||
|
||||
[HandleProcessCorruptedStateExceptions]
|
||||
public static void InitializeSharedResources()
|
||||
{
|
||||
// Only setup once. This is checked multiple times to prevent crashes.
|
||||
if (setupStatus == SharedResourceStatus.Initialized)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
// Make a permanent context to share resources.
|
||||
GraphicsContext.ShareContexts = true;
|
||||
dummyResourceWindow = CreateGameWindowContext();
|
||||
|
||||
if (Runtime.enableOpenTKDebugOutput)
|
||||
EnableOpenTKDebugOutput();
|
||||
|
||||
RenderTools.LoadTextures();
|
||||
GetOpenGLSystemInfo();
|
||||
ShaderTools.SetUpShaders();
|
||||
|
||||
setupStatus = SharedResourceStatus.Initialized;
|
||||
}
|
||||
catch (AccessViolationException)
|
||||
{
|
||||
// Context creation failed.
|
||||
setupStatus = SharedResourceStatus.Failed;
|
||||
}
|
||||
}
|
||||
|
||||
public static void EnableOpenTKDebugOutput()
|
||||
{
|
||||
#if DEBUG
|
||||
// This isn't free, so skip this step when not debugging.
|
||||
// TODO: Only works with Intel integrated.
|
||||
if (SFGraphics.Tools.OpenGLExtensions.IsAvailable("GL_KHR_debug"))
|
||||
{
|
||||
GL.Enable(EnableCap.DebugOutput);
|
||||
GL.Enable(EnableCap.DebugOutputSynchronous);
|
||||
debugProc = DebugCallback;
|
||||
GL.DebugMessageCallback(debugProc, IntPtr.Zero);
|
||||
int[] ids = { };
|
||||
GL.DebugMessageControl(DebugSourceControl.DontCare, DebugTypeControl.DontCare,
|
||||
DebugSeverityControl.DontCare, 0, ids, true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private static void DebugCallback(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam)
|
||||
{
|
||||
string debugMessage = Marshal.PtrToStringAnsi(message, length);
|
||||
Debug.WriteLine(String.Format("{0} {1} {2}", severity, type, debugMessage));
|
||||
}
|
||||
|
||||
public static GameWindow CreateGameWindowContext(int width = 640, int height = 480)
|
||||
{
|
||||
GraphicsMode mode = new GraphicsMode(new ColorFormat(8, 8, 8, 8), 24, 0, 0, ColorFormat.Empty, 1);
|
||||
|
||||
// TODO: Versions higher than 300 do not work for some reason.
|
||||
GameWindow gameWindow = new GameWindow(width, height, mode, "", OpenTK.GameWindowFlags.Default, OpenTK.DisplayDevice.Default, 3, 0, GraphicsContextFlags.Default);
|
||||
|
||||
gameWindow.Visible = false;
|
||||
gameWindow.MakeCurrent();
|
||||
return gameWindow;
|
||||
}
|
||||
|
||||
private static void GetOpenGLSystemInfo()
|
||||
{
|
||||
Runtime.renderer = GL.GetString(StringName.Renderer);
|
||||
Runtime.openGLVersion = GL.GetString(StringName.Version);
|
||||
Runtime.GLSLVersion = GL.GetString(StringName.ShadingLanguageVersion);
|
||||
}
|
||||
}
|
||||
}
|
494
Switch_Toolbox_Library/Rendering/RenderLib.cs
Normal file
|
@ -0,0 +1,494 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using Switch_Toolbox.Library;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
||||
namespace Switch_Toolbox.Library.Rendering
|
||||
{
|
||||
public enum STPolygonType : uint
|
||||
{
|
||||
Point = 0,
|
||||
Line = 1,
|
||||
LineStrip = 2,
|
||||
Triangle = 3
|
||||
}
|
||||
public enum STIndexFormat : uint
|
||||
{
|
||||
UnsignedByte = 0,
|
||||
UInt16 = 1,
|
||||
UInt32 = 2,
|
||||
}
|
||||
public class STGenericObject : GenericObject
|
||||
{
|
||||
public override void OnClick(TreeView treeView)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
public abstract class STGenericModel : GenericModel
|
||||
{
|
||||
public override void OnClick(TreeView treeView)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
public abstract class GenericModel : TreeNode
|
||||
{
|
||||
public abstract void OnClick(TreeView treeview);
|
||||
}
|
||||
public class STGenericMaterial : GenericMaterial
|
||||
{
|
||||
public override void OnClick(TreeView treeView)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
public class STGenericMatTexture
|
||||
{
|
||||
public int mapMode = 0;
|
||||
public int wrapModeS = 1;
|
||||
public int wrapModeT = 1;
|
||||
public int wrapModeW = 1; //Used for 3D textures
|
||||
public int minFilter = 3;
|
||||
public int magFilter = 2;
|
||||
public int mipDetail = 6;
|
||||
public string Name;
|
||||
|
||||
public TextureType Type;
|
||||
|
||||
//An enum for the assumed texture type by sampler
|
||||
//Many games have a consistant type of samplers and type. _a0 for diffuse, _n0 for normal, ect
|
||||
public enum TextureType
|
||||
{
|
||||
Unknown = 0,
|
||||
Diffuse = 1,
|
||||
Normal = 2,
|
||||
Specular = 3,
|
||||
Emission = 4,
|
||||
DiffuseLayer2 = 5,
|
||||
TeamColor = 6,
|
||||
Transparency = 7,
|
||||
Shadow = 8,
|
||||
AO = 9,
|
||||
Light = 10,
|
||||
Roughness = 11,
|
||||
Metalness = 12,
|
||||
MRA = 13, //Combined pbr texture HAL uses for KSA
|
||||
SphereMap = 14,
|
||||
SubSurfaceScattering = 15,
|
||||
}
|
||||
|
||||
public static readonly Dictionary<int, TextureMinFilter> minfilter = new Dictionary<int, TextureMinFilter>()
|
||||
{
|
||||
{ 0x00, TextureMinFilter.LinearMipmapLinear},
|
||||
{ 0x01, TextureMinFilter.Nearest},
|
||||
{ 0x02, TextureMinFilter.Linear},
|
||||
{ 0x03, TextureMinFilter.NearestMipmapLinear},
|
||||
};
|
||||
public static readonly Dictionary<int, TextureMagFilter> magfilter = new Dictionary<int, TextureMagFilter>()
|
||||
{
|
||||
{ 0x00, TextureMagFilter.Linear},
|
||||
{ 0x01, TextureMagFilter.Nearest},
|
||||
{ 0x02, TextureMagFilter.Linear}
|
||||
};
|
||||
public static Dictionary<int, TextureWrapMode> wrapmode = new Dictionary<int, TextureWrapMode>(){
|
||||
{ 0x00, TextureWrapMode.Repeat},
|
||||
{ 0x01, TextureWrapMode.MirroredRepeat},
|
||||
{ 0x02, TextureWrapMode.ClampToEdge},
|
||||
{ 0x03, TextureWrapMode.MirroredRepeat},
|
||||
};
|
||||
}
|
||||
public abstract class GenericMaterial : TreeNode
|
||||
{
|
||||
public abstract void OnClick(TreeView treeview);
|
||||
|
||||
public List<STGenericMatTexture> TextureMaps = new List<STGenericMatTexture>();
|
||||
}
|
||||
public abstract class GenericObject : TreeNode
|
||||
{
|
||||
public abstract void OnClick(TreeView treeview);
|
||||
|
||||
public bool HasPos;
|
||||
public bool HasNrm;
|
||||
public bool HasUv0;
|
||||
public bool HasUv1;
|
||||
public bool HasUv2;
|
||||
public bool HasWeights;
|
||||
public bool HasIndices;
|
||||
public bool HasBitans;
|
||||
public bool HasTans;
|
||||
public bool HasVertColors;
|
||||
public int MaxSkinInfluenceCount;
|
||||
public string ObjectName;
|
||||
public int BoneIndex;
|
||||
public int MaterialIndex;
|
||||
public int VertexBufferIndex;
|
||||
public int DisplayLODIndex;
|
||||
public int Offset;
|
||||
|
||||
public int GetMaxSkinInfluenceCount()
|
||||
{
|
||||
return vertices.Max(t => t.boneNames.Count);
|
||||
}
|
||||
|
||||
public Vector3 GetOrigin()
|
||||
{
|
||||
Vector3 pos = Vector3.Zero;
|
||||
|
||||
foreach (Vertex vert in vertices)
|
||||
{
|
||||
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
public List<string[]> bones = new List<string[]>();
|
||||
public List<float[]> weightsT = new List<float[]>();
|
||||
|
||||
public List<string> boneList = new List<string>();
|
||||
public List<Vertex> vertices = new List<Vertex>();
|
||||
public List<LOD_Mesh> lodMeshes = new List<LOD_Mesh>();
|
||||
public class LOD_Mesh
|
||||
{
|
||||
public STPolygonType PrimitiveType = STPolygonType.Triangle;
|
||||
public STIndexFormat IndexFormat = STIndexFormat.UInt16;
|
||||
public uint FirstVertex;
|
||||
|
||||
public List<SubMesh> subMeshes = new List<SubMesh>();
|
||||
public class SubMesh
|
||||
{
|
||||
public uint size;
|
||||
public uint offset;
|
||||
}
|
||||
|
||||
public void GenerateSubMesh()
|
||||
{
|
||||
subMeshes.Clear();
|
||||
SubMesh subMesh = new SubMesh();
|
||||
subMesh.offset = 0;
|
||||
subMesh.size = (uint)faces.Count;
|
||||
subMeshes.Add(subMesh);
|
||||
}
|
||||
|
||||
public int index = 0;
|
||||
public int strip = 0x40;
|
||||
public int displayFaceSize = 0;
|
||||
|
||||
public List<int> faces = new List<int>();
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "LOD Mesh " + index;
|
||||
}
|
||||
|
||||
public List<int> getDisplayFace()
|
||||
{
|
||||
if ((strip >> 4) == 4)
|
||||
{
|
||||
displayFaceSize = faces.Count;
|
||||
return faces;
|
||||
}
|
||||
else
|
||||
{
|
||||
List<int> f = new List<int>();
|
||||
|
||||
int startDirection = 1;
|
||||
int p = 0;
|
||||
int f1 = faces[p++];
|
||||
int f2 = faces[p++];
|
||||
int faceDirection = startDirection;
|
||||
int f3;
|
||||
do
|
||||
{
|
||||
f3 = faces[p++];
|
||||
if (f3 == 0xFFFF)
|
||||
{
|
||||
f1 = faces[p++];
|
||||
f2 = faces[p++];
|
||||
faceDirection = startDirection;
|
||||
}
|
||||
else
|
||||
{
|
||||
faceDirection *= -1;
|
||||
if ((f1 != f2) && (f2 != f3) && (f3 != f1))
|
||||
{
|
||||
if (faceDirection > 0)
|
||||
{
|
||||
f.Add(f3);
|
||||
f.Add(f2);
|
||||
f.Add(f1);
|
||||
}
|
||||
else
|
||||
{
|
||||
f.Add(f2);
|
||||
f.Add(f3);
|
||||
f.Add(f1);
|
||||
}
|
||||
}
|
||||
f1 = f2;
|
||||
f2 = f3;
|
||||
}
|
||||
} while (p < faces.Count);
|
||||
|
||||
displayFaceSize = f.Count;
|
||||
return f;
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<int> faces = new List<int>();
|
||||
|
||||
#region Methods
|
||||
|
||||
public void FlipUvsVertical()
|
||||
{
|
||||
foreach (Vertex v in vertices)
|
||||
{
|
||||
v.uv0 = new Vector2(v.uv0.X, 1 - v.uv0.Y);
|
||||
}
|
||||
|
||||
}
|
||||
public void FlipUvsHorizontal()
|
||||
{
|
||||
foreach (Vertex v in vertices)
|
||||
{
|
||||
v.uv0 = new Vector2(1 - v.uv0.X, v.uv0.Y);
|
||||
}
|
||||
}
|
||||
public void CalculateTangentBitangent()
|
||||
{
|
||||
List<int> f = lodMeshes[DisplayLODIndex].getDisplayFace();
|
||||
Vector3[] tanArray = new Vector3[vertices.Count];
|
||||
Vector3[] bitanArray = new Vector3[vertices.Count];
|
||||
|
||||
CalculateTanBitanArrays(f, tanArray, bitanArray);
|
||||
ApplyTanBitanArray(tanArray, bitanArray);
|
||||
}
|
||||
|
||||
private void ApplyTanBitanArray(Vector3[] tanArray, Vector3[] bitanArray)
|
||||
{
|
||||
for (int i = 0; i < vertices.Count; i++)
|
||||
{
|
||||
Vertex v = vertices[i];
|
||||
Vector3 newTan = tanArray[i];
|
||||
Vector3 newBitan = bitanArray[i];
|
||||
|
||||
// The tangent and bitangent should be orthogonal to the normal.
|
||||
// Bitangents are not calculated with a cross product to prevent flipped shading with mirrored normal maps.
|
||||
v.tan = new Vector4(Vector3.Normalize(newTan - v.nrm * Vector3.Dot(v.nrm, newTan)), 1);
|
||||
v.bitan = new Vector4(Vector3.Normalize(newBitan - v.nrm * Vector3.Dot(v.nrm, newBitan)), 1);
|
||||
v.bitan *= -1;
|
||||
}
|
||||
}
|
||||
|
||||
private void CalculateTanBitanArrays(List<int> faces, Vector3[] tanArray, Vector3[] bitanArray)
|
||||
{
|
||||
for (int i = 0; i < lodMeshes[DisplayLODIndex].displayFaceSize; i += 3)
|
||||
{
|
||||
Vertex v1 = vertices[faces[i]];
|
||||
Vertex v2 = vertices[faces[i + 1]];
|
||||
Vertex v3 = vertices[faces[i + 2]];
|
||||
|
||||
bool UseUVLayer2 = false;
|
||||
float x1 = v2.pos.X - v1.pos.X;
|
||||
float x2 = v3.pos.X - v1.pos.X;
|
||||
float y1 = v2.pos.Y - v1.pos.Y;
|
||||
float y2 = v3.pos.Y - v1.pos.Y;
|
||||
float z1 = v2.pos.Z - v1.pos.Z;
|
||||
float z2 = v3.pos.Z - v1.pos.Z;
|
||||
|
||||
float s1, s2, t1, t2;
|
||||
if (UseUVLayer2)
|
||||
{
|
||||
s1 = v2.uv1.X - v1.uv1.X;
|
||||
s2 = v3.uv1.X - v1.uv1.X;
|
||||
t1 = v2.uv1.Y - v1.uv1.Y;
|
||||
t2 = v3.uv1.Y - v1.uv1.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
s1 = v2.uv0.X - v1.uv0.X;
|
||||
s2 = v3.uv0.X - v1.uv0.X;
|
||||
t1 = v2.uv0.Y - v1.uv0.Y;
|
||||
t2 = v3.uv0.Y - v1.uv0.Y;
|
||||
}
|
||||
|
||||
|
||||
float div = (s1 * t2 - s2 * t1);
|
||||
float r = 1.0f / div;
|
||||
|
||||
// Fix +/- infinity from division by 0.
|
||||
if (r == float.PositiveInfinity || r == float.NegativeInfinity)
|
||||
r = 1.0f;
|
||||
|
||||
float sX = t2 * x1 - t1 * x2;
|
||||
float sY = t2 * y1 - t1 * y2;
|
||||
float sZ = t2 * z1 - t1 * z2;
|
||||
Vector3 s = new Vector3(sX, sY, sZ) * r;
|
||||
|
||||
float tX = s1 * x2 - s2 * x1;
|
||||
float tY = s1 * y2 - s2 * y1;
|
||||
float tZ = s1 * z2 - s2 * z1;
|
||||
Vector3 t = new Vector3(tX, tY, tZ) * r;
|
||||
|
||||
// Prevents black tangents or bitangents due to having vertices with the same UV coordinates.
|
||||
float delta = 0.00075f;
|
||||
bool sameU, sameV;
|
||||
if (UseUVLayer2)
|
||||
{
|
||||
sameU = (Math.Abs(v1.uv1.X - v2.uv1.X) < delta) && (Math.Abs(v2.uv1.X - v3.uv1.X) < delta);
|
||||
sameV = (Math.Abs(v1.uv1.Y - v2.uv1.Y) < delta) && (Math.Abs(v2.uv1.Y - v3.uv1.Y) < delta);
|
||||
}
|
||||
else
|
||||
{
|
||||
sameU = (Math.Abs(v1.uv0.X - v2.uv0.X) < delta) && (Math.Abs(v2.uv0.X - v3.uv0.X) < delta);
|
||||
sameV = (Math.Abs(v1.uv0.Y - v2.uv0.Y) < delta) && (Math.Abs(v2.uv0.Y - v3.uv0.Y) < delta);
|
||||
}
|
||||
|
||||
if (sameU || sameV)
|
||||
{
|
||||
// Let's pick some arbitrary tangent vectors.
|
||||
s = new Vector3(1, 0, 0);
|
||||
t = new Vector3(0, 1, 0);
|
||||
}
|
||||
|
||||
// Average tangents and bitangents.
|
||||
tanArray[faces[i]] += s;
|
||||
tanArray[faces[i + 1]] += s;
|
||||
tanArray[faces[i + 2]] += s;
|
||||
|
||||
bitanArray[faces[i]] += t;
|
||||
bitanArray[faces[i + 1]] += t;
|
||||
bitanArray[faces[i + 2]] += t;
|
||||
}
|
||||
}
|
||||
|
||||
public void SmoothNormals()
|
||||
{
|
||||
Vector3[] normals = new Vector3[vertices.Count];
|
||||
|
||||
List<int> f = lodMeshes[DisplayLODIndex].getDisplayFace();
|
||||
|
||||
for (int i = 0; i < lodMeshes[DisplayLODIndex].displayFaceSize; i += 3)
|
||||
{
|
||||
Vertex v1 = vertices[f[i]];
|
||||
Vertex v2 = vertices[f[i + 1]];
|
||||
Vertex v3 = vertices[f[i + 2]];
|
||||
Vector3 nrm = CalculateNormal(v1, v2, v3);
|
||||
|
||||
normals[f[i + 0]] += nrm;
|
||||
normals[f[i + 1]] += nrm;
|
||||
normals[f[i + 2]] += nrm;
|
||||
}
|
||||
|
||||
for (int i = 0; i < normals.Length; i++)
|
||||
vertices[i].nrm = normals[i].Normalized();
|
||||
|
||||
// Compare each vertex with all the remaining vertices. This might skip some.
|
||||
for (int i = 0; i < vertices.Count; i++)
|
||||
{
|
||||
Vertex v = vertices[i];
|
||||
|
||||
for (int j = i + 1; j < vertices.Count; j++)
|
||||
{
|
||||
Vertex v2 = vertices[j];
|
||||
|
||||
if (v == v2)
|
||||
continue;
|
||||
float dis = (float)Math.Sqrt(Math.Pow(v.pos.X - v2.pos.X, 2) + Math.Pow(v.pos.Y - v2.pos.Y, 2) + Math.Pow(v.pos.Z - v2.pos.Z, 2));
|
||||
if (dis <= 0f) // Extra smooth
|
||||
{
|
||||
Vector3 nn = ((v2.nrm + v.nrm) / 2).Normalized();
|
||||
v.nrm = nn;
|
||||
v2.nrm = nn;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void CalculateNormals()
|
||||
{
|
||||
Vector3[] normals = new Vector3[vertices.Count];
|
||||
|
||||
for (int i = 0; i < normals.Length; i++)
|
||||
normals[i] = new Vector3(0, 0, 0);
|
||||
|
||||
List<int> f = lodMeshes[DisplayLODIndex].getDisplayFace();
|
||||
|
||||
for (int i = 0; i < lodMeshes[DisplayLODIndex].displayFaceSize; i += 3)
|
||||
{
|
||||
Vertex v1 = vertices[f[i]];
|
||||
Vertex v2 = vertices[f[i + 1]];
|
||||
Vertex v3 = vertices[f[i + 2]];
|
||||
Vector3 nrm = CalculateNormal(v1, v2, v3);
|
||||
|
||||
normals[f[i + 0]] += nrm * (nrm.Length / 2);
|
||||
normals[f[i + 1]] += nrm * (nrm.Length / 2);
|
||||
normals[f[i + 2]] += nrm * (nrm.Length / 2);
|
||||
}
|
||||
|
||||
for (int i = 0; i < normals.Length; i++)
|
||||
vertices[i].nrm = normals[i].Normalized();
|
||||
}
|
||||
|
||||
private Vector3 CalculateNormal(Vertex v1, Vertex v2, Vertex v3)
|
||||
{
|
||||
Vector3 U = v2.pos - v1.pos;
|
||||
Vector3 V = v3.pos - v1.pos;
|
||||
|
||||
// Don't normalize here, so surface area can be calculated.
|
||||
return Vector3.Cross(U, V);
|
||||
}
|
||||
|
||||
public void SetVertexColor(Vector4 intColor)
|
||||
{
|
||||
// (127, 127, 127, 255) is white.
|
||||
foreach (Vertex v in vertices)
|
||||
{
|
||||
v.col = intColor;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class Vertex
|
||||
{
|
||||
public Vector3 pos = new Vector3(0);
|
||||
public Vector3 nrm = new Vector3(0);
|
||||
public Vector4 col = new Vector4(1);
|
||||
public Vector2 uv0 = new Vector2(0);
|
||||
public Vector2 uv1 = new Vector2(0);
|
||||
public Vector2 uv2 = 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 List<string> boneNames = new List<string>();
|
||||
public List<float> weights = new List<float>();
|
||||
|
||||
public List<Bone> boneList = new List<Bone>();
|
||||
public class Bone
|
||||
{
|
||||
public string Name;
|
||||
public int Index;
|
||||
public bool HasWeights;
|
||||
public List<BoneWeight> weights = new List<BoneWeight>();
|
||||
}
|
||||
public class BoneWeight
|
||||
{
|
||||
public float weight;
|
||||
}
|
||||
//For vertex morphing
|
||||
public Vector3 pos1 = new Vector3();
|
||||
public Vector3 pos2 = new Vector3();
|
||||
}
|
||||
}
|
196
Switch_Toolbox_Library/Rendering/RenderTools.cs
Normal file
|
@ -0,0 +1,196 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SFGraphics.GLObjects.Textures;
|
||||
using SFGraphics.GLObjects.Textures.TextureFormats;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using Smash_Forge.Rendering;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public class RenderTools
|
||||
{
|
||||
public static Texture2D defaultTex;
|
||||
public static TextureCubeMap diffusePbr;
|
||||
public static TextureCubeMap specularPbr;
|
||||
public static Texture2D uvTestPattern;
|
||||
|
||||
public static void LoadTextures()
|
||||
{
|
||||
defaultTex = new Texture2D();
|
||||
defaultTex.LoadImageData(Properties.Resources.DefaultTexture);
|
||||
uvTestPattern = new Texture2D();
|
||||
uvTestPattern.LoadImageData(Properties.Resources.UVPattern);
|
||||
|
||||
// DDS specularSdr = new DDS(Properties.Resources.specularSDR);
|
||||
// specularPbr = NUT.CreateTextureCubeMap(specularSdr.ToNutTexture());
|
||||
|
||||
// DDS diffuseSdr = new DDS(Properties.Resources.diffuseSDR);
|
||||
// diffusePbr = CreateTextureCubeMap(bntx.textureData.texture);
|
||||
|
||||
// Don't use mipmaps.
|
||||
// diffusePbr.MinFilter = TextureMinFilter.Linear;
|
||||
// diffusePbr.MagFilter = TextureMagFilter.Linear;
|
||||
}
|
||||
|
||||
public static void DrawSkyBox(Matrix4 RotationMatrix)
|
||||
{
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
GL.DepthFunc(DepthFunction.Lequal);
|
||||
|
||||
GL.Enable(EnableCap.CullFace);
|
||||
GL.CullFace(CullFaceMode.Front);
|
||||
|
||||
GL.Enable(EnableCap.LineSmooth);
|
||||
|
||||
GL.Enable(EnableCap.StencilTest);
|
||||
GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Replace);
|
||||
|
||||
|
||||
SFGraphics.GLObjects.Shaders.Shader shader = OpenTKSharedResources.shaders["HDRSkyBox"];
|
||||
shader.UseProgram();
|
||||
// enable seamless cubemap sampling for lower mip levels in the pre-filter map.
|
||||
GL.Enable(EnableCap.TextureCubeMapSeamless);
|
||||
|
||||
Matrix4 proj = Matrix4.Identity;
|
||||
shader.SetMatrix4x4("projection", ref proj);
|
||||
Matrix4 rot = RotationMatrix;
|
||||
shader.SetMatrix4x4("rotView", ref rot);
|
||||
|
||||
// shader.SetTexture("environmentMap", diffusePbr, 16);
|
||||
|
||||
DrawCube();
|
||||
}
|
||||
|
||||
public static void DrawCube()
|
||||
{
|
||||
int cubeVBO = 0;
|
||||
|
||||
if (cubeVBO == 0)
|
||||
{
|
||||
float[] vertices = {
|
||||
// back face
|
||||
-1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, // bottom-left
|
||||
1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f, // top-right
|
||||
1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f, // bottom-right
|
||||
1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f, // top-right
|
||||
-1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, // bottom-left
|
||||
-1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, // top-left
|
||||
// front face
|
||||
-1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, // bottom-left
|
||||
1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, // bottom-right
|
||||
1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, // top-right
|
||||
1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, // top-right
|
||||
-1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, // top-left
|
||||
-1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, // bottom-left
|
||||
// left face
|
||||
-1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, // top-right
|
||||
-1.0f, 1.0f, -1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f, // top-left
|
||||
-1.0f, -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, // bottom-left
|
||||
-1.0f, -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, // bottom-left
|
||||
-1.0f, -1.0f, 1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, // bottom-right
|
||||
-1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, // top-right
|
||||
// right face
|
||||
1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, // top-left
|
||||
1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, // bottom-right
|
||||
1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, // top-right
|
||||
1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, // bottom-right
|
||||
1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, // top-left
|
||||
1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, // bottom-left
|
||||
// bottom face
|
||||
-1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, // top-right
|
||||
1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f, 1.0f, 1.0f, // top-left
|
||||
1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f, // bottom-left
|
||||
1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f, // bottom-left
|
||||
-1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, // bottom-right
|
||||
-1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, // top-right
|
||||
// top face
|
||||
-1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, // top-left
|
||||
1.0f, 1.0f , 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, // bottom-right
|
||||
1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, // top-right
|
||||
1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, // bottom-right
|
||||
-1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, // top-left
|
||||
-1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f // bottom-left
|
||||
};
|
||||
|
||||
GL.GenVertexArrays(1, out cubeVBO);
|
||||
GL.GenBuffers(1, out cubeVBO);
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, cubeVBO);
|
||||
GL.BufferData(BufferTarget.ArrayBuffer, 4 * vertices.Length, vertices, BufferUsageHint.StaticDraw);
|
||||
GL.BindVertexArray(cubeVBO);
|
||||
GL.EnableVertexAttribArray(0);
|
||||
GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 8 * sizeof(float), (IntPtr)0);
|
||||
GL.EnableVertexAttribArray(1);
|
||||
GL.VertexAttribPointer(1, 3, VertexAttribPointerType.Float, false, 8 * sizeof(float), (IntPtr)(3 * sizeof(float)));
|
||||
GL.EnableVertexAttribArray(2);
|
||||
GL.VertexAttribPointer(2, 2, VertexAttribPointerType.Float, false, 8 * sizeof(float), (IntPtr)(6 * sizeof(float)));
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
|
||||
GL.BindVertexArray(0);
|
||||
|
||||
}
|
||||
GL.BindVertexArray(cubeVBO);
|
||||
GL.DrawArrays(PrimitiveType.Triangles, 0, 36);
|
||||
GL.BindVertexArray(0);
|
||||
}
|
||||
|
||||
public static void DrawCube(Vector3 center, float size)
|
||||
{
|
||||
DrawRectangularPrism(center, size, size, size, false);
|
||||
}
|
||||
|
||||
public static void DrawRectangularPrism(Vector3 center, float sizeX, float sizeY, float sizeZ, bool useWireFrame = false)
|
||||
{
|
||||
PrimitiveType primitiveType = PrimitiveType.Quads;
|
||||
if (useWireFrame)
|
||||
{
|
||||
GL.LineWidth(2);
|
||||
primitiveType = PrimitiveType.LineLoop;
|
||||
}
|
||||
|
||||
GL.Begin(primitiveType);
|
||||
GL.Vertex3(center.X + sizeX, center.Y + sizeY, center.Z - sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y + sizeY, center.Z - sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y + sizeY, center.Z + sizeZ);
|
||||
GL.Vertex3(center.X + sizeX, center.Y + sizeY, center.Z + sizeZ);
|
||||
GL.End();
|
||||
|
||||
GL.Begin(primitiveType);
|
||||
GL.Vertex3(center.X + sizeX, center.Y - sizeY, center.Z + sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y - sizeY, center.Z + sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y - sizeY, center.Z - sizeZ);
|
||||
GL.Vertex3(center.X + sizeX, center.Y - sizeY, center.Z - sizeZ);
|
||||
GL.End();
|
||||
|
||||
GL.Begin(primitiveType);
|
||||
GL.Vertex3(center.X + sizeX, center.Y + sizeY, center.Z + sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y + sizeY, center.Z + sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y - sizeY, center.Z + sizeZ);
|
||||
GL.Vertex3(center.X + sizeX, center.Y - sizeY, center.Z + sizeZ);
|
||||
GL.End();
|
||||
|
||||
GL.Begin(primitiveType);
|
||||
GL.Vertex3(center.X + sizeX, center.Y - sizeY, center.Z - sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y - sizeY, center.Z - sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y + sizeY, center.Z - sizeZ);
|
||||
GL.Vertex3(center.X + sizeX, center.Y + sizeY, center.Z - sizeZ);
|
||||
GL.End();
|
||||
|
||||
GL.Begin(primitiveType);
|
||||
GL.Vertex3(center.X - sizeX, center.Y + sizeY, center.Z + sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y + sizeY, center.Z - sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y - sizeY, center.Z - sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y - sizeY, center.Z + sizeZ);
|
||||
GL.End();
|
||||
|
||||
GL.Begin(primitiveType);
|
||||
GL.Vertex3(center.X + sizeX, center.Y + sizeY, center.Z - sizeZ);
|
||||
GL.Vertex3(center.X + sizeX, center.Y + sizeY, center.Z + sizeZ);
|
||||
GL.Vertex3(center.X + sizeX, center.Y - sizeY, center.Z + sizeZ);
|
||||
GL.Vertex3(center.X + sizeX, center.Y - sizeY, center.Z - sizeZ);
|
||||
GL.End();
|
||||
}
|
||||
}
|
||||
}
|
181
Switch_Toolbox_Library/Rendering/ShaderTools.cs
Normal file
|
@ -0,0 +1,181 @@
|
|||
using OpenTK.Graphics.OpenGL;
|
||||
using SFGraphics.GLObjects.Shaders;
|
||||
using SFGraphics.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using SFGraphics.Tools;
|
||||
using Switch_Toolbox;
|
||||
|
||||
namespace Smash_Forge.Rendering
|
||||
{
|
||||
public static class ShaderTools
|
||||
{
|
||||
private static string shaderSourceDirectory;
|
||||
public static string executableDir;
|
||||
|
||||
public static void SetUpShaders(bool forceBinaryUpdate = false)
|
||||
{
|
||||
var stopwatch = System.Diagnostics.Stopwatch.StartNew();
|
||||
shaderSourceDirectory = Path.Combine(executableDir, "Shader");
|
||||
|
||||
// Reset the shaders first so that shaders can be replaced.
|
||||
OpenTKSharedResources.shaders.Clear();
|
||||
SetUpAllShaders();
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("Shader Setup: {0} ms", stopwatch.ElapsedMilliseconds);
|
||||
}
|
||||
|
||||
private static void SetUpAllShaders()
|
||||
{
|
||||
if (Switch_Toolbox.Library.Runtime.UseLegacyGL)
|
||||
SetUpLegacyBfresShaders();
|
||||
else
|
||||
SetUpBfresShaders();
|
||||
}
|
||||
private static void SetUpLegacyBfresShaders()
|
||||
{
|
||||
List<string> bfresSharedShaders = new List<string>
|
||||
{
|
||||
"Bfres\\Legacy\\BFRES.vert",
|
||||
"Bfres\\Legacy\\BFRES.frag",
|
||||
};
|
||||
|
||||
CreateAndAddShader("BFRES", bfresSharedShaders.ToArray());
|
||||
CreateAndAddShader("BFRES_Debug", bfresSharedShaders.ToArray());
|
||||
|
||||
}
|
||||
private static void SetUpBfresShaders()
|
||||
{
|
||||
List<string> bfresSharedShaders = new List<string>
|
||||
{
|
||||
"Bfres\\BFRES.vert",
|
||||
"Bfres\\BFRES_utility.frag",
|
||||
"Utility\\Utility.frag"
|
||||
};
|
||||
List<string> NormalsSharedShaders = new List<string>
|
||||
{
|
||||
"Bfres\\Normals.frag",
|
||||
"Bfres\\Normals.vert",
|
||||
"Bfres\\Normals.geom",
|
||||
};
|
||||
List<string> HDRShaders = new List<string>
|
||||
{
|
||||
"HDRSkyBox\\HDRSkyBox.vert",
|
||||
"HDRSkyBox\\HDRSkyBox.frag",
|
||||
};
|
||||
|
||||
|
||||
List<string> bfresDebugShaders = new List<string>(bfresSharedShaders);
|
||||
bfresDebugShaders.Add("Bfres\\BFRES_Debug.frag");
|
||||
|
||||
List<string> bfresShaders = new List<string>(bfresSharedShaders);
|
||||
bfresShaders.Add("Bfres\\BFRES.frag");
|
||||
|
||||
List<string> bfresPBRShaders = new List<string>(bfresSharedShaders);
|
||||
bfresPBRShaders.Add("Bfres\\BFRES_PBR.frag");
|
||||
|
||||
|
||||
List<string> bfresBotwShaders = new List<string>(bfresSharedShaders);
|
||||
bfresBotwShaders.Add("Bfres\\BFRES_Botw.frag");
|
||||
|
||||
|
||||
CreateAndAddShader("BFRES", bfresShaders.ToArray());
|
||||
CreateAndAddShader("BFRES_PBR", bfresPBRShaders.ToArray());
|
||||
CreateAndAddShader("BFRES_Debug", bfresDebugShaders.ToArray());
|
||||
CreateAndAddShader("BFRES_Botw", bfresBotwShaders.ToArray());
|
||||
CreateAndAddShader("BFRES_Normals", NormalsSharedShaders.ToArray());
|
||||
CreateAndAddShader("KCL", "KCL.frag", "KCL.vert");
|
||||
CreateAndAddShader("HDRSkyBox", HDRShaders.ToArray());
|
||||
}
|
||||
|
||||
public static void CreateAndAddShader(string shaderProgramName, params string[] shaderRelativePaths)
|
||||
{
|
||||
if (!OpenTKSharedResources.shaders.ContainsKey(shaderProgramName))
|
||||
{
|
||||
Shader shader = CreateShader(shaderProgramName, shaderRelativePaths);
|
||||
OpenTKSharedResources.shaders.Add(shaderProgramName, shader);
|
||||
}
|
||||
}
|
||||
|
||||
private static Shader CreateShader(string shaderProgramName, string[] shaderRelativePaths)
|
||||
{
|
||||
Shader shader = new Shader();
|
||||
LoadShaderFiles(shader, shaderRelativePaths);
|
||||
return shader;
|
||||
}
|
||||
|
||||
private static void LoadShaderFiles(Shader shader, string[] shaderRelativePaths)
|
||||
{
|
||||
var shaders = new List<Tuple<string, ShaderType, string>>();
|
||||
foreach (string file in shaderRelativePaths)
|
||||
{
|
||||
// The input paths are relative to the main shader directory.
|
||||
string shaderPath = shaderSourceDirectory + "\\" + file;
|
||||
if (!File.Exists(shaderPath))
|
||||
continue;
|
||||
|
||||
// Read the shader file.
|
||||
string shaderName = Path.GetFileNameWithoutExtension(shaderPath);
|
||||
string shaderSource = File.ReadAllText(shaderPath);
|
||||
|
||||
// Determine the shader type based on the file extension.
|
||||
ShaderType shaderType = ShaderType.FragmentShader;
|
||||
if (file.EndsWith(".vert"))
|
||||
shaderType = ShaderType.VertexShader;
|
||||
else if (file.EndsWith(".frag"))
|
||||
shaderType = ShaderType.FragmentShader;
|
||||
else if (file.EndsWith(".geom"))
|
||||
shaderType = ShaderType.GeometryShader;
|
||||
|
||||
shaders.Add(new Tuple<string, ShaderType, string>(shaderSource, shaderType, shaderName));
|
||||
}
|
||||
shader.LoadShaders(shaders);
|
||||
}
|
||||
|
||||
public static void SystemColorVector3Uniform(Shader shader, System.Drawing.Color color, string name)
|
||||
{
|
||||
shader.SetVector3(name, ColorUtils.Vector4FromColor(color).Xyz);
|
||||
}
|
||||
|
||||
public static void SaveErrorLogs()
|
||||
{
|
||||
// Export error logs for all the shaders.
|
||||
List<String> compileErrorList = new List<String>();
|
||||
int successfulCompilations = OpenTKSharedResources.shaders.Count;
|
||||
foreach (string shaderName in OpenTKSharedResources.shaders.Keys)
|
||||
{
|
||||
if (!OpenTKSharedResources.shaders[shaderName].LinkStatusIsOk)
|
||||
{
|
||||
compileErrorList.Add(shaderName);
|
||||
successfulCompilations -= 1;
|
||||
}
|
||||
|
||||
// Create the error logs directory if not found.
|
||||
string errorLogDirectory = executableDir + "\\Shader Error Logs\\";
|
||||
if (!Directory.Exists(errorLogDirectory))
|
||||
Directory.CreateDirectory(errorLogDirectory);
|
||||
|
||||
// Export the error log.
|
||||
string logExport = OpenTKSharedResources.shaders[shaderName].GetErrorLog();
|
||||
File.WriteAllText(errorLogDirectory + shaderName + " Error Log.txt", logExport.Replace("\n", Environment.NewLine));
|
||||
}
|
||||
|
||||
// Display how many shaders correctly compiled.
|
||||
string message = String.Format("{0} of {1} shaders compiled successfully. Error logs have been saved to the Shader Error Logs directory.\n",
|
||||
successfulCompilations, OpenTKSharedResources.shaders.Count);
|
||||
|
||||
// Display the shaders that didn't compile.
|
||||
if (compileErrorList.Count > 0)
|
||||
{
|
||||
message += "The following shaders failed to compile:\n";
|
||||
foreach (String shader in compileErrorList)
|
||||
message += shader + "\n";
|
||||
}
|
||||
|
||||
MessageBox.Show(message, "GLSL Shader Error Logs Exported");
|
||||
}
|
||||
}
|
||||
}
|
282
Switch_Toolbox_Library/Rendering/Skeleton.cs
Normal file
|
@ -0,0 +1,282 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using GL_Core;
|
||||
using GL_Core.Interfaces;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
public class STSkeleton : AbstractGlDrawable
|
||||
{
|
||||
public override void Prepare(GL_ControlModern control)
|
||||
{
|
||||
}
|
||||
public override void Prepare(GL_ControlLegacy control)
|
||||
{
|
||||
|
||||
}
|
||||
public override void Draw(GL_ControlLegacy control)
|
||||
{
|
||||
control.ResetModelMatrix();
|
||||
|
||||
foreach (STBone bn in bones)
|
||||
{
|
||||
bn.Render();
|
||||
}
|
||||
}
|
||||
public override void Draw(GL_ControlModern control)
|
||||
{
|
||||
foreach (STBone bn in bones)
|
||||
{
|
||||
bn.Render();
|
||||
}
|
||||
}
|
||||
|
||||
public List<STBone> bones = new List<STBone>();
|
||||
|
||||
public List<STBone> getBoneTreeOrder()
|
||||
{
|
||||
List<STBone> bone = new List<STBone>();
|
||||
Queue<STBone> q = new Queue<STBone>();
|
||||
|
||||
q.Enqueue(bones[0]);
|
||||
|
||||
while (q.Count > 0)
|
||||
{
|
||||
STBone b = q.Dequeue();
|
||||
foreach (STBone bo in b.GetChildren())
|
||||
q.Enqueue(bo);
|
||||
bone.Add(b);
|
||||
}
|
||||
return bone;
|
||||
}
|
||||
|
||||
public int boneIndex(string name)
|
||||
{
|
||||
for (int i = 0; i < bones.Count; i++)
|
||||
{
|
||||
if (bones[i].Text.Equals(name))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void reset(bool Main = true)
|
||||
{
|
||||
for (int i = 0; i < bones.Count; i++)
|
||||
{
|
||||
bones[i].pos = new Vector3(bones[i].position[0], bones[i].position[1], bones[i].position[2]);
|
||||
|
||||
if (bones[i].boneRotationType == 1)
|
||||
{
|
||||
bones[i].rot = (FromQuaternionAngles(bones[i].rotation[2], bones[i].rotation[1], bones[i].rotation[0], bones[i].rotation[3]));
|
||||
}
|
||||
else
|
||||
{
|
||||
bones[i].rot = (FromEulerAngles(bones[i].rotation[2], bones[i].rotation[1], bones[i].rotation[0]));
|
||||
}
|
||||
bones[i].sca = new Vector3(bones[i].scale[0], bones[i].scale[1], bones[i].scale[2]);
|
||||
}
|
||||
update(true);
|
||||
for (int i = 0; i < bones.Count; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
bones[i].invert = Matrix4.Invert(bones[i].transform);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
bones[i].invert = Matrix4.Zero;
|
||||
}
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
public STBone getBone(String name)
|
||||
{
|
||||
foreach (STBone bo in bones)
|
||||
if (bo.Text.Equals(name))
|
||||
return bo;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Quaternion FromQuaternionAngles(float z, float y, float x, float w)
|
||||
{
|
||||
{
|
||||
Quaternion q = new Quaternion();
|
||||
q.X = x;
|
||||
q.Y = y;
|
||||
q.Z = z;
|
||||
q.W = w;
|
||||
|
||||
if (q.W < 0)
|
||||
q *= -1;
|
||||
|
||||
//return xRotation * yRotation * zRotation;
|
||||
return q;
|
||||
}
|
||||
}
|
||||
|
||||
public static Quaternion FromEulerAngles(float z, float y, float x)
|
||||
{
|
||||
{
|
||||
Quaternion xRotation = Quaternion.FromAxisAngle(Vector3.UnitX, x);
|
||||
Quaternion yRotation = Quaternion.FromAxisAngle(Vector3.UnitY, y);
|
||||
Quaternion zRotation = Quaternion.FromAxisAngle(Vector3.UnitZ, z);
|
||||
|
||||
Quaternion q = (zRotation * yRotation * xRotation);
|
||||
|
||||
if (q.W < 0)
|
||||
q *= -1;
|
||||
|
||||
//return xRotation * yRotation * zRotation;
|
||||
return q;
|
||||
}
|
||||
}
|
||||
|
||||
private bool Updated = false;
|
||||
public void update(bool reset = false)
|
||||
{
|
||||
Updated = true;
|
||||
List<STBone> nodesToProcess = new List<STBone>();
|
||||
// Add all root nodes from the VBN
|
||||
foreach (STBone b in bones)
|
||||
if (b.Parent == null)
|
||||
nodesToProcess.Add(b);
|
||||
|
||||
// some special processing for the root bones before we start
|
||||
foreach (STBone b in nodesToProcess)
|
||||
{
|
||||
b.transform = Matrix4.CreateScale(b.sca) * Matrix4.CreateFromQuaternion(b.rot) * Matrix4.CreateTranslation(b.pos);
|
||||
// scale down the model in its entirety only when mid-animation (i.e. reset == false)
|
||||
if (!reset) b.transform *= Matrix4.CreateScale(1);
|
||||
}
|
||||
|
||||
// Process as a tree from the root node's children and beyond. These
|
||||
// all use the same processing, unlike the root nodes.
|
||||
int numRootNodes = nodesToProcess.Count;
|
||||
for (int i = 0; i < numRootNodes; i++)
|
||||
{
|
||||
nodesToProcess.AddRange(nodesToProcess[0].GetChildren());
|
||||
nodesToProcess.RemoveAt(0);
|
||||
}
|
||||
while (nodesToProcess.Count > 0)
|
||||
{
|
||||
// DFS
|
||||
STBone currentBone = nodesToProcess[0];
|
||||
nodesToProcess.RemoveAt(0);
|
||||
nodesToProcess.AddRange(currentBone.GetChildren());
|
||||
|
||||
// Process this node
|
||||
currentBone.transform = Matrix4.CreateScale(currentBone.sca) * Matrix4.CreateFromQuaternion(currentBone.rot) * Matrix4.CreateTranslation(currentBone.pos);
|
||||
if (currentBone.Parent != null)
|
||||
{
|
||||
currentBone.transform = currentBone.transform * ((STBone)currentBone.Parent).transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class STBone : TreeNodeCustom
|
||||
{
|
||||
public STSkeleton skeletonParent;
|
||||
public UInt32 boneRotationType;
|
||||
public int BillboardIndex;
|
||||
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 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)
|
||||
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 void Render()
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
BIN
Switch_Toolbox_Library/Resources/Aamp.png
Normal file
After Width: | Height: | Size: 476 B |
BIN
Switch_Toolbox_Library/Resources/BasicBakeMap.dds
Normal file
BIN
Switch_Toolbox_Library/Resources/Bfres.png
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
Switch_Toolbox_Library/Resources/Bfsha.png
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
Switch_Toolbox_Library/Resources/Bnsh.png
Normal file
After Width: | Height: | Size: 935 B |
BIN
Switch_Toolbox_Library/Resources/Bntx.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
Switch_Toolbox_Library/Resources/Bone.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
Switch_Toolbox_Library/Resources/Byaml.png
Normal file
After Width: | Height: | Size: 473 B |
BIN
Switch_Toolbox_Library/Resources/CheckerBackground.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
Switch_Toolbox_Library/Resources/DefaultTexture.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
Switch_Toolbox_Library/Resources/ErrorCheck.png
Normal file
After Width: | Height: | Size: 739 B |
BIN
Switch_Toolbox_Library/Resources/FileBank.png
Normal file
After Width: | Height: | Size: 467 B |
BIN
Switch_Toolbox_Library/Resources/Folder.png
Normal file
After Width: | Height: | Size: 528 B |
BIN
Switch_Toolbox_Library/Resources/InjectTexErrored.dds
Normal file
BIN
Switch_Toolbox_Library/Resources/LoadingImage.gif
Normal file
After Width: | Height: | Size: 90 KiB |
BIN
Switch_Toolbox_Library/Resources/Music1.png
Normal file
After Width: | Height: | Size: 624 B |
BIN
Switch_Toolbox_Library/Resources/Music2.png
Normal file
After Width: | Height: | Size: 622 B |
BIN
Switch_Toolbox_Library/Resources/Texture.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
Switch_Toolbox_Library/Resources/TextureError.png
Normal file
After Width: | Height: | Size: 6 KiB |
BIN
Switch_Toolbox_Library/Resources/Tool.ico
Normal file
After Width: | Height: | Size: 139 KiB |
BIN
Switch_Toolbox_Library/Resources/UVPattern.png
Normal file
After Width: | Height: | Size: 3 MiB |
BIN
Switch_Toolbox_Library/Resources/arrowMinimize .png
Normal file
After Width: | Height: | Size: 427 B |
BIN
Switch_Toolbox_Library/Resources/defaultDif.png
Normal file
After Width: | Height: | Size: 61 KiB |
BIN
Switch_Toolbox_Library/Resources/defaultShadingSphere.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
Switch_Toolbox_Library/Resources/diffuseSDR.gzip
Normal file
BIN
Switch_Toolbox_Library/Resources/diffuseSphere.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 601 KiB |
BIN
Switch_Toolbox_Library/Resources/materialSphere.png
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
Switch_Toolbox_Library/Resources/mesh.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
Switch_Toolbox_Library/Resources/model.png
Normal file
After Width: | Height: | Size: 837 B |
BIN
Switch_Toolbox_Library/Resources/normalMapSphere.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
Switch_Toolbox_Library/Resources/normalsSphere.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
Switch_Toolbox_Library/Resources/rotateGizmo.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
Switch_Toolbox_Library/Resources/scaleGizmo.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
Switch_Toolbox_Library/Resources/skeleton.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
Switch_Toolbox_Library/Resources/skeletonAnimation.png
Normal file
After Width: | Height: | Size: 188 KiB |
BIN
Switch_Toolbox_Library/Resources/specularSDR.gzip
Normal file
BIN
Switch_Toolbox_Library/Resources/translateGizmo.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
167
Switch_Toolbox_Library/Runtime.cs
Normal file
|
@ -0,0 +1,167 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
using System.Drawing;
|
||||
using GL_Core.Interfaces;
|
||||
|
||||
namespace Switch_Toolbox.Library
|
||||
{
|
||||
//Thanks to Smash Forge for a few of these!
|
||||
// https://github.com/jam1garner/Smash-Forge/blob/master/Smash%20Forge/Runtime.cs
|
||||
|
||||
public class Runtime
|
||||
{
|
||||
public static List<AbstractGlDrawable> abstractGlDrawables = new List<AbstractGlDrawable>();
|
||||
|
||||
public static DockState objectListDockState = DockState.DockLeft;
|
||||
|
||||
public static bool RenderModels = true;
|
||||
public static bool RenderModelSelection = true;
|
||||
public static bool RenderModelWireframe = false;
|
||||
public static ViewportShading viewportShading;
|
||||
public static bool IsDebugMode = false; //Enables experimental features and other things to debug.
|
||||
|
||||
public static bool enableVSync = false;
|
||||
public static float floorSize = 30f;
|
||||
public static Color floorColor = Color.Gray;
|
||||
public static FloorStyle floorStyle = FloorStyle.WireFrame;
|
||||
public static PictureBoxBG pictureBoxStyle = PictureBoxBG.Checkerboard;
|
||||
public static float previewScale = 1.0f;
|
||||
|
||||
public static bool renderFloorLines = true;
|
||||
|
||||
//Viewport Background
|
||||
public static BackgroundStyle backgroundStyle = BackgroundStyle.Gradient;
|
||||
public static bool renderBackGround = true;
|
||||
public static string backgroundTexFilePath = "";
|
||||
public static Color backgroundGradientTop = Color.FromArgb(255, 26, 26, 26);
|
||||
public static Color backgroundGradientBottom = Color.FromArgb(255, 77, 77, 77);
|
||||
public static float zoomspeed = 1.25f;
|
||||
public static float zoomModifierScale = 2.0f;
|
||||
public static bool cameraLight = false;
|
||||
public static bool DisplayPolyCount = true;
|
||||
public static float PolyCount = 0;
|
||||
public static float VertCount = 0;
|
||||
|
||||
public static bool enableOpenTKDebugOutput = false;
|
||||
|
||||
public static bool OpenStartupWindow = true;
|
||||
|
||||
// Toggle Render Passes
|
||||
public static bool renderDiffuse = true;
|
||||
public static bool renderFresnel = true;
|
||||
public static bool renderSpecular = true;
|
||||
public static bool renderReflection = true;
|
||||
public static bool renderBoundingBoxes = true;
|
||||
public static bool renderNormalMap = true;
|
||||
public static bool renderVertColor = true;
|
||||
public static bool renderBfresPbr = false;
|
||||
|
||||
public static bool stereoscopy = false;
|
||||
public static bool UseLegacyGL = false;
|
||||
|
||||
public static bool useNormalMap = true;
|
||||
|
||||
public static CameraMovement cameraMovement;
|
||||
public static CameraView cameraView;
|
||||
|
||||
public static ThumbnailSize thumbnailSize = ThumbnailSize.Small;
|
||||
|
||||
public static float CameraNear = 0.1f;
|
||||
public static float CameraFar = 100000.0f;
|
||||
public static ActiveGame activeGame = ActiveGame.SMO;
|
||||
|
||||
public enum ActiveGame
|
||||
{
|
||||
SMO,
|
||||
MK8D,
|
||||
ARMs,
|
||||
Splatoon2,
|
||||
BOTW,
|
||||
KSA,
|
||||
}
|
||||
|
||||
public enum PictureBoxBG
|
||||
{
|
||||
Checkerboard,
|
||||
Black,
|
||||
}
|
||||
|
||||
public enum CameraMovement
|
||||
{
|
||||
Inspect,
|
||||
Walk,
|
||||
}
|
||||
public enum CameraView
|
||||
{
|
||||
Perspective,
|
||||
Orthographic,
|
||||
}
|
||||
|
||||
public enum ThumbnailSize
|
||||
{
|
||||
Small,
|
||||
Medium,
|
||||
Large
|
||||
}
|
||||
|
||||
public enum BackgroundStyle
|
||||
{
|
||||
Gradient = 0,
|
||||
UserTexture = 1,
|
||||
Solid = 2,
|
||||
}
|
||||
|
||||
public enum FloorStyle
|
||||
{
|
||||
WireFrame = 0,
|
||||
UserTexture = 1,
|
||||
Solid = 2,
|
||||
}
|
||||
|
||||
public enum ViewportShading
|
||||
{
|
||||
Default = 0,
|
||||
Normal = 1,
|
||||
Lighting = 2,
|
||||
Diffuse = 3,
|
||||
NormalMap = 4,
|
||||
VertColor = 5,
|
||||
AmbientOcclusion = 6,
|
||||
UVCoords = 7,
|
||||
UVTestPattern = 8,
|
||||
Tangents = 9,
|
||||
Bitangents = 10,
|
||||
LightMap = 11,
|
||||
SelectedBoneWeights = 12,
|
||||
SpecularMap = 13,
|
||||
ShadowMap = 14,
|
||||
MetalnessMap = 15,
|
||||
RoughnessMap = 16,
|
||||
SubSurfaceScatteringMap = 17,
|
||||
EmmissionMap = 18,
|
||||
}
|
||||
public enum UVChannel
|
||||
{
|
||||
Channel1 = 1,
|
||||
Channel2 = 2,
|
||||
Channel3 = 3
|
||||
}
|
||||
|
||||
// Debug Shading
|
||||
public static bool renderR = true;
|
||||
public static bool renderG = true;
|
||||
public static bool renderB = true;
|
||||
public static bool renderAlpha = true;
|
||||
public static UVChannel uvChannel = UVChannel.Channel1;
|
||||
|
||||
|
||||
// OpenGL System Information
|
||||
public static string renderer = "";
|
||||
public static string openGLVersion = "";
|
||||
public static string GLSLVersion = "";
|
||||
}
|
||||
}
|