コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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 };
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
ファイル: ModelConverter.cs プロジェクト: wm85/AssetStudio
        private static string GetFramePath(ImportedFrame frame)
        {
            var path = frame.Name;

            while (frame.Parent != null)
            {
                frame = frame.Parent;
                path  = frame.Name + "/" + path;
            }
            return(path);
        }
コード例 #7
0
ファイル: ModelConverter.cs プロジェクト: tamzi/AssetStudio
 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;
 }
コード例 #8
0
ファイル: ModelConverter.cs プロジェクト: ndp1100/AssetStudio
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
ファイル: ModelConverter.cs プロジェクト: tamzi/AssetStudio
 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;
 }
コード例 #11
0
ファイル: ModelConverter.cs プロジェクト: tamzi/AssetStudio
 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);
     }
 }
コード例 #12
0
ファイル: ModelConverter.cs プロジェクト: tracer8/AssetStudio
        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);
        }
コード例 #13
0
ファイル: Imported.cs プロジェクト: zhukaixy/AssetStudio
        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);
        }
コード例 #14
0
ファイル: Imported.cs プロジェクト: zhukaixy/AssetStudio
        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);
        }
コード例 #15
0
 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;
 }
コード例 #16
0
 public void Remove(ImportedFrame frame)
 {
     children.Remove(frame);
 }
コード例 #17
0
 public void AddChild(ImportedFrame obj)
 {
     children.Add(obj);
     obj.Parent?.Remove(obj);
     obj.Parent = this;
 }