Jump to content
  • Advertisement
Sign in to follow this  

Creating smoothing normals from 3DS file

This topic is 3982 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm having a small problem with loading a 3DS file and it has probably got something to do with smoothing groups. When I load a 3ds scene with a standard teapot in it, I can look through the whole teapot when I look beneath the top(the thing that lies on top of it). My code to process smoothing groups is:
for (int i = 0; i < TriangleCount; i++)
		for (int j = 0; j < 3; j++)		{
			count = 1;
			int smooth = triangles->SmoothingGroup;

			for (int k = 0; k < TriangleCount; k++)
				if (k != i && triangles[k]->SmoothingGroup & triangles->SmoothingGroup)
					for (int l = 0; l < 3; l++)
						if (triangles->points[j].vertexIndex == triangles[k]->points[l].vertexIndex)
							//triangles[k]->SmoothingGroup |= (triangles[k]->SmoothingGroup & triangles->SmoothingGroup); 
							triangles->points[j].normal = triangles->points[j].normal + triangles[k]->normal;

						triangles->points[j].normal = triangles->points[j].normal / count; //average


Is there an error in it?

Share this post

Link to post
Share on other sites
Hi, I'm doing the same for my engine/demo, and I had the same problem.

I'm using directX and have all the normals flipped, so when importing the index buffer I simply inverted the second and the third index!

It seems that the faces are stored in the file in unscrewed order, but DirectX want faces in screwed order.
The other mistake was that I have set the D3Dviewport farz to a value over 1.0f.

This produced this mess:

Also be sure to have the culling on.

Hope it helps!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!