Challenges
1.
Load examples/portcullis/portcullis.X3D in H3DViewer. Here we have a castle gate where the portcullis is raised and lowered by a position interpolator.
Note the red sphere in the scene. Add a springeffect in the same position as the sphere.
Instead of setting the PositionInterpolator fraction values from the clock node, we are going to use the conceptual ‘extension’ of the spring, so that as the user pulls on the spring the portcullis is raised.
To achieve this we need to make use of a Python script to do the calculations. This script, portcullis.py is provided.
To use a python script you need to use the <PythonScript> element, the url attribute sets the location of the script.
Thereafter you use routes to set the inputs and get output from the script.
The inputs that the portcullis.py script expects are:
active attribute of the spring
startDistance attribute of the spring
escapeDistance attribute of the spring
position attribute of the spring
proxyPositions of the haptic device node HDEV (HDEV is already defined in the file)
A solution for this exercise can be found in portcullis-final.X3D.
2.
Open viscosity-fields.X3D. In this scene there are four spheres representing viscosity fields. The goal is to switch the field on when the proxy is inside the sphere.
A Python script which returns a Boolean if the proxy is inside a sphere is provided in FieldToggle.py. Haptics can be turned on and off by routing Booleans into the ToggleGroup hapticsOn attribute.
The inputs to the python node are:
The translation attribute from a transform node
The radius attribute from a sphere node
TheproxyPositions of the haptic device node HDEV
To check if a toggle group is active or not, use the scene tree view.
A solution is provided in viscosity-fields-final.X3D.
3.
Load L11.X3D in H3DViewer. The sphere in this example has a magnetic surface. Test what happens when the stylus pointer enters the magnetic field of the sphere.
Implement your own example of using haptics in combination with an Interpolator.
4.
Load L12.X3D in H3DViewer. Use the proxy to touch the sphere. Observe how the change in colour is affected by the direction and speed of the proxy.
This example uses the ‘force’ attribute of the sphere to call a python script which maps the force applied to the sphere to an RGB color.
The X3D shapes have a variety of haptics attributes in H3DAPI, in particular ‘isTouched’. Use one of these attributes to achieve some touch-sensitive effect.
5.
Put together all the things you have learned to create a scene with multiple haptic nodes combining to produce appropriate effects.
For inspiration take a look at these examples:
match
[tower]
[deform]