HTP Medium And High Level Combination



Combination Concepts

The medium and high level can work together and create much richer applications that vary between each HTP. The relationship between both levels depends on the flag WidgetWeight in each HTP.

Programming with Mixed Levels

Programming with mixed levels can be very simple. Refer to the following example as reference.

Example

The following example shows an application that tests all combinations of amplitudes and frequencies as illustrated in a graph. The full code can be found in the large set of applications provided with the toolkit (refer to main page). We use an image to represent the height mapping for intensity values, and then we use the medium level to change the weight and the frequency values of an oscillation behavior associated to a particular HTP. In addition, the updating of the medium level behaviors is done through the use of events. In all, this very simple application makes use of most aspects of the API.

  1. public partial class Oscillations : SurfaceWindow
  2.     {
  3.         HTPManager manager = HTPManager.Instance;
  4.         string filePath = System.IO.Directory.GetCurrentDirectory() + "\\";
  5.         OscillationBehavior oscillation;
  6.  
  7.         /// <summary>
  8.         /// Default constructor.
  9.         /// </summary>
  10.         public Oscillations()
  11.         {
  12.             InitializeComponent();
  13.  
  14.             // Add handlers for Application activation events
  15.             AddActivationHandlers();
  16.  
  17.             // Register Window
  18.             this.manager.RegisterWindow(this, this.grid);
  19.  
  20.             // Add new HTP Image
  21.             HTPImage image = new HTPImage(this.stoneRelief);
  22.             this.manager.RegisterWidget(image);
  23.  
  24.             // Add two behaviors, one for the oscillations and another one that will limit the height range
  25.             IntensityBehavior behavior = new IntensityBehavior();
  26.             behavior.IntensityMapping = new SpatialBehaviorMapping(filePath + "OscillationsTestAmplitude.png");
  27.             image.AddHeightMapping(behavior, behavior.IntensityMapping);
  28.  
  29.             this.oscillation = new OscillationBehavior(0);
  30.             HTP h = manager.GetHTP(0xEF);
  31.             h.HTPDown += new HTPEventHandler(h_HTPDown);
  32.             h.HTPChanged += new HTPEventHandler(h_HTPDown);
  33.             h.AddHeightBehavior(this.oscillation);
  34.         }
  35.  
  36.         void h_HTPDown(object sender, HTPEventArgs e)
  37.         {
  38.             this.oscillation.Frequency = e.CenterPoint.X / 1024;
  39.             e.CurrentHTP.WidgetWeight =  e.CenterPoint.Y / 768;
  40.         }