根据切割角度分割 3D 模型

发布于 2024-09-27 22:07:52 字数 392 浏览 4 评论 0原文

在3D Max Studios中,我记得有一个功能(抱歉,我不记得该功能的名称了)可以将3D模型切成两半。例如,您创建一个球体,然后将其从中间切割,留下 2 个半球体。现在,人体怎么样?想象一下,一个武士从敌人的腹部切开,现在敌人的模型将变成2个模型:一个是从头到胃的上半部分,另一个是从胃到脚的下半部分。此外,为了防止玩家看到切割模型的内部,还必须在两个模型中放置一个额外的多边形。 (最好在这个多边形中添加血液纹理,给人一种这是体内血液的印象)抱歉,如果我的解释很糟糕,你明白我想说的是什么吗?

在3D Max Studios中,我们可以做到以上。现在,在 3D 编程方面,如果我想实现这样的目标,我必须做什么?当然,一种廉价的方法是预先制作切割模型,但这并不现实。

我正在寻找一种将模型根据切割角度实时切割成两部分的方法。这可能吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

虐人心 2024-10-04 22:07:52

您需要两个角度来表示 3 维中的“切割角度”。

在数学中使用点和法线来定义平面可能更容易将模型一分为二。

然后,您可以确定模型的哪些部分位于平面的一侧,哪些部分位于另一侧。只需将每个点代入平面方程,例如

ax + by + cz + d

......如果结果是> 0,则该点在一侧,如果<<,则该点在一侧。 0,在另一边。

您可以检测与平面相交的三角形(因为一些顶点在一侧,一些在另一侧)并将它们分成多个三角形以保持“切割”直线,例如

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

(注意您只需要线下方的两个三角形 - i'我不是艺术家:)

然后,如果您将实体模型切成两半并且需要“修补”您创建的孔,则需要曲面细分(或三角剖分)分割平面上的点创建一个新的多边形。这并不总是那么容易,特别是当多边形不是时。

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.

泪眸﹌ 2024-10-04 22:07:52

这称为剪切,有用于剪切任何计算机图形文本中的多边形的标准算法。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文