Smoothing Groups and D3D

Started by
0 comments, last by DmGoober 23 years, 1 month ago
I''m using milkshape 3d files. For those not familiar with it, milkshape defines meshes as such (this is greatly simplified): vertices (int x, int y, int z) indices to vertices (word index) triangles (word index[3], float normal[3][3], int smoothing group) Now, i''m trying to use D3D to render milkshape meshes. The difference here is that D3D uses the following format (again, simplified) vertices (int x, int y, int z, float normal[3]) indices to vertices (word index) Now the difference should be very obvious: D3D stores normals with the vertices and has no smoothing information, while milkshape stores normals per triangle. In other words, in ms3d files, a vertex can have multiple normals. Ok, so if we run with the assumption that all triangles in the mesh have the same smoothing group, then converting from milkshape to d3d is easy -- We simply average all of the normals defined for a certain vertex. This average is now the normal for the vertex. Walla, we''re in d3d land and everything looks nice and smooth. Unfortunately, what happens if we DON''T want the object smoothed? What happens when we have, say, a cube? Or, just two faces that we don''t want to smooth? The only solution that i can think of, is to define the vertices on the not smoothed edge TWICE, but with different normals. This is a major hassle of course. . . and it essentially doubles the size of the mesh. Any suggestions? Thanks. DmGoober
Alexander "DmGoober" Jhinalexjh@online.microsoft.com[Warning! This email account is not attended. All comments are the opinions of an individual employee and are not representative of Microsoft Corporation.]
Advertisement
I always find solutions to my own problems like 20 secs after I post. . .

D3D sdk suggests an easy method for creating not smooth objects is to simply switch the rendering mode to smooth shading before rendering not smooth objects. Since most not smooth objects in my game (tables, chairs, lightswitches) are incidental to the main action, I''m just going to use this cheat, even if the flat objects don''t look as nice as the gouraud ones. Not the best solution, but I don''t care. =) It''ll keep my engine running fast.

I guess flat shading uses face normals, while gouraud uses vertex normals, so I don''t have to worry about smoothing over edges.

Hope this helps someone.

DmGoober
Alexander "DmGoober" Jhinalexjh@online.microsoft.com[Warning! This email account is not attended. All comments are the opinions of an individual employee and are not representative of Microsoft Corporation.]

This topic is closed to new replies.

Advertisement