Skip to main content
GameDev.net gamedev.net
🔒 Locked

normals

Started by GameDev.net Nov 18, 1999 at 2:56 PM 2 replies 750+ views
Original Post
GameDev.net
GameDev.net
If I have a polygon and have calculated the normal to the plane formed by the vertices of the polygon, when I perspective project those vertices from 3D to 2D is there any way to project the normal as well. What I would like to do is be able to find points along a line normal to the plane formed by the vertices of the polygon AFTER perspective projection.

thanks for the help

MikeD
MikeD
Surely if you just want to draw the normal along with the polygon you could generate a start point from the centre point of the polygon (all the points positions averaged), then normalise the normal (if you haven't already) and generate an end point for the line from the normals vector.
i.e.
vx = vy = yz = 0;
for(i=0;i{
vx+=poly.x;
vy+=poly.y;
vz+=poly.z;
}
vx/=poly.num_points;
vy/=poly.num_points;
vz/=poly.num_points;
start.x = vx;
start.y = vy;
start.z = vy;
end.x = vx + poly.normal.x * length;
end.y = vy + poly.normal.y * length;
end.z = vz + poly.normal.z * length;
Then perspective project this line into 2D and plot it.
MikeD
MikeD
Okay, the normal you would project could have a vector of (1,0,0), this is fine.
It has a start point and an end point, the end point being
start + (length * normal)
If this should result in you getting a point with a z of zero or less then it should be clipped in the same way you clip your poly vertex's.
In fact the view fustrum I used when I wrote my first 3D program clipped everything at about 50cm in front of the camera.

However, from what you've said, you appear to want to find the normals perspective projected values without projecting them.
I can't see how that's possible.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.