ZBrushCentral

Surely placing a picture on the canvas can't be this difficult?

First, thanks for all the help as I was getting up to speed with the syntax and semantics of ZBrush.

Now that I can write ZScripts that have fewer errors than lines, I’m actually getting into solving my problem, which begins with: just bringing in a picture and painting it on the center of the canvas, at a 1:1 pixel scaling.

Bringing in the picture is no problem. The real problem is in getting it painted to the canvas while maintaining correct dimensions. Here are the things I’ve looked at.

  • crop and fill

    • no good because the size of the canvas should not change. Also intrusive to the user.
  • fill canvas

    • distorts and resizes the image
  • using the simple brush, square alpha, and appropriate brush size, and drag dot stroke, click in the middle of the canvas.

    • problem; the image may be too large for the max brush size.
  • use the dragrect stroke, and CanvasClick, to drag the picture out on the canvas.

    • problem: dragrect has only a square aspect ratio.

Next try; apply the texture to a 1-quad plane3d and drop it.

  • use dragrect stroke; well, through various settings I can solve the aspect ratio problem, but the edge of the poly does not ‘keep up’ with the cursor position as the drag goes on; a gap develops between them. This means that CanvasClick ends up creating a smaller poly than expected.

  • use dot stroke; again, the size of the stroke can’t be set high enough to draw out picutures at full size…

I’m pretty sure I’ve finally figured out one way to do this, but it’s pretty baroque, and I’d really prefer not to have to use it. Sure there’s a simpler way?

Thanks,
Ken

Here’s what I’d do:

  1. Import the texture
  2. Check the size of the texture and note the values of the width and height for future reference. Do the same for the Document width and height.
  3. Select the Plane3D
  4. Apply the texture to the plane.
  5. Perform a simple canvas click to draw a little copy of the plane.
  6. Activate Move mode
  7. Set Transform>Info>X and Y to be equal to half the canvas dimensions. This will center your plane on the canvas.
  8. Activate Scale mode
  9. Set the Transform>Info>Y to half the size of the canvas.
  10. Set the Transform>Info>X to be proportional with the original size of the image and the new value of the Info>Y slider.

You’d need to modify it slightly for images that are wider than they are high, but you should have a good place to begin with these steps.

Very cool Aurick! Thanks for the tip.

r

Attached is my canvasmaker script. You might get an idea of how it works by looking at the code. It will automatically keep the aspect ratio of the texture no matter if the Document size is smaller or greater than your original image.

hope it helps

Thanks for the help, everyone. Here’s what my routine ended up looking like (Note that a 1-quad plane works fine):

[RoutineDef, SetCurrentView,
[VarSet, OrigTool, [IGet, Tool:Item Info]]
[VarSet, OrigDrawSize, [IGet, Draw:DrawSize]]
[VarSet, OrigStroke, [IGet, Stroke:Item Info]]
[IFreeze,
[IPress, Layer:Clear]
[IPress, Tool:Plane3D]
// [IPress, Alpha:Brush 00]
[ISet, Tool:Initialize:HDivide, 2]
[ISet, Tool:Initialize:VDivide, 2]
[IPress, Stroke:DragDot]
[ISet, Draw:DrawSize, 200]

[FileNameSetNext, [StrMerge, folder, file]] [IPress, Texture:Import] [VarSet, width, [IGet, Texture:Width]] [VarSet, height, [IGet, Texture:Height]] [VarSet, x0, Document:Width/2] [VarSet, y0, Document:Height/2] [CanvasClick, x0, y0] [TransformSet, x0, y0, 0, width/2, height/2, 1] [ISet, Tool:Item Info, OrigTool] [ISet, Draw:DrawSize, OrigDrawSize] [ISet, Stroke:Item Info, OrigStroke] [IPress, Texture:Remove] ]

//ARGS
,folder, file]

Cheers,
Ken