Exemplo n.º 1
0
        public static (double volume, Point3D center)? GetVolumeAndMassCenter(this IINode node)
        {
            try
            {
                bool       toDelete  = false;
                ITriObject triObject = node.GetTriObjectFromNodeInCurrentTime(out toDelete);

                (double volume, IDPoint3 center)? ret = triObject.GetVolumeAndMassCenter();

                // Delete the triObject
                //triObject.DeleteAllRefsToMe();

                // Gets the WORLD position
                IDMatrix3 tm          = node.GetObjectTM(MaxInterface.Time, null).ToDMatrix3();
                IDPoint3  worldCenter = MaxGlobal.Multiply(tm, ret.Value.center);

                return(ret.Value.volume, worldCenter.ToPoint3D());
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 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;
        }