[Closed] Slice
Hi all you genius maxscripters out there! I’m fairly new to maxscript, only done some dead simple stuff like a pivot transform/fix thing and a sort of auto slicing thing which will chop up poly faces based on a distance using the slice plane, which is kind of where I’m stuck…
It works great if the faces are aligned to the world axis, but it’s no so great if you have a face at an odd angle… You can probably see it coming How do I align the slice plane properly to the face and transform it accuratly across the face (in what would appear to be the faces’ local x or y axis), also is there a quick and easy way to get the extents of a selected face? The idea I have is to slice at 75cm from each end of a wall, and then slice the centre poly into even 3mx3m chunks, ideally I would then go about getting the script to automatically map the freshly sliced pieces with a 256×256 texture too .
Cheers!
A little digging about I found a useful bit of code (from bobo I think?) in the reference, which I have adapted slightly:
fn getAlignMatrix face =
(
local faceNormal = in coordsys theObject (polyop.getfacenormal theObject face)
local worldUpVector = point3 0 0 1
format "% == % ?
" faceNormal worldUpVector
if faceNormal != worldUpVector then
(
print "Calculating face coords system!"
local rightVector = normalize (cross worldUpVector faceNormal)
local upVector = normalize (cross rightVector faceNormal)
return (matrix3 rightVector upVector faceNormal (polyop.getfacecenter theObject face))
)
else
(
print "Retruning world!"
local returnnormal = matrixfromnormal [0,0,1]
returnnormal.row4 = polyop.getfacecenter theObject face
return returnnormal
)
)
One problem remains though, for some reason it refuses to evaluate the if test correctly… At least that’s what it seems anyway, can anyone shed any light on why it returns true even though: if [0,0,1] != [0,0,1] should return false, or am I confused (probably)?
Ah Ha! Figured it, the poly it was trying to test was an infinetly small amount out, and Max was rounding… So although the values displayed were equal the actual figures it was dealing with were not, so did not evaluate correctly. Phew, i’m not going crazy.