NAME
view3d - create unit to provide an interactive 3d-view
PROTOTYPE
unitptr view3d( char *win, char *fmt, int argnum, unitptr* arglist, unitptr host)
ARGUMENTS
- char *win
- window description "title xll yll width height"
- char *fmt
- format string for coordinate frame
- int argnum
- number of elements in arglist
- unitptr* arglist
- array of pointers to argnum NST-units. Execution of these units is assumed to render the objects which are to be viewed.
- unitptr host
- host unit
RETURN VALUE:
- unitptr u
- ptr to created instance
INTERFACE OF CREATED UNIT:
- X_in[3]:
- center point (xc,yc,zc) of viewing
volume (default is (0,0,0)).
- Y_in[3]:
- size dx,dy,dz of viewing volume
(default is 1,1,1, i.e. unit cube).
- Z_in[3]:
- eye point (vx,vy,vz)
- in_3[3]:
- size dxw,dyw,dzw of display cube to
which view volume is mapped (default is
(1,1,1)).
- in_4[3]:
- scaling of x-axis: xsteps,tx,dtx
- in_5[3]:
- scaling of y-axis: ysteps,ty,dty
- in_6[3]:
- scaling of z-axis: zsteps,tz,dtz
- in_7[3]:
- currently not used
- in_8[3]:
- currently not used
- in_9[3]:
- CTL-input pin[0]=0 for interactive
operation (default), pin[0]>0 for non-
blocking mode. pin[1..2]: rotation
angles rx,ry (in degrees) to be used
for initial view (default=(0,0)).
- X_out[2]:
- current mouse position (in pixels, with
respect to lower left corner of window)
- Y_out[3]:
- 1,rx,ry a constant value and x-rotation
and z-rotation angle (in tenths of
degree) used for current view (this
field can be connected to CTL_in of
another view3d-unit ("slave", if it is
desired to synchronize two views). The
second unit must then appear as a member
in the view list viewlist[] of the first
view, which acts as the controlling
"master" of the second "slave".
DESCRIPTION:
Creates a unit that works in conjunction with a set of drawing
units specified by the viewel unitptr's in array viewlist[].
The units viewlist[0..viewel-1] are expected to
render the objects which are to be viewed. Creation of the
present unit then opens the necessary viewing window, and
execution provides the necessary coordinate transformations
and interactive, mouse driven view control to view the
objects rendered by executing the sequence of units in
viewlist (the user need not care about the execution of the
specified units in viewlist; this is also done under the
control of the present unit).
Creation of the present unit opens a window (title, location
and size described in string win) that provides a 3d-view
onto a space volume that is specified by the values at the
input pins of this unit. If the initial default view is
used, the window provides a perpendicular view onto the
xz-plane with the eypoint a distance of 10 units along the
negative y-direction away from the point (xc,yc,zc). The
positive z-direction points upward, and the positive
x-direction leftward.
Execution of the unit can be in two modes, depending on the
value of CTL_in[0]. If CTL_in[0]>0, the scene is rendered
once and execution terminates. If CTL_in[0]==0, ("interactive
mode", the default), execution starts an interactive loop
that continuously calls the sequence of drawing units specified
in viewlist in order to render the objects to be
viewed. As long as this loop is active, the mouse may be
used to change the view direction onto the viewed volume
(this requires to keep the middle mouse button pressed).
The current mouse and rotation parameters are continuously
updated at output fields X_out and Y_out [they may be
accessed by the units in viewlist to change the appearance
of the displayed objects]. The loop is terminated by press-
ing the right mouse button, after which the execution of the
present unit ends.
The center (xc,yc,zc) and the size (dx,dy,dz) of the viewed
volume and additional view parameters can be specified at
the input fields of the unit [default values are provided].
If fmt contains the toke %cF with c=0,1,2,3 or 4,
a three dimensional, cartesian coordinate
frame is displayed together with the viewed objects, and
optional axis scalings and labels are displayed according to
the values specified at input fields in_4..6. Depending
on the value of c, only a tripod (c=1), a tripod with a
base square (c=1), a corner (c=2) or a full cube
(c=3) is drawn.
Each of the three input fields in_4..6 specifies for one of
the three axis directions how tick marks and labels are set.
If isteps=0 (i=x,y or z), tick marks and labels are set
automatically for axis direction i (this is the default).
For isteps>0 and dti>0, marked labels, separated by isteps
subintervals of length dti are displayed. and one labelled
tick mark will be attached to axis value ti. In this case,
the number of labelled tick marks is controlled by the value
specified for dti and isteps.
Finally, if dti=0, labeling for axis i will be supressed.
(this specification is the same as for unit frame3d).
This unit has the special feature of becoming "invisible" in
the exec-queue of its host unit during the time of its (i.e.
the view3d- unit's execution. This allows its host unit to be
a member of the view list viewlist[] without causing an
infinite recursion (if a view3d- unit has its host unit on
its viewlist[], the effect will be to display all remaining
members of this host unit (i.e. with the view3d- unit
excluded) in the window of the view3d-unit. This is the
general method by which composite viewing units can be
conveniently encapsulated in NST).
SEE ALSO:
make_mesh, frame3d
EXAMPLES:
The program fview.c shows a simple use of the view3d-unit to
view the images rendered by one or several make_mesh-units.
The program logo.c shows how an input_window- unit can be a
member of the view list of a view3d- unit to allow
interactive control of changes to the viewed objects.
The program xor.c shows how several view3d -units can be
linked together with one view3d- unit acting as "master view"
that controls the remaining "slave views" and how an
input_window- unit embedded in the viewing loop can interact
with the associated view3d-unit and the other viewing loop
members.
The program somdemo.c shows how repeated exec_unit and
adapt_unit- calls of a set of units can be embedded in the
viewing loop of a view3d- unit.
FILE
/homes/jontrup/nst5/man/../o.sol2//../foldersrc/nst_solid.c