HTP High Level

Toolkits.HTPHighLevel History

Hide minor edits - Show changes to output

May 24, 2011, at 03:32 PM by 136.159.18.19 -
Deleted lines 8-10:
* [[#programming | Programming with Haptic Widgets]]
** [[#shapesprog | Programming Shapes ]]
** [[#imagesprog | Programming Images ]]
Added lines 20-21:
Another aspect to have in mind is that changing the opacity levels of the widgets (or the mappings, which will be introduced later in this section) allows people to change the weights of the behaviors associated to them.
Changed lines 38-39 from:
box1.AddFrictionBehavior(new OscillationBehavior(0.5));
box2.AddFrictionBehavior(new SoftnessBehavior(1.0));
to:
hapticShape.AddFrictionBehavior(new OscillationBehavior(0.5));
hapticShape.AddFrictionBehavior(new SoftnessBehavior(1.0));
Changed lines 44-46 from:

[[#
Programming]]
to:
Programming haptic images is simple, although slightly more challenging than working with shapes. The idea behind programming haptic images is that you associate a particular behavior to the image and then map that to a grayscale image. The API will automatically look at the current pixel and determine the intensity value and map it from 0 to 1 to the corresponding parameter.

The walkthrough is still easy to follow, we create an image in xaml or C#, we'll call it @@image@@. We also have another image (called @@mapping@@) which is the image we use to map to a particular behavior. We create a haptic image and then register it.
(:source lang=csharp tabwidth=2 linenum=1 :) [=
HTPImage hapticImage = new HTPImage(image);
this.manager.RegisterWidget(hapticImage);
=
]
Next we create a haptic behavior that we want to map, and set the image mapping to @@mapping@@.
(:source lang=csharp tabwidth=2 linenum=1 :) [=
IntensityBehavior behavior = new IntensityBehavior();
behavior.IntensityMapping = new SpatialBehaviorMapping(mapping);
image.AddHeightMapping(behavior, behavior.IntensityMapping);
=
]
An image may have multiple behaviors and mappings associated to them. Mappings represent each of the corresponding parameters to the individual behaviors.
May 24, 2011, at 03:20 PM by 136.159.18.19 -
Added lines 10-11:
** [[#shapesprog | Programming Shapes ]]
** [[#imagesprog | Programming Images ]]
Changed lines 14-47 from:
\\
to:
\\
[[#explanation]]
!!High Level Concepts
The high level allows users to rapidly create widgets that simplify most common operations when using the API. In this case, a user can create a shape or an image and quickly associate behaviors to them, so that when any HTP goes on top, such behaviors get passed on to the shapes.

[[#widgets]]
!!Haptic Widgets
The high level is composed of haptic widgets, mainly shapes and images. Regardless of the widget one is programming with, the procedure to create them remains the same: one must first create the widget, then register it and finally associate behaviors to them.

[[#shapes]]
!!!Haptic Shapes
Haptic shapes follow a very simple pattern: you create a physical shape and then associate behaviors to them. As soon as a hit test is associated to the shape, all those behaviors are passed on to the HTP that is on top of that shape. The other nice thing about haptic shapes is that it can take in just about any kind of shape, including paths. Also, a shape may have a transparent brush fill, which allows the user to have behaviors in certain areas without necessarily having a visual connection.

Here's a walkthrough that will allow you to create and use a haptic shape.

We first create a shape in XAML or C# and add it to the HTP canvas, we'll call it @@rectangle@@. Then, we create a haptic shape object:
(:source lang=csharp tabwidth=2 linenum=1 :) [=
HTPShape hapticShape = new HTPShape(rectangle);
=]
Next, we proceed to register the widget we just created:
(:source lang=csharp tabwidth=2 linenum=1 :) [=
this.manager.RegisterWidget(hapticShape);
=]
Finally, we can add any behaviors we may wish to:
(:source lang=csharp tabwidth=2 linenum=1 :) [=
box1.AddFrictionBehavior(new OscillationBehavior(0.5));
box2.AddFrictionBehavior(new SoftnessBehavior(1.0));
=]

[[#images]]
!!! Haptic Images

[[#Programming]]
May 24, 2011, at 01:03 PM by 136.159.70.106 -
Added line 11:
May 24, 2011, at 01:02 PM by 136.159.70.106 -
Added lines 1-11:
\\

>>frame<<
!!!'''Contents'''
* [[#explanation | High Level Concepts]]
* [[#widgets| Haptic Widgets]]
** [[#shapes| Haptic Shapes]]
** [[#images | Haptic Images]]
* [[#programming | Programming with Haptic Widgets]]
>><<
\\