1

I have a VRML code I want to convert to X3D. The code should define spheres with different radius and colors to later instantiate by giving the coordinates as an argument.

First, I used an online converter suggested in another question, then opened it in blender to check it but it only displays one sphere instead of the 4 it's supposed to. I compared it with other similar examples found by googling and I don't see any difference or clue as to why it does this. I've tried changing some fields so it looks more like the examples: field accessType to initializeOnly, the information inside <X3D ...> to 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". I also tried placing <Shape> inside <children> like in VRML but in all cases it displays just one sphere.

This is a simplified version of the VRML code I want to convert to 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

This is what I get from the converter:

<?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>
izxle
  • 386
  • 1
  • 3
  • 19

1 Answers1

0

Unfortunately, it looks like a bug in the Blender X3D importer, because the following shows four spheres (as expected) in the BS Contact viewer, yet only one sphere in 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>
wildpeaks
  • 7,273
  • 2
  • 30
  • 35