Archived

This topic is now archived and is closed to further replies.

GamerSg

Number of normals in MaxScript

Recommended Posts

I am attempting to write a file exporter in Maxscript and am stuck at this point. How do i get the number of normals using MaxScript? When using smoothing groups, the number of normals tend to be different from the number of vertices. Max doesnt split vertices for every unique normal which is what i want since i plan to use vertex arrays to do the rendering.

Share this post


Link to post
Share on other sites
Chuck is correct. In general, Max tends to store information per-face, not per vertex. This is the case whether you use Maxscript or the Max SDK. The downside to this, of course, is that getting an optimized set of data where each vertex has the information takes a bit more work.

Basically, the easiest way to do this is to simply create 3 vertices for every triangle. Then, once you have all the verices you can go back and check for duplicate data and make an optimized list.

Also, on a seperate note, I seem to recall that there are multiple methods for getting the normal for each face''s vertex. Unfortunately, most methods DO NOT return the result you''re after. I don''t have my code here, but if I recall correctly, the function you want to use to get the normals is "meshop.getFaceRNormals". I believe the other functions, for whatever reason, didn''t seem to take into account things like smoothing groups correctly. Also, if I remember correctly, meshop.getFaceRNormals also gave incorrect results, but only in the case where the face had NO smoothing groups applied.

So, basically to get the normals for each face you do something like this(psuedo-code):

if ( Face has smoothing group )
(
Use "meshop.getFaceRNormals" to get the face''s 3 normals
)
else
(
Use "getFaceNormal" to get the normal of the face itself
Set each of the face''s 3 normals to that normal
)

Hope that saves ya some time

-John

Share this post


Link to post
Share on other sites
I''ll look into it. Im currently considering modifying the IGAME example on discreets website which generates a xml file to what i need. The example also takes care of smoothing groups, skinning and bones nicely.

Share this post


Link to post
Share on other sites