Date:     Fri, 30 Oct 87 3:58:14 EST
From:     Phil Dykstra <phil@BRL.ARPA>
Subject:  Re:  Animation querry.

I have been meaning to put a few notes together about animation in
BRL-CAD for some time now.  Your message presses the point so here's
a really quick basic overview.  Note that animation control is
still very early and experimental.  Don't be surprised if much of
it changes in the future.
------

The earliest form of animation was just changing the viewpoint.
So that RT could ray trace the "current" MGED view, a -M flag was
added which tells RT to read the viewing matrix from stdin.
This matrix is written on six lines in the form:

viewsize
xpos ypos zpos
[4x4 rotation matrix, 4 elements per line]

Such data can be saved along with an RT shell script by the "saveview"
command in MGED.  To get just this data (i.e. without the shell script),
the "savekey" command can be used.  Thus one can save a string of
viewpoint keyframes via "savekey."  ["Times" can also be added to
the keyframes for the purposes of some interpolation programs.]

Several tools were written (not in the distribution) which generate
sequences of such views, interpolate a set a keyframes, etc.

The "rmats" command was added to allow a file of these views to be
read in to MGED so you could watch the keyframes go by.  Feeding the
same data to RT (via the -M flag) computes an image for each view.
The views either go to the frame buffer, or if an output filename
is given, they go into files with frame number suffixes.

Animation previews are typically made via low resolution ray traces,
composited into one large image via "pixtile," and viewed on a frame
buffer via "fbanim" (preferably one with hardware pan and zoom).

Later we wished to articulate the models themselves, so a command
script language was created for RT.  These are also fed to RT
via the -M flag.  RT figures out whether it is given the old form
above or a real script.  An animation description script contains
transformation matrices to be applied to the model tree.  A simple
one might look like:

start 42;
clean;
anim frob/nitz matrix rmul
	1 0 0 1
	0 1 0 2
	0 0 1 0
	0 0 0 0;
end;
etc.

start - says to start frame number 42.
clean - make RT clean up after itself (this may not be needed any more...).
anim -	says to apply an matrix animation to the arc connecting frob to
	nitz.  The type of matrix operation is a right multiply (choices
	include right or left multiply, replace, or reroot (i.e. world
	coordinates)).
end -	tells it to go ahead and shoot this frame.

Eventually there will be things besides "matrix" animations to allow
material properties etc. to be animated.

Various outboard tools generate motions, merge animation scripts
together, allow the previewing/editing of motions, etc.  For the
most part these tools are sufficiently ad hoc and experimental
that we aren't giving any of them away yet.  Next year some time....

-------
I didn't explain any of it in much detail, but hopefully it
gives you an overview.  One of these days we will write some
more about it - like when we start including some motion tools.

==============================
Date:     Fri, 30 Oct 87 16:42:14 EST
From:     Phil Dykstra <phil@BRL.ARPA>
Subject:  Re:  Animation querry.

Here's a bit more about the matrix operations available in RT
animation scripts.
-----

RT Matrix Animation Operations:
==============================

In BRL-CAD, matrices are handled in their usual mathematical form
(the transpose of the Newman and Sproull "computer graphics form").
That is, a matrix looks like this:

	r1 r2 r3 dx
	r4 r5 r6 dy
	r7 r8 r9 dz
	0  0  0  1/s

Points are *column* vectors, so a point is transformed by:

	newpoint = Matrix * oldpoint;

Thus the world coordinate system is on the "left" end of a stack of
matrix operations; the local coordinate system being that of the point
on the extreme right.

In walking a model tree (such as "prep'ing" the model for ray tracing),
each arc crossed from root to leaf normally gets its matrix multipled on
the right side of the current matrix stack[1].  Rigid body articulations
of a model can then be described by changing or adding matrices at the
appropriate points in this stack.

The matrix animation operations currently recognized by RT are:

	rstack		replace the entire stack up to this point
	rarc		replace the matrix on the specified arc
	rboth		replace the entire stack and the arc matrix
	rmul		arc = arc * Matrix
	lmul		arc = Matrix * arc

The path specifying where in the model tree the operation is to
be applied can either be an absolute path, e.g.

/body/left/arm/hand

which would affect the arc between the left arm of body and the hand
(note that hand need not be a leaf), or it can be a "wildcard", e.g.

arm/hand

would mean the arc between arm and hand anywhere in the model tree, i.e.
it is not restricted to the left one as above.  Finally a wildcard like

arm

means the arc before any node called arm.

-------------------------
[1] It is interesting to note that our "right multiply" operation
corresponds exactly to the SGI Iris multmatrix() command.  The later
pre-multiplies the matrix stack, but the matrix stack post-multiplies
any points being transformed!  In fact, if one looks at the Iris at the
geometry engine level, one finds that it works with matrices in the
usual mathematical form - the gl2 library transposes them in and out of
N&S form.
