Archived

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

QReboundSoftware

Normals

Recommended Posts

Hey, im 12, and im learning OpenGL. I have created a pyramid and now im adding light, but i cant figure out how to calculate the normals of the face. If you could help that would be great. After i get my awnser, Moderator, you can delete this, so it doesnt take up bandwidth. ______________________________ Quantum CEO of Quantum Rebound Software Website Up Soon

Share this post


Link to post
Share on other sites
Endemoniada    430
Hi,

Given three points you can compute the normal.

If P1, P2, and P3 are points on the plane (the side of your pyramid) you do this:

P1P2 Cross P1P3 = normal

If you aren''t sure what the Cross Product is you should look through the articles on this site, I''m sure it''s there.

Bye.

Share this post


Link to post
Share on other sites
Ok, Another question: Is it better to precalculate and then just hard code the normals into my objects and rendering, or should there be some function at startup that finds all the normals and stores them?


______________________________
Quantum
CEO of Quantum Rebound Software
Website Up Soon

Share this post


Link to post
Share on other sites
AN_D_K    158
Pre-calculating normals is worth doing for most objects. If you know that the LOCAL vertex coordinates are not going to change thoughout the program then pre-calcuate them. For the triangle this is worth doing as all you will probably be doing with it is moving and rotating it.

If the vertex co-ordinates are going to be easily changable then you should calcuate normals in the program. This is done if you are going to rescale the model, warp the models shape or don''t know all of the coordinates yet (terrain). I don''t think you''ll be getting up to all that for a little while yet.

What you perhaps should do is create a small program that works out normals for you (maybe a simple dos or shell program). You can use it to pre-calcuate the normals for your model while still letting you learn the code that can be adapted later for terrain and the likes.

Share this post


Link to post
Share on other sites
Ebony: No not yet
AN_D_K: Good idea, ill try that. I just barely got the equation from a friend, and i put it in excel.


______________________________
Quantum
CEO of Quantum Rebound Software
Website Up Soon

Share this post


Link to post
Share on other sites
AN_D_K    158
That being said, I actually use a spreadsheet to do all my my normals because I''m lazy.

...also, I never learnt Cross Product when I was 12. Actually, I learnt when I was 18 after doing Maths throughout my academic career. Do the US really do them when their 12? Seems a bit useless to people who don''t want anything more than good basic skills outside of Maths related fields.

Share this post


Link to post
Share on other sites
shadowman13131    122
AN_D_K: No no no, people in the US do not learn cross products or even matrices when they''re 12. I''m 16 now (in Alg 2), we just learned about matrices (we being the class, being a programmer I''ve known for awhile) and we haven''t touched vector math.

He''s probably making an effort to learn this stuff on his own, as I''m sure many (myself included) did.

Share this post


Link to post
Share on other sites
AN_D_K    158
Oh, I just thought it was the UK education system dumbing down again. Thinking about it though, our government are planning on scrapping proper Maths as a compulsory subject anyway to make way for "citizen maths" (as in how many "euros" do I have left if I...).

Share this post


Link to post
Share on other sites
Uberapan    122
Hm...I went through high school without ever learning about matrices. Complex numbers, calculus and integrals ahoy, but no matrices. My russian teacher showed me how to use the Ti-83 to use matrices, but it was never taught in class. Well well, that''s the Swedish school system for you.

Share this post


Link to post
Share on other sites