Message 1 of 21
How to get vertex normal using python

Not applicable
03-06-2018
07:05 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I drag a box into an empty scene, then using the following python script to get vertex normal. However, the result is not what i expected.
From the output, we can see there are just two kind of normals, which is obviously wrong.
I know the face normal can be retrieved with Mesh.GetFaceNormal, but what I really want to get is the vertex normal taking smooth group into account(That means every vertex has three normals). I searched the python API docs, but can't find the right way to do that.
Can somebody help me?
python script:
n=list(MaxPlus.Core.GetRootNode().Children)[0] obj=n.EvalWorldState(0).Getobj() tri_obj = MaxPlus.TriObject._CastFrom(obj.ConvertToType(MaxPlus.ClassIds.TriMeshGeometry, 0)) mesh=tri_obj.GetMesh()
for i in xrange(mesh.GetNumVertices()): print mesh.GetRenderedVertexNormal(i)
output:
Point3(0, 0, -1.5708)
Point3(0, 0, -1.5708)
Point3(0, 0, -1.5708)
Point3(0, 0, -1.5708)
Point3(0, 0, 1.5708)
Point3(0, 0, 1.5708)
Point3(0, 0, 1.5708)
Point3(0, 0, 1.5708)