C# Class SurfaceToTUIO.App1

This is the main type for your application.
Inheritance: Microsoft.Xna.Framework.Game
Datei anzeigen Open project: touchcoder/SurfaceToTUIO Class Usage Examples

Private Properties

Property Type Description
InitializeSurfaceInput void
OnAffine2DDelta void
OnAffine2DManipulationCompleted void
OnAffine2DManipulationStarted void
OnApplicationActivated void
OnApplicationDeactivated void
OnApplicationPreviewed void
SetWindowOnSurface void

Public Methods

Method Description
App1 ( ) : System

Default constructor.

addManipulationProcessor ( Contact c ) : void

Each Contact gets its own ManipulationProcessor assigned This way we can use the Manipulator data even if there are multiple Contacts

cleanHistory ( int id ) : void

Removes all unnecessary entries from the history Dictionaries

cleanManipulationProcessorList ( List removedContacts ) : void

Removes ManipulationProcessor assigned to removed Contacts

computeAngularVelocity ( Contact currentContact, Contact previousContact, float &angularVelocity, float &angularAcceleration ) : void

Computes the angular velocity and the angular acceleration of a Contact The unit for the velocity is: Rotations / Seconds The unit for the acceleration is: Rotations / Seconds^2

getMotionAcceleration ( int id, float &acceleration, long frameTimestamp ) : void

If possible, computes the motion acceleration This is done by subtracting the preceding Contact velocity from the current contact velocity, devided by the time delta The unit is acceleration is: Screen Dimesion / Seconds^2

getVelocity ( int id, float &velocityX, float &velocityY, InteractiveSurface surface ) : void

Retrieve the movement velocity of a Contact The data is taken from a ManipulationProcessor linked to the Contact The final unit is: SurfaceDimension / Seconds

processContactManipulator ( Contact c, ReadOnlyContactCollection currentContacts, ReadOnlyContactCollection previousContacts ) : void
sendTUIO_2DBlb ( List contacts, ReadOnlyContactCollection previousContacts ) : void

Sends a /tuio/2Dblb message The remote Host is specified in the appConfig The message is built according to TUIO 1.1 specifications (see http://www.tuio.org/?specification)

sendTUIO_2DCur ( List contacts, ReadOnlyContactCollection previousContacts ) : void

Sends a /tuio/2Dcur message The remote Host is specified in the appConfig The message is built according to TUIO 1.1 specifications (see http://www.tuio.org/?specification)

sendTUIO_2DObj ( List contacts, ReadOnlyContactCollection previousContacts ) : void

Sends a /tuio/2Dobj message The remote Host is specified in the appConfig The message is built according to TUIO 1.1 specifications (see http://www.tuio.org/?specification)

updateHistoryData ( int id, long frameTimestamp ) : void

Updates the history data needed for computing Contact velocities

Protected Methods

Method Description
Draw ( GameTime gameTime ) : void

This is called when the app should draw itself.

Initialize ( ) : void

Allows the app to perform any initialization it needs to before starting to run. This is where it can query for any required services and load any non-graphic related content. Calling base.Initialize will enumerate through any components and initialize them as well.

LoadContent ( ) : void

Load your graphics content.

UnloadContent ( ) : void

Unload your graphics content.

Update ( GameTime gameTime ) : void

Main application Logic We retrieve the current Contacts and send TUIO messages accordingly You can specify via appConfig if you want a Finger Contact to be sent as /tuio/2Dcur or /tuio/2Dblb Sending it as /tuio/2Dblb conserves the Contact size, rotation, angular velocity and angular acceleration

Private Methods

Method Description
InitializeSurfaceInput ( ) : void

Initializes the surface input system. This should be called after any window initialization is done, and should only be called once.

OnAffine2DDelta ( object sender, Affine2DOperationDeltaEventArgs e ) : void

Extract the Manipulation Data and write it into our Dictionary

OnAffine2DManipulationCompleted ( object sender, Affine2DOperationCompletedEventArgs e ) : void

Unused

OnAffine2DManipulationStarted ( object sender, Affine2DOperationStartedEventArgs e ) : void

Unused

OnApplicationActivated ( object sender, EventArgs e ) : void

This is called when application has been activated.

OnApplicationDeactivated ( object sender, EventArgs e ) : void

This is called when application has been deactivated.

OnApplicationPreviewed ( object sender, EventArgs e ) : void

This is called when application is in preview mode.

SetWindowOnSurface ( ) : void

Moves and sizes the window to cover the input surface.

Method Details

App1() public method

Default constructor.
public App1 ( ) : System
return System

Draw() protected method

This is called when the app should draw itself.
protected Draw ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime Provides a snapshot of timing values.
return void

Initialize() protected method

Allows the app to perform any initialization it needs to before starting to run. This is where it can query for any required services and load any non-graphic related content. Calling base.Initialize will enumerate through any components and initialize them as well.
protected Initialize ( ) : void
return void

LoadContent() protected method

Load your graphics content.
protected LoadContent ( ) : void
return void

UnloadContent() protected method

Unload your graphics content.
protected UnloadContent ( ) : void
return void

Update() protected method

Main application Logic We retrieve the current Contacts and send TUIO messages accordingly You can specify via appConfig if you want a Finger Contact to be sent as /tuio/2Dcur or /tuio/2Dblb Sending it as /tuio/2Dblb conserves the Contact size, rotation, angular velocity and angular acceleration
protected Update ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime
return void

addManipulationProcessor() public method

Each Contact gets its own ManipulationProcessor assigned This way we can use the Manipulator data even if there are multiple Contacts
public addManipulationProcessor ( Contact c ) : void
c Contact Contact to add the Manipulator to
return void

cleanHistory() public method

Removes all unnecessary entries from the history Dictionaries
public cleanHistory ( int id ) : void
id int Contact Id that is no longer active
return void

cleanManipulationProcessorList() public method

Removes ManipulationProcessor assigned to removed Contacts
public cleanManipulationProcessorList ( List removedContacts ) : void
removedContacts List
return void

computeAngularVelocity() public method

Computes the angular velocity and the angular acceleration of a Contact The unit for the velocity is: Rotations / Seconds The unit for the acceleration is: Rotations / Seconds^2
public computeAngularVelocity ( Contact currentContact, Contact previousContact, float &angularVelocity, float &angularAcceleration ) : void
currentContact Contact
previousContact Contact
angularVelocity float Output parameter for the angular velocity
angularAcceleration float Output parameter for the angular acceleration
return void

getMotionAcceleration() public method

If possible, computes the motion acceleration This is done by subtracting the preceding Contact velocity from the current contact velocity, devided by the time delta The unit is acceleration is: Screen Dimesion / Seconds^2
public getMotionAcceleration ( int id, float &acceleration, long frameTimestamp ) : void
id int Contact ID
acceleration float Output parameter
frameTimestamp long Timestamp of the current Contact
return void

getVelocity() public method

Retrieve the movement velocity of a Contact The data is taken from a ManipulationProcessor linked to the Contact The final unit is: SurfaceDimension / Seconds
public getVelocity ( int id, float &velocityX, float &velocityY, InteractiveSurface surface ) : void
id int Contact Id
velocityX float Output parameter
velocityY float Output parameter
surface InteractiveSurface Object representing the Surface
return void

processContactManipulator() public method

public processContactManipulator ( Contact c, ReadOnlyContactCollection currentContacts, ReadOnlyContactCollection previousContacts ) : void
c Contact
currentContacts ReadOnlyContactCollection
previousContacts ReadOnlyContactCollection
return void

sendTUIO_2DBlb() public method

Sends a /tuio/2Dblb message The remote Host is specified in the appConfig The message is built according to TUIO 1.1 specifications (see http://www.tuio.org/?specification)
public sendTUIO_2DBlb ( List contacts, ReadOnlyContactCollection previousContacts ) : void
contacts List Current active contacts
previousContacts ReadOnlyContactCollection Contacts from the previous frame
return void

sendTUIO_2DCur() public method

Sends a /tuio/2Dcur message The remote Host is specified in the appConfig The message is built according to TUIO 1.1 specifications (see http://www.tuio.org/?specification)
public sendTUIO_2DCur ( List contacts, ReadOnlyContactCollection previousContacts ) : void
contacts List Current active contacts
previousContacts ReadOnlyContactCollection Contacts from the previous frame
return void

sendTUIO_2DObj() public method

Sends a /tuio/2Dobj message The remote Host is specified in the appConfig The message is built according to TUIO 1.1 specifications (see http://www.tuio.org/?specification)
public sendTUIO_2DObj ( List contacts, ReadOnlyContactCollection previousContacts ) : void
contacts List Current acitve Contacts
previousContacts ReadOnlyContactCollection Contacts from the previous frame
return void

updateHistoryData() public method

Updates the history data needed for computing Contact velocities
public updateHistoryData ( int id, long frameTimestamp ) : void
id int Contact Id
frameTimestamp long Contact Frame Timestamp
return void