Jump to content
  • Advertisement

Archived

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

Xeno

Normals for 3D Cone

This topic is 6936 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

im working on function that create a 3D Cone . it uses triangles that share one point , that point have a diffrent y value. now , how do i calculate the normal for each triangle???? beacause the light(im using diractional light) is lighting all the triangles in the same power, so it not looks a 3d cone..... any iseas for calculate the normals ??? Posted By Xeno. Kobe Bryant - "Just believe in yourself"

Share this post


Link to post
Share on other sites
Advertisement
The normals be set to the following values:

l = sqrt(Height*Height + Radius*Radius);
x = Height*cos(angle)/l;
y = Radius/l;
z = Height*sin(angle)/l;

The angle is the same angle you use to produce the vertex pos.

Now for the top vertex. Because you are using gouraud shading, that is not flat shading, the top vertex cannot be shared among the triangles. You''ll need one vertex per triangle, these vertices should have the same normal as the one directly below in the base.

Share this post


Link to post
Share on other sites
first - "wow , how did u think about that!"

it look like it need to work but it working just on something like half of all the triangles.

and yes every trinagle have its own top vertex, they dont really share the top vertex.

but i dont understand how to apply the normal for the top vertex, what do u mean that the top vertex should have the same normal as the one directly below in the base?

Thanks a lot.
its very help.

Posted By Xeno.
Kobe Bryant - "Just believe in yourself"

Share this post


Link to post
Share on other sites
I recognized that the normals have the same angle to the ground plane as the cone''s side have to the cone''s axis. If you draw it on paper you can easily see this. Plus I know my math.

Hmm, maybe I don''t know my math, I just spotted an error in the formulas. They should be

l = sqrt(Height*Height + Radius*Radius);
x = Height*Radius*cos(Angle)/l;
y = Radius/l;
z = Height*Radius*sin(Angle)/l;

The normal for the top vertex of a triangle has the same angle against the ground plane as the two vertices in the cone''s base. Now that I have more time to think about it you should compute the normal with the middle angle like this:

l = sqrt(Height*Height + Radius*Radius);
x = Height*Radius*cos(Angle+AngleStep/2)/l;
y = Radius/l;
z = Height*Radius*sin(Angle+AngleStep/2)/l;

Here AngleStep is the angle between each of the vertices in the base.

This should work for all triangle, not just half.

- WitchLord

Share this post


Link to post
Share on other sites
it still dont work , seems that i dont really understand it.
hmmm.... can i post here the code that create the cone, and u will check it??

Posted By Xeno.
Kobe Bryant - "Just believe in yourself"

Share this post


Link to post
Share on other sites

  • 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!