Optimising Scenes by Reducing Objects

One of the most efficient ways to optimise a scene in 3dsmax is to cut down on the sheer number of objects in the viewport. I’m not talking about deleting object, just merging objects together to one mesh can seriously improve the redraw rate and improve the handling with the Scene Explorer. It currently seems to struggle above 8000 objects regardless of polygon count. Often a scene that has come from CAD might have a crazy amount of helpers, you can delete a lot of these helpers to speed things up right away, and there’s way to strip down a hierarchy to a certain depth level so you don’t have 20 helpers for each piece of geometry.  Finding lots of similar objects that could easily be represented as one object is a nice way to improve speed.

Attaching Objects in 3dsmax is something that is slooooowww…….. using the built-in tool in 3dsmax it can take hours to attach even just a hundred objects. A few years ago there was a maxscript challenge thread on CGTalk to attach objects together as efficiently as possible. There were some very good solutions, and like any good coder, I borrowed the one I found best for me. Written by Tyson Ibele, it’s called Cluster Attach, it’s very easy to make this a macroscript and use it instead of the built-in attach button in Editable Poly.

Fast Attaching Methods

I find myself using this code all the time…

function clusterAttach objArr =
(

j = 1
count = objArr.count

undo off
(
while objArr.count > 1 do
(
if classof objArr[j] != Editable_Poly then converttopoly objArr[j]

polyop.attach objArr[j] objArr[j+1]
deleteItem objArr (j+1)

j += 1

if (j + 1) > objArr.count then j = 1

)
)
return objArr[1]
)

To call the function you can use this on an active Selection.

clusterAttach (selection as array)

Here’s a real-world solution which can help when say you get a file which has a load of stitches as individual objects rather than just one object for all the stitches.  It’s assuming those stitches are at least linked to a helper that define a set of stitches. If not, you’ll have to manually select them and run the code above.

–find all objects which have a child object with the name ‘stitch’ in its name.
for o in objects where o.children.count != 0 and matchpattern o.children[1].name pattern:”Stitch*” do
(
–merge all the children of our object
myObj = clusterAttach (for c in o.children collect c)
–reset the
myObj.parent = o

)

Or another one where maybe we want to find objects that have loooooads of children…

for o in objects where o.children.count > 500 do
(
–merge all the children of our object
myObj = clusterAttach (for c in o.children collect c)
–reset the
myObj.parent = o

)

Advertisements

About davewortley

Somewhere between an artist and a programmer, I like technical things, but being creative. I love problem solving and coming up with elaborate solutions. This blog is where I shall share ideas, tips, tutorials and anything that amuses me.
This entry was posted in 3dsmax, MaxScript. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s