Jump to content
  • Advertisement
Sign in to follow this  
Ratslayer

Coordinate types in 3ds max

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

If you intended to correct an error in the post then please contact us.

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 box
fn 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 this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!