Jump to content
  • Advertisement
Sign in to follow this  
Revelation60

Creating smoothing normals from 3DS file

This topic is 3811 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;
							count++;
						}

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

		}
		
		
	}


Is there an error in it?

Share this post


Link to post
Share on other sites
Advertisement
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:
http://i114.imagethrust.com/images/2Pin/view-image/hydraslayertextureglitches-01.html

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!