Example #1
0
        // The data array contains 4 values, it's the associated data of the vertices that resulted in an intersection.
        private static object VertexCombine(LibTessDotNet.Vec3 position, object[] data, float[] weights)
        {
            // Fetch the vertex data.
            var colors = new Color[] { (Color)data[0], (Color)data[1], (Color)data[2], (Color)data[3] };
            // Interpolate with the 4 weights.
            var rgba = new float[] {
                colors[0].R * weights[0] + colors[1].R * weights[1] + colors[2].R * weights[2] + colors[3].R * weights[3],
                colors[0].G * weights[0] + colors[1].G * weights[1] + colors[2].G * weights[2] + colors[3].G * weights[3],
                colors[0].B * weights[0] + colors[1].B * weights[1] + colors[2].B * weights[2] + colors[3].B * weights[3],
                colors[0].A * weights[0] + colors[1].A * weights[1] + colors[2].A * weights[2] + colors[3].A * weights[3]
            };

            // Return interpolated data for the new vertex.
            return(Color.FromArgb((int)rgba[3], (int)rgba[0], (int)rgba[1], (int)rgba[2]));
        }
Example #2
0
        private static object VertexCombine(LibTessDotNet.Vec3 position, object[] data, float[] weights)
        {
            // Fetch the vertex data.
            var colors = new Color[] { (Color)data[0], (Color)data[1], (Color)data[2], (Color)data[3] };
            // Interpolate with the 4 weights.
            var color = new Color(
                colors[0].r * weights[0] + colors[1].r * weights[1] + colors[2].r * weights[2] + colors[3].r * weights[3],
                colors[0].g * weights[0] + colors[1].g * weights[1] + colors[2].g * weights[2] + colors[3].g * weights[3],
                colors[0].b * weights[0] + colors[1].b * weights[1] + colors[2].b * weights[2] + colors[3].b * weights[3],
                colors[0].a * weights[0] + colors[1].a * weights[1] + colors[2].a * weights[2] + colors[3].a * weights[3]
                );

            // Return interpolated data for the new vertex.
            return(color);
        }
Example #3
0
 public static Vector2 ToVector2D(this LibTessDotNet.Vec3 point)
 {
     return(new Vector2(point.X / INT_SCALE, point.Y / INT_SCALE));
 }
Example #4
0
 public static ClipperLib.IntPoint ToClipperVector(this LibTessDotNet.Vec3 point)
 {
     return(new ClipperLib.IntPoint(point.X, point.Y));
 }