评估从 C++ 中 max 导出的 3d 样条线程序

发布于 2024-12-18 07:32:41 字数 1456 浏览 2 评论 0原文

我的 C++ 程序需要访问在 3ds Max (2011) 中构建的 3D 样条线。 我找到了一个简单的 maxscript 可以导出这些样条线作为 XML 文件 - 示例如下:

<spline name='Line001' knots='5' closed='true'>
<knot x='-4.67297e-005' y='0.0' z='0.0'>
    <invec x='-0.000144482' y='-600.0' z='-1.52588e-005' />
    <outvec x='5.10227e-005' y='600.0' z='1.52588e-005' />
</knot>
<knot x='6.17511e-005' y='800.0' z='500.0'>
    <invec x='7.92357e-005' y='800.0' z='100.0' />
    <outvec x='4.42666e-005' y='800.0' z='900.0' />
</knot>
<knot x='-66.0574' y='1000.0' z='900.0'>
    <invec x='-66.0574' y='700.0' z='900.0' />
    <outvec x='-66.0573' y='1300.0' z='900.0' />
</knot>
<knot x='323.651' y='1300.0' z='4.57764e-005'>
    <invec x='323.651' y='1600.0' z='200.0' />
    <outvec x='323.651' y='1000.0' z='-200.0' />
</knot>
<knot x='-0.000152032' y='-700.0' z='-200.0'>
    <invec x='-0.00014329' y='-700.0' z='-400.0' />
    <outvec x='-0.000160774' y='-700.0' z='-1.52588e-005' />
</knot>
</spline>

我的问题是 - 在我的 C++ 程序中访问和评估此样条线的最简单(也是最轻量级)的方法是什么?我知道如何解析 XML 中的数据,但从那时起我就迷失了。我需要能够a)评估沿该3D样条线的点,并b)计算描述该点切线的向量(如果可能)。我知道有一些库可用于此类事情,但我不确定哪个是最合适的 - 特别是就上述格式而言(结,每个都有一个 invec 和 outvec)。

My C++ program requires access to 3D splines that have been constructed in 3ds Max (2011). I have found a simple maxscript that exports these splines as XML files - an example as follows:

<spline name='Line001' knots='5' closed='true'>
<knot x='-4.67297e-005' y='0.0' z='0.0'>
    <invec x='-0.000144482' y='-600.0' z='-1.52588e-005' />
    <outvec x='5.10227e-005' y='600.0' z='1.52588e-005' />
</knot>
<knot x='6.17511e-005' y='800.0' z='500.0'>
    <invec x='7.92357e-005' y='800.0' z='100.0' />
    <outvec x='4.42666e-005' y='800.0' z='900.0' />
</knot>
<knot x='-66.0574' y='1000.0' z='900.0'>
    <invec x='-66.0574' y='700.0' z='900.0' />
    <outvec x='-66.0573' y='1300.0' z='900.0' />
</knot>
<knot x='323.651' y='1300.0' z='4.57764e-005'>
    <invec x='323.651' y='1600.0' z='200.0' />
    <outvec x='323.651' y='1000.0' z='-200.0' />
</knot>
<knot x='-0.000152032' y='-700.0' z='-200.0'>
    <invec x='-0.00014329' y='-700.0' z='-400.0' />
    <outvec x='-0.000160774' y='-700.0' z='-1.52588e-005' />
</knot>
</spline>

My question is - what would be the simplest (and most lightweight) approach to accessing and evaluating this spline in my C++ program? I know how to parse the XML for the data but from then onwards I am currently lost. I need to be able to a) evaluate a point along this 3D spline and b) calculate a vector describing the tangent at this point (if possible). I understand there are libraries available for this sort of thing, but I'm unsure of which is most appropriate - particularly in terms of the format described above (knots, each with an invec and outvec).

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

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

发布评论

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

评论(1

jJeQQOZ5 2024-12-25 07:32:42

由于 3ds Max 已经在计算这些曲线,因此您可以按照您需要的分辨率将“烘焙”曲线导出到 XML,我猜这将是每帧一个点。

如果您更喜欢评估应用程序中的曲线,那么贝塞尔曲线(我猜这些是)非常容易计算,无需外部库的帮助。看看维基百科上的 De Casteljau 算法,特别是描述几何的部分解释,比公式更容易掌握。

Since 3ds Max is already computing these curves, you could export the 'baked' curves to XML at the resolution that you need them, which I'm guessing will be one point per frame.

If you prefer to evaluate the curves in your application, then Bézier curves (which I'm guessing these are) are pretty easy to compute without the help of an external library. Take a look at the De Casteljau's algorithm on Wikipedia, in particular the section that describes the geometric interpretation, which is a lot easier to grasp than the formulas.

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