【问题标题】:X3D: PROTO converted from VRML not workingX3D:从 VRML 转换的 PROTO 不起作用
【发布时间】:2018-05-17 01:22:53
【问题描述】:

我有一个 VRML 代码要转换为 X3D。代码应定义具有不同半径和颜色的球体,以便稍后通过将坐标作为参数进行实例化。

首先,我使用了another question 中建议的online converter,然后在搅拌机中打开它进行检查,但它只显示一个球体而不是它应该显示的 4 个球体。我将它与通过谷歌搜索发现的其他类似示例进行了比较,我看不出它为什么这样做有任何区别或线索。我尝试更改一些字段,使其看起来更像示例:field accessTypeinitializeOnly<X3D ...> 中的信息到 profile="Interchange" version="3.2" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="http://www.web3d.org/specifications/x3d-3.2.xsd"。我还尝试将<Shape> 放在<children> 中,就像在 VRML 中一样,但在所有情况下它都只显示一个球体。

这是我要转换为 x3d 的 VRML 代码的简化版本:

#VRML 2.0 utf8
PROTO Copper [ exposedField SFVec3f xyz 0 0 0 ] {
  Transform {
    translation IS xyz
    children [
      Shape {
        appearance Appearance {
          material Material { diffuseColor 0.78 0.5 0.2 }
        }
        geometry Sphere { radius 1.32 }
      }
    ]
  }
}
Copper { xyz 0.0 0.0 0.0 } # 0
Copper { xyz 0.0 1.8 1.8 } # 1
Copper { xyz 1.8 0.0 1.8 } # 2
Copper { xyz 1.8 1.8 0.0 } # 3

这是我从转换器得到的:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' profile='Full' version='3.0' xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.0.xsd'>
  <Scene DEF='scene'>
    <ProtoDeclare name='Copper'>
      <ProtoInterface>
        <field accessType='inputOutput' name='xyz' type='SFVec3f' value='0 0 0'/>
          </ProtoInterface>
          <ProtoBody>
        <Transform>
          <Shape>
            <Appearance>
              <Material diffuseColor='0.78 0.5 0.2'/>
            </Appearance>
            <Sphere radius='1.32'/>
          </Shape>
          <IS>
            <connect nodeField='translation' protoField='xyz'/>
          </IS>
        </Transform>
      </ProtoBody>
    </ProtoDeclare>
    <Copper xyz='0.0 0.0 0.0'/>
    <Copper xyz='0.0 1.8 1.8'/>
    <Copper xyz='1.8 0.0 1.8'/>
    <Copper xyz='1.8 1.8 0.0'/>
  </Scene>
</X3D>

【问题讨论】:

    标签: x3d vrml


    【解决方案1】:

    不幸的是,它看起来像是 Blender X3D 导入器中的一个错误,因为下图在 BS Contact 查看器中显示了四个球体(如预期的那样),但在 Blender 中只有一个球体:

    <?xml version="1.0" encoding="UTF-8"?>
    <X3D profile="Immersive" version="3.0">
        <Scene>
            <ProtoDeclare name="Copper">
                <ProtoInterface>
                    <field accessType="inputOutput" name="xyz" type="SFVec3f"/>
                </ProtoInterface>
                <ProtoBody>
                    <Transform translation='0 0 0'>
                        <Shape>
                            <Appearance>
                                <Material diffuseColor='0.78 0.5 0.2'/>
                            </Appearance>
                            <Sphere radius='1.32' />
                        </Shape>
                        <IS>
                            <connect nodeField="translation" protoField="xyz"/>
                        </IS>
                    </Transform>
                </ProtoBody>
            </ProtoDeclare>
            <Copper />
            <Copper xyz='0 1.8 1.8' />
            <Copper xyz='1.8 0 1.8' />
            <Copper xyz='1.8 1.8 0' />
        </Scene>
    </X3D>
    

    【讨论】:

      猜你喜欢
      • 2023-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-23
      相关资源
      最近更新 更多