Rreal Ttime Mmorpher.
By Erik and Roland Karlsson - April 1998 (roland@cslab.ericsson.se)
Drakenbergsgatan 3 4tr, S-117 41 Stockholm, Sweden : +46-8-842857
Introduction
While I was reading the Rredline Reference Manual I got an idea. Texture mapping is really nothing else than morphing. Morphing programs I have seen have always been slow. You have to generate all the frames into a film before you can look at it. A 3D card could do this much faster, in real time, making the morphing more interactive. This would be fun! But is it good enough?
Me and my son Erik had earlier decided to participate in the Take it to the Rredline competition and we now decided that we should try to make a morpher. Very soon we found that the morphing code in Rredline was really trivial and it looked good and was fast. The real challenge was the user interface. Mesh points and triangles needed to be generated. I have tried some morphers before and found their user interfaces to be slow and irritating. We think that the user interface we have designed is much faster. The main improvement is that you doesn't have to hit exactly at a point when you want to mark or move it. The program tracks the cursor continously and highlights the nearest point.
Morphing back end forth between two pictures is all very nice. But to make it more interesting we wanted to be able to make a movie where we could morph randomly between a set of pictures. We did so. There were some tough design decisions to make there. We kept the two picture window view but added a file format for the mesh files containing one triangle setup and several point tables. In the file we also stored the default file names.
The program is either started without parameters or with a mesh file. The latter makes it possible to bind .msh-files to the rrmorph program. You can also give the modes described below (e.g. rrmorph -w foo.mesh
) and you can also give a zoom factor 1-4 (1 means 1/2 and 4 means 4/2=2) (e.g. rrmorph -z1 foo.msh
). If you run the precompiled version rrmorph_console
instead you will get a frame rate counter in the console window.
The window contains two pictures (left and right) in the editing modes, but in the animation modes only one picture is used. In the editing modes the triangles and points are shown. The point nearest to the cursor is always highlited. This point is chosen when you either move a point (with the left mouse button), delete a point (with the delete key) or mark a point (with the right mouse button). New points are added with the insert key. Triangles are created (or removed, if the already exist) by marking three points.
Many functions can be executed from the menus (and corresponding shortcuts).
In the file menu you can create, open, close and save mesh files and also quit (shortcut q) the program. When you open a mesh file you will also load the default pictures.
In the mode menu you choose the current mode of the program. There are four animation modes (warp, morph, film and random film) and two editing modes (normal edit and one showing the triangles). There are shortcuts for all modes (w, m, f, r, e and t). In the command menu you can zoom in and out (shortcuts + and -).
In the mesh menu you can either manipulate what pictures shall be in the mesh file (new, delete and replace file) or you can choose what picture to show as left picture. You can also choose the left picture with the shortcuts 0-9 and you can also step through the pictures (for the picture where the cursor is) with Page Up and Page Down.
In the frames menu you can choose the number of frames for morphing/warping between two pictures.
There are some demo meshes and pictures included. The demos are started with demo1, demo2 etc in the rrmorph directory. The main demo is demo1, showing a random film of the Karlsson family and one doll called Lotta
A Hercules Thriller 3D 8MB card on a 225 MHz Pentium MMX machine using Windows 95. Microsoft Visual C++ 5.0 development environment. The Rredline 3.0.1 SDK.
Lots of code is used (modified or not) from the Rredline SDK 3.0.1 (mainly from the Sphere demo). The bmp reading/writing code is used as is (but we plan to add reading JPEG). We have read the Rredline Programming Guide, but we have not followed the advices entirely as it is partly in conflict with the Sphere demo code. We have found some flaws in the Sphere demo, like allocating twice as much memory as needed for the pictures and not choosing the optimal size of the window.