/// <summary> /// /// </summary> /// <param name="reader"></param> private static void ReadSRT3D(BinaryDataReader reader) { ValueSrt3D = new Srt3D(); Syroot.Maths.Vector3F scaleVector3F = new Syroot.Maths.Vector3F(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); ValueSrt3D.Scaling = scaleVector3F; Syroot.Maths.Vector3F rotVector3F = new Syroot.Maths.Vector3F(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); ValueSrt3D.Rotation = rotVector3F; Syroot.Maths.Vector3F transVector3F = new Syroot.Maths.Vector3F(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); ValueSrt3D.Translation = transVector3F; }
public void Write(Syroot.Maths.Vector3F v) { Write(v.X); Write(v.Y); Write(v.Z); }
public static string DataToString(Syroot.Maths.Vector3F v) { return($"{v.X},{v.Y},{v.Z}"); }
public static Vector3 ToVec3(Syroot.Maths.Vector3F v) { return(new Vector3(v.X, v.Y, v.Z)); }
public static OpenTK.Vector3 ToTKVector3(this Syroot.Maths.Vector3F vec3) { return(new OpenTK.Vector3(vec3.X, vec3.Y, vec3.Z)); }
/// <summary> /// Returns string in a format of "X,Y,Z" without parentheses. /// </summary> /// <param name="vec3"></param> /// <returns></returns> public static string Vector3FToString(Syroot.Maths.Vector3F vec3) { return(vec3.X.ToString() + "," + vec3.Y.ToString() + "," + vec3.Z.ToString()); }
private static bool IsUniform(Syroot.Maths.Vector3F value) { return(value.X == value.Y && value.X == value.Z); }
public void ReplaceMatchingFile( ) { OpenFileDialog ofd = new OpenFileDialog(); ofd.DefaultExt = ReplaceFilter; if (ofd.ShowDialog() == DialogResult.OK) { string extension = System.IO.Path.GetExtension(ofd.FileName); if (extension == ".bfskl") { if (SkeletonU != null) { ResU.Skeleton SkeltonTemp = new ResU.Skeleton(); SkeltonTemp.Import(ofd.FileName, GetResFileU()); foreach (BfresBone bone in fskl.bones) { if (SkeltonTemp.Bones.ContainsKey(bone.Text)) { bone.CopyData(SkeltonTemp.Bones[bone.Text]); } } BfresWiiU.ReadSkeleton(this, SkeletonU, fskl); } else { Skeleton SkeltonTemp = new Skeleton(); SkeltonTemp.Import(ofd.FileName); foreach (BfresBone bone in fskl.bones) { if (SkeltonTemp.BoneDict.ContainsKey(bone.Text)) { int index = SkeltonTemp.BoneDict.GetIndex(bone.Text); bone.CopyData(SkeltonTemp.Bones[index]); } } BfresSwitch.ReadSkeleton(this, Skeleton, fskl); } } if (extension == ".csv") { using (var reader = new System.IO.StringReader(System.IO.File.ReadAllText(ofd.FileName))) { string value = reader.ReadLine(); if (value != "Bones Geometry") { return; } float X = 0; float Y = 0; float Z = 0; float W = 0; while (true) { string line = reader.ReadLine(); if (line != null) { foreach (BfresBone bone in fskl.bones) { if (bone.Text == line) { string name = line; string scaleStr = reader.ReadLine(); string rotationStr = reader.ReadLine(); string translationStr = reader.ReadLine(); string[] valuesS = scaleStr.Replace("\n", "").Replace("\r", "").Split(','); string[] valuesR = rotationStr.Replace("\n", "").Replace("\r", "").Split(','); string[] valuesT = translationStr.Replace("\n", "").Replace("\r", "").Split(','); Syroot.Maths.Vector3F translate; Syroot.Maths.Vector3F scale; Syroot.Maths.Vector4F rotate; float.TryParse(valuesT[0], out X); float.TryParse(valuesT[1], out Y); float.TryParse(valuesT[2], out Z); translate = new Syroot.Maths.Vector3F(X, Y, Z); float.TryParse(valuesR[0], out X); float.TryParse(valuesR[1], out Y); float.TryParse(valuesR[2], out Z); float.TryParse(valuesR[3], out W); rotate = new Syroot.Maths.Vector4F(X, Y, Z, W); float.TryParse(valuesS[0], out X); float.TryParse(valuesS[1], out Y); float.TryParse(valuesS[2], out Z); scale = new Syroot.Maths.Vector3F(X, Y, Z); if (bone.BoneU != null) { bone.BoneU.Position = translate; bone.BoneU.Scale = scale; bone.BoneU.Rotation = rotate; } else { bone.Bone.Position = translate; bone.Bone.Scale = scale; bone.Bone.Rotation = rotate; } } } } else { break; } } if (SkeletonU != null) { BfresWiiU.ReadSkeleton(this, SkeletonU, fskl); } else { BfresSwitch.ReadSkeleton(this, Skeleton, fskl); } LibraryGUI.UpdateViewport(); } } } }
public static Vector3 ToVec3(this Syroot.Maths.Vector3F vec) => new Vector3(vec.X, vec.Y, vec.Z);