private void ConvertFrames(Transform trans, ImportedFrame parent) { ImportedFrame frame = new ImportedFrame(); frame.Name = trans.m_GameObject.instance.m_Name; frame.InitChildren(trans.Count); Vector3 euler = FbxUtility.QuaternionToEuler(trans.m_LocalRotation); euler.Y *= -1; euler.Z *= -1; Quaternion mirroredRotation = FbxUtility.EulerToQuaternion(euler); frame.Matrix = Matrix.Scaling(trans.m_LocalScale) * Matrix.RotationQuaternion(mirroredRotation) * Matrix.Translation(-trans.m_LocalPosition.X, trans.m_LocalPosition.Y, trans.m_LocalPosition.Z); if (parent == null) { FrameList = new List <ImportedFrame>(); FrameList.Add(frame); } else { parent.AddChild(frame); } foreach (Transform child in trans) { ConvertFrames(child, frame); } }
private ImportedFrame ConvertFrames(remBone frame) { ImportedFrame iFrame = new ImportedFrame(); iFrame.InitChildren(frame.Count); iFrame.Name = frame.name; iFrame.Matrix = frame.matrix; FrameList.Add(iFrame); foreach (remBone child in frame) { ImportedFrame iChild = ConvertFrames(child); iFrame.AddChild(iChild); } return(iFrame); }
private ImportedFrame ImportFrame(Section section) { ImportedFrame frame = new ImportedFrame(); frame.InitChildren(0); if (section.name == null) { frame.Name = "no_name" + noNameCount; noNameCount++; } else { frame.Name = section.name; } List<bool> hasBonesList = new List<bool>(); SortedDictionary<string, byte> boneDic = new SortedDictionary<string, byte>(); ImportedMesh meshList = new ImportedMesh(); meshList.Name = frame.Name; meshList.BoneList = new List<ImportedBone>(); meshList.SubmeshList = new List<ImportedSubmesh>(); Matrix matrix = new Matrix(); foreach (Section child in section.children) { if (child.type == "FrameTransformMatrix") { LinkedListNode<object> node = child.data.First; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { matrix[i, j] = ConvertFloat(node.Value); node = node.Next; } } frame.Matrix = RHToLHMatrix(matrix); } else if (child.type == "Mesh") { ImportMesh(child, meshList, boneDic, hasBonesList); } else if (child.type == "Frame") { ImportedFrame childFrame = ImportFrame(child); if (childFrame != null) { frame.AddChild(childFrame); } } else { Report.ReportLog("Warning: unexpected section " + child.type); } } SetBones(meshList, hasBonesList); if (meshList.SubmeshList.Count > 0) { MeshList.Add(meshList); } if (matrix == null) { frame.Matrix = Matrix.Identity; } return frame; }
private ImportedFrame ConvertFrames(odfFrame frame) { ImportedFrame iFrame = new ImportedFrame(); iFrame.InitChildren(frame.Count); iFrame.Name = frame.Name; iFrame.Matrix = frame.Matrix; FrameList.Add(iFrame); foreach (odfFrame child in frame) { ImportedFrame iChild = ConvertFrames(child); iFrame.AddChild(iChild); } return iFrame; }
private void ConvertFrames(Transform trans, ImportedFrame parent) { ImportedFrame frame = new ImportedFrame(); frame.Name = trans.m_GameObject.instance.m_Name; frame.InitChildren(trans.Count); Vector3 euler = FbxUtility.QuaternionToEuler(trans.m_LocalRotation); euler.Y *= -1; euler.Z *= -1; Quaternion mirroredRotation = FbxUtility.EulerToQuaternion(euler); frame.Matrix = Matrix.Scaling(trans.m_LocalScale) * Matrix.RotationQuaternion(mirroredRotation) * Matrix.Translation(-trans.m_LocalPosition.X, trans.m_LocalPosition.Y, trans.m_LocalPosition.Z); if (parent == null) { FrameList = new List<ImportedFrame>(); FrameList.Add(frame); } else { parent.AddChild(frame); } foreach (Transform child in trans) { ConvertFrames(child, frame); } }