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

Point Projection

Started by dinaharchery Apr 15, 2009 at 12:00 PM 3 replies 750+ views
Original Post
dinaharchery
dinaharchery
Please Help, I have a set of simple, convex polygons that I am trying to cut/trim. These polygons are in 3-space, so I ignored the z-coordinate and used 2D segment intersections to alter. This works great in 2D but when I move the "cut" back to 3D it does not look correct. The 3D image looks as if the z is all over the place. Is simply ignoring the z-coordinate the proper thing to do? I hope this is something simple :), any ideas would be great.
Erik Rufelt
Erik Rufelt
I don't understand what you are trying to do. Are you cutting the model by a plane, so only the part on one side of the plane remains?
Or are you trying to intersect the polygons with each other for something?
dinaharchery
dinaharchery
Erik, thank you for your reply - I am sorry about the confusion on my earlier post. However, I now think the problem is not in the "cutting" of the polygon(s) but rather in triangulating them. The triangulation of the modified/cut polygon(s) is called using the Ear-Trimming algorithm which worked great in 2-Space (not so good in 3-Space).

For Example:
If I start with a polygon: (1,0,0),(3,0,3),(3,2,3),(2,2,2),(2,3,2),(1,3,0) and triangulate it I get 4 triangles:
Triangle 0:
(1,3,0),(1,0,0),(3,0,3)
Triangle 1:
(3,0,3),(3,2,3),(2,2,2)
Triangle 2:
(2,2,2),(2,3,2),(1,3,0)
Triangle 3:
(1,3,0),(3,0,3),(2,2,2)

Rendering the above 4 Triangles yields an odd-looking image. The z-coordinates look out of place in that they don't blend with the over all polygon (jutting out at almost right-angles).

At this point I am unsure if the major issue exists with the triangulation algorithm itself or somehow the z-coordinates need to be "smoothed" via some kind of linear interpolation between resulting triangles.

Any ideas would be great :)


Thank you.
Geoffrey
Geoffrey
Quote:
Original post by dinaharchery
If I start with a polygon: (1,0,0),(3,0,3),(3,2,3),(2,2,2),(2,3,2),(1,3,0)


That's not a polygon!

To be more precise, it isn't planar (flat), so you shouldn't expect to be able to render it out of flat triangles.
Erik Rufelt
Erik Rufelt
Are the resultant polygons also convex?
It's very easy to triangulate convex polygons. For example put one new point in the middle, and combine it with every edge of the polygon.

Topic Locked

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

Sign in to reply to this topic.