|
|
|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
| Can anyone help with a Mesh Splitting script -> 5 million poly object split into objects that have XXX number of polys?
|
|
|
Hi Everyone,
I work for a University where we use Virtual Reality to look at building models, city data, 3d scanner data etc.
I have been working on turning point cloud scanner data into 3d geometry and am having some success.
However our 3D virtual reality viewing software has a massive performance hit if objects contain more than 200,000 triangles!
I’m hoping that a script could be created to go through the faces on an object and detach them to a separate object when a specific number is reached, then loops through until there are no faces left in the original object, but it has generated many other objects from the original high resolution mesh.
I’m a complete newbie to MaxScript so the chances of me pulling this off anytime soon just won’t happen.
Can anyone advise how easy/hard this would be to accomplish?
|
|
|
|
No need to write a script (unless you really want to) because (a) one has already been written and (b) it can be done within an Editable Mesh object anyway.
http://area.autodesk.com/for...ct-into-individual-parts/
Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.
|
|
|
|
Steve,
Many thanks for the prompt reply but neither of those solutions allow me to control exactly how many triangles to put into each of the split objects. The ‘Explode’ method uses Edge angle and Neil Blevins script appears to just split an object up by it’s elements.
To make myself a bit clearer I’d like a UI that asks me to enter a number i.e. 500 or 20,000 and then it will detach groups of faces with that number and create new objects until the original high resolution mesh has no faces left, and deletes it.
|
|
|
|
( local roFaceCount
fn Min V1 V2 =
(
if (V1 < V2) then
V1
else
V2
)
fn DetachToObjects obj FaceCount =
(
DetachedMesh = meshop.detachFaces obj #{1..FaceCount} delete:true asMesh:true
update obj
newName = uniquename roFaceCount.edtDetachedPrefix.text
newMesh = Editable_Mesh name:newName position:obj.pos
newMesh.mesh = DetachedMesh
update newMesh
)
fn DetachThem obj MaxFaces =
(
FaceCount = Min (getNumFaces obj) MaxFaces
while (FaceCount > 0) do
(
DetachToObjects obj FaceCount
FaceCount = Min (getNumFaces obj) MaxFaces
)
)
rollout roFaceCount "Detach Faces" width:248 height:125 (
spinner spnFaceCount "Number of faces to detach " pos:[20,19] width:215 height:16 range:[1,1e+006,1] type:#integer scale:1
label lbl1 "Prefix for detached objects" pos:[4,46] width:132 height:15
edittext edtDetachedPrefix "" pos:[133,45] width:102 height:16
button btnOK "OK" pos:[88,88] width:70 height:22
on btnOK pressed do
(
DetachThem selection[1] spnFaceCount.value
delete selection[1]
try (destroyDialog roFaceCount) catch()
)
)
fn ShowWarning =
(
messageBox "You must select ONE Editable Mesh object before running this script." title:"Error"
)
try (destroyDialog roFaceCount) catch()
if (selection.count != 1) then
(
showWarning()
)
else
if ((classof selection[1]) != Editable_mesh) then
(
showWarning()
)
else
(
CreateDialog roFaceCount
roFaceCount.spnFaceCount.value = 1
roFaceCount.edtDetachedPrefix.text = "Detached_"
)
)
Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.
|
|
|
|
Steve,
Believe it or not I was actually making progress myself (without the UI!). I managed to get an object, convet to editable mesh and detach faces to another object.
I was just in the middle of working out the loop I would need (and a checker for knowing when to end the loop).
obj = $—uses current object selected
converttomesh obj—convert current object to an editable mesh
NumF = getKBValue prompt:"Enter how many faces per split object:”—gets a user input value for how many faces to split
Start = 1
newMesh = meshop.detachfaces obj #{Start..NumF} delete:true asMesh:true
update obj
emesh = Editable_mesh()
emesh.mesh = newMesh
newMesh.pivot = obj.pivot
update emesh
emesh.pos = obj.pos
Your script works very well and you have my whole hearted thanks. I’m going to try it now and see if it keeps my UVWmapping for the extracted geometry.
...not to worry - It’s an easy workaround for me to do that.
THANKS THANKS THANKS
|
|
|
|
You’re welcome :)
A couple of points.
The forum software “messes” with code if you’re not careful - best to enclose any code in [ code ] ... [ /code ] tags.
Always a good idea to state the version of Max you’re working with - I’d suggest you put that, and your brief system specs, in your sig (it’s in your user profile).
Be careful using “Start..NumF” in the detachFaces call - after the removal of one set of faces and an “update obj”, the vertices will be renumbered to start again from 1, so incrementing your Start value will fail at some point. It would work if you detach as a clone (delete:false).
Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.
|
|
|
|
|
|