Пример #1
0
        private Mesh MeshFromRandomTriangles()
        {
            Mesh m = RenderTarget.CreateMesh();

            using (TessellationSink sink = m.Open())
            {
                int count = Random.Next(2, 20);
                triangles = new List <Triangle>();
                CreateRandomTriangles(count);

                sink.AddTriangles(triangles);
                sink.Close();
            }
            return(m);
        }
Пример #2
0
        private Mesh MeshFromRandomGeometry()
        {
            if (geometry != null)
            {
                geometry.Dispose();
            }
            geometry = new GeometryShape(RenderTarget, Random, d2DFactory, Bitmap);
            Mesh             m    = RenderTarget.CreateMesh();
            TessellationSink sink = m.Open();

            if (geometry.worldTransform.HasValue)
            {
                geometry.Geometry.Tessellate(sink, FlatteningTolerance, geometry.worldTransform.Value);
            }
            else
            {
                geometry.Geometry.Tessellate(sink, FlatteningTolerance);
            }
            sink.Close();
            sink.Dispose();
            return(m);
        }
Пример #3
0
 /// <summary>	
 /// Creates a set of clockwise-wound triangles that cover the geometry after it has been transformed using the specified matrix and flattened using the specified tolerance	
 /// </summary>	
 /// <param name="worldTransform">The transform to apply to this geometry, or NULL.</param>
 /// <param name="flatteningTolerance">The maximum bounds on the distance between points in the polygonal approximation of the geometry. Smaller values produce more accurate results but cause slower execution. </param>
 /// <param name="tessellationSink">The <see cref="SharpDX.Direct2D1.TessellationSink"/> to which the tessellated is appended.</param>
 /// <returns>If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
 /// <unmanaged>HRESULT Tessellate([In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] FLOAT flatteningTolerance,[In] ID2D1TessellationSink* tessellationSink)</unmanaged>
 public void Tessellate(RawMatrix3x2? worldTransform, float flatteningTolerance, TessellationSink tessellationSink)
 {
     this.Tessellate_(worldTransform, flatteningTolerance, TessellationSinkShadow.ToIntPtr(tessellationSink));
 }
Пример #4
0
 /// <summary>	
 /// Creates a set of clockwise-wound triangles that cover the geometry after it has been transformed using the specified matrix and flattened using the specified tolerance	
 /// </summary>	
 /// <param name="flatteningTolerance">The maximum bounds on the distance between points in the polygonal approximation of the geometry. Smaller values produce more accurate results but cause slower execution. </param>
 /// <param name="tessellationSink">The <see cref="SharpDX.Direct2D1.TessellationSink"/> to which the tessellated is appended.</param>
 /// <returns>If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
 /// <unmanaged>HRESULT Tessellate([In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] FLOAT flatteningTolerance,[In] ID2D1TessellationSink* tessellationSink)</unmanaged>
 public void Tessellate(float flatteningTolerance, TessellationSink tessellationSink)
 {
     Tessellate(null, flatteningTolerance, tessellationSink);
 }
Пример #5
0
 /// <summary>	
 /// Creates a set of clockwise-wound triangles that cover the geometry after it has been transformed using the specified matrix and flattened using the specified tolerance	
 /// </summary>	
 /// <param name="tessellationSink">The <see cref="T:SharpDX.Direct2D1.TessellationSink" /> to which the tessellated is appended.</param>
 /// <returns>If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
 /// <unmanaged>HRESULT Tessellate([In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] FLOAT flatteningTolerance,[In] ID2D1TessellationSink* tessellationSink)</unmanaged>
 public void Tessellate(TessellationSink tessellationSink)
 {
     this.Tessellate(null, FlatteningTolerance, tessellationSink);
 }
Пример #6
0
 /// <summary>
 /// Get a native callback pointer from a managed callback.
 /// </summary>
 /// <param name="tessellationSink">The geometry sink.</param>
 /// <returns>A pointer to the unmanaged geomerty sink counterpart</returns>
 public static IntPtr ToIntPtr(TessellationSink tessellationSink)
 {
     return ToIntPtr<TessellationSink>(tessellationSink);
 }
Пример #7
0
 /// <summary>	
 /// Creates a set of clockwise-wound triangles that cover the geometry after it has been transformed using the specified matrix and flattened using the specified tolerance	
 /// </summary>	
 /// <param name="flatteningTolerance">The maximum bounds on the distance between points in the polygonal approximation of the geometry. Smaller values produce more accurate results but cause slower execution. </param>
 /// <param name="tessellationSink">The <see cref="SharpDX.Direct2D1.TessellationSink"/> to which the tessellated is appended.</param>
 /// <returns>If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
 /// <unmanaged>HRESULT Tessellate([In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] FLOAT flatteningTolerance,[In] ID2D1TessellationSink* tessellationSink)</unmanaged>
 public void Tessellate(float flatteningTolerance, TessellationSink tessellationSink)
 {
     Tessellate(null, flatteningTolerance, tessellationSink);
 }
Пример #8
0
 /// <summary>	
 /// Creates a set of clockwise-wound triangles that cover the geometry after it has been transformed using the specified matrix and flattened using the specified tolerance	
 /// </summary>	
 /// <param name="tessellationSink">The <see cref="T:SharpDX.Direct2D1.TessellationSink" /> to which the tessellated is appended.</param>
 /// <returns>If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
 /// <unmanaged>HRESULT Tessellate([In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] FLOAT flatteningTolerance,[In] ID2D1TessellationSink* tessellationSink)</unmanaged>
 public void Tessellate(TessellationSink tessellationSink)
 {
     this.Tessellate(null, FlatteningTolerance, tessellationSink);
 }
Пример #9
0
 /// <summary>
 /// Get a native callback pointer from a managed callback.
 /// </summary>
 /// <param name="tessellationSink">The geometry sink.</param>
 /// <returns>A pointer to the unmanaged geometry sink counterpart</returns>
 public static IntPtr ToIntPtr(TessellationSink tessellationSink)
 {
     return(ToCallbackPtr <TessellationSink>(tessellationSink));
 }