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
                           ));
            }
        }
        string Disp(D3DMATRIX m)
        {
            return($@"{m._11:F3} {m._12:F3} {m._13:F3} {m._14:F3}
{m._21:F3} {m._22:F3} {m._23:F3} {m._24:F3}
{m._31:F3} {m._32:F3} {m._33:F3} {m._34:F3}
{m._41:F3} {m._42:F3} {m._43:F3} {m._44:F3}");
        }
Exemple #3
0
 /// <unmanaged>HRESULT ID3DXSprite::SetTransform([In] const D3DXMATRIX* pTransform)</unmanaged>
 public unsafe HRESULT SetTransform(ref D3DMATRIX transform)
 {
     fixed(void *pTransform = &transform)
     {
         //result = calli(System.Int32(System.Void*,System.Void*), this._nativePointer, ptr, *(*(IntPtr*)this._nativePointer + (IntPtr)5 * (IntPtr)sizeof(void*)));
         return((HRESULT)NativeHelper.CalliInt32(5, _nativePointer, (void *)pTransform));
     }
 }
 private extern static /*HRESULT*/ int MIL3DCalcProjected2DBounds(
     ref D3DMATRIX pFullTransform3D,
     ref MILRect3D pboxBounds,
     out MilRectF prcDestRect);
Exemple #5
-1
        public unsafe static void Draw2D(
            D3DXSprite sprite,
            Direct3DTexture9 texture,
            RectangleF dstRect,
            Size srcSize)
        {
            var scale = new D3DXVECTOR2(
                dstRect.Width / (float)srcSize.Width,
                dstRect.Height / (float)srcSize.Height);
            var       trans = new D3DXVECTOR2(dstRect.Location.X, dstRect.Location.Y);
            D3DMATRIX m;

            D3DMATRIX.Transformation2D(&m, null, 0f, &scale, null, 0f, &trans);
            sprite.SetTransform(ref m).CheckError();
            sprite.Draw(texture, null, null, null, 0xffffffff).CheckError();
        }