Monday, May 23, 2011

Tracking Shots with GEF3D

One of the most important things for 3D user interfaces are good navigation tools. So far, GEF3D comes with a nice first person like camera tool. You can fly around in the 3D scene and orbit around figures. If you have watched previous GEF3D videos, you may have noticed how we fiddled to nicely position figures in front of the camera. This is more or less ok for editing smaller diagrams, but in the long run it's annoying. In order to improve navigation, we needed a basic technique for tracking shots (see bug 30019 ). I have now added a basic API for tracking shots, together with some predefined shots for moving the camera in front of figures, as demonstrated in the following video.

These tracking shots are now (as of GEF3D revision 578) available, and the default camera tool provides the following (old and new) navigation features:
  • move camera around with keys (up, down, etc.), mouse (grab scene and drag it around) or mouse wheel or touch pad with two fingers (zoom in / out)
  • orbit around figures by holding down a modifier key and clicking on a figure to be the center of the orbit
  • new: double click on a figure to start a tracking shot, ending in front of the figure. The double clicked figure will then be shown in the center of the 3D scene, much as if opened in a 2D editor.
  • new: double click on background, to start a tracking shot to a predefined position. The default camera tool defines three positions, in order to look at the 3D scene from the front, from the side (hold modifier), or from the top (hold shift and modifier).

Actually, the idea of tracking shots in GEF3D is not that new. It had been prototypically implemented in a master thesis 2008 (see A. Bauer: Visualisierung von Suchtreffern und Clustern in 3D-Diagrammeditoren.) -- however the new moves are much nicer ;-) I'm looking forward to re-implementing the basic feature of this thesis again using the new tracking shot API: We combined EMF search with GEF3D, in order to automatically move the camera to search hits visualized in the 3D scene. And there are much more applications for tracking shots, such as following connections, visualizing timelines, switch between "sub-scenarios" in the 3D scene, etc. Stay tuned!


Friday, May 13, 2011

Interactively rotate and move figures in 3D space

Although GEF3D provides full 3D capabilities for placing and rotating figures, it was not possible to interactively place figures everywhere in 3D space. GEF3D adapts moving and resizing of figures as provided by GEF, by enabling moving and resizing of figures on so called virtual planes (which are unbounded surfaces). Since surfaces are always 2D planes, this is similar to moving figures in a 2D editor (in which the surface is always the screen surface). As of revision 576 (we are still working on a nightly build system, until then you have to get GEF3D from the code repository), it is possible to interactively move figures in 3D space. In the movie below, you will see how some planes are interactively moved and placed in 3D space. The editor is part of the GEF3D examples. It consists of simple (2D GEF) editors for graphs, that is labeled nodes connected with edges. Several graphs, each one drawn on its own diagram surface, are combined into a GEF3D multi editor. You will find this example called "Multiple Graphs in Dia2D Mode Sample" in the example package (org.eclipse.gef3d.examples.graph).

This closes bug 300321 and it also demonstrates a lot of nice features of GEF3D which are not that obvious. In the following, I will highlight some interesting aspects, using some snapshots taken from the movie.

Fig. 1: Virtual Plane
Figure 1 shows how 2D figures can be moved around just like moving figures with GEF. GEF3D provides a concept called "virtual planes", that is, a figure is moved parallel to a (virtually extended) surface of a 3D figure, which usually is the surface of the diagram. This always worked for 2D  figures. (For people not that much involved in GEF3D: a 2D figure actually is an original GEF or Draw2D figure! It's code is not modified at all!)

Fig. 2: 2D breaks free!
As shown in Figure 2, 2D figures are not necessarily bound to the actual surface of a 3D figure. Instead, 2D figures are rendered as real 3D content, which does improve quality and performance (Kristian is a real 3D wizard making this possible), but also removes restrictions on how 2D content is drawn in 3D.

Fig. 3: Move 3D figure on virtual plane
Now, 3D figures can be moved like that as well. A 3D figure, which is not placed onto a figure with a surface, such as the digram figure itself, can then simply be moved parallel to its own surface. This is illustrated in Figure 3.

Fig. 4: Interactively rotate 3D figure
One of the most interesting features of GEF3D is the full support of rotation. In the current version, 3D figures can be interactively rotated by holding down a modifier key (command key for on OS X, alt key for Windows and Linux). Instead of moving the figure, it is then rotated around its own x- and y axis. Figure 4 shows the feedback figure, which exactly shows the rotation.
Fig. 5: Connection anchors are placed correctly
One of the trickiest things with rotations is the correct handling of connection and connection anchors. Figure 5 shows that the connection between an element of the one diagram is still correctly connected with an element of another diagram, although the first diagram is rotated. This works with all arbitrarily rotated figures. Since 2D content is rendered using OpenGL as well, we also have no problems with image quality or whatever. So, if you need fully supported rotation capabilities for a 2D editor (in which the figures are to be rotated around the z-axis), GEF3D may be interesting for you as well (all you need to do is to restrict the camera in order to emulate a 2D editor).

Fig. 6: Move along normal vector
Holding down the modifier and shift will cause the figure to be moved orthogonally to the virtual plane, that is along its own z-axis (or normal vector). This is shown in Figure 6.

Fig. 7: Resize 3D figure
This enables one to arbitrarily place 3D figures in the 3D space. It is also possible to resize 3D figures, however at the moment I only have implemented the resizing itself. Thus, only resizing along the x- and y-axis are supported (as shown in Figure 7), because only handles for x- and y-resizing are provided yet.

While modifier keys may work in some cases, it is only a temporary hack. In the long run, we have planned to add 3D handles. We are thinking about adding handles for x-, y-, and z-axis rotation, z-axis movement, and resizing the depth of a figure. This will also remove conflicts with applications using the modifier keys for different kind of actions.