在C ++程序中评估从max导出的3d样条曲线 [英] Evaluating 3d splines exported from max in a C++ program

查看:98
本文介绍了在C ++程序中评估从max导出的3d样条曲线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的C ++程序需要访问3ds Max(2011)中构造的3D样条曲线. 我已经找到了导出这些样条的简单maxscript 作为XML文件-示例如下:

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>

我的问题是-在我的C ++程序中访问和评估该样条线的最简单(最轻便)的方法是什么?我知道如何解析XML的数据,但是从那时起,我现在迷路了.我需要能够 a)评估沿着该3D样条线的点,并 b)计算一个描述此点切线的矢量(如果可能).我知道可以使用这种库,但是我不确定哪种库最合适-特别是上述格式的(结,每个结都有invec和outvec).

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).

推荐答案

由于3ds Max已经在计算这些曲线,因此您可以按照所需的分辨率将烘焙的"曲线导出到XML,我想这会每帧一个点.

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.

如果您希望在应用程序中评估曲线,那么贝塞尔曲线(我猜是这样)很容易在没有外部库帮助的情况下进行计算.看一下Wikipedia上的 De Casteljau的算法,特别是描述几何的部分解释,比公式更容易掌握.

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.

这篇关于在C ++程序中评估从max导出的3d样条曲线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆