internal static Rect ProjectBounds(
            ref Matrix3D viewProjMatrix,
            ref Rect3D originalBox)
        {
            D3DMATRIX viewProjFloatMatrix = CompositionResourceManager.Matrix3DToD3DMATRIX(viewProjMatrix);
            MILRect3D originalBoxFloat    = new MILRect3D(ref originalBox);
            MilRectF  outRect             = new MilRectF();

            HRESULT.Check(
                MIL3DCalcProjected2DBounds(
                    ref viewProjFloatMatrix,
                    ref originalBoxFloat,
                    out outRect));

            if (outRect.Left == outRect.Right ||
                outRect.Top == outRect.Bottom)
            {
                return(Rect.Empty);
            }
            else
            {
                return(new Rect(
                           outRect.Left,
                           outRect.Top,
                           outRect.Right - outRect.Left,
                           outRect.Bottom - outRect.Top
                           ));
            }
        }
Exemple #2
0
        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        #region Internal Methods

        internal override void UpdateResource(DUCE.Channel channel, bool skipOnChannelCheck)
        {
            // If we're told we can skip the channel check, then we must be on channel
            Debug.Assert(!skipOnChannelCheck || _duceResource.IsOnChannel(channel));

            if (skipOnChannelCheck || _duceResource.IsOnChannel(channel))
            {
                base.UpdateResource(channel, skipOnChannelCheck);

                // Read values of properties into local variables
                Transform3D vTransform = Transform;

                // Obtain handles for properties that implement DUCE.IResource
                DUCE.ResourceHandle hTransform;
                if (vTransform == null ||
                    Object.ReferenceEquals(vTransform, Transform3D.Identity)
                    )
                {
                    hTransform = DUCE.ResourceHandle.Null;
                }
                else
                {
                    hTransform = ((DUCE.IResource)vTransform).GetHandle(channel);
                }

                // Pack & send command packet
                DUCE.MILCMD_MATRIXCAMERA data;
                unsafe
                {
                    data.Type             = MILCMD.MilCmdMatrixCamera;
                    data.Handle           = _duceResource.GetHandle(channel);
                    data.htransform       = hTransform;
                    data.viewMatrix       = CompositionResourceManager.Matrix3DToD3DMATRIX(ViewMatrix);
                    data.projectionMatrix = CompositionResourceManager.Matrix3DToD3DMATRIX(ProjectionMatrix);

                    // Send packed command structure
                    channel.SendCommand(
                        (byte *)&data,
                        sizeof(DUCE.MILCMD_MATRIXCAMERA));
                }
            }
        }
Exemple #3
0
        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        #region Internal Methods

        internal override void UpdateResource(DUCE.Channel channel, bool skipOnChannelCheck)
        {
            // If we're told we can skip the channel check, then we must be on channel
            Debug.Assert(!skipOnChannelCheck || _duceResource.IsOnChannel(channel));

            if (skipOnChannelCheck || _duceResource.IsOnChannel(channel))
            {
                base.UpdateResource(channel, skipOnChannelCheck);

                // Pack & send command packet
                DUCE.MILCMD_MATRIXTRANSFORM3D data;
                unsafe
                {
                    data.Type   = MILCMD.MilCmdMatrixTransform3D;
                    data.Handle = _duceResource.GetHandle(channel);
                    data.matrix = CompositionResourceManager.Matrix3DToD3DMATRIX(Matrix);

                    // Send packed command structure
                    channel.SendCommand(
                        (byte *)&data,
                        sizeof(DUCE.MILCMD_MATRIXTRANSFORM3D));
                }
            }
        }