How to Build X3D Graphics With Textures

Using 2D image textures mapped to 3D geometries brings greater realism to 3D graphics. X3D has five node types, which allows for basic texture mapping: Background, ImageTexture, MovieTexture, MultiTexture, and PixelTexture in the core profile. Advance texture mapping components are supported in the advanced X3D profiles such as 3D textures, Multi-Texturing, Image Shaders, and Cube mapping.

Things You'll Need

  • X3D-Edit or other X3D content authoring tool
  • X3D viewing web browser plug-in or stand alone player
  • Internet access
Show More

Instructions

    • 1

      Decide what piece of geometry is going to have the 2D texture applied in the X3D scene and add an Appearance tag as a child in the scene. The Appearance node should have a DEF name applied in order to allow repeatability throughout the X3D scene. In the example scene, the shape that will have the defined Appearance node applied to it will be a box.

      <Scene>
      <Background skyColor='1 1 1'/>
      <Transform translation='-5 0 0'>
      <Shape DEF='DefaultShape'>
      <Box DEF='DefaultBox'/>
      <Appearance DEF='DefaultAppearance'>

    • 2

      Add a Material node as a child of the Appearance node from Step 1. The diffuse value of the Material node should be modified in the event the ImageTexture fails to load on the client web browser, preventing the default color of grey from being applied to the 3D geometry.

      <Material diffuseColor='1 0.2 0.2'/>

    • 3

      Add an ImageTexture node as another child to the Appearance node. The ImageTexture node requires a Uniform Resource Locator (URL) in order to access an Image to download for use in the X3D scene. Multiple URLs can be provided in order to provide for maximum redundancy in the scene, starting with file paths that may be found on the local computer first. If the image fails to load or is slow to load, the defined Material color will be displayed until the image loads. Adding multiple URLs does not slow the speed of loading the 3D world.

      <ImageTexture DEF='earth-topo'
      url=' "../Chapter01-TechnicalOverview/earth-topo.png" "../Chapter01-TechnicalOverview/earth-topo.jpg" "../Chapter01-TechnicalOverview/earth-topo-small.gif" "http://www.web3d.org/x3d/content/examples/Basic/earth-topo.png" "http://www.web3d.org/x3d/content/examples/Basic/earth-topo.jpg" "http://www.web3d.org/x3d/content/examples/Basic/earth-topo-small.gif" '/>
      </Appearance>
      </Shape>
      </Transform>

    • 4

      Reuse the defined Appearance node on other desired geometries in the scene. The difference in the reuse of the ImageTexture defined in Step 3 is that the USE field is employed referencing the DEF name previously defined for the node. The pattern is then reused for other geometries in the scene.
      <Transform translation='-2.5 0 0'>
      <Shape>
      <Cone DEF='DefaultCone'/>
      <Appearance>
      <Material diffuseColor='0.2 1 0.2'/>
      <ImageTexture USE='earth-topo'/>
      </Appearance>
      </Shape>
      </Transform>

    • 5

      Reuse the ImageTexture definition for other geometries in the example scene. The first shape applies the earth-topo ImageTexture definition to a cylinder shape. The second applies the same ImageTexture to a sphere. The authors chose to apply a rotation at the Transform node of the sphere to spin the Earth to see North America.
      <Transform>
      <Shape>
      <Cylinder DEF='DefaultCylinder'/>
      <Appearance>
      <Material diffuseColor='0.2 0.2 1'/>
      <ImageTexture USE='earth-topo'/>
      </Appearance>
      </Shape>
      </Transform>

      <Transform rotation='0 1 0 -1.57' translation='2.5 0 0'>
      <Shape>
      <Sphere DEF='DefaultSphere'/>
      <Appearance>
      <Material diffuseColor='1 1 0.2'/>
      <ImageTexture USE='earth-topo'/>
      </Appearance>
      </Shape>
      </Transform>

    • 6

      View the scene in an X3D browser.

Tips & Warnings

  • The ImageTexture node retrieves a 2D Image and uses it as a texture for the intended geometry. JPG and PNG are the only guaranteed 2D Image types to be supported when authoring X3D worlds. Once you have successfully recreated scenes using 2D image textures, use the PixelTexture generator java program provided by the SAVAGE research group of the MOVES Institute at the Naval Postgraduate School if you need to minimize file redundancy of your X3D scene.

  • GIF 2D Image files may not be universally supported when authoring X3D. It is recommended to convert the GIF file to JPG or PNG , which are required to be supported by the X3D Specification. Read the X3D specification on 2D texture mapping and axis to verify how the 2D image will be mapped to the 3D geometry.

Related Searches:

Resources

Comments

You May Also Like

Related Ads

Featured