Vector Field


VRML Concepts



  1. Create and edit a new VRML file:

    In the file, build an arrow-shape using an IndexedFaceSet geometry node. Make the arrow conform to the following specifications:

    SOLUTION: vector1.wrl

  2. Make a copy of the "vector1.wrl" file:

    To build a vector field you're going to need dozens of arrows, all with approximately the same shape. Wouldn't it be nice if there was a Vector node? Your task is to modify the vector2.wrl file to create a Vector node. Add a PROTO wrapper around the vector shape. Make sure that it conforms to the following specifications:

    You can test your new Vector node by temporarily adding a line to the end of your file, like this:

    Try adding translation, scale, rotation, and color fields and values to your Vector node test. Remember to get rid of this test node before you move on to the next task.

    SOLUTION: vector2.wrl

  3. Compile and run the vecfield program, and view the resulting VRML scene (call it vecfield.wrl).

    The program generates a volume of vectors, each one positioned, oriented, scaled, and colored based upon a function the program computes. Each vector is rendered by using your Vector node! The program's "vecfield.wrl" output uses your Vector node by using an EXTERNPROTO statement at the top of the file. That statement tells the browser to get your Vector PROTO from your file "vector2.wrl".

    SOLUTION: vecfield.c, vecfield.wrl

  4. Extra credit: Run the vecfield program 10 times providing a phase argument, redirecting the output into corresponding VRML files:

    INTERMEDIATE SOLUTION: vecfld1.wrl, vecfld2.wrl, vecfld3.wrl, vecfld4.wrl, vecfld5.wrl, vecfld6.wrl, vecfld7.wrl, vecfld8.wrl, vecfld9.wrl, vecfld10.wrl

    Don't bother viewing each of the individual VRML files. Your task is to build an animation that automatically cycles between these 10 files, treating each one like a "frame" in an animation sequence.

    Create and edit a new VRML file:

    In this new VRML file, use a grouping node to switch between the 10 vector fields, each one inlined from its own file.

    To animate the switch you'll need to build a new interpolator using your own script. You'll need a Script node and the usual TimeSensor node. For the script, you'll need a fractional time input and an SFInt32 output. On each fractional time input event (varying from 0.0 to 1.0), generate an integer output event (varying from 0 to 10). Route that integer event into the whichChoice field of the switch.

    View the resulting "multivec.wrl" VRML scene. Be patient: it takes a while to load.

    SOLUTION: multivec.wrl