Skip to main content
GameDev.net gamedev.net
🔒 Locked

Normals

Started by Zmax Sep 20, 2005 at 5:51 AM 1 replies 1.4k views
Original Post
Zmax
Zmax
Hi i have to create a custom shape from the code with dx9 and don't know how to set the normals of that shape so that the ligth will work properly.Is there anyway i can set them automaticaly? Do you know some good tutorials about this topic.(i know they have to be perpendicular on the surface not on the vertexes,..but what happens when i have manny surfaces?)
Armadon
Armadon
Hi there ZMax,
How are you doing?

The Problem
Calculating normals for an object.

The Solution
Ok, there are a couple of ways you could do this.

Option 1 - D3DXComputeNormals
I like this nifty little trick using D3DXComputeNormals. You create a new ID3DXMesh Interface and then fill the vertex buffer of this new mesh object with the vertices of your custom shape. You then use the D3DXComputeNormals function on this mesh which will calculate the normals for you and you can just read back the information from the vertex buffer of the mesh.

Option 2 - Creating a ComputeNormals function and doing the math
You could follow the following post on calculating normals per vertex using the correct math.

I hope this helps buddy.
Take care.
Zmax
Zmax
Aham,..I'll try the trick, it seems to be easyer than calculting every normal one by one.Thanx Armadon! :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.