glNormal must DIe
im using this function to get my normals for polygons
Point3 normal(Point3 p1, Point3 p2, Point3 p3)
{
Point3 tmp1 = {p1.x - p2.x, p1.y - p2.y, p1.z - p2.z};
Point3 tmp2 = {p2.x - p3.x, p2.y - p3.y, p2.z - p3.z};
Point3 tmp3 = {tmp1.y*tmp2.z - tmp1.z*tmp2.y,
tmp1.z*tmp2.x - tmp1.x*tmp2.z,
tmp1.x*tmp2.y - tmp1.y*tmp2.x};
float length = (float)sqrt( tmp3.x*tmp3.x + tmp3.y*tmp3.y + tmp3.z*tmp3.z);
tmp3.x /= length;
tmp3.y /= length;
tmp3.z /= length;
return tmp3;
}
it is not workin good, only half of the polygons im rendering are shaded correctly, i''m doing something wrong. Can''t opengl just specify a camera and do all light bloking testing and all taht stuff, its killing me!!
try changing this:
Point3 tmp1 = {p1.x - p2.x, p1.y - p2.y, p1.z - p2.z};
Point3 tmp2 = {p2.x - p3.x, p2.y - p3.y, p2.z - p3.z};
to this:
Point3 tmp1 = {p2.x - p1.x, p2.y - p1.y, p2.z - p1.z};
Point3 tmp2 = {p3.x - p1.x, p3.y - p1.y, p3.z - p1.z};
other from that I think everything else looks good.
If only OpenGL would do all the lighting and camera stuff for us that would be great
Sadly, we are left with all that dirty work
Edited by - blueEbola on February 20, 2002 9:03:42 PM
Point3 tmp1 = {p1.x - p2.x, p1.y - p2.y, p1.z - p2.z};
Point3 tmp2 = {p2.x - p3.x, p2.y - p3.y, p2.z - p3.z};
to this:
Point3 tmp1 = {p2.x - p1.x, p2.y - p1.y, p2.z - p1.z};
Point3 tmp2 = {p3.x - p1.x, p3.y - p1.y, p3.z - p1.z};
other from that I think everything else looks good.
If only OpenGL would do all the lighting and camera stuff for us that would be great

Edited by - blueEbola on February 20, 2002 9:03:42 PM
another thing you can do is enable normalising. This way you don''t have to change the normal i,j,k to a range of -1 to 1. saves code and its faster than what you have.
btw, you could have used a bunch of if statements instead of the sqrt call aswell, but using normalise will let you not bother about it.
Beer - the love catalyst
good ol'' homepage
quote:
float length = (float)sqrt( tmp3.x*tmp3.x + tmp3.y*tmp3.y + tmp3.z*tmp3.z);
tmp3.x /= length;
tmp3.y /= length;
tmp3.z /= length;
btw, you could have used a bunch of if statements instead of the sqrt call aswell, but using normalise will let you not bother about it.
Beer - the love catalyst
good ol'' homepage
Beer - the love catalystgood ol' homepage
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement