Whats so normal?

Posted by Scott_AW on Feb. 10, 2007, 10:17 p.m.

Just how can one accurately calculate normals? I still have no clue. I'm no math wiz, I slept through my last year of math because I didn't need the credits…actually I even drew a 30 some odd page comic about a cow druid in my graphing book for math, but thats another story…

So far I'm just using simple squares to create maps in my previously mentioned 3d-sidescroller map maker and decided instead of tweaking the normal values until they look good in all ways of light that I would use one of those normal calculating examples. Naturally I would assume better results since my floors are still slightly off, but heres what happened:

Heres how things look with normals manually added.

http://64digits.com/users/Scott_AW/my_normals.jpg

Heres what happend when I attempted to use a normal calculating code.

http://64digits.com/users/Scott_AW/example_normals.jpg

My assumed normals for a fore facing wall.

 d3d_model_primitive_begin(global.model_basic[0],pr_trianglestrip);
 {
   d3d_model_vertex_normal_texture(global.model_basic[0], 0, 0, 0, 0,-1, 1/4, 0, 0);
   d3d_model_vertex_normal_texture(global.model_basic[0],64, 0, 0, 0,-1, 1/4, 1, 0);
   d3d_model_vertex_normal_texture(global.model_basic[0],64, 0,64, 0,-1, 1/4, 1, 1);
   d3d_model_vertex_normal_texture(global.model_basic[0], 0, 0,64, 0,-1, 1/4, 0, 1);
   d3d_model_vertex_normal_texture(global.model_basic[0], 0, 0, 0, 0,-1, 1/4, 0, 0);
}

Standard normal calulation found in various examples

x1 = argument0;
y1 = argument1;
z1 = argument2;

x2 = argument3;
y2 = argument4;
z2 = argument5;

x3 = argument6;
y3 = argument7;
z3 = argument8;

crossX = (y2-y1)*(z3-z1)-(y3-y1)*(z2-z1);
crossY = (z2-z1)*(x3-x1)-(z3-z1)*(x2-x1);
crossZ = (x2-x1)*(y3-y1)-(x3-x1)*(y2-y1);

length = sqrt(sqr(crossX) + sqr(crossY) + sqr(crossZ));

global.normX = crossX/length;
global.normY = crossY/length;
global.normZ = crossZ/length; 

Conclusion? Well for flat surfaces its best to figure your own normals I suppose, but I wouldn't recommend it for anything more complex. At least I haven't tried anything complex yet…

Which brings to question, does anyone really know how to figure normals without that formula mentioned above or is it that length variable added in there that causes all the oddness?

Comments

Radnom_Games 17 years, 9 months ago

I drew superhero Log Man in my maths book.

"Hey kids! Don't do crime, you nazi bastards!"

firestormx 17 years, 9 months ago

I think you should clarify to most members here, that you mean mathimatical normals, and not simply a "who can say what is normal?" comment. =P

Scott_AW 17 years, 9 months ago

Its a play on words, is that so bad?