Cutaway objects

Hi All,

I’m still looking for an ‘easy’ way to cut an object (like a saw or jigsaw does to a piece of wood).

It was suggested that I either use Stencil buffer, or CSG (Constructive Solid Geometry) to render objects where a piece needs to be ‘visually’ cut away.

I need more than a rendering solution. What I want to do is ‘cut’ a solid and ‘repair’ the exposed opening. I want to store the new vertice data for my modified object, so I can do further ‘cuts’ later.

For example. Let’s say I have a piece of wood (2 feet long, 2" x 10" on-end). So I create an object to represent it in 3D. It is composed solely of all tri’s (no quads) and it may have fans or strips.

Now I want to draw a ‘cut’ line on the surface using a multi-segment line. This describes the ‘cut’ I want to jigsaw. Just like drawing a line on a board with a pencil before you saw it.

Imagine I can convert the multi-segment line into a plane that projects completely through the board (an contoured plane for jigsaw cuts). Or imagine I can ‘project’ lines vertically downward from each vertice in the multi-segment line until they ‘hit’ the bottom of the board (a great way to create tri-strips!).

  1. How do I figure out the vertices formed where the ‘plane’ (vertices) cut through the ‘board’?

  2. What’s the best way to ‘seal’ the open end (I’m guessing tri strips)?

If I can do that I can construct fans or (better yet) strips of tri’s and that would define the cutaway side of the object.

Then I could store the modified object data and ‘cut’ the object over-and-over-and…

Any ideas?

SteveH

Hum that does excluse any stencil solution. You can try a CSG solution but they’re generally pretty complex to implement.

Here’s another idea: i’m assuming you’ve got the “cut” plane equation. Loop all vertices of the mesh, test against the plane. If it’s negative, keep the vertex. If it’s positive, “cap” the vertex to the plane (ie. move the vertex onto the plane).

After that you can imagine an algorithm that will loop on the faces on the cap and “simplify” them if you don’t need them anymore.

I can think of many situations where this idea wouldn’t work, but maybe you can tweak the idea, or just live with it, depending on the nature of your objects ?

Y.

Well, maybe I can create a ‘plane’ from each pair of vertices in my multi-segment line I use for my ‘cut’. All I need is a pair of vertices and the third vertice (need at least 3 to define a plane) comes from the fact that I’m cutting vertically downward (negative Y direction, if the board lies flat in the X/Z plane).

Then all points that are between the vertices and positive in the Z direction are elimated, negative ones kept (as you said in your post).

So it ‘might’ work. I was thinking that after I determined all vertices a the ‘cut’ I could ‘seal’ the hole with a filled polygon that is tesselated.

Do you know if/how the gluTesselator might return the vertices that it calculates (if you haven used it)?

Anyone else who has used gluTesselator please chime in…

SteveH

Yeah that’s the idea, but it will cause problems if you end up with holes or intersecting faces after they’re projected onto the plane. If it doesn’t happen it should work.

As for gluTesselator, you can specify a callback function that will receive the new vertices (old vertices are left unchanged, as you already have them!). You can build an index array from other callbacks. Here’s one tutorial (have a look in the middle of the page):
http://www.geocities.com/foetsch/extrude/extrude.htm

Y.

Yes, there could be holes left where tri’s straddled the cut-line and were broken, so I’ll have to program for that. But, the gluTesselator seems the easiest way to go for the mending phase (under the circumstances).

This should be much easier to implement than CSG and ‘fun’ too…

Much thanks,

SteveH