Heilan X3D Browser

Introductory X3D Tutorial

This is an extremely basic tutorial explaining how to create a rudimentary X3D scene. Ideally Heilan would have a fancy GUI-based 3d modeller/audio sequencer-type program to do this, but it doesn't, so you're stuck with editing the .x3d file by hand (I do eventually intend to create such a tool (to be called Heilan Composer), but it'll be a lot of work, so that's some way in the future).

This tutorial does not make use of any Heilan-specific features, so the resultant file should be compatible with any X3D browser you care to use.

  1. The first thing to do is open a text editor that lets you save to plain text. Anything will do really, but you might want to check out X3D-Edit. I don't use it myself (I prefer my text editors to be a bit more lightweight), but I believe it's the only X3D-specific editor out there so it's worth a look.
  2. Now create a new file (remembering to save it with the .x3d extension) and add the following:
    <?xml version='1.0' encoding='utf-8'?>
    <!DOCTYPE X3D>
    This is the basic template you want to start any X3D scenes from. The first line basically says that this is an XML file, and that it's saved in UTF-8 encoding (incidentally, when you save the file, make sure you save it as UTF-8 - I believe it's the most compatible text encoding). The second line simply says that this is an X3D file.
  3. Now add:
    <X3D profile='Immersive'>
    Before I explain what this means, I'll quickly go over basic XML syntax so you have a better idea what's going on (obviously, skip this bit if you already know it):
    • XML files are made up of elements. An element is basically the following:
      Basically, it's a name surrounded by angle brackets. Elements must have what's known as an end tag in order for the XML file to be considered well-formed. In the above example, the end tag is the forward-slash character (/). However, elements can also be heirarchical, and can contain other elements, in which case a different form of end tag is used:
      In this example, the second instance of ParentExample constitutes the end tag - anything that occurs between the two ParentExample tags is considered a child element of the ParentExample element.

      Elements can also have attributes:
      <Example exampleAttribute='some value'/>
      Where an attribute defines an aspect of the element that can be modified (we'll see how attributes are used in X3D later on).
    So the two X3D tags represent a parent element in the file, and essentially demarcate the actual X3D content of the file - all the child elements will define the X3D scene we're creating. The profile attribute is used to specify which subset of the X3D specification we're working with. There are a number of different profiles defined by the specification, but the most relevant three are probably the following:
    • Interchange: Encompasses basic 3d geometry description, but with no scope for interaction or sound.
    • Interactive: Encompasses the Interchange profile, and adds various interaction possibiities. No sound support.
    • Immersive: Encompasses the Interactive profile, and aims to describe 'immersive' virtual worlds (so includes sound support).
    Since sound is very important to Heilan, we're going to be using the Immersive profile (though I should point out that, at the time of writing, Heilan does not support the entire Immersive profile).
    The two Scene tags then delineate the actual 3d scene to be displayed.
  4. Now, to add something to the scene, add the following lines between the two Scene tags:
            <Transform translation='0 0 0'>
    The Shape tags tell the browser that we want to put a 3d shape in the scene, and the Box tag within them tells it that we want that shape to be a box shape. I'll come back to the Transform tags in a minute. Now, if you load this file in Heilan, you'll find that you get what appears to be a blank white screen. This is because we haven't assigned a colour to this box shape and it has defaulted to white, so it blends into the background. Try clicking with the left mouse button and dragging around and you'll see what I mean.
  5. To change the Box's colour, add the following lines above the <Box/> line in your .x3d file:
                        <Material diffuseColor='1 0 0'/>
    Here, the Appearance tags delineate any alterations we want to make to the Box's default appearance. We use a Material tag to alter the Box's colour. The diffuseColor attribute takes three values to define the amount of Red, Green and Blue in this colour, with each having a range of 0 to 1. As you can perhaps guess from the above, we've now made the Box red. If you run this file in Heilan, you should see something like the following:
    Basic Tutorial Red Box
  6. Now, back to the Transform tags. As you can perhaps infer from the name, Transform is used to transform its children tags. The most useful transformation is the translation operation. Translation essentially lets you move objects in the 3d scene. It takes three values, representing the amounts to move the object along the X (left-right), Y(up-down), and Z(in-out) axes respectively. Try altering the '0 0 0' values above to see how it works.
  7. This concludes the basic tutorial. I'll put up more tutorials in the future, but for now if you want to go further, why not check out the other things you can do with Transform, or try using a different type of geometry in place of Box. You could also try replacing the Material node with an ImageTexture. You can download a copy of the x3d file for this tutorial here.