Example #1
0
        public IEnumerable <Pos3Norm3VertexSDX> GetVertices(D2DGeometry geometry, float height = 1f)
        {
            List <Pos3Norm3VertexSDX> vertices = new List <Pos3Norm3VertexSDX>();

            //Empty mesh
            if (geometry == null)
            {
                Pos3Norm3VertexSDX zero = new Pos3Norm3VertexSDX();
                vertices.Add(zero);
                vertices.Add(zero);
                vertices.Add(zero);
                return(vertices);
            }

            if (height > 0)
            {
                D2DGeometry flattenedGeometry = this.FlattenGeometry(geometry, sc_flatteningTolerance);
                D2DGeometry outlinedGeometry  = this.OutlineGeometry(flattenedGeometry);

                //Add snap here

                var sink = new ExtrudingSink(vertices, height);

                outlinedGeometry.Simplify(GeometrySimplificationOption.Lines, sink);

                var bounds  = flattenedGeometry.GetBounds();
                var scaling = Math.Min(1 / Math.Abs(bounds.Bottom - bounds.Top), 1);

                outlinedGeometry.Tessellate(sink);

                outlinedGeometry.Dispose();
                flattenedGeometry.Dispose();

                sink.Dispose();

                return(vertices.Select(v => v.Scale(scaling).AssignTexCd()).Reverse());
            }
            else
            {
                D2DGeometry flattenedGeometry = this.FlattenGeometry(geometry, sc_flatteningTolerance);

                //Add snap here
                var sink = new FlatSink(vertices);

                var bounds  = flattenedGeometry.GetBounds();
                var scaling = Math.Min(1 / Math.Abs(bounds.Bottom - bounds.Top), 1);

                flattenedGeometry.Tessellate(sink);

                flattenedGeometry.Dispose();
                sink.Dispose();

                return(vertices.Select(v => v.Scale(scaling).AssignTexCd()).Reverse());
            }
        }
Example #2
0
        public void Tessellate(DxGeometry resolvedSource, ITessellationSink sink, float tolerance)
        {
            Contract.Requires(resolvedSource != null);
            Contract.Requires(sink != null);
            Contract.Requires(Check.IsPositive(tolerance));

            _Sink = sink;

            _Sink.Begin();

            resolvedSource.Tessellate(tolerance, this);

            _Sink = null;
        }
Example #3
0
        public void GetVertices(D2DGeometry geometry, List <Pos3Norm3VertexSDX> vertices, float height = 24.0f)
        {
            vertices.Clear();
            //Empty mesh
            if (geometry == null)
            {
                Pos3Norm3VertexSDX zero = new Pos3Norm3VertexSDX();
                vertices.Add(zero);
                vertices.Add(zero);
                vertices.Add(zero);
            }

            using (D2DGeometry flattenedGeometry = this.FlattenGeometry(geometry, sc_flatteningTolerance))
            {
                using (D2DGeometry outlinedGeometry = this.OutlineGeometry(flattenedGeometry))
                {
                    using (ExtrudingSink sink = new ExtrudingSink(vertices, height))
                    {
                        outlinedGeometry.Simplify(GeometrySimplificationOption.Lines, sink);
                        outlinedGeometry.Tessellate(sink);
                    }
                }
            }
        }