DEF/USE
Flux Studio 101 ] Begin ] Box Cyl Cone ] Pyramid ] Sculpted Surface Vase ] Revolution ] Square One ] Basics ] [ DEF/USE ] Colors ] Textured Box ] Sounds ] Anchor ] InLines ] Easy Animation ] Background ] A painting? ] Bath Tub ] Glossary ]

 

What is DEF/USE?

The VRML specification (or the spec as we lovingly call it) says this about DEF/USE...

"A node given a name using the DEF keyword may be referenced by name later in the same file with USE or ROUTE statements. The USE statement does not create a copy of the node. Instead, the same node is inserted into the scene graph a second time, resulting in the node having multiple parents. Using an instance of a node multiple times is called instantiation."

OK, what does that all mean? Mostly it means that you DEFine the geometry once, then you can USE many times.  So that means that the geometry (all those silly numbers that define the shape) for an object gets placed in your output file once, but is referred to many times. Hence...a smaller sized final file! It also means that you can change to color or texture of the "master" object once and all the references are also changed.


OK, in Flux Studio it is called REFerence (meaning that another node is referenced or referred to).

How do you to use it?

  1. Select the Object
  2. Select the Copy button
  3. Select the REFrence button
  4. Place the geometry where you want  it to be replicated

 

box_ref_tree.jpg (29572 bytes)def_use_numb.jpg (146431 bytes)

In the simplified example below, notice how much code was required for the first instance of the box. Then notice how much code there is for the second box!

#VRML V2.0 utf8
WorldInfo { title "Flux Studio" }
    DEF dad_Box1 Transform {
     translation -2.0341 0.02352 0.0
     children [
      DEF Box1 Shape {
       appearance Appearance {
        material DEF Red_mat Material {
         ambientIntensity 0.200
         shininess 0.200
         diffuseColor 1.0 0.0 0.0     }
       }
       geometry IndexedFaceSet {
        solid TRUE
        creaseAngle 0.524
        coord Coordinate {
         point [
          -0.50000 0.50000 -0.50000
          -0.50000 0.50000 0.50000
          0.50000 0.50000 0.50000
          0.50000 0.50000 -0.50000
          -0.50000 -0.50000 0.50000
          0.50000 -0.50000 0.50000
          0.50000 -0.50000 -0.50000
          -0.50000 -0.50000 -0.50000    ]
        }
        coordIndex [
          0 1 2 -1 
          0 2 3 -1 
          1 4 5 -1 
          1 5 2 -1 
          2 5 6 -1 
          2 6 3 -1 
          3 6 7 -1 
          3 7 0 -1 
          0 7 4 -1 
          0 4 1 -1 
          5 4 7 -1 
          5 7 6 -1  ]
       }
      }
     ]
    }
    DEF dad_Reference1 Transform {
     translation 1.96355 -0.02352 0.0
     children [   USE Box1     ]
    }
   ]
  }        

Think of making a model of the Parthenon (with 108 identical columns) and how much smaller the file would be if you use DEF/USE than if you don't. You can also DEF/USE material nodes (colors or textures). Additionally, you can make a group and put an animation in it and then DEF/USE the whole group elsewhere saving lots of space because you only have the geometry, material, and animation in the file once. This is what we mean when we talk about optimization.

You need a VRML plug-in to see this content!

This example of a Flower is a 4KB file that uses all of the above techniques.

Back ] Home ] Up ] Next ]