[Closed] Move verts in their local coord sys
This is probably an easy one, but can’t quite work it out. I’m trying to move some editable poly verts in their local coord sys along their y axis.
I don’t see any way of moving in vertices local axis, so do have to calculate it? From their normal maybe?
Thanks
As far as i know there ain’t such command. I have used normal command.
aNor = getnormal $Sphere01.mesh 9 -- get normal of vertex 9
aTra = matrixFromNormal aNor -- create a matrix
aPos = $Sphere01.mesh.verts[9].pos
$Teapot01.transform = aTra -- transform teapot to orientation of sphere vertex 9
$teapot01.pos = aPos -- move it to vertex
in coordsys aTra $Teapot01.pos.z += 10.0 -- offset 10.0 units in in vertex normal "space"
Hope this helps!
I think i didn’t read it properly… Here’s something more closely related
aNor = getnormal $Sphere01.mesh 9 -- get normal of vertex 9
aTra = matrixFromNormal aNor -- create a matrix
in coordsys aTra
(
polyop.moveVert $sphere01 9 [5,0,0]
)
Thanks, the 2nd one is close to what I want, but it’s not quite there. I’m trying to move along the y axis, but trying out your method doesn’t recreate what happens when you use local coord sys and move verts in teh view port… try it on open edges for instance…
any idea?
Aaa… That’s bit different. Now i got it. You don’t want to move in normal’s “space” but something different. I take it this is related to vertices on open edge, yes?
In this case, i would first find for example vert 1’s neighbours, then get center point of these two. Next create a vector using vert 1 and this point. Then another vector from normal, and another facing from plane created by these two.
I’m not that good with vectors, but here is something i’ve used earlier. Note: I think it works, but it only works on round profile, (i doesn’t have to be flat) but not with dents, as the “triangle” formed by vert 1 and 2 edge verts would be sort for “flipped” and move will move it to opposite direction…
P.S.
I’m using 4×4 plane converted to poly as demo… And vector experts could correct this, if there is something wrong…
fn middlePoint pA pB = ((pA+pB)/2.0)
v = 2 -- vert number
my_edges = (polyop.getEdgesUsingVert $plane v) as array -- two edges connected to vertex 1
-- get verts next to vertex
my_vert1 = ((polyop.getVertsUsingEdge $plane my_edges[1]) as array)[2] -- dirty way to get first edge's vert
my_vert2 = ((polyop.getVertsUsingEdge $plane my_edges[2]) as array)[2] -- another edges's vert
-- midpoint of first and second edges verts...
my_point_this = $plane.verts[v].pos
my_point_mid = middlePoint $plane.verts[my_vert1].pos $plane.verts[my_vert2].pos
-- axis 1, along vert 1 and center point of edge1 and edge2 verts
my_v1 = normalize (my_point_mid - my_point_this)
-- axis 2, normal dir
my_v2 = getnormal $plane.mesh v
-- axis 3, perpendicular axis to previous two vecto
my_v3 = normalize (cross my_v1 my_v2)
-- matrix3
my_sys = matrix3 my_v1 my_v2 my_v3 [0,0,0]
-- move vertex in this coordsys
in coordsys my_sys
(
polyop.moveVert $plane v [20.0,0,0]
)
Wouldnt something like
nrml = [0,0,0] --set normal to 0
fcs = (polyOp.getFacesUsingVert cobj vrts[vrt]) as array --get all faces sharing that vertex
for fci = 1 to fcs.count do nrml += polyOp.getFaceNormal cobj fcs[fci] --calc all vertex related face normals
print ("Average Normal: " + (nrml/fcs.count)) --print normal values / number of connected faces
Be enough to get the normal of the vertex, that is if its not a single floating vertice without connected faces (doesnt have a normal then anyways)
Or would that result in the same as
getnormal $Sphere01.mesh 9
In your example (havn’t tried it)
a normal, at least in max, only gets you a ‘Z’ axis. Doesn’t say anything about the ‘spin’ around that Z axis for you to determine the X and Y axes
Hmm, I seem to always find stuff that is easy in general use Max, but very complicated in scripting!
Does anyone have a clear idea of how max works out it’s x and y vectors in vertex local space?
S-S, your 3rd example doesn’t work here, your calling my_axis1 & 2 but it’s never declared…?
Try it now. Fault was that “my_axis” ones should have been “my_v1” and “my_v2” and there was one “$” instead of “$plane”. Try it with 4×4 plane which has name “plane”. And this is just more like an idea, selection of edge verts won’t most likely work for all edge verts of a plane.