Jump to content
  • Advertisement
Sign in to follow this  

Holes and contours...

This topic is 3694 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

How do I make a hole in a surface or cut a contour around a surface? To try to explain more clearly; I start with a simple square, which represents a piece of paper, and the paper has a picture on it. (The picture is put on the square as a texture.) How can I make a hole in the paper? ...and i also want to "contour-cut" the paper, ie. I have a picture texturemapped on a square, and I want to be able cut the paper to different shapes. I can of course just start with the required shape, but then the problem is to get the texture correctly mapped to the irregularly shaped surface. Does anyone understand my question :), and if you do, can you give me any advice on how to solve the problems? Thanks in advance...

Share this post

Link to post
Share on other sites
I am not sure what you mean by the mapping problems, but as far as displaying the hole:

If you are just looking for a solution to display the hole as transparent I would use alpha transparency on the mapped texture.

If you are looking to alter the mesh I would suggest the following solution (untested):
1) Detect all of the intersection points on the mesh edges between the paper and the cut's you want to make.
2) Tessalate the mesh in the following way: For each edge detected which intersects the contour split he edge into 2 egdes (and split all triangles who own that edge by passing a new edge to the opposing vertex).
Do not count vertices who are directly on the contour as edge intersections.
3)Repeat 2 until there are no more edges intersecting the contour.
4)Once done with 2+3 look for triangles who have all three vertecies on the contour. Add a vertex in the center of these and split into three different triangles
5) Repeat 4 until no face remains for which all triangles are on the contour.
6) Remove all triangles with a single vertex (or more) inside/outside the contour (depending if you want the outside or inside of the shape.).
Do not count vertices who are directly on the contour as inside/outside.

I think that should do it.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!