我有一个想要转换为X3D的VRML代码。代码应定义具有不同半径和颜色的球体,以便稍后通过将坐标作为参数进行实例化。
首先,我使用online converter中建议的another question,然后在搅拌机中打开它来检查它,但它只显示一个球体而不是它应该的4个球体。我将它与谷歌搜索发现的其他类似例子进行了比较,我没有看到为什么会这样做有任何区别或线索。我尝试更改某些字段,使其看起来更像是示例:field accessType
到initializeOnly
,<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>
答案 0 :(得分:0)
不幸的是,它看起来像是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>