[sectionBegin," 3D Copying ",0,"ZScript Primer (Press to expand this section)",
	[varDef,zbPrimerTempOpenTD][varDef,zbInitDocSavedTD,0][varDef,zbInitSavedDocTD,""]
	[iPress,7442][if,(zbPrimerTempOpenTD),
		[iKeyPress,'N',[iPress,document:newdocument]]
	, // else
		[if,[messageYesNo,"OK to clear all customized tools, lights and materials?","DOCUMENT MUST BE CLEARED BEFORE PROCEEDING..."],
			[if,[isEnabled,document:save],
				[if,[messageYesno,"Would you like to save this document before proceeding?","Document has not been saved."],
					[iPress,document:saveas]
					[varSet,zbInitSavedDocTD,[fileNameGetLastUsed]]
					[varSet,zbInitDocSavedTD,1]
				] // end if (user saves)
			] // end if (save enabled)
			[Note,"One moment please...",,2]
			[iKeyPress,13,[iReset]]
			[varSet,zbPrimerTempOpenTD,1]
		, // else (user won't reset)
			[iUnPress,0][exit]
		] // end if (wanna reset?)
	] // end if PrimerTemp
	[Note,"This primer describes 3D Copying, which copies the image from the canvas onto a 3D object as a projection.",transform:3dcopy,-1]
	[Note,"\n\n\C909090(Click to continue)\Cc0c0c0",,0]
] // end sectionBegin
[pd][paintBackSliver,2,40,40,40][pd]
You may already be familiar with using the MRGBZ Grabber to convert the canvas into a texture, which can then be wrapped onto the surface of a 3D object.

3D Copy does something similar. It projects an image of the canvas onto a 3D object, as if it were shining through a film projector.

[iButton,"Click here","Create a background",
	[routineCall,zbPrimerStencilMakeBG]
] // end iButton
to create an arbitrary background which will be 3D Copied onto an object. [iButton,"Click here","Draw a sphere",
	[iPress,tool:sphere3d]
	[iColorSet,80,255,255]
	[iSet,material:itemInfo,3]
	[iSet,texture:itemInfo,0]
	[canvasClick,320,240,320,245]
	[transformSet,320,240,-999,180,180,180,90,0,0]
	[iPress,transform:move]
] // end iButton
to draw a sphere in front of the background.

With the sphere in a Transform Mode ([buttonFind,transform:move,"Move"], [buttonFind,transform:scale,"Scale"], or [buttonFind,transform:rotate,"Rotate"]), or in [buttonFind,transform:editobject,"Edit Mode"], you can press [buttonFind,transform:3dcopy:3dcopy,"3D Copy"] to project the canvas onto the object [iButton,"show me","3D Copy the canvas onto this sphere",
	[iSet,draw:rgbintensity,100]
	[iPress,transform:3dcopy:s]
	[iPress,transform:3dcopy:3dcopy]
]. // end iButton
[pd]
This is different from wrapping; the image of the canvas is projected onto the surface of the sphere. If you rotate the sphere you can see that the image is distorted, stretching more where the surface curves away from you the viewer [iButton,"show me","show the sides of the sphere",
	[routineCall,zbPrimerStencilShow]
]. // end iButton
[pd]
3D Copying only copies portions of the canvas which lie behind the object. Also, 3D Copying is affected by the [buttonFind,tool:modifiers:double,"Double"] modifier for the 3D object. In this case, the Double modifier is un-pressed, so only the front half of the sphere is affected.

Notice how rough the image looks -- the curves are jagged. This is because you are copying directly onto polygons which make up the sphere. ZBrush is converting the image on the canvas to polygon colors. [iButton,"Click here","Show the individual polygons",
	[iUnPress,tool:modifiers:sv]
	[iUnPress,tool:modifiers:sh]
] // end iButton
to turn off [buttonFind,tool:modifiers:sh,"Horizontal Smoothing"] and [buttonFind,tool:modifiers:sv,"Vertical Smoothing"] to see the polygons more clearly.

To make the image look smoother, you could increase the polygon count by increasing the [buttonFind,tool:modifiers:initialize:hdivide,"HDivide"] and [buttonFind,tool:modifiers:initialize:vdivide,"VDivide"] sliders for the object (or by pressing [buttonFind,tool:modifiers:deformation:divide,"Divide"] in the Deformation sub-palette), before copying. This is a processor-intensive task that may increase render time, especially if you are working with complex models.

There's a better way: apply a texture to the object first. This enables you to work with a low-polygon model with a high-resolution texture. Start by creating a new texture with a finer resolution, say, 512x512 (the maximum is 4096x4096). Do this by setting the [buttonFind,texture:inventory:width,"Width"] and [buttonFind,texture:inventory:height,"Height"] sliders in the Texture:Inventory sub-palette, then pressing [buttonFind,texture:inventory:new,"New"]. A new texture is created, at the chosen resolution, filled with the current [buttonFind,color:maincolor,"Main Color"].

[iButton,"Click here","Create a new texture before 3D Copying",
	[iSet,texture:inventory:height,512]
	[iSet,texture:inventory:width,512]
	[iPress,texture:inventory:new]
] // end iButton
to create a new texture. The sphere is automatically assigned this new blank texture.

Now [iButton,"Click here","3D Copy onto a texture",
	[iPress,tool:modifiers:sh][iPress,tool:modifiers:sv]
	[iPress,tool:modifiers:double]
	[iPress,texture:inventory:clone]
	[iPress,transform:3dcopy:s]
	[iPress,transform:3dcopy:3dcopy]
	[iPress,transform:3dcopy:autoint]
	[routineCall,zbPrimerStencilShow]
] // end iButton
to 3D Copy the same background onto the sphere with this blank texture applied. This time the [buttonFind,tool:modifiers:double,"Double"] modifier is pressed so you can see the difference.

Notice that the images is much smoother. In addition, you've created a bizarre [buttonFind,28601,"texture"] which represents how the canvas image must be distorted to project properly onto the sphere. (Incidentally, this is one example of how ZBrush packs enormous computing power into very simple tools -- imagine if you had to create this texture by hand!)

Un-pressing the [buttonFind,transform:3dcopy:s,"S"] (Shaded) modifier copies the image without lighting attributes. [iButton,"Click here","3D Copy without shading",
	[iPress,texture:clear]
	[iPress,tool:modifiers:sh][iPress,tool:modifiers:sv]
	[iPress,tool:modifiers:double]
	[iUnPress,transform:3dcopy:s]
	[iPress,transform:3dcopy:3dcopy]
	[routineCall,zbPrimerStencilShow]
] // end iButton
to copy the colors from the background without highlights or shading. (Note: as of this writing, 3D Copying onto a texture cannot be undone, so the texture must be cleared first.)

3D Copying is also sensitive to the [buttonFind,draw:RGBintensity,"RGB Intensity slider"]. At 100 (maximum), 3D Copy transfers the background at full intensity; at a lesser value, it blends the background with the base colors or texture.

3D Copying onto a 3D object with texture applied enables another feature: [buttonFind,transform:3dcopy:autoint,"Auto Intensity"]. Pressing this button enables you to control the way the canvas image is 3D Copied, using the [iButton,"Auto Intensity Curve","Show the Auto Intensity Curve",
	[iPress,transform:3dcopy:autointensity]
	[iShow,transform:3dcopy:autointensitycurve,0]
	[iPress,transform:3dcopy:autointensitycurve]
	[iShow,transform:3dcopy:autointensitycurve,1]
]. // end iButton
The left side of the curve determines the intensity of the image (higher = stronger) where the surface is perpendicular to the canvas; the right side determines the strength where it's parallel to the canvas (lying flat to you the viewer).

[iButton," Return to your original (saved) document ","Return to your original file",
	[fileNameSetNext,zbInitSavedDocTD]
	[if,[isEnabled,document:save],
		[iKeyPress,'N',[iPress,document:open]]
	, // else nothing to save
		[iPress,document:open]
	] // end if
	[varSet,zbInitSavedDocTD,""]
	[varSet,zbInitDocSavedTD,0]
	[varSet,zbPrimerTempOpenTD,0]
] // end iButton
[pd][pd][sectionEnd] // end of 3D Copying

[routineDef,zbPrimerStencilMakeBG,
[varSet,zbPrimerStencilDocW,document:modifiers:width]
[varSet,zbPrimerStencilDocH,document:modifiers:height]
[varSet,zbPrimerStencilCubeR,50]
	[iPress,layer:modifiers:clear]
	[iPress,tool:cube3d]
	[iSet,texture:itemInfo,0]
	[iSet,material:itemInfo,3]
	[iUnPress,tool:modifiers:sh][iUnPress,tool:modifiers:sv]
	[canvasClick,50,50,50,60]
	[iPress,transform:move]
	[varSet,zbPrimerStenciliY,0]
	[varSet,zbPrimerStencileo,0]
	[loop,(zbPrimerStencilDocH/(zbPrimerStencilCubeR*2.33))+1,
		[varSet,zbPrimerStenciliX,0+(zbPrimerStencileo*zbPrimerStencilCubeR*1.414)]
		[if,zbPrimerStencileo,[varSet,zbPrimerStencileo,0],[varSet,zbPrimerStencileo,1]]
	[loop,(zbPrimerStencilDocW/(zbPrimerStencilCubeR*2.828))+1,
		[iColorSet,180+(rand(75)),180+(rand(75)),100]
		[transformSet,zbPrimerStenciliX,zbPrimerStenciliY,0,
			zbPrimerStencilCubeR,zbPrimerStencilCubeR,zbPrimerStencilCubeR,
			45,0,45]
		[iPress,transform:snapshotobject]
		[varAdd,zbPrimerStenciliX,zbPrimerStencilCubeR*2.828]
	] // end loop (iy)
		[varAdd,zbPrimerStenciliY,zbPrimerStencilCubeR*2.33]
	] // end loop (ix)
	[iUnPress,transform:move]
] // end routine

[routineDef,zbPrimerStencilShow,
	[iPress,transform:rotate]
[CanvasStroke,(ZObjStrokeV02n28=H165V114H15EV113H153V113H13EV112H129V110HECV110HEDV110H10CV111H12AV113H14FV116H171V115H19AV113H1C3V116H1D8V119H1E6V119H1E5V119H1D5V118H1ACV117H19AV117H184V118H180V118H17CV119H177V119H172V11AH16AV11AH167V11AH165V11AH165V11A)]
	[transformSet,320,240,-999,180,180,180,90,0,0]	
] // end routine
