Normals

Sage
Posts: 1,066
Joined: 2004.07
Post: #1
I found a website (gametutorials.com) where I am learning OpenGL at and I stumbled upon a tutorial about something called a "normal." It says that it is used for many things. What is a normal and what are the applications?
Quote this message in a reply
Moderator
Posts: 365
Joined: 2002.04
Post: #2
A normal is a unit vector which is perpendicular to a surface. You usually have one for each polygon in your 3D models. They're used for things like smooth shading, lighting and collision calculations.

Incidentally, it's possible to have 'normals' which aren't perpendicular or unit-length, but that's generally a bad thing.

Neil Carter
Nether - Mac games and comic art
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #3
Would normals apply at all to a 2D based sidescroller?
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #4
not NORMALLY! LOL
Quote this message in a reply
Member
Posts: 72
Joined: 2004.06
Post: #5
SimReality/Nick Wrote:Would normals apply at all to a 2D based sidescroller?

It depends. How 2d is it? Do you want to use some cool lighting effects? If you want things in your scene to be lit then you basically need normals. They're very simple if your objects are just cubes though
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #6
All of my characters, items, and, in general, anything that moves, is going to be a 2D textured quad. This leaves things like buildings, boxes, and stationary scenery as 3D objects (cubes). And because my current idea/challenge is a spy type game I'll later (much much later) want to throw in some lighting effects. So I'll go learn normals after I get everything else learned that I need just to get the basics.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #7
I put off learning this stuff for a while now and I'm trying to come back to it.

I get the idea of normals of polygons, but what about normals of vertices such as what's listed in a .OBJ file? I was thinking that I needed to learn normals to not only light my scenes, but to be able to scale objects in my programs. Is that correct?

Also, how do normals apply to collisions? I thought that a collision you just checked vertices or sides, but normals? I guess I don't know anything about these.

On a side note, what could I use to rotate an object in 3d assuming I have list of the vertices and the coordinates of the center? Would normals apply at all here?
Quote this message in a reply
Puzzler183
Unregistered
 
Post: #8
Quote:Incidentally, it's possible to have 'normals' which aren't perpendicular or unit-length, but that's generally a bad thing.

This is true most of the time but not always - smoothed normals can make low polygon models of curves look smoother, even if they aren't actually perpendicular to anything; non unit length normals can be used for special effects.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #9
Nick Wrote:I put off learning this stuff for a while now and I'm trying to come back to it.

I get the idea of normals of polygons, but what about normals of vertices such as what's listed in a .OBJ file? I was thinking that I needed to learn normals to not only light my scenes, but to be able to scale objects in my programs. Is that correct?

Also, how do normals apply to collisions? I thought that a collision you just checked vertices or sides, but normals? I guess I don't know anything about these.

On a side note, what could I use to rotate an object in 3d assuming I have list of the vertices and the coordinates of the center? Would normals apply at all here?

Per-vertex normals can be calculated as the average of the normals of the polygons sharing that vertex. That said, smarter averaging approaches might do more complicated stuff like weighting the average by the surface area of the adjacent polys.

Regarding collisions -- with normals you can say which side of a poly is the "inside" and which side is the "outside" -- this allows for much more robust collision mechanics.
Quote this message in a reply
Member
Posts: 277
Joined: 2004.10
Post: #10
Try creating a spinning cube that has lighting (without normals)

This will give a GOOOOOOOD idea why you need them LOL

(a gold/yellow texture looks best LOL)

Then add the normals,
MUCH BETTER LOL
.
.
.
.
.
.
.
.
.
.
.
(I hate normals Wink)

Global warming is caused by hobos and mooses
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #11
TomorrowPlusX Wrote:Per-vertex normals can be calculated as the average of the normals of the polygons sharing that vertex. That said, smarter averaging approaches might do more complicated stuff like weighting the average by the surface area of the adjacent polys.

Regarding collisions -- with normals you can say which side of a poly is the "inside" and which side is the "outside" -- this allows for much more robust collision mechanics.
That makes sense. That actually clears a bit up. So with my mesh class, would it be best to save the vertex normals in the vertex class or create a new class of vertex normals and then make some association between them in my main mesh class?
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #12
Nick Wrote:That makes sense. That actually clears a bit up. So with my mesh class, would it be best to save the vertex normals in the vertex class or create a new class of vertex normals and then make some association between them in my main mesh class?

Different people have different ways of approaching it. You could have vertex, color, normal, etc all packed into one struct and have an array of those for your mesh. This certainly would work, but if you want to use vertex arrays you'd have to worry about striding since the vertices would be non-contiguous.

Personally, I'd just have an array of vertices, an array of normals, an array of colors -- they'd be associated by their respective positions in the array.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #13
TomorrowPlusX Wrote:Personally, I'd just have an array of vertices, an array of normals, an array of colors -- they'd be associated by their respective positions in the array.
So far that's how I'm approaching it with an array of vertices and an array of vertex textures (or colors). Then the mesh class keeps track of which face is made of which three vertices and what each vertex's texture is. I think I'll give that a try.

Can anyone post up some sample code of their normals (either their class or "in action" (being used for lighting or whatnot))? I've been looking around at various websites and I understand what they are and what they can be used for, but I haven't found out HOW to use them yet.
Quote this message in a reply
Puzzler183
Unregistered
 
Post: #14
Uh, color arrays? People still use those? Everyone I see now uses a material setting and a texture setting and that's it...
Quote this message in a reply
Member
Posts: 277
Joined: 2004.10
Post: #15
.............I.........Must........recomend...........NeHe...................

...........I........must............not.............anger............myself.....​.........


Ya, that thing I recomended (what was that?)
It should have a nice lighting tutoroial....

Global warming is caused by hobos and mooses
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Normals? Quicksilver 3 2,851 Jan 13, 2003 05:31 PM
Last Post: henryj