0

我有一个通过 JAXB 输出 X3D 文件的 java 程序。这是当前的输出。

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<X3D version="1.0" profile="Full">
    <head>
        <meta name="Sim3DAnimator" content="jaxbtext.x3d"/>
    </head>
    <Scene>
        <WorldInfo info="by Patrick R. Aquilone" title="Testing Simu 3D Animator"/>
        <DirectionalLight ambientIntensity="1.0" intensity="1.0"/>
        <Viewpoint orientation="0.0 0.0 0.0 90.0" position="0.0 10.0 100.0" description="SIM3D"/>
        <Transform>
            <Transform scale="1 1 1" translation="0.000000 0.000000 0.000000" DEF="person">
                <Transform rotation="0 1 0 0.000000">
                    <Transform rotation="0 0 1 0.000000">
                        <Transform rotation="1 0 0 0.000000">
                            <Transform>
                                <MetadataString value="test"/>
                                <Transform scale="1 1 1" translation="0.000000 25.200000 0.000000">
                                    <Shape>
                                        <Sphere radius="8.0"/>
                                        <Appearance>
                                            <Material ambientIntensity="0.5" diffuseColor="0.500000 0.500000 0.500000"/>
                                        </Appearance>
                                    </Shape>
                                </Transform>
                                <Transform rotation="0 0 1 1.570800" scale="1 1 1" translation="0.000000 13.200000 0.000000">
                                    <Shape>
                                        <Cylinder height="16.0" radius="1.0"/>
                                        <Appearance>
                                            <Material ambientIntensity="0.5" diffuseColor="0.500000 0.500000 0.500000"/>
                                        </Appearance>
                                    </Shape>
                                </Transform>
                                <Transform scale="1 1 1" translation="0.000000 13.200000 0.000000">
                                    <Shape>
                                        <Cylinder height="16.0" radius="1.0"/>
                                        <Appearance>
                                            <Material ambientIntensity="0.5" diffuseColor="0.500000 0.500000 0.500000"/>
                                        </Appearance>
                                    </Shape>
                                </Transform>
                                <Transform scale="1 1 1" translation="9.600000 3.000000 0.000000">
                                    <MetadataString value="test-right-arm"/>
                                    <Transform translation="0.000000 10.500000 0.000000">
                                        <Shape>
                                            <Appearance>
                                                <Material ambientIntensity="0.5" diffuseColor="0.500000 0.500000 0.500000"/>
                                            </Appearance>
                                            <Sphere radius="2.5"/>
                                        </Shape>
                                    </Transform>
                                    <Transform translation="0.000000 0.000000 0.000000">
                                        <Shape>
                                            <Appearance>
                                                <Material ambientIntensity="0.5" diffuseColor="0.500000 0.500000 0.500000"/>
                                            </Appearance>
                                            <Cylinder height="21.0" radius="2.5"/>
                                        </Shape>
                                    </Transform>
                                    <Transform translation="0.000000 -10.500000 0.000000">
                                        <Shape>
                                            <Appearance>
                                                <Material ambientIntensity="0.5" diffuseColor="0.500000 0.500000 0.500000"/>
                                            </Appearance>
                                            <Sphere radius="2.5"/>
                                        </Shape>
                                    </Transform>
                                </Transform>
                                <Transform scale="1 1 1" translation="-9.600000 3.000000 0.000000">
                                    <MetadataString value="test-left-arm"/>
                                    <Transform translation="0.000000 10.500000 0.000000">
                                        <Shape>
                                            <Appearance>
                                                <Material ambientIntensity="0.5" diffuseColor="0.500000 0.500000 0.500000"/>
                                            </Appearance>
                                            <Sphere radius="2.5"/>
                                        </Shape>
                                    </Transform>
                                    <Transform translation="0.000000 0.000000 0.000000">
                                        <Shape>
                                            <Appearance>
                                                <Material ambientIntensity="0.5" diffuseColor="0.500000 0.500000 0.500000"/>
                                            </Appearance>
                                            <Cylinder height="21.0" radius="2.5"/>
                                        </Shape>
                                    </Transform>
                                    <Transform translation="0.000000 -10.500000 0.000000">
                                        <Shape>
                                            <Appearance>
                                                <Material ambientIntensity="0.5" diffuseColor="0.500000 0.500000 0.500000"/>
                                            </Appearance>
                                            <Sphere radius="2.5"/>
                                        </Shape>
                                    </Transform>
                                </Transform>
                                <Transform scale="1 1 1" translation="5.000000 -24.000000 0.000000">
                                    <MetadataString value="test-right-leg"/>
                                    <Transform translation="0.000000 10.500000 0.000000">
                                        <Shape>
                                            <Appearance>
                                                <Material ambientIntensity="0.5" diffuseColor="0.500000 0.500000 0.500000"/>
                                            </Appearance>
                                            <Sphere radius="2.5"/>
                                        </Shape>
                                    </Transform>
                                    <Transform translation="0.000000 0.000000 0.000000">
                                        <Shape>
                                            <Appearance>
                                                <Material ambientIntensity="0.5" diffuseColor="0.500000 0.500000 0.500000"/>
                                            </Appearance>
                                            <Cylinder height="21.0" radius="2.5"/>
                                        </Shape>
                                    </Transform>
                                    <Transform translation="0.000000 -10.500000 0.000000">
                                        <Shape>
                                            <Appearance>
                                                <Material ambientIntensity="0.5" diffuseColor="0.500000 0.500000 0.500000"/>
                                            </Appearance>
                                            <Sphere radius="2.5"/>
                                        </Shape>
                                    </Transform>
                                </Transform>
                                <Transform scale="1 1 1" translation="-5.000000 -24.000000 0.000000">
                                    <MetadataString value="test-left-leg"/>
                                    <Transform translation="0.000000 10.500000 0.000000">
                                        <Shape>
                                            <Appearance>
                                                <Material ambientIntensity="0.5" diffuseColor="0.500000 0.500000 0.500000"/>
                                            </Appearance>
                                            <Sphere radius="2.5"/>
                                        </Shape>
                                    </Transform>
                                    <Transform translation="0.000000 0.000000 0.000000">
                                        <Shape>
                                            <Appearance>
                                                <Material ambientIntensity="0.5" diffuseColor="0.500000 0.500000 0.500000"/>
                                            </Appearance>
                                            <Cylinder height="21.0" radius="2.5"/>
                                        </Shape>
                                    </Transform>
                                    <Transform translation="0.000000 -10.500000 0.000000">
                                        <Shape>
                                            <Appearance>
                                                <Material ambientIntensity="0.5" diffuseColor="0.500000 0.500000 0.500000"/>
                                            </Appearance>
                                            <Sphere radius="2.5"/>
                                        </Shape>
                                    </Transform>
                                </Transform>
                                <Transform scale="1 1 1" translation="0.000000 0.000000 0.000000">
                                    <MetadataString value="test-torso"/>
                                    <Transform translation="0.000000 12.000000 0.000000">
                                        <Shape>
                                            <Appearance>
                                                <Material ambientIntensity="0.5" diffuseColor="0.500000 0.500000 0.500000"/>
                                            </Appearance>
                                            <Sphere radius="5.0"/>
                                        </Shape>
                                    </Transform>
                                    <Transform translation="0.000000 0.000000 0.000000">
                                        <Shape>
                                            <Appearance>
                                                <Material ambientIntensity="0.5" diffuseColor="0.500000 0.500000 0.500000"/>
                                            </Appearance>
                                            <Cylinder height="24.0" radius="5.0"/>
                                        </Shape>
                                    </Transform>
                                    <Transform translation="0.000000 -12.000000 0.000000">
                                        <Shape>
                                            <Appearance>
                                                <Material ambientIntensity="0.5" diffuseColor="0.500000 0.500000 0.500000"/>
                                            </Appearance>
                                            <Sphere radius="5.0"/>
                                        </Shape>
                                    </Transform>
                                </Transform>
                            </Transform>
                        </Transform>
                    </Transform>
                </Transform>
                <PositionInterpolator keyValue="   0   0   0  10   0   0  20   0   0  30   0   0  40   0   0  50   0   0  60   0   0  70   0   0  80   0   0  90   0   0 100   0   0  90   0   0  80   0   0  70   0   0  60   0   0  50   0   0  40   0   0  30   0   0  20   0   0  10   0   0" key="  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19" DEF="person-position"/>
                <TimeSensor cycleInterval="1.0" loop="true" DEF="person-time"/>
                <ROUTE fromNode="person-time" fromField="fraction_changed" toNode="person-position" toField="set_fraction"/>
                <ROUTE fromNode="person-position" fromField="value_changed" toNode="person" toField="set_translation"/>
            </Transform>
        </Transform>
    </Scene>
</X3D>

我的问题是您可以看到插值占 20 个点,但是当它运行时它只运行其中的一半,然后又回到开头。我不明白为什么它会在第 10 个间隔停止。我知道我错过了什么,但是什么?

顺便说一句,我是新来的,所以你看到我可以修复的任何东西,请继续让我知道。

提前致谢。

4

1 回答 1

0

fraction_changed输出介于 0 和 1 之间的值。PositionInterpolator 的具有从 0 到 20 的整数值。这意味着每当 TimeSensor 开始/结束时,只有第一个 (0) 和第二个 (1) 值将处于活动状态。基本上,您的转换将交替转换为 (0,0,0) 5 次和 (10, 0, 0) 5 次。

要实现您想要的,您必须将键数组更改为:key [0 0.05 0.10 0.15 .... 0.95 1]

或将person-time.time路由到 person-position.set_fraction。这将遍历所有键值一次。

它应该以这种方式工作。

于 2013-06-21T15:05:55.690 回答