views:

18

answers:

2

In 3D Max Studios, I recalled there is a function (I couldn't recall the name of the function, sorry) to cut a 3D model into two. For instance, you create a sphere, then you cut it in the middle, leaving 2 half spheres. Now, how about a human body? Imagine a samurai cutting up an enemy at the stomach, now that enemy's model will become 2 models: one is the upper part from head to stomach and another is the lower part from stomach to feet. Also, in order to prevent the player to see inside the cut model, an extra polygon will also have to be placed into both models. (and preferably, add blood texture in this polygon to give an impression that this is the blood inside the body) Sorry if my explanation is poor, do you understand what I am trying to say?

In 3D Max Studios, we can do above. Now, 3D programming-wise, what do I have to do if I want to achieve something like this? Sure, one cheap method is to have the cut models pre-made, but this is not realistic.

I am looking for a way to cut a model into two with respect to angle of cut in real time. Is this possible?

+1  A: 

This is called clipping there are standard algorithms for clipping polygons in any computer graphics text.

anonymous_21321
+1  A: 

You need two angles to represent the 'angle of cut' in 3 dimensions.

It's probably easier in the maths to use a point and a normal, defining a plane that divides the model in two.

You can then determine which parts of the model are on one side of the plane, and which parts are on the other. Just plug each point into your plane equation, e.g.

ax + by + cz + d

..if the result is > 0, the point is on one side, and if it's < 0, it's on the other.

You can detect triangles that intersect the plane (because some vertices are on one side, some on the other) and split them into multiple triangles to keep the 'cut' straight, e.g.

       /\
      /  \
  --------------- (cut)
    /\    /\
   /  \  /  \
  /    \/    \
  ------------

(Note you only need two triangles below the line - i'm not an artist :)

Then, if you've cut a solid model in two and you need to 'patch' over hole you've created, you'll need to tessellate (or triangulate) the points on the dividing plane to create a new polygon there. This isn't always easy, particularly if the polygon is not convex.

sje397