NAME
camera_unit -- view scene from simulated camera
PROTOTYPE
unitptr camera_unit( int iOperands, char *pcWindow, char *pcFmt, unitptr uHost)
ARGUMENTS
- int iOperands
- nr of operand units in view
- char *pcWindow
- window title and location
- char *pcFmt
- option string: currently recognized options include %H, %V, %R. Specify NULL for no option.
- unitptr uHost
- host unit
RETURN VALUE:
A pointer to the created unit or NULL in the case of an error.
INTERFACE OF CREATED UNIT:
If pcFmt contains option %V:
- X_in[3]:
- camera location in world coordinates
- Y_in[3]:
- viewing direction of camera in world coordinates
(default (0,0,-1))
- Z_in[3]:
- unit vector perpendicular to Y_in[]: direction
in world coordinates along which camera image is up
(default (0,1,0))
- CTL_in[1]:
- (control field) this specifies the tan of
the angle between the view direction and the
sides of the viewing frustrum. I.e., a value
of 1 (the default) gives an angular width of
90 degrees for the viewing frustrum (45 deg
to the right and to the left).
Otherwise, location and orientation of camera is specified by
means of a homogeneous 4x4 matrix:
- X_in[16]:
- (packed input field 0) homogenous transform
specifying camera location. The first three
rows of this matrix are a 3x4 matrix that is
given by [nx,ny,nz,po], where nx,ny and nz are
three unit vectors, that specify the unit vectors
of the camera coordinate system, expressed in
world coordinates.
po is the location of the camera coordinate
origin. The camera is looking along the
direction -nz, i.e., the camera image is
a xy-rectangle with y taken as upward
direction.
- CTL_in[1]:
- (control field) this specifies the tan of
the angle between the view direction and the
sides of the viewing frustrum. I.e., a value
of 1 (the default) gives an angular width of
90 degrees for the viewing frustrum (45 deg
to the right and to the left).
EXECUTION OF CREATED UNIT:
Produces a perspective projection of the iOperands operands
to render objects.
EXAMPLE:
For a perpendicular view down onto the world-xy plane,
with the camera at height z perpendicularly
above the point (x,y), and the camera rotated by
45 degrees about the vertical direction (so that
the camera x-direction points along the diagonal between
the positive world x and y directions)
and specification with a homogeneous transform matrix,
specify X_in[] as
c -s 0 x
s c 0 y
0 0 1 z
0 0 0 1
In this case, the camera's up-direction (.ny of the camera
coord system = second column of the input matrix) is
[-s c 0] and c=cos(45), s=sin(45) (=0.707.. in both
cases). The camera viewing direction is the along
minus third column, i.e., along [0,0,-1], the negative
z direction (=downward). Other viewing and up-directions
require to rotate the upper 3x3 submatrix suitably
(you can use the rot_trans unit for this).
OPTIONS:
- %H
- hide window (start with window closed)
- %V
- use vector interface (see above)
- %R
- reverse camera direction (rotate camera
180 degrees about its vertical)
LIGHTING:
In order to fix lighting to the world coordinate system
any set_light unit(s) must be placed within the scope
of the camera_unit (this is important when the
camera_unit is itself within the scope of a view3d
unit).
NOTE:
Each object unit is executed once per rendering step, i.e., if the
camera_unit is operand of a view3d unit to render some or
all of the view3d unit's objects from an additional perspective,
these objects will be executed twice per pass: one time by
the view3d unit to make them appear in its view, and once
by the camera_unit to make them appear in the camera image.
This multiple execution should be kept in mind, when among
the rendered circuit there are subunits (such as counters)
whose state is affected by the number of executions performed
with them.
SEE ALSO:
view3d, rot_trans
FILE
/homes/jontrup/nst5/man/../o.sol2//../foldersrc/nst_solid2.c