In this exercise you will build a 3D volume filled with vectors (arrows). Each vector will point in a different direction and have a different color.
In visualization, vector fields are often used to indicate the flow of a fluid through a volume. Each arrow indicates the direction and magnitude of the flow at a point in the volume. To show changes in the fluid flow, the vector field is animated, causing the vectors to change direction, length, and color.
This exercise focuses upon use of IndexedFaceSet and Coordinate nodes and the PROTO syntax.
In "vector1.wrl", build a flat arrow-shape using an IndexedFaceSet geometry node. Make the arrow conform to the following specifications:
| Parameter | Dimension |
| total vector height | 1.0 |
| body width | 0.2 |
| body height | 0.75 |
| tip width | 0.5 |
| tip height | 0.25 |
| origin | center base of arrow body |
HINT: Build the tip with one triangle and the base with one rectangle.
HINT: Remember, use a "-1" index value to delimit faces.
| Field | Value |
| ambientIntensity | 0.0 |
| diffuseColor | 0.8 0.8 0.8 |
| emissiveColor | 0.0 0.0 0.0 |
SOLUTION: vector1.wrl
SOLUTION: vector2.wrl
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 "vector3.wrl" file to create a Vector node. Add a PROTO wrapper around the vector shape. Make sure that it conforms to the following specifications:
| Data Type | Field Name | Default Value |
| SFVec3f | translation | 0.0 0.0 0.0 |
| SFVec3f | scale | 1.0 1.0 1.0 |
| SFRotation | rotation | 0.0 1.0 0.0 0.0 |
| SFColor | color | 0.8 0.8 0.8 |
HINT: Connect the translation, rotation, scale, and color fields of the PROTO interface to your vector shape using the IS syntax.
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.
SOLUTION: vector3.wrl
Load "vecfld1.wrl". This file contains an EXTERNPROTO that looks in your "vector.wrl" file and loads your Vector node PROTO. The vector field file then uses your node to create a 3D block of arrows, all pointing in different directions.
SOLUTION: vecfld1.wrl