示例#1
0
        protected void SetTransform(GameObject node, TRS components)
        {
#pragma warning disable 0618 //Max passes angles in radians, so this *is* the one we want
            node.transform.localRotation = Quaternion.EulerAngles(-ToVector3(components.EulerRotation));
#pragma warning restore 0618
            node.transform.localScale = ToVector3S(components.Scale);
            node.transform.localPosition = ToVector3(components.Translate);

        }
示例#2
0
        unsafe protected TRS GetTransform(IINode node)
        {
            TRS t = new TRS();

            IMatrix3 tm = node.GetObjectTM(0, _gi.Interval.Create());


            IAffineParts affine = _gi.AffineParts.Create();
            _gi.DecompAffine( tm, affine);


            t.Translate = affine.T.ToPoint3();
            t.Scale = affine.K.ToPoint3();


            float roll = 0;
            float pitch = 0;
            float yaw = 0;

            GCHandle hRoll = GCHandle.Alloc(roll, GCHandleType.Pinned);
            GCHandle hPitch = GCHandle.Alloc(pitch, GCHandleType.Pinned);
            GCHandle hYaw = GCHandle.Alloc(yaw, GCHandleType.Pinned);

            tm.GetYawPitchRoll(hYaw.AddrOfPinnedObject(), hPitch.AddrOfPinnedObject(), hRoll.AddrOfPinnedObject());

            t.EulerRotation.x = (float)hPitch.Target;
            t.EulerRotation.y = (float)hYaw.Target;
            t.EulerRotation.z = (float)hRoll.Target;

            hRoll.Free();
            hYaw.Free();
            hPitch.Free();

            return t;
        }