kopar
11-04-2008, 11:36 PM
Just thought I'd post this here. Had a question in the regular Max forum to see if I could relax along the Z only. Nothing in MAX allows this so I wrote this:
(
/*
Zlax
Relaxes verts only along the Z axis
2008 shannont@pbworld.com
*/
local theQuery = queryBox "This will convert your object into an editable poly.\nALL modifiers will be lost!\nDo you still want to do this?"
if theQuery != false do
(
--functions
fn geomFilt o = (superClassOf o == GeometryClass)
--variables
local theMessage = "Select the object to relax"
local theSourceObject = pickObject message:theMessage prompt:theMessage filter:geomFilt
convertToPoly theSourceObject
--Copy our object to a new one
local theCopy = copy theSourceObject
local numberOfVerts = theCopy.numVerts
--set the relax settings
theCopy.relaxAmount = .25
theCopy.relaxIterations = 4
theCopy.relaxHoldOuterPoints = false
theCopy.relaxHoldBoundaryPoints = false
theCopy.EditablePoly.Relax selLevel:#Object
--Change the Z values for all the original verts based on the z value of the relaxed object
for i = 1 to numberOfVerts do
(
theOriginalVertPos = polyOp.getVert theSourceObject i
theNewVertPos = polyOp.getVert theCopy i
theZrealxedPos = [theOriginalVertPos.x,theOriginalVertPos.y,theNewVertPos.z]
polyOp.setVert theSourceObject i theZrealxedPos
)
delete theCopy
select theSourceObject
)
)
I hope it helps somebody somewhere!
(
/*
Zlax
Relaxes verts only along the Z axis
2008 shannont@pbworld.com
*/
local theQuery = queryBox "This will convert your object into an editable poly.\nALL modifiers will be lost!\nDo you still want to do this?"
if theQuery != false do
(
--functions
fn geomFilt o = (superClassOf o == GeometryClass)
--variables
local theMessage = "Select the object to relax"
local theSourceObject = pickObject message:theMessage prompt:theMessage filter:geomFilt
convertToPoly theSourceObject
--Copy our object to a new one
local theCopy = copy theSourceObject
local numberOfVerts = theCopy.numVerts
--set the relax settings
theCopy.relaxAmount = .25
theCopy.relaxIterations = 4
theCopy.relaxHoldOuterPoints = false
theCopy.relaxHoldBoundaryPoints = false
theCopy.EditablePoly.Relax selLevel:#Object
--Change the Z values for all the original verts based on the z value of the relaxed object
for i = 1 to numberOfVerts do
(
theOriginalVertPos = polyOp.getVert theSourceObject i
theNewVertPos = polyOp.getVert theCopy i
theZrealxedPos = [theOriginalVertPos.x,theOriginalVertPos.y,theNewVertPos.z]
polyOp.setVert theSourceObject i theZrealxedPos
)
delete theCopy
select theSourceObject
)
)
I hope it helps somebody somewhere!
