6.2 Parametrization of the Haptic Virtual Environment
6.2.2 Implementation of the GUI
We have seen previously, that our GUI needs five main features:
• Open/Save files functionalities. • Multiple viewport rendering. • Geometry/material editing. • Mass property parameterizing.
• Immediate dynamic simulation previewing.
The core of the application uses a Finite State Machine (FSM) shown in figure 6.4. Most operations, commands or drawing executions depends on the current state. State ma- chines provide a powerful mechanism to avoid multiple tests. For instance, it is authorized to modify the mass of an object only if it has been selected, i.e. if the state is “Object Selected”. Internal commands are also triggered during a state transition, such as the syn- chronization of all views on one object when the user just picked one. Some components of the 2D and 3D GUI are also displayed according to the state of the application. The 2D GUI contains for example the toolbar (see figure 6.5), information messages, the selection area and so on. The 3D GUI contains some objects integrated to the scene that belong to the editor, such as the arcball.
The Haptic Scene Creator is implemented in C++, using only the MHaptic and MVisio libraries.
Some basic features of the Haptic Scene Creator are presented in the following sub- sections, whereas some more complicated/automated features that have been progressively added are described in section 6.2.3.
Navigation State Object Selected Geometry Creation Dynamic Properties Initialized Texture Parametrizing Geometry Positioning Animation Previewing Load/Save haptic or visual files Press Animate Press Edit Click on an object IF ‘dynamic’ Apply Lauch a ball Press Space Click on another object Click on nothing Mouse
moves Press “Edit Textures”
Press on a collision primitive
button
Apply Apply
Figure 6.4: The Finite State Machine is the core of the Haptic Scene Creator
6.2.2.1 Multiple viewports rendering and navigation
Navigation using more than one viewport is intuitive because it simplifies visualization and editing, especially when dealing with complex sets of data. Most of the Computer-Aided Design (CAD) software provide the ability to display a 3D object from multiples points of view, as shown in figure 6.6.
In the Haptic Scene Creator, three orthographic cameras and one camera in perspective are provided to visualize the environment. In the three orthographic views, the objects are rendered in wireframe mode. The objects in the perspective view are shaded using transparency, textures and smooth lighting.
6.2.2.2 Creating geometry and body of an object
As stated previously, a haptic object contains two parts: the mass properties, also called body, and the collision geometries.
In the Haptic Scene Creator, the body is computed automatically according to the posi- tion of its geometries and their respective densities. The only information that the designer may want to modify is the mass or the density of an object. This can be simply done in the toolbar on the right side of the screen.
6.2. PARAMETRIZATION OF THE HAPTIC VIRTUAL ENVIRONMENT 81
Figure 6.5: The toolbar contains all available commands of the Haptic Scene Creator
Figure 6.6: Multiple viewports rendering in CAD systems: Maya on the left and LightWave 3D on the right
The designer must also be able to approximate the geometry of a visual object by adding and linking some simple collision geometries to it, such as boxes, spheres, planes and cap- sules(also called capped cylinder, or line-swept spheres). These primitives can be defined by a low number of parameters: three for a box (height, length, depth), one for a sphere (radius), etc. In the first implementation of the Haptic Scene Creator, the input of these values is performed manually by the designer. However, even if this method works, it is a relatively tedious task. This convinced us to implement a method that is described in section 6.2.3.
6.2.2.3 Editing materials
As introduced previously in subsection 6.1.1, each object has some material properties, which are the restitution (bounciness), the static friction and the dynamic friction.
Materials can be modified for each geometry in the scene. For example, a carpet would provide a stronger frictional force-feedback to the user’s hands during its manipulation than a wooden table. The restitution and the frictional coefficients can also be set for each collision geometry independently, allowing various interesting effects.
In the Haptic Scene Creator, the designer can modify materials by using three scroll- bars. Some materials have also been predefined in the editor. They are accessible in the toolbar when editing a geometry. One simply has to click on the button corresponding to the predefined material to modify the properties of the selected object.
6.2.2.4 Immediate physics simulation of the system
The Haptic Scene Creator provides also an immediate simulation of the augmented haptic scene, as shown in figure 6.7. During the simulation, the designer is able to launch virtual balls on the objects, in order to see if the reaction is correct, and if the collision geometries provides a good approximation.
In this section, the basic features have been covered. However, in this state, the Haptic Scene Creator suffers from a lack of flexibility. At usage, it is not possible to augment quickly a scene. The task is repetitive and tedious. In the next section, we will present advanced features that reduce the time and the difficulty of it.