【问题标题】:How to allow 180 degree angles in X3DOM IndexedFaceSet如何在 X3DOM IndexedFaceSet 中允许 180 度角
【发布时间】:2019-10-18 13:57:46
【问题描述】:

我正在尝试在 X3DOM 中制作一个简单的平面 2D 形状,但由于坐标是自动生成的,其中一些坐标在直线上,在这种情况下 X3DOM 似乎失败了。下面是一个简单的例子。我在这里做错了什么?

<X3D width='800px' height='600px'>
<Scene>
<Viewpoint description='Front view' orientation='0 1 0 1.57' position='8 0 0'/> 
<Shape DEF='Front'>
<IndexedFaceSet coordIndex='0 1 2 3' solid='false', convex='false'>
<Coordinate DEF='Points' point='
1 1 1
1 1 2
1 1 3
1 1 4
2 1 4
2 1 3
2 1 2
2 1 1
1 1 1'/> 
</IndexedFaceSet>
<Appearance>
<Material diffuseColor="0 0 1" specularColor=".5 .5 .5" DEF="edgecolour" />
</Appearance>

</Shape> </Scene>
</X3D> 

如果我剪掉中间的 4 个点(1 1 3、1 1 4、2 1 4、2 1 3),这可以正常工作,但我无法在我的脚本中轻松更改它(实际形状更多复杂)

【问题讨论】:

    标签: x3dom


    【解决方案1】:

    首先,您发布的 x3d sn-p 格式错误:

    <IndexedFaceSet coordIndex='0 1 2 3' solid='false', convex='false'>
                                                      ^
    

    第二,你的IndexedFaceSet只使用Coordinate节点的前4个坐标:

    coordIndex='0 1 2 3'
    

    而前4个点只画了一条直线,它作为一个面是不可见的(面积为0,没有可渲染的东西)。只有 Z 变化:

    1 1 1
    1 1 2
    1 1 3
    1 1 4
    

    但是在将所有点添加到IndexedFaceSetcoordIndex 并将convex 设置为true 之后,我的X3D 查看器能够渲染一个蓝色矩形:

    <?xml version="1.0" encoding="UTF-8"?>
    <X3D>
        <Scene>
            <Viewpoint description='Front view' orientation='0 1 0 1.57' position='8 0 0'/> 
            <Shape DEF='Front'>
                <IndexedFaceSet coordIndex='0 1 2 3 4 5 6 7' solid='false' convex='true'>
                    <Coordinate DEF='Points' point='
                    1 1 1
                    1 1 2
                    1 1 3
                    1 1 4
                    2 1 4
                    2 1 3
                    2 1 2
                    2 1 1
                    1 1 1'/> 
                </IndexedFaceSet>
                <Appearance>
                    <Material diffuseColor="0 0 1" specularColor=".5 .5 .5" DEF="edgecolour" />
                </Appearance>
            </Shape>
        </Scene>
    </X3D>
    

    希望有帮助:)

    【讨论】:

    • 但您可能需要检查脚本中的 coordIndex 生成情况
    猜你喜欢
    • 2016-09-15
    • 2015-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-20
    • 1970-01-01
    相关资源
    最近更新 更多