PDA

View Full Version : maxscript and editable poly welding vertices coordinate system


Elpin
10-29-2009, 10:22 PM
Hi,

I'm having a bit of trouble with welding editable poly vertices.

I use this command to weld the two given vertices together:
$.weldVerts 76 875 [100,0,100]It works nicely and the two vertices (76 and 875) are welded together, but the problem is that the new welded vertex is not at the given coordinates (100,0,100). It's the coordinates from the Absolute:World coordinates for the 76 vertex I see in 3dsmax.

As I understand it, there are two weldVerts() functions. The one I use is from an Editable Poly interface and the other one is from a polyOp class.

Editable Poly interface:
<bool>weldVerts <index>vertex1 <index>vertex2 <point3>destinationPointpolyOp class:
polyOp.weldVerts <Poly poly> <int vert1> <int vert2> <point3 location> node:<node=unsupplied>

Now if I use the polyOp one then it works great, but I miss the bool return value (true on success) of the Editable Poly one so I can't really use it.

Is there a way how I can force the <bool>weldVerts() function to place the new vertex into a correct place or can I somehow get a success/fail report if the polyOp.weldVerts function welded the two vertices or not?
Any of the two solutions could solve my problem...

Thanks for any help guys...

denisT
10-29-2009, 10:49 PM
Editable poly's weldverts wants the destination point in the local coord system. To get world pos in local coordsys you have to:

<editable_poly>.weldverts v1 v2 (world_pos*(inverse <editable_poly>.objecttransform))



to get the result of using polyop.weldverts you can check number of verts before and after weld. If after verts number is one vert less then before it means the welding was successful, if they are equal - the welding didn't happen.

Elpin
10-29-2009, 11:13 PM
Thank you denisT! After I wrote my question I tried to put [0,0,0] as coordinates and noticed the vertex jumped into the exact center of the editable poly object. So I figured it must be something with local coordinate system, but I didn't know how to convert it.

Your answer is perfect! It did the trick right out of the box and the script I was working on the whole day finaly works. I'm quite happy this was the last problem I stumbled upon, heh.

Ah yes, to count the vertices is quite obvious, don't know why I didn't think of that.

It's interesting that even if the programing languages differ in functions and syntax a lot, the mechanics in which they work is very much the same... It's a few years since I wrote any kind of application (loved C++) but it was really easy to get into maxscript. Fors and Ifs just never change, heh.

Anyway, thanks again!

CGTalk Moderation
10-29-2009, 11:13 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.