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

clipping

Started by Kaesebrot May 23, 2002 at 9:36 AM 0 replies 200+ views
Original Post
Kaesebrot
Kaesebrot
How can I clip a polygon against a BSP-Tree ? I need it for portal-generation..
JuNC
JuNC
Just recursively clip the polygon to each plane in the tree,


polylist


recursive_clip(poly,node):

if node == NULL:
polylist += poly
return



if poly completely on side 0 of node_plane:
recursive_clip(poly,node_child0)
else if poly completely on side 1 of node_plane:
recursive_clip(poly,node_child1)
else
clip poly against node_plane into poly0,poly1
recursive_clip(poly0,node_child0)
recursive_clip(poly1,node_child1)



(dear god let that be right )

polylist then contains the list of polygon fragments. If you only want polys on one side of plane, simply don't do the recursive calls for that side.

EDIT: formatting

[edited by - JuNC on May 23, 2002 1:05:16 PM]

Topic Locked

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

Sign in to reply to this topic.