2017-10-09 40 views
1

我有一個VRML代碼,我想轉換爲X3D。代碼應該定義具有不同半徑和顏色的球體,以便通過將座標作爲參數進行實例化。X3D:從VRML轉換成PROTO不起作用

首先,我使用another question中建議的online converter,然後在攪拌機中打開它來檢查它,但它只顯示一個球體而不是它應該顯示的四個球體。我將其與Google搜索中發現的其他類似示例進行了比較,我沒有看到任何區別或線索,爲什麼它會這樣做。我試過改變一些字段,所以它看起來更像是例子: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中一樣,但是在所有情況下它只顯示一個球體。

這是VRML代碼的簡化版本,我想轉換到X3D:

#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/> 
    <Copper xyz='0 1.8 1.8'/> 
    <Copper xyz='1.8 0 1.8'/> 
    <Copper xyz='1.8 1.8 0'/> 
    </Scene> 
</X3D> 

回答

0

不幸的是,它看起來像一個bug在Blender X3D導入器中,因爲以下顯示了BS Contact viewer中的四個球體(如預期的那樣),但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>