Пример #1
0
        public static optional <TextAsset> render(PlanetariaCollider collider, float width)
        {
            VectorGraphicsWriter.begin_canvas();
            VectorGraphicsWriter.begin_shape();

            BlockRendererIterator.prepare(collider);

            foreach (ArcIterator arc_iterator in BlockRendererIterator.arc_iterator())
            {
                ShapeRenderer.partition_arc(arc_iterator.arc, arc_iterator.begin, arc_iterator.end);
            }

            VectorGraphicsWriter.end_shape(Color.black, width);
            return(VectorGraphicsWriter.end_canvas());
        }
Пример #2
0
        private static void subdivide(Arc arc, float begin_point_angle, float end_point_angle)
        {
            float middle_point_angle = max_error_location(arc, begin_point_angle, end_point_angle);

            Vector3 begin  = arc.position(begin_point_angle);
            Vector3 middle = arc.position(middle_point_angle);
            Vector3 end    = arc.position(end_point_angle);

            OctahedronUVCoordinates begin_point  = new NormalizedCartesianCoordinates(begin);
            OctahedronUVCoordinates middle_point = new NormalizedCartesianCoordinates(middle);
            OctahedronUVCoordinates end_point    = new NormalizedCartesianCoordinates(end);

            if (PlanetariaMath.point_line_distance(begin_point.data, end_point.data, middle_point.data) > Precision.threshold) // if the max error is greater than a threshold, recursively add the left and right halves into the list of lines
            {
                subdivide(arc, begin_point_angle, middle_point_angle);
                subdivide(arc, middle_point_angle, end_point_angle);
            }
            else
            {
                QuadraticBezierCurve curve = new QuadraticBezierCurve(begin_point.data, middle_point.data, end_point.data);
                VectorGraphicsWriter.set_edge(curve);
            }
        }