using System.Text;\r
using System.Xml.Serialization;\r
\r
-namespace tso2mqo\r
+namespace Tso2MqoGui\r
{\r
[XmlRoot("TsoMqoConfig")]\r
[Serializable]\r
+++ /dev/null
-using System;\r
-using System.Collections.Generic;\r
-using System.IO;\r
-using System.Text;\r
-using Microsoft.DirectX;\r
-using Microsoft.DirectX.Direct3D;\r
-\r
-namespace tso2mqo.Extensions\r
-{\r
- /// <summary>\r
- /// BinaryReader\82Ì\8ag\92£\83\81\83\\83b\83h\82ð\92è\8b`\82µ\82Ü\82·\81B\r
- /// </summary>\r
- public static class BinaryReaderMethods\r
- {\r
- /// <summary>\r
- /// null\8fI\92[\95¶\8e\9a\97ñ\82ð\93Ç\82Ý\82Æ\82è\82Ü\82·\81B\r
- /// </summary>\r
- /// <returns>\95¶\8e\9a\97ñ</returns>\r
- public static string ReadCString(this BinaryReader reader)\r
- {\r
- StringBuilder string_builder = new StringBuilder();\r
- while ( true ) {\r
- char c = reader.ReadChar();\r
- if (c == 0) break;\r
- string_builder.Append(c);\r
- }\r
- return string_builder.ToString();\r
- }\r
-\r
- /// <summary>\r
- /// Matrix\82ð\93Ç\82Ý\82Æ\82è\82Ü\82·\81B\r
- /// </summary>\r
- /// <param name="reader">BinaryReader</param>\r
- /// <param name="m">Matrix</param>\r
- public static void ReadMatrix(this BinaryReader reader, ref Matrix m)\r
- {\r
- m.M11 = reader.ReadSingle();\r
- m.M12 = reader.ReadSingle();\r
- m.M13 = reader.ReadSingle();\r
- m.M14 = reader.ReadSingle();\r
-\r
- m.M21 = reader.ReadSingle();\r
- m.M22 = reader.ReadSingle();\r
- m.M23 = reader.ReadSingle();\r
- m.M24 = reader.ReadSingle();\r
-\r
- m.M31 = reader.ReadSingle();\r
- m.M32 = reader.ReadSingle();\r
- m.M33 = reader.ReadSingle();\r
- m.M34 = reader.ReadSingle();\r
-\r
- m.M41 = reader.ReadSingle();\r
- m.M42 = reader.ReadSingle();\r
- m.M43 = reader.ReadSingle();\r
- m.M44 = reader.ReadSingle();\r
- }\r
-\r
- /// <summary>\r
- /// Vector3\82ð\93Ç\82Ý\82Æ\82è\82Ü\82·\81B\r
- /// </summary>\r
- /// <param name="reader">BinaryReader</param>\r
- /// <param name="v">Vector3</param>\r
- public static void ReadVector3(this BinaryReader reader, ref Vector3 v)\r
- {\r
- v.X = reader.ReadSingle();\r
- v.Y = reader.ReadSingle();\r
- v.Z = reader.ReadSingle();\r
- }\r
- }\r
-}\r
+++ /dev/null
-using System;\r
-using System.Collections.Generic;\r
-using System.IO;\r
-using System.Text;\r
-using Microsoft.DirectX;\r
-using Microsoft.DirectX.Direct3D;\r
-\r
-namespace tso2mqo.Extensions\r
-{\r
- /// <summary>\r
- /// BinaryWriter\82Ì\8ag\92£\83\81\83\\83b\83h\82ð\92è\8b`\82µ\82Ü\82·\81B\r
- /// </summary>\r
- public static class BinaryWriterMethods\r
- {\r
- /// <summary>\r
- /// \8ew\92è\83\89\83C\83^\82Énull\8fI\92[\95¶\8e\9a\97ñ\82ð\8f\91\82«\8fo\82µ\82Ü\82·\81B\r
- /// </summary>\r
- /// <param name="bw">BinaryWriter</param>\r
- /// <param name="s">null\8fI\92[\95¶\8e\9a\97ñ</param>\r
- public static void WriteCString(this BinaryWriter bw, string s)\r
- {\r
- foreach(byte i in Encoding.Default.GetBytes(s))\r
- bw.Write(i);\r
-\r
- bw.Write((byte)0);\r
- }\r
-\r
- /// <summary>\r
- /// \8ew\92è\83\89\83C\83^\82É\83x\83N\83g\83\8b\82ð\8f\91\82«\8fo\82µ\82Ü\82·\81B\r
- /// </summary>\r
- /// <param name="bw">BinaryWriter</param>\r
- /// <param name="v">\83x\83N\83g\83\8b</param>\r
- public static void Write(this BinaryWriter bw, ref Vector3 v)\r
- {\r
- bw.Write(v.X);\r
- bw.Write(v.Y);\r
- bw.Write(v.Z);\r
- }\r
-\r
- /// <summary>\r
- /// \8ew\92è\83\89\83C\83^\82É\8ds\97ñ\82ð\8f\91\82«\8fo\82µ\82Ü\82·\81B\r
- /// </summary>\r
- /// <param name="bw">BinaryWriter</param>\r
- /// <param name="m">\8ds\97ñ</param>\r
- public static void Write(this BinaryWriter bw, ref Matrix m)\r
- {\r
- bw.Write(m.M11); bw.Write(m.M12); bw.Write(m.M13); bw.Write(m.M14);\r
- bw.Write(m.M21); bw.Write(m.M22); bw.Write(m.M23); bw.Write(m.M24);\r
- bw.Write(m.M31); bw.Write(m.M32); bw.Write(m.M33); bw.Write(m.M34);\r
- bw.Write(m.M41); bw.Write(m.M42); bw.Write(m.M43); bw.Write(m.M44);\r
- }\r
- }\r
-}\r
-namespace tso2mqo\r
+namespace Tso2MqoGui\r
{\r
partial class Form1\r
{\r
this.label2 = new System.Windows.Forms.Label();\r
this.tabControl1 = new System.Windows.Forms.TabControl();\r
this.tabPage1 = new System.Windows.Forms.TabPage();\r
+ this.rbBoneRokDeBone = new System.Windows.Forms.RadioButton();\r
+ this.rbBoneNone = new System.Windows.Forms.RadioButton();\r
this.cbCopyTSO = new System.Windows.Forms.CheckBox();\r
this.cbMakeSub = new System.Windows.Forms.CheckBox();\r
this.tabPage2 = new System.Windows.Forms.TabPage();\r
// tabPage1\r
// \r
this.tabPage1.BackColor = System.Drawing.Color.LightSteelBlue;\r
+ this.tabPage1.Controls.Add(this.rbBoneRokDeBone);\r
+ this.tabPage1.Controls.Add(this.rbBoneNone);\r
this.tabPage1.Controls.Add(this.cbCopyTSO);\r
this.tabPage1.Controls.Add(this.cbMakeSub);\r
this.tabPage1.Controls.Add(this.label1);\r
this.tabPage1.Controls.Add(this.label2);\r
this.tabPage1.Controls.Add(this.button1);\r
this.tabPage1.Controls.Add(this.tbPath);\r
- this.tabPage1.Location = new System.Drawing.Point(4, 22);\r
+ this.tabPage1.Location = new System.Drawing.Point(4, 21);\r
this.tabPage1.Name = "tabPage1";\r
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);\r
- this.tabPage1.Size = new System.Drawing.Size(488, 274);\r
+ this.tabPage1.Size = new System.Drawing.Size(488, 275);\r
this.tabPage1.TabIndex = 0;\r
this.tabPage1.Text = "Tso->Mqo";\r
// \r
+ // rbBoneRokDeBone\r
+ // \r
+ this.rbBoneRokDeBone.AutoSize = true;\r
+ this.rbBoneRokDeBone.Location = new System.Drawing.Point(126, 75);\r
+ this.rbBoneRokDeBone.Name = "rbBoneRokDeBone";\r
+ this.rbBoneRokDeBone.Size = new System.Drawing.Size(170, 16);\r
+ this.rbBoneRokDeBone.TabIndex = 7;\r
+ this.rbBoneRokDeBone.TabStop = true;\r
+ this.rbBoneRokDeBone.Text = "RokDeBone形式のボーン作成";\r
+ this.rbBoneRokDeBone.UseVisualStyleBackColor = true;\r
+ // \r
+ // rbBoneNone\r
+ // \r
+ this.rbBoneNone.AutoSize = true;\r
+ this.rbBoneNone.Location = new System.Drawing.Point(6, 75);\r
+ this.rbBoneNone.Name = "rbBoneNone";\r
+ this.rbBoneNone.Size = new System.Drawing.Size(114, 16);\r
+ this.rbBoneNone.TabIndex = 6;\r
+ this.rbBoneNone.TabStop = true;\r
+ this.rbBoneNone.Text = "ボーンを作成しない";\r
+ this.rbBoneNone.UseVisualStyleBackColor = true;\r
+ // \r
// cbCopyTSO\r
// \r
this.cbCopyTSO.AutoSize = true;\r
this.tabPage2.Controls.Add(this.bRefMqoIn);\r
this.tabPage2.Controls.Add(this.tbMqoIn);\r
this.tabPage2.Controls.Add(this.label3);\r
- this.tabPage2.Location = new System.Drawing.Point(4, 22);\r
+ this.tabPage2.Location = new System.Drawing.Point(4, 21);\r
this.tabPage2.Name = "tabPage2";\r
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);\r
- this.tabPage2.Size = new System.Drawing.Size(488, 274);\r
+ this.tabPage2.Size = new System.Drawing.Size(488, 275);\r
this.tabPage2.TabIndex = 1;\r
this.tabPage2.Text = "Mqo->Tso";\r
// \r
this.tabPage3.Controls.Add(this.bMergeAdd);\r
this.tabPage3.Controls.Add(this.label8);\r
this.tabPage3.Controls.Add(this.tvMerge);\r
- this.tabPage3.Location = new System.Drawing.Point(4, 22);\r
+ this.tabPage3.Location = new System.Drawing.Point(4, 21);\r
this.tabPage3.Name = "tabPage3";\r
- this.tabPage3.Size = new System.Drawing.Size(488, 274);\r
+ this.tabPage3.Size = new System.Drawing.Size(488, 275);\r
this.tabPage3.TabIndex = 2;\r
this.tabPage3.Text = "Merge";\r
// \r
private System.Windows.Forms.Label label4;\r
private System.Windows.Forms.Button bExpOk;\r
private System.Windows.Forms.CheckBox cbCopyTSO;\r
+ private System.Windows.Forms.RadioButton rbBoneRokDeBone;\r
+ private System.Windows.Forms.RadioButton rbBoneNone;\r
private System.Windows.Forms.GroupBox gbBone;\r
private System.Windows.Forms.Button bRefresh;\r
private System.Windows.Forms.Button bSelectAll;\r
using System.Windows.Forms;\r
using Microsoft.Win32;\r
\r
-namespace tso2mqo\r
+namespace Tso2MqoGui\r
{\r
public partial class Form1 : Form\r
{\r
tbMergeTso.Text = (string)reg.GetValue("MergeTso", "");\r
rbAutoBone .Checked = (int)reg.GetValue("AutoBone", 1) == 1;\r
rb1Bone .Checked = (int)reg.GetValue("OneBone", 0) == 1;\r
+ rbBoneNone .Checked = (int)reg.GetValue("BoneNone", 1) == 1;\r
+ rbBoneRokDeBone.Checked = (int)reg.GetValue("BoneRokDeBone", 0) == 1;\r
cbMakeSub .Checked = (int)reg.GetValue("MakeSub", 1) == 1;\r
cbCopyTSO .Checked = (int)reg.GetValue("CopyTSO", 1) == 1;\r
cbShowMaterials.Checked = (int)reg.GetValue("ShowMaterials", 0) == 1;\r
reg.SetValue("MergeTso", tbMergeTso.Text);\r
reg.SetValue("AutoBone", rbAutoBone .Checked ? 1 : 0);\r
reg.SetValue("OneBone", rb1Bone .Checked ? 1 : 0);\r
+ reg.SetValue("BoneNone", rbBoneNone .Checked ? 1 : 0);\r
+ reg.SetValue("BoneRokDeBone", rbBoneRokDeBone.Checked ? 1 : 0);\r
reg.SetValue("MakeSub", cbMakeSub .Checked ? 1 : 0);\r
reg.SetValue("CopyTSO", cbCopyTSO .Checked ? 1 : 0);\r
reg.SetValue("ShowMaterials", cbShowMaterials.Checked ? 1 : 0);\r
TSOFile tso = new TSOFile(f);\r
tso.ReadAll();\r
\r
+ if(rbBoneRokDeBone.Checked) mqo.BoneMode = MqoBoneMode.RokDeBone;\r
+\r
mqo.Write(tso);\r
mqo.Close();\r
\r
MessageBox.Show(e.ToString());\r
}\r
}\r
-}\r
+}
\ No newline at end of file
-namespace tso2mqo\r
+namespace Tso2MqoGui\r
{\r
partial class FormMaterial\r
{\r
using System.Text;\r
using System.Windows.Forms;\r
\r
-namespace tso2mqo\r
+namespace Tso2MqoGui\r
{\r
public partial class FormMaterial : Form\r
{\r
}\r
}\r
}\r
-}\r
+}
\ No newline at end of file
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace Tso2MqoGui\r
+{\r
+ public partial struct Point2\r
+ {\r
+ public float x, y;\r
+\r
+ public Point2(float x, float y)\r
+ {\r
+ this.x = x;\r
+ this.y = y;\r
+ }\r
+\r
+ public float X { get { return x; } set { x= value; } }\r
+ public float Y { get { return y; } set { y= value; } }\r
+\r
+ public override string ToString()\r
+ {\r
+ return X+","+Y;\r
+ }\r
+ }\r
+\r
+ public partial struct Point3\r
+ {\r
+ public float x, y, z;\r
+\r
+ public Point3(float x, float y, float z)\r
+ {\r
+ this.x = x;\r
+ this.y = y;\r
+ this.z = z;\r
+ }\r
+\r
+ public float X { get { return x; } set { x= value; } }\r
+ public float Y { get { return y; } set { y= value; } }\r
+ public float Z { get { return z; } set { z= value; } }\r
+\r
+ public static Point3 operator+(Point3 a, Point3 b)\r
+ {\r
+ return new Point3(a.x+b.x, a.y+b.y, a.z+b.z);\r
+ }\r
+\r
+ public static Point3 operator-(Point3 a, Point3 b)\r
+ {\r
+ return new Point3(a.x-b.x, a.y-b.y, a.z-b.z);\r
+ }\r
+\r
+ public override string ToString()\r
+ {\r
+ return X+","+Y+","+Z;\r
+ }\r
+\r
+ public static Point3 Cross(Point3 p, Point3 q)\r
+ {\r
+ return new Point3(\r
+ p.y*q.z - p.z*q.y,\r
+ p.z*q.x - p.x*q.z,\r
+ p.x*q.y - p.y*q.x);\r
+ }\r
+\r
+ public static Point3 Normalize(Point3 p)\r
+ {\r
+ float d = p.x*p.x + p.y*p.y + p.z*p.z;\r
+\r
+ if(d < 0.00001f)\r
+ return p;\r
+\r
+ d = (float)(1 / (Math.Sqrt(d)));\r
+ return new Point3(p.x*d, p.y*d, p.z*d);\r
+ }\r
+ }\r
+\r
+ public partial struct Point4\r
+ {\r
+ public float x, y, z, w;\r
+\r
+ public Point4(float x, float y, float z, float w)\r
+ {\r
+ this.x = x;\r
+ this.y = y;\r
+ this.z = z;\r
+ this.w = w;\r
+ }\r
+\r
+ public float X { get { return x; } set { x= value; } }\r
+ public float Y { get { return y; } set { y= value; } }\r
+ public float Z { get { return z; } set { z= value; } }\r
+ public float W { get { return w; } set { w= value; } }\r
+\r
+ public override string ToString()\r
+ {\r
+ return X+","+Y+","+Z+","+W;\r
+ }\r
+ }\r
+\r
+ public partial struct Color3\r
+ {\r
+ public float r, g, b;\r
+ \r
+ public Color3(float r, float g, float b)\r
+ {\r
+ this.r = r;\r
+ this.g = g;\r
+ this.b = b;\r
+ }\r
+\r
+ public float R { get { return r; } set { r= value; } }\r
+ public float G { get { return g; } set { g= value; } }\r
+ public float B { get { return b; } set { b= value; } }\r
+\r
+ public override string ToString()\r
+ {\r
+ return R+","+G+","+B;\r
+ }\r
+ }\r
+\r
+ public partial struct Color3\r
+ {\r
+ public static Color3 Parse(string[] t, int begin)\r
+ {\r
+ return new Color3(\r
+ float.Parse(t[begin+0]),\r
+ float.Parse(t[begin+1]),\r
+ float.Parse(t[begin+2]));\r
+ }\r
+ }\r
+\r
+ public partial struct Point2\r
+ {\r
+ public static Point2 Parse(string[] t, int begin)\r
+ {\r
+ return new Point2(\r
+ float.Parse(t[begin+0]),\r
+ float.Parse(t[begin+1]));\r
+ }\r
+ }\r
+\r
+ public partial struct Point3\r
+ {\r
+ public static Point3 Parse(string[] t, int begin)\r
+ {\r
+ return new Point3(\r
+ float.Parse(t[begin+0]),\r
+ float.Parse(t[begin+1]),\r
+ float.Parse(t[begin+2]));\r
+ }\r
+ }\r
+}\r
using System.Text;\r
using System.Runtime.InteropServices;\r
\r
-namespace tso2mqo\r
+namespace Tso2MqoGui\r
{\r
using BYTE = Byte;\r
using WORD = UInt16;\r
using System.Text;\r
using System.Xml.Serialization;\r
\r
-namespace tso2mqo\r
+namespace Tso2MqoGui\r
{\r
[XmlRoot("TsoImportInfo")]\r
public class ImportInfo\r
+++ /dev/null
-using System;\r
-using System.Collections.Generic;\r
-using Microsoft.DirectX;\r
-using Microsoft.DirectX.Direct3D;\r
-\r
-namespace tso2mqo\r
-{\r
- public class Cell : LinkedList<int>\r
- {\r
- /// nodeをプッシュ\r
- public bool Push(LinkedListNode<int> node)\r
- {\r
- if (node == null)\r
- return false; // 無効オブジェクトは登録しない\r
- if (node.List == this)\r
- return false; // 2重登録チェック\r
- AddFirst(node);\r
- return true;\r
- }\r
- }\r
-\r
- /// 線形8分木空間管理クラス\r
- public class LinerOctreeManager\r
- {\r
- public const int MaxLevel = 7;\r
-\r
- /// 線形空間ポインタ配列\r
- public Cell[] cells;\r
- /// べき乗数値配列\r
- protected UInt32[] pow = new UInt32[MaxLevel + 1];\r
- /// 領域の幅\r
- protected Vector3 size;\r
- /// 領域の最小値\r
- protected Vector3 rgn_min;\r
- /// 領域の最大値\r
- protected Vector3 rgn_max;\r
- /// 最小領域の辺の長さ\r
- protected Vector3 unit;\r
- /// 空間の数\r
- public UInt32 ncell;\r
- /// 最下位レベル\r
- protected int level;\r
-\r
- /// 線形8分木配列を構築する\r
- public bool Init(int level, ref Vector3 min, ref Vector3 max)\r
- {\r
- // 各レベルでの空間数を算出\r
- pow[0] = 1;\r
- for (int i = 1; i < MaxLevel + 1; i++)\r
- pow[i] = pow[i - 1] * 8;\r
-\r
- // levelレベル(0基点)の配列作成\r
- ncell = (pow[level + 1] - 1) / 3;\r
- cells = new Cell[ncell];\r
-\r
- // 領域を登録\r
- rgn_min = min;\r
- rgn_max = max;\r
- size = rgn_max - rgn_min;\r
- float div = (float)(1 << level);\r
- Console.WriteLine("div {0}", div);\r
- unit = size;\r
- unit.X /= div;\r
- unit.Y /= div;\r
- unit.Z /= div;\r
-\r
- this.level = level;\r
-\r
- return true;\r
- }\r
-\r
- /// オブジェクトを登録する\r
- public bool Regist(ref Vector3 min, ref Vector3 max, LinkedListNode<int> node)\r
- {\r
- // オブジェクトの境界範囲から登録モートン番号を算出\r
- UInt32 num = GetMortonNumber(ref min, ref max);\r
- if (num < ncell)\r
- {\r
- // 空間が無い場合は新規作成\r
- if (cells[num] == null)\r
- CreateNewCell(num);\r
- return cells[num].Push(node);\r
- }\r
- return false; // 登録失敗\r
- }\r
-\r
- /// 空間を生成\r
- public bool CreateNewCell(UInt32 num)\r
- {\r
- // 引数の要素番号\r
- while (num < ncell && cells[num] == null)\r
- {\r
- // 指定の要素番号に空間を新規作成\r
- cells[num] = new Cell();\r
-\r
- // 親空間にジャンプ\r
- num = (num - 1) >> 2;\r
- }\r
- return true;\r
- }\r
-\r
- /// 座標から空間番号を算出\r
- public UInt32 GetMortonNumber(ref Vector3 min, ref Vector3 max)\r
- {\r
- // 最小レベルにおける各軸位置を算出\r
- UInt32 LT = GetPointElem(ref min);\r
- UInt32 RB = GetPointElem(ref max);\r
-\r
- // 空間番号を引き算して\r
- // 最上位区切りから所属レベルを算出\r
- UInt32 Def = RB ^ LT;\r
- int HiLevel = 1;\r
- int i;\r
- for (i = 0; i < level; i++)\r
- {\r
- UInt32 Check = (Def >> (i * 3)) & 0x7;\r
- if (Check != 0)\r
- HiLevel = i + 1;\r
- }\r
- UInt32 SpaceNum = RB >> (HiLevel * 3);\r
- UInt32 AddNum = (pow[level - HiLevel] - 1) / 7;\r
- SpaceNum += AddNum;\r
-\r
- if (SpaceNum > ncell)\r
- return UInt32.MaxValue;\r
-\r
- return SpaceNum;\r
- }\r
-\r
- /// ビット分割関数\r
- public static UInt32 BitSeparateFor3D(Byte n)\r
- {\r
- UInt32 s = n;\r
- s = (s | s << 8) & 0x0000f00f;\r
- s = (s | s << 4) & 0x000c30c3;\r
- s = (s | s << 2) & 0x00249249;\r
- return s;\r
- }\r
-\r
- /// 3Dモートン空間番号算出関数\r
- public static UInt32 Get3DMortonNumber(Byte x, Byte y, Byte z)\r
- {\r
- return BitSeparateFor3D(x) | BitSeparateFor3D(y) << 1 | BitSeparateFor3D(z) << 2;\r
- }\r
-\r
- /// 座標→線形8分木要素番号変換関数\r
- public UInt32 GetPointElem(ref Vector3 p)\r
- {\r
- return Get3DMortonNumber(\r
- (Byte)((p.X - rgn_min.X) / unit.X),\r
- (Byte)((p.Y - rgn_min.Y) / unit.Y),\r
- (Byte)((p.Z - rgn_min.Z) / unit.Z)\r
- );\r
- }\r
- }\r
-}\r
using System.IO;\r
using System.Text;\r
using System.Text.RegularExpressions;\r
-using Microsoft.DirectX;\r
-using Microsoft.DirectX.Direct3D;\r
\r
-namespace tso2mqo\r
+namespace Tso2MqoGui\r
{\r
public class MqoFile\r
{\r
{\r
if(tokens[2].ToLower() != "{") Error(tokens);\r
\r
- current.vertices = new List<Vector3>(int.Parse(tokens[1]));\r
+ current.vertices = new List<Point3>(int.Parse(tokens[1]));\r
DoRead(SectionVertex);\r
}\r
\r
current.faces = new List<MqoFace>(int.Parse(tokens[1]));\r
DoRead(SectionFace);\r
}\r
-\r
- public partial struct Color3\r
- {\r
- public static Vector3 Parse(string[] t, int begin)\r
- {\r
- return new Vector3(\r
- float.Parse(t[begin + 0]),\r
- float.Parse(t[begin + 1]),\r
- float.Parse(t[begin + 2]));\r
- }\r
- }\r
-\r
- public partial struct Point2\r
- {\r
- public static Vector2 Parse(string[] t, int begin)\r
- {\r
- return new Vector2(\r
- float.Parse(t[begin + 0]),\r
- float.Parse(t[begin + 1]));\r
- }\r
- }\r
-\r
- public partial struct Point3\r
- {\r
- public static Vector3 Parse(string[] t, int begin)\r
- {\r
- return new Vector3(\r
- float.Parse(t[begin + 0]),\r
- float.Parse(t[begin + 1]),\r
- float.Parse(t[begin + 2]));\r
- }\r
- }\r
}\r
\r
public class MqoScene\r
{\r
- public Vector3 pos;\r
- public Vector3 lookat;\r
+ public Point3 pos;\r
+ public Point3 lookat;\r
public float head;\r
public float pich;\r
public float ortho;\r
public float zoom2;\r
- public Vector3 amb;\r
+ public Color3 amb;\r
\r
public override string ToString()\r
{\r
{\r
public string name;\r
public int shader;\r
- public Vector3 col;\r
+ public Color3 col;\r
public float dif;\r
public float amb;\r
public float emi;\r
public int locking;\r
public int shading;\r
public float facet;\r
- public Vector3 color;\r
+ public Color3 color;\r
public int color_type;\r
- public List<Vector3> vertices;\r
+ public List<Point3> vertices;\r
public List<MqoFace> faces;\r
\r
public MqoObject() { }\r
public class MqoFace\r
{\r
public ushort a, b, c, mtl;\r
- public Vector2 ta, tb, tc;\r
+ public Point2 ta, tb, tc;\r
\r
public MqoFace()\r
{\r
}\r
\r
- public MqoFace(ushort a, ushort b, ushort c, ushort mtl, Vector2 ta, Vector2 tb, Vector2 tc)\r
+ public MqoFace(ushort a, ushort b, ushort c, ushort mtl, Point2 ta, Point2 tb, Point2 tc)\r
{\r
this.a = a;\r
this.b = b;\r
using System.Collections.Generic;\r
using System.IO;\r
using System.Text;\r
-using Microsoft.DirectX;\r
-using Microsoft.DirectX.Direct3D;\r
\r
-namespace tso2mqo\r
+namespace Tso2MqoGui\r
{\r
+ public enum MqoBoneMode\r
+ {\r
+ None,\r
+ RokDeBone,\r
+ Mikoto,\r
+ }\r
+\r
public class Pair<T, U>\r
{\r
public T First;\r
public TextWriter tw;\r
public string OutPath;\r
public string OutFile;\r
+ public MqoBoneMode BoneMode = MqoBoneMode.None;\r
\r
public MqoWriter(string file)\r
{\r
++cnt;\r
va= vb; a= b;\r
vb= vc; b= c;\r
- vc= k; c= vh.Add(new UVertex(k.Pos.X, k.Pos.Y, k.Pos.Z, k.Nrm.X, k.Nrm.Y, k.Nrm.Z, k.Tex.X, k.Tex.Y, j.spec));\r
+ vc= k; c= vh.Add(new UVertex(k.Pos.x, k.Pos.y, k.Pos.z, k.Nrm.x, k.Nrm.y, k.Nrm.z, k.Tex.x, k.Tex.y, j.spec));\r
\r
if(cnt < 3) continue;\r
if(a == b || b == c || c == a) continue;\r
//face.Add(a); uv.Add(va.Tex.x); uv.Add(va.Tex.y);\r
//face.Add(b); uv.Add(vb.Tex.x); uv.Add(vb.Tex.y);\r
//face.Add(c); uv.Add(vc.Tex.x); uv.Add(vc.Tex.y);\r
- face.Add(a); uv.Add(va.Tex.X); uv.Add(1-va.Tex.Y);\r
- face.Add(b); uv.Add(vb.Tex.X); uv.Add(1-vb.Tex.Y);\r
- face.Add(c); uv.Add(vc.Tex.X); uv.Add(1-vc.Tex.Y);\r
+ face.Add(a); uv.Add(va.Tex.x); uv.Add(1-va.Tex.y);\r
+ face.Add(b); uv.Add(vb.Tex.x); uv.Add(1-vb.Tex.y);\r
+ face.Add(c); uv.Add(vc.Tex.x); uv.Add(1-vc.Tex.y);\r
mtl.Add(j.spec);\r
} else\r
{\r
//face.Add(a); uv.Add(va.Tex.x); uv.Add(va.Tex.y);\r
//face.Add(c); uv.Add(vc.Tex.x); uv.Add(vc.Tex.y);\r
//face.Add(b); uv.Add(vb.Tex.x); uv.Add(vb.Tex.y);\r
- face.Add(a); uv.Add(va.Tex.X); uv.Add(1-va.Tex.Y);\r
- face.Add(c); uv.Add(vc.Tex.X); uv.Add(1-vc.Tex.Y);\r
- face.Add(b); uv.Add(vb.Tex.X); uv.Add(1-vb.Tex.Y);\r
+ face.Add(a); uv.Add(va.Tex.x); uv.Add(1-va.Tex.y);\r
+ face.Add(c); uv.Add(vc.Tex.x); uv.Add(1-vc.Tex.y);\r
+ face.Add(b); uv.Add(vb.Tex.x); uv.Add(1-vb.Tex.y);\r
mtl.Add(j.spec);\r
}\r
}\r
tw.WriteLine("}");\r
}\r
\r
+ // ボーンを出す\r
+ switch(BoneMode)\r
+ {\r
+ case MqoBoneMode.None: break;\r
+ case MqoBoneMode.RokDeBone:\r
+ {\r
+ // マトリクス計算\r
+ foreach(TSONode i in file.nodes)\r
+ {\r
+ if(i.parent == null)\r
+ i.world = i.Matrix;\r
+ else i.world = Matrix44.Mul(i.Matrix, i.parent.World);\r
+ }\r
+ \r
+#if false\r
+ // 位置一覧\r
+ Dictionary<string, Point3> pointmap= new Dictionary<string, Point3>();\r
+ Dictionary<string, int> indexmap= new Dictionary<string, int();\r
+\r
+ foreach(TSONode i in file.nodes)\r
+ {\r
+ points.Add(i.World.Translation);\r
+ pointmap.Add(i.name, i.World.Translation);\r
+ }\r
+\r
+ //RDBBonFile bonfile = new RDBBonFile();\r
+#endif\r
+ List<Point3> points = new List<Point3>();\r
+ List<int> bones = new List<int>();\r
+\r
+ tw.WriteLine("Object \"{0}\" {{", "Bone");\r
+#if true\r
+ tw.WriteLine(" visible {0}", 15);\r
+ tw.WriteLine(" locking {0}", 0);\r
+ tw.WriteLine(" shading {0}", 1);\r
+ tw.WriteLine(" facet {0}", 59.5);\r
+ tw.WriteLine(" color {0} {1} {2}", 1, 0, 0);\r
+ tw.WriteLine(" color_type {0}", 0);\r
+#else\r
+ tw.WriteLine(" depth {0}", 0);\r
+ tw.WriteLine(" folding {0}", 0);\r
+ tw.WriteLine(" scale {0} {1} {2}", 1.000000, 1.000000, 1.000000);\r
+ tw.WriteLine(" rotation {0} {1} {2}", 0.000000, 0.000000, 0.000000);\r
+ tw.WriteLine(" translation {0} {1} {2}", 0.000000, 0.000000, 0.000000);\r
+ tw.WriteLine(" visible {0}", 15);\r
+ tw.WriteLine(" locking {0}", 0);\r
+ tw.WriteLine(" shading {0}", 1);\r
+ tw.WriteLine(" facet {0}", 59.5);\r
+ tw.WriteLine(" color {0} {1} {2}", 0.898, 0.498, 0.698);\r
+ tw.WriteLine(" color_type {0}", 0);\r
+#endif\r
+\r
+ foreach(TSONode i in file.nodes)\r
+ {\r
+ if(i.children.Count == 0)\r
+ continue;\r
+\r
+ Point3 q = new Point3(i.world.M41, i.world.M42, i.world.M43);\r
+ Point3 p = new Point3();\r
+ \r
+ foreach(TSONode j in i.children)\r
+ {\r
+ p.x +=j.world.M41;\r
+ p.y +=j.world.M42;\r
+ p.z +=j.world.M43;\r
+ }\r
+\r
+ p.x /=i.children.Count;\r
+ p.y /=i.children.Count;\r
+ p.z /=i.children.Count;\r
+\r
+ bones.Add(points.Count); points.Add(q);\r
+ bones.Add(points.Count); points.Add(p);\r
+ }\r
+\r
+ tw.WriteLine(" vertex {0} {{", points.Count);\r
+\r
+ foreach(Point3 j in points)\r
+ WriteVertex(j.x, j.y, j.z);\r
+\r
+ tw.WriteLine(" }");\r
+\r
+ //\r
+ tw.WriteLine(" face {0} {{", bones.Count / 2);\r
+\r
+ for(int j= 0, n= bones.Count; j < n; j+=2)\r
+ tw.WriteLine(string.Format(" 2 V({0} {1})", bones[j+0], bones[j+1]));\r
+\r
+ tw.WriteLine(" }");\r
+ tw.WriteLine("}");\r
+ }\r
+ break;\r
+\r
+ case MqoBoneMode.Mikoto:\r
+ {\r
+ }\r
+ break;\r
+ }\r
+\r
tw.WriteLine("Eof");\r
}\r
\r
using System.Text;\r
using System.Runtime.InteropServices;\r
\r
-namespace tso2mqo\r
+namespace Tso2MqoGui\r
{\r
public enum PrimType\r
{\r
+//#define SEARCH_DEBUG\r
using System;\r
using System.Collections.Generic;\r
using System.Text;\r
-using Microsoft.DirectX;\r
-using Microsoft.DirectX.Direct3D;\r
\r
-namespace tso2mqo\r
+namespace Tso2MqoGui\r
{\r
+ public class Array3D<T>\r
+ {\r
+ public T[] data;\r
+ public int xx, yy, zz;\r
+\r
+ public Array3D(int x, int y, int z)\r
+ {\r
+ data = new T[x*y*z];\r
+ xx = x;\r
+ yy = y;\r
+ zz = z;\r
+ }\r
+\r
+ public T Get(int x, int y, int z)\r
+ {\r
+ return data[x+y*xx+z*xx*yy];\r
+ }\r
+\r
+ public void Set(int x, int y, int z, T v)\r
+ {\r
+ data[x+y*xx+z*xx*yy] = v;\r
+ }\r
+ }\r
+\r
public class PointCluster\r
{\r
- LinerOctreeManager octree = new LinerOctreeManager();\r
- public List<Vector3> points;\r
- public Vector3 min = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);\r
- public Vector3 max = new Vector3(float.MinValue, float.MinValue, float.MinValue);\r
+ public List<Point3> points;\r
+ public int div;\r
+ public float divu;\r
+ public Array3D<List<int>> clusters;\r
+ public Point3 min= new Point3(float.MaxValue, float.MaxValue, float.MaxValue);\r
+ public Point3 max= new Point3(float.MinValue, float.MinValue, float.MinValue);\r
\r
public PointCluster(int n)\r
{\r
- points = new List<Vector3>(n);\r
+ points = new List<Point3>(n);\r
}\r
\r
- public Vector3 GetPoint(int i)\r
+ public Point3 GetPoint(int i)\r
{\r
return points[i];\r
}\r
\r
- public void Add(Vector3 p)\r
+ public void Add(Point3 p)\r
{\r
points.Add(p);\r
- if (p.X < min.X) min.X = p.X; else if (p.X > max.X) max.X = p.X;\r
- if (p.Y < min.Y) min.Y = p.Y; else if (p.Y > max.Y) max.Y = p.Y;\r
- if (p.Z < min.Z) min.Z = p.Z; else if (p.Z > max.Z) max.Z = p.Z;\r
+ if(p.x < min.x) min.x= p.x; else if(p.x > max.x) max.x= p.x;\r
+ if(p.y < min.y) min.y= p.y; else if(p.y > max.y) max.y= p.y;\r
+ if(p.z < min.z) min.z= p.z; else if(p.z > max.z) max.z= p.z;\r
+ }\r
+\r
+ public void Add(float x, float y, float z)\r
+ {\r
+ Add(new Point3(x, y, z));\r
}\r
\r
public void Clustering()\r
{\r
- octree.Init(5, ref min, ref max);\r
- for (int i = 0; i < points.Count; i++)\r
+ float x = max.x - min.x;\r
+ float y = max.y - min.y;\r
+ float z = max.z - min.z;\r
+ div = (int)Math.Ceiling((float)Math.Sqrt(Math.Sqrt(points.Count)));\r
+\r
+ if(x >= y && x >= z) divu= x / div;\r
+ else if(y >= x && y >= z) divu= y / div;\r
+ else if(z >= x && z >= y) divu= z / div;\r
+\r
+ clusters = new Array3D<List<int>>\r
+ (Math.Max(1, (int)(x / divu)),\r
+ Math.Max(1, (int)(y / divu)),\r
+ Math.Max(1, (int)(z / divu)));\r
+\r
+ for(int i= 0, n= points.Count; i < n; ++i)\r
+ AddCluster(i, points[i].x, points[i].y, points[i].z);\r
+ }\r
+\r
+ public int Clump(int a, int min, int max)\r
+ {\r
+ return a < min ? min : a > max ? max : a;\r
+ }\r
+\r
+ public int IndexX(float x) { return Clump((int)((x-min.x) / divu), 0, clusters.xx-1); }\r
+ public int IndexY(float y) { return Clump((int)((y-min.y) / divu), 0, clusters.yy-1); }\r
+ public int IndexZ(float z) { return Clump((int)((z-min.z) / divu), 0, clusters.zz-1); }\r
+\r
+ public void AddCluster(int i, float x, float y, float z)\r
+ {\r
+ int a = IndexX(x), b= IndexY(y), c= IndexZ(z);\r
+ List<int> l;\r
+ \r
+ try\r
{\r
- Vector3 p = points[i];\r
- if (!octree.Regist(ref p, ref p, new LinkedListNode<int>(i)))\r
- {\r
- Console.WriteLine("failed to regist node");\r
- }\r
+ l = clusters.Get(a, b, c);\r
+\r
+ if(l == null)\r
+ clusters.Set(a, b, c, l= new List<int>());\r
+\r
+ l.Add(i);\r
+ } catch(Exception e)\r
+ {\r
+ System.Diagnostics.Debug.WriteLine(e);\r
}\r
}\r
\r
- public int NearestIndex(Vector3 p)\r
+ public int NearestIndex(float x, float y, float z)\r
{\r
- int near = -1;\r
- float nearest_lensq = float.MaxValue;\r
- UInt32 num = octree.GetMortonNumber(ref p, ref p);\r
- if (num < octree.ncell)\r
+#if SEARCH_DEBUG\r
+ int dbgcount= 0; \r
+#endif\r
+ int limit = 99;\r
+ int near = -1;\r
+ float distsq = float.MaxValue;\r
+ int a = IndexX(x);\r
+ int b = IndexY(y);\r
+ int c = IndexZ(z);\r
+\r
+ for(int i= 0; i <= limit; ++i)\r
{\r
- Cell cell = octree.cells[num];\r
- //Console.WriteLine("cell {0} {1}", num, cell.Count);\r
- foreach (int i in cell)\r
+ for(int xx= a-i; xx <= a+i; ++xx)\r
+ for(int yy= b-i; yy <= b+i; ++yy)\r
+ for(int zz= c-i; zz <= c+i; ++zz)\r
{\r
- float lensq = Vector3.LengthSq(points[i] - p);\r
- if (lensq < nearest_lensq)\r
+ if(xx < 0 || xx >= clusters.xx) continue;\r
+ if(yy < 0 || yy >= clusters.yy) continue;\r
+ if(zz < 0 || zz >= clusters.zz) continue;\r
+\r
+ List<int> l = clusters.Get(xx, yy, zz);\r
+\r
+ if(l == null)\r
+ continue;\r
+\r
+ foreach(int j in l)\r
{\r
- nearest_lensq = lensq;\r
- near = i;\r
+ Point3 p = points[j];\r
+ p.x -=x;\r
+ p.y -=y;\r
+ p.z -=z;\r
+ float d = p.x*p.x + p.y*p.y + p.z*p.z;\r
+#if SEARCH_DEBUG\r
+ ++dbgcount;\r
+#endif\r
+ if(d >= distsq)\r
+ continue;\r
+\r
+ if(limit == 99)\r
+ limit = i + 1;\r
+ distsq = d;\r
+ near = j;\r
}\r
}\r
}\r
- else\r
- Console.WriteLine("near index not found");\r
+#if SEARCH_DEBUG\r
+ System.Diagnostics.Debug.WriteLine(string.Format(\r
+ "dbgcount:{0} index:{1} distance:{2}", dbgcount, near, distsq));\r
+#endif\r
return near;\r
}\r
}\r
using System.Text;\r
using System.Windows.Forms;\r
\r
-namespace tso2mqo\r
+namespace Tso2MqoGui\r
{\r
static class Program\r
{\r
//------------------------------------------------------------------------------\r
// <auto-generated>\r
// このコードはツールによって生成されました。\r
-// ランタイム バージョン:2.0.50727.4200\r
+// ランタイム バージョン:2.0.50727.1433\r
//\r
// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、\r
// コードが再生成されるときに損失したりします。\r
// </auto-generated>\r
//------------------------------------------------------------------------------\r
\r
-namespace tso2mqo.Properties {\r
+namespace Tso2MqoGui.Properties {\r
using System;\r
\r
\r
internal static global::System.Resources.ResourceManager ResourceManager {\r
get {\r
if (object.ReferenceEquals(resourceMan, null)) {\r
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("tso2mqo.Properties.Resources", typeof(Resources).Assembly);\r
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tso2MqoGui.Properties.Resources", typeof(Resources).Assembly);\r
resourceMan = temp;\r
}\r
return resourceMan;\r
//------------------------------------------------------------------------------\r
// <auto-generated>\r
// このコードはツールによって生成されました。\r
-// ランタイム バージョン:2.0.50727.4200\r
+// ランタイム バージョン:2.0.50727.1433\r
//\r
// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、\r
// コードが再生成されるときに損失したりします。\r
// </auto-generated>\r
//------------------------------------------------------------------------------\r
\r
-namespace tso2mqo.Properties {\r
+namespace Tso2MqoGui.Properties {\r
\r
\r
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]\r
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.IO;\r
+using System.Text;\r
+\r
+namespace Tso2MqoGui\r
+{\r
+ public class RDBJoint\r
+ {\r
+ public int No;\r
+ public string Name;\r
+\r
+ public RDBJoint(int no, string name)\r
+ {\r
+ No = no;\r
+ Name= name;\r
+ }\r
+\r
+ public override string ToString()\r
+ {\r
+ return No.ToString().PadLeft(4, '0') + ":" + Name;\r
+ }\r
+ }\r
+\r
+ public class RDBBone\r
+ {\r
+ public int Begin;\r
+ public int End;\r
+\r
+ public RDBBone(int begin, int end)\r
+ {\r
+ Begin = begin;\r
+ End = end;\r
+ }\r
+\r
+ public override string ToString()\r
+ {\r
+ return "0003," + Begin.ToString().PadLeft(4, '0')\r
+ + "," + End .ToString().PadLeft(4, '0');\r
+ }\r
+ }\r
+\r
+ public class RDBBonFile\r
+ {\r
+ public int no = 0;\r
+ public List<RDBJoint> joints = new List<RDBJoint>();\r
+ public Dictionary<string, RDBJoint> jointmap= new Dictionary<string, RDBJoint>();\r
+ public List<RDBBone> bones = new List<RDBBone>();\r
+\r
+ public void AddJoint(string name)\r
+ {\r
+ RDBJoint j = new RDBJoint(no++, name);\r
+ joints.Add(j);\r
+ jointmap.Add(name, j);\r
+ }\r
+\r
+ public void AddBone(int begin, int end)\r
+ {\r
+ bones.Add(new RDBBone(begin, end));\r
+ }\r
+\r
+ public void Save(string file)\r
+ {\r
+ StringBuilder sb = new StringBuilder();\r
+\r
+ sb.AppendLine("BoneFile : type separated : ver1001")\r
+ .AppendLine("")\r
+ .AppendLine("NAMEPART_START");\r
+\r
+ foreach(RDBJoint i in joints)\r
+ sb.AppendLine(i.ToString());\r
+\r
+ sb.AppendLine("NAMEPART_END")\r
+ .AppendLine("")\r
+ .AppendLine("")\r
+ .AppendLine("TREEPART_START")\r
+ .AppendLine("");\r
+\r
+ foreach(RDBBone i in bones)\r
+ sb.AppendLine(i.ToString());\r
+ \r
+ sb.AppendLine("TREEPART_END");\r
+\r
+ File.WriteAllText(file, sb.ToString(), Encoding.Default);\r
+ }\r
+ }\r
+}\r
using System.Collections.Generic;\r
using System.IO;\r
using System.Text;\r
-using Microsoft.DirectX;\r
-using Microsoft.DirectX.Direct3D;\r
\r
-namespace tso2mqo\r
+namespace Tso2MqoGui\r
{\r
public class TDCGFile\r
{\r
return enc.GetString(buf.ToArray());\r
}\r
\r
- public unsafe Matrix ReadMatrix()\r
+ public unsafe Matrix44 ReadMatrix()\r
{\r
- Matrix m;\r
- m.M11 = r.ReadSingle();\r
- m.M12 = r.ReadSingle();\r
- m.M13 = r.ReadSingle();\r
- m.M14 = r.ReadSingle();\r
-\r
- m.M21 = r.ReadSingle();\r
- m.M22 = r.ReadSingle();\r
- m.M23 = r.ReadSingle();\r
- m.M24 = r.ReadSingle();\r
-\r
- m.M31 = r.ReadSingle();\r
- m.M32 = r.ReadSingle();\r
- m.M33 = r.ReadSingle();\r
- m.M34 = r.ReadSingle();\r
-\r
- m.M41 = r.ReadSingle();\r
- m.M42 = r.ReadSingle();\r
- m.M43 = r.ReadSingle();\r
- m.M44 = r.ReadSingle();\r
+ Matrix44 m = new Matrix44();\r
+ float* p = &m.m11;\r
+\r
+ for(int i= 0; i < 16; ++i)\r
+ *p++ = r.ReadSingle();\r
\r
return m;\r
}\r
using System.IO;\r
using System.Text;\r
using System.ComponentModel;\r
-using Microsoft.DirectX;\r
-using Microsoft.DirectX.Direct3D;\r
\r
-namespace tso2mqo\r
+namespace Tso2MqoGui\r
{\r
public class TSOFile : TDCGFile\r
{\r
internal int id;\r
internal string name;\r
internal string sname;\r
- internal Matrix matrix;\r
- internal Matrix world;\r
+ internal Matrix44 matrix;\r
+ internal Matrix44 world;\r
internal List<TSONode> children = new List<TSONode>();\r
internal TSONode parent;\r
\r
[Category("General")] public int ID { get { return id; } }\r
[Category("General")] public string Name { get { return name; } }\r
[Category("General")] public string ShortName { get { return sname; } }\r
- [Category("Detail")]\r
- public Matrix Matrix { get { return matrix; } set { matrix = value; } }\r
- [Category("Detail")]\r
- public Matrix World { get { return world; } set { world = value; } }\r
+ [Category("Detail")] public Matrix44 Matrix { get { return matrix; } set { matrix= value; } }\r
+ [Category("Detail")] public Matrix44 World { get { return world; } set { world = value; } }\r
\r
public override string ToString()\r
{\r
internal float lightDirY; // = [-0.0582338]\r
internal float lightDirZ; // = [-0.998302]\r
internal float lightDirW; // = [0]\r
- internal Vector4 shadowColor; // = [0, 0, 0, 1]\r
+ internal Point4 shadowColor; // = [0, 0, 0, 1]\r
internal string shadeTex; // = Ninjya_Ribbon_Toon_Tex\r
internal float highLight; // = [0]\r
internal float colorBlend; // = [10]\r
internal float highLightBlend; // = [10]\r
- internal Vector4 penColor; // = [0.166, 0.166, 0.166, 1]\r
+ internal Point4 penColor; // = [0.166, 0.166, 0.166, 1]\r
internal float ambient; // = [38]\r
internal string colorTex; // = file24\r
internal float thickness; // = [0.018]\r
[Category("Parameters")] public float LightDirY { get { return lightDirY; } set { lightDirY = value; } }\r
[Category("Parameters")] public float LightDirZ { get { return lightDirZ; } set { lightDirZ = value; } }\r
[Category("Parameters")] public float LightDirW { get { return lightDirW; } set { lightDirW = value; } }\r
- [Category("Parameters")]\r
- public Vector4 ShadowColor { get { return shadowColor; } set { shadowColor = value; } }\r
+ [Category("Parameters")] public Point4 ShadowColor { get { return shadowColor; } set { shadowColor = value; } }\r
[Category("Parameters")] public string ShadeTex { get { return shadeTex; } set { shadeTex = value; } }\r
[Category("Parameters")] public float HighLight { get { return highLight; } set { highLight = value; } }\r
[Category("Parameters")] public float ColorBlend { get { return colorBlend; } set { colorBlend = value; } }\r
[Category("Parameters")] public float HighLightBlend { get { return highLightBlend; } set { highLightBlend= value; } }\r
- [Category("Parameters")]\r
- public Vector4 PenColor { get { return penColor; } set { penColor = value; } }\r
+ [Category("Parameters")] public Point4 PenColor { get { return penColor; } set { penColor = value; } }\r
[Category("Parameters")] public float Ambient { get { return ambient; } set { ambient = value; } }\r
[Category("Parameters")] public string ColorTex { get { return colorTex; } set { colorTex = value; } }\r
[Category("Parameters")] public float Thickness { get { return thickness; } set { thickness = value; } }\r
return float.Parse(value.Trim('[', ']', ' '));\r
}\r
\r
- public Vector4 GetPoint4(string value)\r
+ public Point4 GetPoint4(string value)\r
{\r
string[] token = value.Trim('[', ']', ' ').Split(',');\r
- Vector4 p;\r
+ Point4 p = new Point4();\r
p.X = float.Parse(token[0].Trim());\r
p.Y = float.Parse(token[1].Trim());\r
p.Z = float.Parse(token[2].Trim());\r
{\r
internal TSOFile file;\r
internal string name;\r
- internal Matrix matrix;\r
+ internal Matrix44 matrix;\r
internal int effect;\r
internal int numsubs;\r
internal TSOSubMesh[] sub;\r
\r
[Category("General")] public string Name { get { return name; } set { name= value; } }\r
//[Category("Detail")] public int Effect { get { return name; } set { name= value; } }\r
- [Category("Detail")]\r
- public Matrix Matrix { get { return matrix; } set { matrix = value; } }\r
+ [Category("Detail")] public Matrix44 Matrix { get { return matrix; } set { matrix= value; } }\r
\r
public override string ToString()\r
{\r
}\r
}\r
\r
+ public struct Matrix44\r
+ {\r
+ public static readonly Matrix44 Identity = new Matrix44(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);\r
+\r
+ public float m11, m12, m13, m14;\r
+ public float m21, m22, m23, m24;\r
+ public float m31, m32, m33, m34;\r
+ public float m41, m42, m43, m44;\r
+\r
+ public float M11 { get { return m11; } set { m11= value; } }\r
+ public float M12 { get { return m12; } set { m12= value; } }\r
+ public float M13 { get { return m13; } set { m13= value; } }\r
+ public float M14 { get { return m14; } set { m14= value; } }\r
+ public float M21 { get { return m21; } set { m21= value; } }\r
+ public float M22 { get { return m22; } set { m22= value; } }\r
+ public float M23 { get { return m23; } set { m23= value; } }\r
+ public float M24 { get { return m24; } set { m24= value; } }\r
+ public float M31 { get { return m31; } set { m31= value; } }\r
+ public float M32 { get { return m32; } set { m32= value; } }\r
+ public float M33 { get { return m33; } set { m33= value; } }\r
+ public float M34 { get { return m34; } set { m34= value; } }\r
+ public float M41 { get { return m41; } set { m41= value; } }\r
+ public float M42 { get { return m42; } set { m42= value; } }\r
+ public float M43 { get { return m43; } set { m43= value; } }\r
+ public float M44 { get { return m44; } set { m44= value; } }\r
+\r
+ public Matrix44(\r
+ float a11, float a12, float a13, float a14,\r
+ float a21, float a22, float a23, float a24,\r
+ float a31, float a32, float a33, float a34,\r
+ float a41, float a42, float a43, float a44)\r
+ {\r
+ m11=a11; m12=a12; m13=a13; m14=a14;\r
+ m21=a21; m22=a22; m23=a23; m24=a24;\r
+ m31=a31; m32=a32; m33=a33; m34=a34;\r
+ m41=a41; m42=a42; m43=a43; m44=a44;\r
+ }\r
+\r
+ public Point3 Translation { get { return new Point3(M41, M42, M43); } } \r
+\r
+ public override string ToString()\r
+ {\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.Append("[").Append(M11).Append(", ")\r
+ .Append(M12).Append(", ")\r
+ .Append(M13).Append(", ")\r
+ .Append(M14).Append("], ")\r
+ .Append("[").Append(M21).Append(", ")\r
+ .Append(M22).Append(", ")\r
+ .Append(M23).Append(", ")\r
+ .Append(M24).Append("], ")\r
+ .Append("[").Append(M31).Append(", ")\r
+ .Append(M32).Append(", ")\r
+ .Append(M33).Append(", ")\r
+ .Append(M34).Append("], ")\r
+ .Append("[").Append(M41).Append(", ")\r
+ .Append(M42).Append(", ")\r
+ .Append(M43).Append(", ")\r
+ .Append(M44).Append("]");\r
+ return sb.ToString();\r
+ }\r
+\r
+ public static Matrix44 Mul(Matrix44 a, Matrix44 b)\r
+ {\r
+ Matrix44 m = new Matrix44();\r
+\r
+ m.M11 = a.M11*b.M11 + a.M12*b.M21 + a.M13*b.M31 + a.M14*b.M41;\r
+ m.M12 = a.M11*b.M12 + a.M12*b.M22 + a.M13*b.M32 + a.M14*b.M42;\r
+ m.M13 = a.M11*b.M13 + a.M12*b.M23 + a.M13*b.M33 + a.M14*b.M43;\r
+ m.M14 = a.M11*b.M14 + a.M12*b.M24 + a.M13*b.M34 + a.M14*b.M44;\r
+\r
+ m.M21 = a.M21*b.M11 + a.M22*b.M21 + a.M23*b.M31 + a.M24*b.M41;\r
+ m.M22 = a.M21*b.M12 + a.M22*b.M22 + a.M23*b.M32 + a.M24*b.M42;\r
+ m.M23 = a.M21*b.M13 + a.M22*b.M23 + a.M23*b.M33 + a.M24*b.M43;\r
+ m.M24 = a.M21*b.M14 + a.M22*b.M24 + a.M23*b.M34 + a.M24*b.M44;\r
+\r
+ m.M31 = a.M31*b.M11 + a.M32*b.M21 + a.M33*b.M31 + a.M34*b.M41;\r
+ m.M32 = a.M31*b.M12 + a.M32*b.M22 + a.M33*b.M32 + a.M34*b.M42;\r
+ m.M33 = a.M31*b.M13 + a.M32*b.M23 + a.M33*b.M33 + a.M34*b.M43;\r
+ m.M34 = a.M31*b.M14 + a.M32*b.M24 + a.M33*b.M34 + a.M34*b.M44;\r
+\r
+ m.M41 = a.M41*b.M11 + a.M42*b.M21 + a.M43*b.M31 + a.M44*b.M41;\r
+ m.M42 = a.M41*b.M12 + a.M42*b.M22 + a.M43*b.M32 + a.M44*b.M42;\r
+ m.M43 = a.M41*b.M13 + a.M42*b.M23 + a.M43*b.M33 + a.M44*b.M43;\r
+ m.M44 = a.M41*b.M14 + a.M42*b.M24 + a.M43*b.M34 + a.M44*b.M44;\r
+\r
+ return m;\r
+ }\r
+ }\r
+\r
public partial struct Vertex : IComparable<Vertex>\r
{\r
- public Vector3 Pos;\r
- public Vector4 Wgt;\r
+ public Point3 Pos;\r
+ public Point4 Wgt;\r
public UInt32 Idx;\r
- public Vector3 Nrm;\r
- public Vector2 Tex;\r
+ public Point3 Nrm;\r
+ public Point2 Tex;\r
//public int Count;\r
//public Weights[] Weights;\r
\r
- public Vertex(Vector3 pos, Vector4 wgt, UInt32 idx, Vector3 nrm, Vector2 tex)\r
+ public Vertex(Point3 pos, Point4 wgt, UInt32 idx, Point3 nrm, Point2 tex)\r
{\r
Pos = pos;\r
Wgt = wgt;\r
\r
public int CompareTo(Vertex o)\r
{\r
- if(Pos.X < o.Pos.X) return -1; if(Pos.X > o.Pos.X) return 1;\r
- if(Pos.Y < o.Pos.Y) return -1; if(Pos.Y > o.Pos.Y) return 1;\r
- if(Pos.Z < o.Pos.Z) return -1; if(Pos.Z > o.Pos.Z) return 1;\r
- if(Nrm.X < o.Nrm.X) return -1; if(Nrm.X > o.Nrm.X) return 1;\r
- if(Nrm.Y < o.Nrm.Y) return -1; if(Nrm.Y > o.Nrm.Y) return 1;\r
- if(Nrm.Z < o.Nrm.Z) return -1; if(Nrm.Z > o.Nrm.Z) return 1;\r
- if(Tex.X < o.Tex.X) return -1; if(Tex.X > o.Tex.X) return 1;\r
- if(Tex.Y < o.Tex.Y) return -1; if(Tex.Y > o.Tex.Y) return 1;\r
- if(Wgt.X < o.Wgt.X) return -1; if(Wgt.X > o.Wgt.X) return 1;\r
- if(Wgt.Y < o.Wgt.Y) return -1; if(Wgt.Y > o.Wgt.Y) return 1;\r
- if(Wgt.Z < o.Wgt.Z) return -1; if(Wgt.Z > o.Wgt.Z) return 1;\r
- if(Wgt.W < o.Wgt.W) return -1; if(Wgt.W > o.Wgt.W) return 1;\r
+ if(Pos.x < o.Pos.x) return -1; if(Pos.x > o.Pos.x) return 1;\r
+ if(Pos.y < o.Pos.y) return -1; if(Pos.y > o.Pos.y) return 1;\r
+ if(Pos.z < o.Pos.z) return -1; if(Pos.z > o.Pos.z) return 1;\r
+ if(Nrm.x < o.Nrm.x) return -1; if(Nrm.x > o.Nrm.x) return 1;\r
+ if(Nrm.y < o.Nrm.y) return -1; if(Nrm.y > o.Nrm.y) return 1;\r
+ if(Nrm.z < o.Nrm.z) return -1; if(Nrm.z > o.Nrm.z) return 1;\r
+ if(Tex.x < o.Tex.x) return -1; if(Tex.x > o.Tex.x) return 1;\r
+ if(Tex.y < o.Tex.y) return -1; if(Tex.y > o.Tex.y) return 1;\r
+ if(Wgt.x < o.Wgt.x) return -1; if(Wgt.x > o.Wgt.x) return 1;\r
+ if(Wgt.y < o.Wgt.y) return -1; if(Wgt.y > o.Wgt.y) return 1;\r
+ if(Wgt.z < o.Wgt.z) return -1; if(Wgt.z > o.Wgt.z) return 1;\r
+ if(Wgt.w < o.Wgt.w) return -1; if(Wgt.w > o.Wgt.w) return 1;\r
if(Idx < o.Idx) return -1; if(Idx > o.Idx) return 1;\r
return 0;\r
}\r
\r
public override int GetHashCode()\r
{\r
- return Pos.X.GetHashCode() ^ Pos.Y.GetHashCode() ^ Pos.Z.GetHashCode()\r
- ^ Nrm.X.GetHashCode() ^ Nrm.Y.GetHashCode() ^ Nrm.Z.GetHashCode()\r
- ^ Tex.X.GetHashCode() ^ Tex.Y.GetHashCode() ^ Wgt.W.GetHashCode()\r
- ^ Wgt.X.GetHashCode() ^ Wgt.Y.GetHashCode() ^ Wgt.Z.GetHashCode()\r
+ return Pos.x.GetHashCode() ^ Pos.y.GetHashCode() ^ Pos.z.GetHashCode()\r
+ ^ Nrm.x.GetHashCode() ^ Nrm.y.GetHashCode() ^ Nrm.z.GetHashCode()\r
+ ^ Tex.x.GetHashCode() ^ Tex.y.GetHashCode() ^ Wgt.w.GetHashCode()\r
+ ^ Wgt.x.GetHashCode() ^ Wgt.y.GetHashCode() ^ Wgt.z.GetHashCode()\r
- Idx.GetHashCode();\r
}\r
\r
{\r
Vertex o = (Vertex)obj;\r
\r
- return Pos.X==o.Pos.X && Pos.Y==o.Pos.Y && Pos.Z==o.Pos.Z\r
- && Nrm.X==o.Nrm.X && Nrm.Y==o.Nrm.Y && Nrm.Z==o.Nrm.Z\r
- && Tex.X==o.Tex.X && Tex.Y==o.Tex.Y && Wgt.W==o.Wgt.W\r
- && Wgt.X==o.Wgt.X && Wgt.Y==o.Wgt.Y && Wgt.Z==o.Wgt.Z\r
+ return Pos.x==o.Pos.x && Pos.y==o.Pos.y && Pos.z==o.Pos.z\r
+ && Nrm.x==o.Nrm.x && Nrm.y==o.Nrm.y && Nrm.z==o.Nrm.z\r
+ && Tex.x==o.Tex.x && Tex.y==o.Tex.y && Wgt.w==o.Wgt.w\r
+ && Wgt.x==o.Wgt.x && Wgt.y==o.Wgt.y && Wgt.z==o.Wgt.z\r
&& Idx ==o.Idx;\r
}\r
}\r
using System.Collections.Generic;\r
using System.Text;\r
\r
-namespace tso2mqo\r
+namespace Tso2MqoGui\r
{\r
public class TSOGenerateConfig\r
{\r
using System.Collections.Generic;\r
using System.IO;\r
using System.Text;\r
-using Microsoft.DirectX;\r
-using Microsoft.DirectX.Direct3D;\r
-using tso2mqo.Extensions;\r
\r
-namespace tso2mqo\r
+namespace Tso2MqoGui\r
{\r
public class TSOWriter\r
{\r
bw.Write(0x314F5354);\r
}\r
\r
+ public static void Write(BinaryWriter bw, string s)\r
+ {\r
+ foreach(byte i in Encoding.Default.GetBytes(s))\r
+ bw.Write(i);\r
+\r
+ bw.Write((byte)0);\r
+ }\r
+\r
public static void Write(BinaryWriter bw, string[] s)\r
{\r
int n = s[s.Length-1] == "" ? s.Length-1 : s.Length;\r
bw.Write(n);\r
\r
for(int i= 0; i < n; ++i)\r
- bw.WriteCString(s[i]);\r
+ Write(bw, s[i]);\r
}\r
\r
public static void Write(BinaryWriter bw, TSONode[] items)\r
\r
bw.Write(items.Length);\r
\r
- foreach (var i in items)\r
- {\r
- Matrix m = i.Matrix;\r
- bw.Write(ref m);\r
- }\r
+ foreach(var i in items)\r
+ Write(bw, i.Matrix);\r
}\r
\r
public static void Write(BinaryWriter bw, TSONode item)\r
{\r
- bw.WriteCString(item.Name);\r
+ Write(bw, item.Name);\r
+ }\r
+\r
+ public static void Write(BinaryWriter bw, Matrix44 item)\r
+ {\r
+ bw.Write(item.M11); bw.Write(item.M12); bw.Write(item.M13); bw.Write(item.M14);\r
+ bw.Write(item.M21); bw.Write(item.M22); bw.Write(item.M23); bw.Write(item.M24);\r
+ bw.Write(item.M31); bw.Write(item.M32); bw.Write(item.M33); bw.Write(item.M34);\r
+ bw.Write(item.M41); bw.Write(item.M42); bw.Write(item.M43); bw.Write(item.M44);\r
}\r
\r
public static void Write(BinaryWriter bw, TSOTex[] items)\r
\r
public static void Write(BinaryWriter bw, TSOTex item)\r
{\r
- bw.WriteCString(item.name);\r
- bw.WriteCString(item.file);\r
+ Write(bw, item.name);\r
+ Write(bw, item.file);\r
bw.Write(item.Width);\r
bw.Write(item.Height);\r
bw.Write(item.Depth);\r
\r
public static void Write(BinaryWriter bw, TSOEffect item)\r
{\r
- bw.WriteCString(item.Name);\r
+ Write(bw, item.Name);\r
Write(bw, item.Code.Split('\n'));\r
}\r
\r
\r
public static void Write(BinaryWriter bw, TSOMaterial item)\r
{\r
- bw.WriteCString(item.Name);\r
- bw.WriteCString(item.File);\r
+ Write(bw, item.Name);\r
+ Write(bw, item.File);\r
Write(bw, item.Code.Split('\n'));\r
}\r
\r
\r
public static void Write(BinaryWriter bw, TSOMesh item)\r
{\r
- bw.WriteCString(item.Name);\r
- Matrix m = item.Matrix;\r
- bw.Write(ref m);\r
+ Write(bw, item.Name);\r
+ Write(bw, item.Matrix);\r
bw.Write(1);\r
Write(bw, item.sub);\r
}\r
List<int> idxs = new List<int>(4);\r
List<float> wgts = new List<float>(4);\r
\r
- if(v.Wgt.X > 0) { idxs.Add(idx[0]); wgts.Add(v.Wgt.X); }\r
- if(v.Wgt.Y > 0) { idxs.Add(idx[1]); wgts.Add(v.Wgt.Y); }\r
- if(v.Wgt.Z > 0) { idxs.Add(idx[2]); wgts.Add(v.Wgt.Z); }\r
- if(v.Wgt.W > 0) { idxs.Add(idx[3]); wgts.Add(v.Wgt.W); }\r
+ if(v.Wgt.x > 0) { idxs.Add(idx[0]); wgts.Add(v.Wgt.x); }\r
+ if(v.Wgt.y > 0) { idxs.Add(idx[1]); wgts.Add(v.Wgt.y); }\r
+ if(v.Wgt.z > 0) { idxs.Add(idx[2]); wgts.Add(v.Wgt.z); }\r
+ if(v.Wgt.w > 0) { idxs.Add(idx[3]); wgts.Add(v.Wgt.w); }\r
\r
- bw.Write(ref v.Pos);\r
- bw.Write(ref v.Nrm);\r
+ bw.Write(v.Pos.X); bw.Write(v.Pos.Y); bw.Write(v.Pos.Z);\r
+ bw.Write(v.Nrm.X); bw.Write(v.Nrm.Y); bw.Write(v.Nrm.Z);\r
bw.Write(v.Tex.X); bw.Write(v.Tex.Y);\r
\r
bw.Write(wgts.Count);\r
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">\r
<PropertyGroup>\r
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
- <ProductVersion>9.0.30729</ProductVersion>\r
+ <ProductVersion>9.0.21022</ProductVersion>\r
<SchemaVersion>2.0</SchemaVersion>\r
<ProjectGuid>{C0DE49DD-78AB-4517-8234-7331DEF93472}</ProjectGuid>\r
- <OutputType>Exe</OutputType>\r
+ <OutputType>WinExe</OutputType>\r
<AppDesignerFolder>Properties</AppDesignerFolder>\r
- <RootNamespace>tso2mqo</RootNamespace>\r
- <AssemblyName>tso2mqo</AssemblyName>\r
+ <RootNamespace>Tso2MqoGui</RootNamespace>\r
+ <AssemblyName>Tso2MqoGui</AssemblyName>\r
<FileUpgradeFlags>\r
</FileUpgradeFlags>\r
<OldToolsVersion>2.0</OldToolsVersion>\r
</UpgradeBackupLocation>\r
<StartupObject>\r
</StartupObject>\r
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>\r
</PropertyGroup>\r
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
<DebugSymbols>true</DebugSymbols>\r
<PlatformTarget>x64</PlatformTarget>\r
<ErrorReport>prompt</ErrorReport>\r
</PropertyGroup>\r
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">\r
- <PlatformTarget>x86</PlatformTarget>\r
- <OutputPath>..\debug\</OutputPath>\r
- <DefineConstants>TRACE;DEBUG</DefineConstants>\r
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\r
- </PropertyGroup>\r
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">\r
- <PlatformTarget>x86</PlatformTarget>\r
- <OutputPath>..\build\</OutputPath>\r
- <Optimize>true</Optimize>\r
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\r
- </PropertyGroup>\r
<ItemGroup>\r
- <Reference Include="Microsoft.DirectX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />\r
- <Reference Include="Microsoft.DirectX.Direct3D, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />\r
- <Reference Include="Microsoft.DirectX.Direct3DX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />\r
<Reference Include="System" />\r
- <Reference Include="System.Core">\r
- <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
- </Reference>\r
<Reference Include="System.Data" />\r
<Reference Include="System.Deployment" />\r
<Reference Include="System.Design" />\r
</ItemGroup>\r
<ItemGroup>\r
<Compile Include="Config.cs" />\r
- <Compile Include="Extensions\BinaryReaderMethods.cs" />\r
- <Compile Include="Extensions\BinaryWriterMethods.cs" />\r
<Compile Include="Form1.cs">\r
<SubType>Form</SubType>\r
</Compile>\r
<Compile Include="FormMaterial.Designer.cs">\r
<DependentUpon>FormMaterial.cs</DependentUpon>\r
</Compile>\r
+ <Compile Include="General.cs" />\r
<Compile Include="ImageFile.cs" />\r
<Compile Include="ImportInfo.cs" />\r
- <Compile Include="LinerOctreeManager.cs" />\r
<Compile Include="MqoFile.cs" />\r
<Compile Include="MqoWriter.cs" />\r
<Compile Include="NvTriStrip.cs" />\r
<DependentUpon>Settings.settings</DependentUpon>\r
<DesignTimeSharedInput>True</DesignTimeSharedInput>\r
</Compile>\r
+ <Compile Include="RDBBonFile.cs" />\r
<Compile Include="TDCGFile.cs" />\r
<Compile Include="TSOFile.cs" />\r
<Compile Include="TSOGenerateConfig.cs" />\r
<Target Name="AfterBuild">\r
</Target>\r
-->\r
-</Project>
\ No newline at end of file
+</Project>\r
--- /dev/null
+\r
+Microsoft Visual Studio Solution File, Format Version 10.00\r
+# Visual C# Express 2008\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tso2MqoGui", "Tso2MqoGui.csproj", "{C0DE49DD-78AB-4517-8234-7331DEF93472}"\r
+EndProject\r
+Global\r
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+ Debug|Any CPU = Debug|Any CPU\r
+ Debug|x64 = Debug|x64\r
+ Release|Any CPU = Release|Any CPU\r
+ Release|x64 = Release|x64\r
+ EndGlobalSection\r
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+ {C0DE49DD-78AB-4517-8234-7331DEF93472}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+ {C0DE49DD-78AB-4517-8234-7331DEF93472}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+ {C0DE49DD-78AB-4517-8234-7331DEF93472}.Debug|x64.ActiveCfg = Debug|x64\r
+ {C0DE49DD-78AB-4517-8234-7331DEF93472}.Debug|x64.Build.0 = Debug|x64\r
+ {C0DE49DD-78AB-4517-8234-7331DEF93472}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+ {C0DE49DD-78AB-4517-8234-7331DEF93472}.Release|Any CPU.Build.0 = Release|Any CPU\r
+ {C0DE49DD-78AB-4517-8234-7331DEF93472}.Release|x64.ActiveCfg = Release|x64\r
+ {C0DE49DD-78AB-4517-8234-7331DEF93472}.Release|x64.Build.0 = Release|x64\r
+ EndGlobalSection\r
+ GlobalSection(SolutionProperties) = preSolution\r
+ HideSolutionNode = FALSE\r
+ EndGlobalSection\r
+EndGlobal\r
using System.ComponentModel;\r
using System.Windows.Forms;\r
using System.Windows.Forms.Design;\r
-using Microsoft.DirectX;\r
-using Microsoft.DirectX.Direct3D;\r
\r
-namespace tso2mqo\r
+namespace Tso2MqoGui\r
{\r
public unsafe class TsoGenerator\r
{\r
pc = new PointCluster(vlst.Count);\r
\r
foreach(Vertex i in vlst)\r
- pc.Add(i.Pos);\r
+ pc.Add(i.Pos.x, i.Pos.y, i.Pos.z);\r
\r
pc.Clustering();\r
}\r
// 一番近い頂点への参照\r
List<int> vref= new List<int>(i.vertices.Count);\r
\r
- foreach (Vector3 j in i.vertices)\r
- vref.Add(pc.NearestIndex(j));\r
+ foreach(Point3 j in i.vertices)\r
+ vref.Add(pc.NearestIndex(j.x, j.y, j.z));\r
\r
// 法線生成\r
- Vector3[] nrm = new Vector3[i.vertices.Count];\r
+ Point3[] nrm = new Point3[i.vertices.Count];\r
\r
foreach(MqoFace j in i.faces)\r
{\r
- Vector3 v1 = Vector3.Normalize(i.vertices[j.b] - i.vertices[j.a]);\r
- Vector3 v2 = Vector3.Normalize(i.vertices[j.c] - i.vertices[j.b]);\r
- Vector3 n = Vector3.Normalize(Vector3.Cross(v1, v2));\r
+ Point3 v1 = Point3.Normalize(i.vertices[j.b] - i.vertices[j.a]);\r
+ Point3 v2 = Point3.Normalize(i.vertices[j.c] - i.vertices[j.b]);\r
+ Point3 n = Point3.Normalize(Point3.Cross(v1, v2));\r
#if false\r
nrm[j.a] +=n;\r
nrm[j.b] +=n;\r
}\r
\r
for(int j= 0; j < nrm.Length; ++j)\r
- nrm[j] = Vector3.Normalize(nrm[j]);\r
+ nrm[j] = Point3.Normalize(nrm[j]);\r
\r
// フェイスの組成\r
List<int> faces1 = new List<int>();\r
{\r
Vertex vv = v[k];\r
UInt32 idx0 = vv.Idx;\r
- Vector4 wgt0 = vv.Wgt;\r
+ Point4 wgt0 = vv.Wgt;\r
byte* idx = (byte*)(&idx0);\r
float* wgt = (float*)(&wgt0);\r
\r
}\r
\r
// \todo 点の追加\r
- Vertex va = new Vertex(i.vertices[f.a], v[0].Wgt, v[0].Idx, nrm[f.a], new Vector2(f.ta.X, 1 - f.ta.Y));\r
- Vertex vb = new Vertex(i.vertices[f.b], v[1].Wgt, v[1].Idx, nrm[f.b], new Vector2(f.tb.X, 1 - f.tb.Y));\r
- Vertex vc = new Vertex(i.vertices[f.c], v[2].Wgt, v[2].Idx, nrm[f.c], new Vector2(f.tc.X, 1 - f.tc.Y));\r
+ Vertex va = new Vertex(i.vertices[f.a], v[0].Wgt, v[0].Idx, nrm[f.a], new Point2(f.ta.x, 1-f.ta.y));\r
+ Vertex vb = new Vertex(i.vertices[f.b], v[1].Wgt, v[1].Idx, nrm[f.b], new Point2(f.tb.x, 1-f.tb.y));\r
+ Vertex vc = new Vertex(i.vertices[f.c], v[2].Wgt, v[2].Idx, nrm[f.c], new Point2(f.tc.x, 1-f.tc.y));\r
#if false\r
indices.Add(vh.Add(va));\r
indices.Add(vh.Add(vb));\r
{\r
uint idx0= verts[j].Idx;\r
byte* idx = (byte*)(&idx0);\r
- Vector4 wgt0 = verts[j].Wgt;\r
+ Point4 wgt0= verts[j].Wgt;\r
float* wgt = (float*)(&wgt0);\r
\r
for(int k= 0; k < 4; ++k)\r
mesh.name = i.name;\r
mesh.numsubs = subs.Count;\r
mesh.sub = subs.ToArray();\r
- mesh.matrix = Matrix.Identity;\r
+ mesh.matrix = Matrix44.Identity;\r
mesh.effect = 0;\r
meshes.Add(mesh);\r
}\r
System.Diagnostics.Debug.WriteLine("object:" + i.name); \r
#endif\r
// 法線生成\r
- Vector3[] nrm = new Vector3[i.vertices.Count];\r
+ Point3[] nrm = new Point3[i.vertices.Count];\r
\r
foreach(MqoFace j in i.faces)\r
{\r
- Vector3 v1 = Vector3.Normalize(i.vertices[j.b] - i.vertices[j.a]);\r
- Vector3 v2 = Vector3.Normalize(i.vertices[j.c] - i.vertices[j.b]);\r
- Vector3 n = Vector3.Normalize(Vector3.Cross(v1, v2));\r
+ Point3 v1 = Point3.Normalize(i.vertices[j.b] - i.vertices[j.a]);\r
+ Point3 v2 = Point3.Normalize(i.vertices[j.c] - i.vertices[j.b]);\r
+ Point3 n = Point3.Normalize(Point3.Cross(v1, v2));\r
nrm[j.a] -=n;\r
nrm[j.b] -=n;\r
nrm[j.c] -=n;\r
}\r
\r
for(int j= 0; j < nrm.Length; ++j)\r
- nrm[j] = Vector3.Normalize(nrm[j]);\r
+ nrm[j] = Point3.Normalize(nrm[j]);\r
\r
// ボーン情報作成\r
uint idx = 0x00000000;\r
- Vector4 wgt = new Vector4(1, 0, 0, 0);\r
+ Point4 wgt = new Point4(1, 0, 0, 0);\r
int[] bones = new int[1];\r
string bone = config.boneref[i.name];\r
bones[0] = nodes[bone].ID;\r
if(f.mtl != mtl)\r
continue;\r
\r
- Vertex va = new Vertex(i.vertices[f.a], wgt, idx, nrm[f.a], new Vector2(f.ta.X, 1 - f.ta.Y));\r
- Vertex vb = new Vertex(i.vertices[f.b], wgt, idx, nrm[f.b], new Vector2(f.tb.X, 1 - f.tb.Y));\r
- Vertex vc = new Vertex(i.vertices[f.c], wgt, idx, nrm[f.c], new Vector2(f.tc.X, 1 - f.tc.Y));\r
+ Vertex va = new Vertex(i.vertices[f.a], wgt, idx, nrm[f.a], new Point2(f.ta.x, 1-f.ta.y));\r
+ Vertex vb = new Vertex(i.vertices[f.b], wgt, idx, nrm[f.b], new Point2(f.tb.x, 1-f.tb.y));\r
+ Vertex vc = new Vertex(i.vertices[f.c], wgt, idx, nrm[f.c], new Point2(f.tc.x, 1-f.tc.y));\r
\r
indices.Add(vh.Add(va));\r
indices.Add(vh.Add(vc));\r
mesh.name = i.name;\r
mesh.numsubs = subs.Count;\r
mesh.sub = subs.ToArray();\r
- mesh.matrix = Matrix.Identity;\r
+ mesh.matrix = Matrix44.Identity;\r
mesh.effect = 0;\r
meshes.Add(mesh);\r
}\r
bw.Write((byte)0);\r
}\r
\r
- public void WriteMatrix(BinaryWriter bw, Matrix m)\r
+ public void WriteMatrix(BinaryWriter bw, Matrix44 m)\r
{\r
bw.Write(m.M11); bw.Write(m.M12); bw.Write(m.M13); bw.Write(m.M14);\r
bw.Write(m.M21); bw.Write(m.M22); bw.Write(m.M23); bw.Write(m.M24);\r
List<int> idxs = new List<int>(4);\r
List<float> wgts = new List<float>(4);\r
\r
- if(v.Wgt.X > 0) { idxs.Add(idx[0]); wgts.Add(v.Wgt.X); }\r
- if(v.Wgt.Y > 0) { idxs.Add(idx[1]); wgts.Add(v.Wgt.Y); }\r
- if(v.Wgt.Z > 0) { idxs.Add(idx[2]); wgts.Add(v.Wgt.Z); }\r
- if(v.Wgt.W > 0) { idxs.Add(idx[3]); wgts.Add(v.Wgt.W); }\r
+ if(v.Wgt.x > 0) { idxs.Add(idx[0]); wgts.Add(v.Wgt.x); }\r
+ if(v.Wgt.y > 0) { idxs.Add(idx[1]); wgts.Add(v.Wgt.y); }\r
+ if(v.Wgt.z > 0) { idxs.Add(idx[2]); wgts.Add(v.Wgt.z); }\r
+ if(v.Wgt.w > 0) { idxs.Add(idx[3]); wgts.Add(v.Wgt.w); }\r
\r
bw.Write(v.Pos.X); bw.Write(v.Pos.Y); bw.Write(v.Pos.Z);\r
bw.Write(v.Nrm.X); bw.Write(v.Nrm.Y); bw.Write(v.Nrm.Z);\r
using System.Collections.Generic;\r
using System.Text;\r
\r
-namespace tso2mqo\r
+namespace Tso2MqoGui\r
{\r
public class VertexHeap\r
{\r
+++ /dev/null
-Microsoft Visual Studio Solution File, Format Version 10.00\r
-# Visual C# Express 2008\r
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tso2mqo", "tso2mqo.csproj", "{C0DE49DD-78AB-4517-8234-7331DEF93472}"\r
-EndProject\r
-Global\r
- GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
- Debug|x86 = Debug|x86\r
- Release|x86 = Release|x86\r
- EndGlobalSection\r
- GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
- {C0DE49DD-78AB-4517-8234-7331DEF93472}.Debug|x86.ActiveCfg = Debug|x86\r
- {C0DE49DD-78AB-4517-8234-7331DEF93472}.Debug|x86.Build.0 = Debug|x86\r
- {C0DE49DD-78AB-4517-8234-7331DEF93472}.Release|x86.ActiveCfg = Release|x86\r
- {C0DE49DD-78AB-4517-8234-7331DEF93472}.Release|x86.Build.0 = Release|x86\r
- EndGlobalSection\r
- GlobalSection(SolutionProperties) = preSolution\r
- HideSolutionNode = FALSE\r
- EndGlobalSection\r
-EndGlobal\r