Coordinate types in 3ds max

This topic is 2729 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Ehhh, I'm really not sure if I'm in the right forum, please move me if I'm not.

So I'm trying to make my 3ds max automatically generate bounding shapes about various meshes, and I'm stuck trying to find the center for them. I tried to calculate the middle of all the vertices but I have found no way of converting it to the coordinate system of the mesh. Here is my 3ds max code:
for obj in selection do			(				verts=obj.mesh.verts				for vertex in verts do				(					top = maxvector top vertex.pos //top is the vector for the positive corner of the bounding shape					bot = minvector bot vertex.pos //bot is the negative corner										pos = pos + vertex.pos //this is my attempt to calculate the center				)				pos=pos/obj.mesh.numverts				if gr.checked==false then				(					local params=top-bot					local center= pos					mybox = createbox params center //create a box					top=[0,0,0]					bot=[0,0,0]				)			)//here is the function that create the boxfn createbox params center =(	mybox=box length:params.y width:params.x height:params.z	mybox.center=center	mybox)

I can not just put it in the center of the object, because I plan to have multiple shapes in an object based on selected vertices (like around vertices affected by one specific bone in a skinned mesh). So what am I doing wrong?

Share on other sites
I have no experience with max scripting whatsoever, but I'd think the vertex positions are in object space. That would mean you would have to add the position of the box in world space to your found position.