In Part 1 I described a lightweight class to process general multitouch manipulations using a game-loop model in XNA.
A key aspect in bringing realism to a multitouch experience is the use of momentum and inertia. The Microsoft.Surface.Core.Manipulations.Affine2DInertiaProcessor provides this support in an event-driven model. In order to continue the approach of using a game-loop model, I needed to add linear and angular velocities, and expansion rates to my manipulation processor.
Changes in manipulator position occur relatively rarely in relation to the game loop frequency, hence calculating rates of change requires averaging these changes over time. The choice of duration and quantity of these time periods is somewhat subjective, and I settled on 5 samples averaged over a maximum of 200ms. Clearly this leads to a small latency between measured and actual velocities, however the smoothing effect is beneficial.
In order to visualise these rates, both for debbugging and to settle on suitable sampling settings, I added visual indicators of direction and magnitude, as shown below in Figure 1.
Figure 1. Visualising linear and angular velocities and expansion rates during multitouch manipulation.
With the addition of linear and angular velocities and expansion rates, I could now add a simple inertial processing component which uses these properties as input parameters. This inertial processor uses a simple deceleration algorithm, with configurable rates for translation, rotation, and expansion. The solution is demonstrated in the following video.
Video 1. Multitouch game loop inertia processing.
Note that for gestures such as a flick, where velcity increases rapidly, a time-weighted average may be more suitable for calculating the inertia processor's input parameters, and I'll investigate this at a later date.
Comments
Nice article. I have tried to use the Physiscs library but as mentioned it has limitations like scaling and Rotation of the items.Unlike the ScatterViewItems we are not able to scale or rotate the items. Is the Physics.SurfaceControls.dll updated to handle these if yes please let us know where we can find it. Thanks in advance.
Regards,
Vidds
Thanks for trying out the library! :) Supporting rotation and scaling in a physics-enabled manner is somewhat more complex than standard ScatterView behaviour, since it may not be possible to rotate or scale an item if it is colliding with another item which itself is fixed. That said, at least I now have the code for implementing the multitouch manipulation itself, which formed the basis of this article. It's not in there yet, but it's next on the list!
For posts relating to my physics-enabled ScatterView control for Surface, see http://drdave.co.uk/blog/archive/category/Surface-Physics.
Regards,
Dave
Add Comment