示例#1
0
        public void LookAt(OpenTK.Vector3 at, OpenTK.Vector3 up)
        {
            var zaxis = (at - Position).Normalized();
            var xaxis = OpenTK.Vector3.Cross(up, zaxis).Normalized();
            var yaxis = OpenTK.Vector3.Cross(zaxis, xaxis);

            var mat = new OpenTK.Matrix3(xaxis, yaxis, zaxis);



            Rotation = mat.ExtractRotation();
        }
示例#2
0
        public static GenericBone ToBone(byte[] data)
        {
            if (data.Length == 0)
            {
                return(null);
            }
            GenericBone bone = new GenericBone();

            using (DataReader r = new DataReader(new System.IO.MemoryStream(data)))
            {
                bone.ID          = r.ReadInt32();
                bone.ParentIndex = r.ReadInt32();
                r.Skip(4);

                r.Seek(0xC);
                bone.Position = new OpenTK.Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle());
                var rot = new OpenTK.Matrix3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle(),
                                             r.ReadSingle(), r.ReadSingle(), r.ReadSingle(),
                                             r.ReadSingle(), r.ReadSingle(), r.ReadSingle());
                bone.QuaternionRotation = rot.ExtractRotation().Inverted();
                bone.Scale = new OpenTK.Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle());
            }
            return(bone);
        }