|
The Arrow PROTO connects two
positions in space by a) a Cylinder
node or by b) a Cylinder and a
Cone forming an arrow.
Both, the start and end position as well as the geometric properties are
exposedFields, therefore you
can change them all dynamically.
EXTERNPROTO Arrow
[
exposedField SFVec3f From # 0 0 0
exposedField SFVec3f To # 0 1 0
exposedField SFFloat CapLength # .25
exposedField SFFloat CapRadius # .08
exposedField SFFloat LineRadius # .028
exposedField SFNode appearance # NULL
]
"Arrow.wrl#Arrow"
|
|
|
Explanation of the fields:
exposedField SFVec3f From 0 0 0
exposedField SFVec3f To 0 1 0
These are the start and end position of the arrow or cylinder. If
an arrow is created, it points from the position specified by
From to the position
specified by To.
exposedField SFFloat CapLength .25
exposedField SFFloat CapRadius .08
exposedField SFFloat LineRadius .028
These fields determine the geometric properties of the arrow. The arrow consists
of a line and a cap. The line is a Cylinder
that connects the position specified by the From
field and the beginning of the cap. The cap is a
Cone at the position specified by
the To field.
If you want the two positions be connected by a
Cylinder instead of an arrow,
set CapLength to zero. There's a
Switch node that disables the
geometry of the Cylinder. Similar, if you set
CapRadius
or LineRadius to zero,
a Switch node disables
the Cylinder or
Cone respectively.
exposedField SFNode appearance NULL
In my opinion the Arrow should work
like a Box or
IndexedFaceSet that can be
placed at the geometry field of
a Shape. But the
Arrow node must start its internal
scene graph with a Transform node,
which is not allowed at this place. Therefore you have to specify the
Appearance node at the
appearance field of the
Arrow node.
The Demo:
This demo consists of three parts: On the left you have six
sliders that
let you modify the start and end points of the arrow shown in the center. On the
right there are three sliders that let you modifiy the
CapLength,
CapRadius and
LineRadius geometric properties.
The center of the screen shows the Arrow
in a color cube. You see the cube from inside though you are outside the cube.
As a side effect this demo not only demonstrates the use of the
Arrow PROTO but also demonstrates
the effects of the diffuseColor
and emissiveColor fields on an
Appearance node.
The sliders for the From position
also specify the diffuseColor
and the sliders for the To position
also specify the emissiveColor of
the arrow.
__.-.__ end of document
|