Here’s a little hacked together experiment which may or (probably) may not help!
Basically this generates a mesh point cloud around the object based off a conformToShape lattice. The only reason it does verts only is because i’ll be damned if I know how to calculate the faces. I’ll let the more experienced mesh-monkeys work it out.
It only works on a selected mesh or primitive.
--create box lattice and conform it to the selected object
fn latticeObject obj dim =
(
local boxLattice = FFDBox()
addModifier obj boxLattice
setDimensions boxLattice dim
conformToShape boxLattice
animateAll boxLattice
boxLattice
)
fn meshFromLattice obj verts objTM modTM=
(
local objProps = getPropNames obj #dynamicOnly
local modBBMin=getModContextBBoxMin $ obj
local modBBMax=getModContextBBoxMax $ obj
local cPConv = #()
for i = 2 to (verts+1) do
(
cPoint = getProperty obj objProps[i]
cPConv[i-1]=(modBBMin+(cPoint*(modBBMax-modBBMin)) * (inverse modTM) * objTM)
)
objMesh = mesh vertices: cPConv faces:#()
)
controlVerts = [4,4,4] --change this for lattice density
objTM = $.objecttransform
ncLattice = latticeObject $ controlVerts --make the lattice
modTM = (getModContextTM $ ncLattice)*ncLattice.lattice_transform.value
newMesh = meshFromLattice ncLattice (controlVerts[1]*controlVerts[2]*controlVerts[3]) objTM modTM --create the mesh
You can change the amount of controlVerts to get more lattice points, and thus more mesh verts.
As I said, this is probably worthless, but it might give you a starting point, or at the very least a smirk. :):
EDIT: for some reason the mxs highlight wrapper is screwing the code in arrays:
--create box lattice and conform it to the selected object
fn latticeObject obj dim =
(
local boxLattice = FFDBox()
addModifier obj boxLattice
setDimensions boxLattice dim
conformToShape boxLattice
animateAll boxLattice
boxLattice
)
fn meshFromLattice obj verts objTM modTM=
(
local objProps = getPropNames obj #dynamicOnly
local modBBMin=getModContextBBoxMin $ obj
local modBBMax=getModContextBBoxMax $ obj
local cPConv = #()
for i = 2 to (verts+1) do
(
cPoint = getProperty obj objProps[i]
cPConv[i-1]=(modBBMin+(cPoint*(modBBMax-modBBMin)) * (inverse modTM) * objTM)
)
objMesh = mesh vertices: cPConv faces:#()
)
controlVerts = [4,4,4] --change this for lattice density
objTM = $.objecttransform
ncLattice = latticeObject $ controlVerts --make the lattice
modTM = (getModContextTM $ ncLattice)*ncLattice.lattice_transform.value
newMesh = meshFromLattice ncLattice (controlVerts[1]*controlVerts[2]*controlVerts[3]) objTM modTM --create the mesh