Implementation details & hints
9/30/98
Linear algebra library
Check the news group for a posting from Ian on an easy-to-use vector library.
You may also want to check out the Inventor linear library. To use it, just include < Inventor/SbLinear.h> and use the class SbVec2f. Other neat classes : SbVec3f, SbLine, SbPlane, SbBox2f, SbBox3f, SbMatrix, SbRotation... All these have man pages.
Behavior of the user interface:
Inventor viewers have 2 modes: viewing and editing. You can toggle between them by pressing ESC.
- In the viewing mode, the cursor is a little hand. You can zoom in and out by dragging up/down with the left mouse button. You can move left/right/up/down by dragging with the middle mouse button.
-
In editing mode, the cursor is a small arrow. When the user presses a mouse button OVER THE IMAGE, the function mouseDown (that you will have to fill in) will be called. When the user releases the button, mouseUp will be called. When the mouse moves (not necessarily dragging), mouseMove gets called.
In the supplied demo program:
- To add a new line pair
- move mouse over the initial image window
- go into editing mode (press ESC)
- press left mouse button, drag, and then release
- repeat the above steps for the final image window
- To move an endpoint, press the middle mouse button OVER THE LINE to be moved, drag the endpoint and then release.
- To highlight a line pair, click with the left mouse button over a line.
- To delete a line pair, press DEL or BACKSPACE over one of the lines (either in the initial image window or in the final image window)
The format of the configuration
file
-
the word "InitialImg"
followed by the path to the file containing the image you are morphing
from.
-
on a different line, the
word "FinalImg" followed by the path of the file containing the image
you are morphing to.
-
on a different line, the
word "LinePairs", followed by the number of line pairs introduced, followed
by the coordinates of the lines:
-
A line pair consisting
of the oriented line ((xi1,yi1) -> (xi2,yi2)) in the initial image and
the oriented line ((xf1,yf1) -> (xf2, yf2)) in the final image would appear in the config file on a line of the form:
xi1 yi1 xi2 yi2
xf1 yf1 xf2 yf2
The file may contain an
arbitrary number of comment lines, that start with "#".
If no initial image
has been specified at the time when the config file was saved, "InitialImg"
should not appear in the file. If no final image was specified, "FinalImg"
should not appear. If no lines were drawn, "LinePairs" should not appear.
Creating a movie
The "SaveMovie"
menu should just write out 11 frames, at morphing parameters 0, 0.1, 0.2,
... 0.9 and 1. To convert these to a movie, use the program movieconvert.
Mapping functions
The direct mapping function determines where a point
from the initial or final images wants to go on the morphed image. The
inverse (backward) mapping function determines where in the initial or
final images does a point in the morphed image come from. You need
backward mapping to perform the pixel-by-pixel morph and the direct
function to show the warping grid.
SGI has a very good debugging environment, with integrated profiler. Run
%cvd morph
and set a profiling task from the Perf menu. There is extensive on-line documentation. Run
% insight
and select the books on Developer Magic: Debugger's User's Guide, Performance Analyser User's Guide, etc.
Note that "The Inventor Mentor" and "OpenGL User's guide" can also be accessed through insight.