private void ConvertFrames(Transform trans, ImportedFrame parent) { var frame = new ImportedFrame(); assetsfileList.TryGetGameObject(trans.m_GameObject, out var m_GameObject); frame.Name = m_GameObject.m_Name; frame.InitChildren(trans.m_Children.Count); Quaternion mirroredRotation = new Quaternion(trans.m_LocalRotation[0], trans.m_LocalRotation[1], trans.m_LocalRotation[2], trans.m_LocalRotation[3]); mirroredRotation.Y *= -1; mirroredRotation.Z *= -1; var m_LocalScale = new Vector3(trans.m_LocalScale[0], trans.m_LocalScale[1], trans.m_LocalScale[2]); var m_LocalPosition = new Vector3(trans.m_LocalPosition[0], trans.m_LocalPosition[1], trans.m_LocalPosition[2]); frame.Matrix = Matrix.Scaling(m_LocalScale) * Matrix.RotationQuaternion(mirroredRotation) * Matrix.Translation(-m_LocalPosition.X, m_LocalPosition.Y, m_LocalPosition.Z); if (parent == null) { FrameList = new List <ImportedFrame>(); FrameList.Add(frame); } else { parent.AddChild(frame); } foreach (var pptr in trans.m_Children) { if (assetsfileList.TryGetTransform(pptr, out var child)) { ConvertFrames(child, frame); } } }
private static ImportedFrame CreateFrame(string name, Vector3 t, Quaternion q, Vector3 s) { var frame = new ImportedFrame(); frame.Name = name; SetFrame(frame, t, q, s); return(frame); }
private void SetFrame(ImportedFrame frame, Vector3 t, Quaternion q, Vector3 s) { var m_EulerRotation = QuatToEuler(new[] { q.X, -q.Y, -q.Z, q.W }); frame.LocalRotation = new[] { m_EulerRotation[0], m_EulerRotation[1], m_EulerRotation[2] }; frame.LocalScale = new[] { s.X, s.Y, s.Z }; frame.LocalPosition = new[] { -t.X, t.Y, t.Z }; }
private ImportedFrame ConvertFrame(Vector3 t, Quaternion q, Vector3 s, string name) { var frame = new ImportedFrame(); frame.Name = name; frame.InitChildren(0); SetFrame(frame, t, q, s); return(frame); }
private static ImportedFrame ConvertTransform(Transform trans) { var frame = new ImportedFrame(trans.m_Children.Length); trans.m_GameObject.TryGet(out var m_GameObject); frame.Name = m_GameObject.m_Name; SetFrame(frame, trans.m_LocalPosition, trans.m_LocalRotation, trans.m_LocalScale); return(frame); }
private static string GetFramePath(ImportedFrame frame) { var path = frame.Name; while (frame.Parent != null) { frame = frame.Parent; path = frame.Name + "/" + path; } return(path); }
private ImportedFrame ConvertFrame(Transform trans) { var frame = new ImportedFrame(); trans.m_GameObject.TryGetGameObject(out var m_GameObject); frame.Name = m_GameObject.m_Name; frame.InitChildren(trans.m_Children.Count); var m_EulerRotation = QuatToEuler(new[] { trans.m_LocalRotation[0], -trans.m_LocalRotation[1], -trans.m_LocalRotation[2], trans.m_LocalRotation[3] }); frame.LocalRotation = new[] { m_EulerRotation[0], m_EulerRotation[1], m_EulerRotation[2] }; frame.LocalScale = new[] { trans.m_LocalScale[0], trans.m_LocalScale[1], trans.m_LocalScale[2] }; frame.LocalPosition = new[] { -trans.m_LocalPosition[0], trans.m_LocalPosition[1], trans.m_LocalPosition[2] }; return frame; }
private ImportedFrame ConvertFrame(Transform trans, string name) { var frame = new ImportedFrame(); frame.Name = name; frame.InitChildren(0); var m_EulerRotation = QuatToEuler(new[] { trans.m_LocalRotation[0], -trans.m_LocalRotation[1], -trans.m_LocalRotation[2], trans.m_LocalRotation[3] }); frame.LocalRotation = new[] { m_EulerRotation[0], m_EulerRotation[1], m_EulerRotation[2] }; frame.LocalScale = new[] { trans.m_LocalScale[0], trans.m_LocalScale[1], trans.m_LocalScale[2] }; frame.LocalPosition = new[] { -trans.m_LocalPosition[0], trans.m_LocalPosition[1], trans.m_LocalPosition[2] }; return(frame); }
public static ImportedFrame FindChild(string name, ImportedFrame root) { foreach (var child in root) { var frame = FindFrame(name, child); if (frame != null) { return(frame); } } return(null); }
private ImportedFrame ConvertFrame(Vector3 t, Quaternion q, Vector3 s, string name) { var frame = new ImportedFrame(); frame.Name = name; frame.InitChildren(0); var m_LocalPosition = new[] { t.X, t.Y, t.Z }; var m_LocalRotation = new[] { q.X, q.Y, q.Z, q.W }; var m_LocalScale = new[] { s.X, s.Y, s.Z }; var m_EulerRotation = QuatToEuler(new[] { m_LocalRotation[0], -m_LocalRotation[1], -m_LocalRotation[2], m_LocalRotation[3] }); frame.LocalRotation = new[] { m_EulerRotation[0], m_EulerRotation[1], m_EulerRotation[2] }; frame.LocalScale = new[] { m_LocalScale[0], m_LocalScale[1], m_LocalScale[2] }; frame.LocalPosition = new[] { -m_LocalPosition[0], m_LocalPosition[1], m_LocalPosition[2] }; return frame; }
private void ConvertFrames(Transform trans, ImportedFrame parent) { var frame = ConvertFrame(trans); if (parent == null) { FrameList.Add(frame); } else { parent.AddChild(frame); } foreach (var pptr in trans.m_Children) { if (pptr.TryGetTransform(out var child)) ConvertFrames(child, frame); } }
private ImportedFrame ConvertFrames(Transform trans) { var frame = new ImportedFrame(); assetsfileList.TryGetGameObject(trans.m_GameObject, out var m_GameObject); frame.Name = m_GameObject.m_Name; frame.InitChildren(trans.m_Children.Count); Quaternion mirroredRotation = new Quaternion(trans.m_LocalRotation[0], trans.m_LocalRotation[1], trans.m_LocalRotation[2], trans.m_LocalRotation[3]); mirroredRotation.Y *= -1; mirroredRotation.Z *= -1; var m_LocalScale = new Vector3(trans.m_LocalScale[0], trans.m_LocalScale[1], trans.m_LocalScale[2]); var m_LocalPosition = new Vector3(trans.m_LocalPosition[0], trans.m_LocalPosition[1], trans.m_LocalPosition[2]); frame.Matrix = Matrix.Scaling(m_LocalScale) * Matrix.RotationQuaternion(mirroredRotation) * Matrix.Translation(-m_LocalPosition.X, m_LocalPosition.Y, m_LocalPosition.Z); return(frame); }
public static ImportedFrame FindFrame(string name, ImportedFrame root) { ImportedFrame frame = root; if ((frame != null) && (frame.Name == name)) { return(frame); } for (int i = 0; i < root.Count; i++) { if ((frame = FindFrame(name, root[i])) != null) { return(frame); } } return(null); }
public static ImportedMesh FindMesh(ImportedFrame frame, List <ImportedMesh> importedMeshList) { string framePath = frame.Name; ImportedFrame root = frame; while (root.Parent != null) { root = root.Parent; framePath = root.Name + "/" + framePath; } foreach (ImportedMesh mesh in importedMeshList) { if (mesh.Name == framePath) { return(mesh); } } return(null); }
private static void SetFrame(ImportedFrame frame, Vector3 t, Quaternion q, Vector3 s) { frame.LocalPosition = new Vector3(-t.X, t.Y, t.Z); frame.LocalRotation = Fbx.QuaternionToEuler(new Quaternion(q.X, -q.Y, -q.Z, q.W)); frame.LocalScale = s; }
public void Remove(ImportedFrame frame) { children.Remove(frame); }
public void AddChild(ImportedFrame obj) { children.Add(obj); obj.Parent?.Remove(obj); obj.Parent = this; }