Пример #1
0
    private void ShowBrushPreview(P3D_Result result)
    {
        var width      = currentTexture.width;
        var height     = currentTexture.height;
        var uv         = result.GetUV(P3D_CoordType.UV1);
        var xy         = P3D_Helper.CalculatePixelFromCoord(uv, CurrentTiling, CurrentOffset, width, height);
        var matrix     = P3D_Helper.CreateMatrix(xy + new Vector2(0.01f, 0.01f), currentBrush.Size * 0.999f, currentBrush.Angle).Inverse;
        var resolution = new Vector2(width, height);

        P3D_BrushPreview.Show(lockedMesh, currentMaterialIndex, lockedGameObject.transform, previewBrushOpacity, matrix, resolution, currentBrush.Shape, CurrentTiling, CurrentOffset);
    }
    public static P3D_Painter.PaintOperation Preview(Mesh mesh, int submeshIndex, Transform transform, Texture2D shape, Color color, Vector2 tiling, Vector2 offset)
    {
        return((Texture2D canvas, P3D_Matrix matrix, float opacity) =>
        {
            if (transform != null)
            {
                var paintMatrix = matrix.Inverse;
                var canvasResolution = new Vector2(canvas.width, canvas.height);

                P3D_BrushPreview.Show(mesh, submeshIndex, transform, opacity, paintMatrix, canvasResolution, shape, color, tiling, offset);
            }
        });
    }