thatoneguy
11-27-2007, 07:13 PM
TileLengthX,Y,Z = UVWGizmoGlobalLengthX,Y,X / (UVW TileX,Y,Z * Map TileX,Y,Z * 2)
TotalX,Y,ZSlices=((BoxLengthX,Y,Z/TileLengthX,Y,Z)+1)
Determine the offset of the UVW Gizmo. Figure out where the first checker "loop" begins. The "min" if you will.
Then use code similar to this to slice and detach the mesh. (rinse repeat for each new slice for all 3 dimensions).
macroScript Julliene
category:"Pongoloid"
buttonText:"Julienne"
toolTip:"Julienne"
(
undolabel = "Julienne"
rollout julienne "Julienne"
(
checkbox Xcheck "X"
checkbox Ycheck "Y"
checkbox Zcheck "Z"
spinner XSpin type:#integer range:[2,100,2] pos:[45,5]
spinner YSpin type:#integer range:[2,100,2] pos:[45,24]
spinner ZSpin type:#integer range:[2,100,2] pos:[45,44]
button dice "Dice" pos:[120,5] height:55
on dice pressed do
(
try
(
undo label:undolabel on
(
p = (selection as array)[1]
zeroed = quat 0 0 0 1
sticker = p.rotation
p.rotation = zeroed
SliceMin = p.min
SliceMax = p.max
if xcheck.checked == true then
(
xchops = xspin.value
)
else
(
xchops = undefined
)
if ycheck.checked == true then
(
ychops = yspin.value
)
else
(
ychops = undefined
)
if Zcheck.checked == true then
(
zchops = zspin.value
)
else
(
zchops = undefined
)
if xchops != undefined then
(
slicelen = slicemax-slicemin
slicelen = slicelen/xchops
for i = 1 to (xchops-1) do
(
slicepoint = [(slicemin.x+(i*slicelen.x)), (slicemin.y+(i*slicelen.y)), (slicemin.z+(i*slicelen.z))]
p.slice [1,0,0] (slicepoint-p.pos)
)
)
if ychops != undefined then
(
slicelen = slicemax-slicemin
slicelen = slicelen/ychops
for i = 1 to (ychops-1) do
(
slicepoint = [(slicemin.x+(i*slicelen.x)), (slicemin.y+(i*slicelen.y)), (slicemin.z+(i*slicelen.z))]
p.slice [0,1,0] (slicepoint-p.pos)
)
)
if zchops != undefined then
(
slicelen = slicemax-slicemin
slicelen = slicelen/zchops
for i = 1 to (zchops-1) do
(
slicepoint = [(slicemin.x+(i*slicelen.x)), (slicemin.y+(i*slicelen.y)), (slicemin.z+(i*slicelen.z))]
p.slice [0,0,1] (slicepoint-p.pos)
)
)
p.rotation = sticker
) -- end Undo
) -- end try
catch (messagebox "Something went wrong. Make sure it's an editable poly.")
) -- end on "Dice"
)
createdialog julienne
)
I would then take all of the slices and arrange them in an array based on their position. Determine if the first slice was within the first color if the min/min/min object's minimum is < (tile size + slice origin point) or the second color. Get the map for each checker color and apply properly. (Make sure all the slices have shared UVW Map coordinates).
thatoneguy
11-27-2007, 07:14 PM
That should let you extract the checkers from any arbitrary object not just Cubes and planes.
Kameleon
11-28-2007, 10:02 AM
Thanks thatoneguy but I was thinking if it wasnt more effective creating planes rather than slicing the mesh. For example, create a plane in front of an object, find out the correct dimensions of the plane based on the checker size, subdivide the plane and then projecting the plane into the mesh, very much like conform compound object does but better and based on the object uvw and checker map applied.
CGTalk Moderation
11-28-2007, 10:02 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.