Notifications
Clear all

[Closed] Vertex align

Hi there you maxscript Gurus.

Where are you LFShade and Mr Bobo?

Anyway, I got a doubt on an automation script of my own.

I need to align copies of a original object to each vertex normal.

I have reached the stage below so far, but got stucked and rotation.


indexx = undefined
Addmodifier $dome (Mesh_Select())
VertexCount = getnumverts $dome

for indexx in 1 to VertexCount do ( 
    print (getNormal $dome indexx) 
    VertexPosition = getvert $dome indexx
    objCopy = copy $source 
    objCopy.pos = VertexPosition 
)

How can I apply each vertex normal to the new object matrix transform?

I am completely sure you’ve got the answer right away!

Thank you, thank you and thank you!

4 Replies

As you have vertex normal you have only one vertor for matrix. You have to define another one to create a matrix. If you don’t care about spin about vertex normal direction you can use matrixFromNormal or arbMatrix (both these function use world UP vector as second vector to create the matrix):


-- objCopy.pos = VertexPosition change this line to
objCopy.transform = translate (matrixFromNormal (getNormal $dome indexx)) VertexPosition 

Hi Denis!
Works nicely!

Thanks!

Hi! I still need help

Why my new copies are getting re-scaled to a bigger size?

how can I retain the original size?

1 Reply
(@denist)
Joined: 1 year ago

Posts: 0

because matrixfromnormal creates matrix with scale [1,1,1]… if you want to keep original node’s scale you have to build matrix in the different way:


_scale = <your_node>.transform.scale
<your_node>.transform = translate (rotate (scalematrix _scale) (matrixfromnormal vertNormal).rotation) vertPos

something like that