Jump to content
  • Advertisement

Archived

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

Guest Anonymous Poster

normals

This topic is 6820 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Thanks Mike.

I understand completely what you said, however, I think I might have been unclear in my original question.

I could find the points along the line normal to the polygon and then prespective project those points from 3D to 2D. This however, would require a divide for each point along the line normal to the polygon. This is the problem I want to avoid. I don't want the extra divides.

The equations I use for perspective projection are x'=(focus*x)/z and y'=(focus*y)/z, where focus is the focal length.

I've contemplated just projecting the normal along with the polygon, but then what do you do when the normal is <1,0,0>. Won't you get a divide-by-zero?

Any help would be greatly appreciated

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!