front_idill/extern/fajran-npTuioClient/TuioClient/TuioContainer.h
author bastiena
Thu, 12 Apr 2012 13:09:46 +0200
changeset 27 6c08d4d7219e
parent 24 2bdf5d51d434
child 28 9ccef81f02ab
permissions -rw-r--r--
Middleware : GPL License added. Front Processing : GPL License added. Front IDILL : extern altered to send TUIO cursors from Middleware to Front. implemented as a plugin.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     1
/*
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     2
	TUIO C++ Library - part of the reacTIVision project
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     3
	http://reactivision.sourceforge.net/
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     4
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     5
	Copyright (c) 2005-2008 Martin Kaltenbrunner <mkalten@iua.upf.edu>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     6
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     7
    This program is free software; you can redistribute it and/or modify
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     8
    it under the terms of the GNU General Public License as published by
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     9
    the Free Software Foundation; either version 2 of the License, or
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    10
    (at your option) any later version.
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    11
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    12
    This program is distributed in the hope that it will be useful,
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    15
    GNU General Public License for more details.
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    16
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    17
    You should have received a copy of the GNU General Public License
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    18
    along with this program; if not, write to the Free Software
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    19
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    20
*/
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    22
#ifndef INCLUDED_TUIOCONTAINER_H
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    23
#define INCLUDED_TUIOCONTAINER_H
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    24
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    25
#include <list>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    26
#include <math.h>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    27
#include "TuioPoint.h"
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    28
#include <iostream>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    29
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    30
#define TUIO_ADDED 0
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    31
#define TUIO_UPDATED 1
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    32
#define TUIO_REMOVED 2
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    33
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    34
class TuioContainer: public TuioPoint {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    35
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    36
	protected:
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    37
	long session_id;
24
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
    38
	float xpos, ypos, zpos;
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    39
	float x_speed, y_speed;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    40
	float motion_speed, motion_accel;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    41
	std::list<TuioPoint> path;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    42
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    43
	int state;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    44
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    45
	public:
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    46
	TuioContainer (long s_id, float xpos, float ypos):TuioPoint(xpos,ypos) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    47
		this->session_id = s_id;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    48
		this->x_speed = 0.0f;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    49
		this->y_speed = 0.0f;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    50
		this->motion_speed = 0.0f;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    51
		this->motion_accel = 0.0f;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    52
		TuioPoint p(xpos,ypos);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    53
		path.push_back(p);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    54
		
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    55
		state = TUIO_ADDED;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    56
	};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    57
24
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
    58
	/*
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
    59
	* Surcharg� par alexandre.bastien@iri.centrepompidou.fr
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
    60
	*/
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
    61
	TuioContainer (long s_id, float xpos, float ypos, float zpos):TuioPoint(xpos,ypos,zpos) {
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
    62
		this->session_id = s_id;
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
    63
		this->x_speed = 0.0f;
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
    64
		this->y_speed = 0.0f;
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
    65
		this->motion_speed = 0.0f;
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
    66
		this->motion_accel = 0.0f;
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
    67
		TuioPoint p(xpos,ypos,zpos);
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
    68
		path.push_back(p);
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
    69
		
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
    70
		state = TUIO_ADDED;
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
    71
	};
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
    72
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
    73
	/*
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
    74
	* Modifi� par alexandre.bastien@iri.centrepompidou.fr
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
    75
	*/
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    76
	TuioContainer (TuioContainer *tuioContainer):TuioPoint(tuioContainer) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    77
		this->session_id = tuioContainer->getSessionID();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    78
		this->x_speed = 0.0f;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    79
		this->y_speed = 0.0f;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    80
		this->motion_speed = 0.0f;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    81
		this->motion_accel = 0.0f;
24
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
    82
		TuioPoint p(xpos,ypos,zpos);
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    83
		path.push_back(p);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    84
		
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    85
		state = TUIO_ADDED;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    86
	};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    87
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    88
	virtual ~TuioContainer(){};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    89
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    90
	virtual void update (float xpos, float ypos,float xspeed, float yspeed,float maccel) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    91
		TuioPoint::update(xpos, ypos);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    92
		this->x_speed = xspeed;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    93
		this->y_speed = yspeed;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    94
		this->motion_speed = (float)sqrt(xspeed*xspeed+yspeed*yspeed);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    95
		this->motion_accel = maccel;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    96
		TuioPoint p(xpos,ypos);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    97
		path.push_back(p);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    98
		
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    99
		state = TUIO_UPDATED;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   100
	};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   101
24
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   102
	/*
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   103
	* Surcharg� par alexandre.bastien@iri.centrepompidou.fr
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   104
	*/
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   105
	virtual void update (float xpos, float ypos, float zpos, float xspeed, float yspeed,float maccel) {
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   106
		TuioPoint::update(xpos, ypos, zpos);
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   107
		this->x_speed = xspeed;
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   108
		this->y_speed = yspeed;
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   109
		this->motion_speed = (float)sqrt(xspeed*xspeed+yspeed*yspeed);
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   110
		this->motion_accel = maccel;
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   111
		TuioPoint p(xpos,ypos,zpos);
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   112
		path.push_back(p);
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   113
		
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   114
		state = TUIO_UPDATED;
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   115
	};
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   116
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   117
	/*
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   118
	* Modifi� par alexandre.bastien@iri.centrepompidou.fr
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   119
	*/
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   120
	virtual void update (TuioContainer *tuioContainer) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   121
		TuioPoint::update(tuioContainer);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   122
		this->x_speed = tuioContainer->getXSpeed();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   123
		this->y_speed =  tuioContainer->getYSpeed();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   124
		this->motion_speed =  tuioContainer->getMotionSpeed();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   125
		this->motion_accel = tuioContainer->getMotionAccel();
24
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   126
		TuioPoint p(xpos,ypos,zpos);
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   127
		path.push_back(p);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   128
		
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   129
		state = TUIO_UPDATED;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   130
	};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   131
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   132
	virtual long getSessionID() { return session_id; };
24
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   133
	
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   134
	/*
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   135
	* Modifi� par alexandre.bastien@iri.centrepompidou.fr
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   136
	*/
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   137
	virtual TuioPoint getPosition() {
24
2bdf5d51d434 Front IDILL :
bastiena
parents: 21
diff changeset
   138
		TuioPoint p(xpos,ypos,zpos);
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   139
		return p;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   140
	};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   141
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   142
	 virtual std::list<TuioPoint> getPath() {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   143
		return path;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   144
	};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   145
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   146
	virtual void remove() {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   147
		state = TUIO_REMOVED;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   148
		timestamp = TUIO_UNDEFINED;		
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   149
	}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   150
				 
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   151
	virtual float getXSpeed() { return x_speed; };
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   152
	virtual float getYSpeed() { return y_speed; };
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   153
	virtual float getMotionSpeed() { return motion_speed; };
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   154
	virtual float getMotionAccel() { return motion_accel; };
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   155
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   156
	virtual int getState() { return state; };
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   157
	virtual void setUpdateTime(long timestamp) { 
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   158
		this->timestamp = timestamp;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   159
		TuioPoint *lastPoint = &path.back();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   160
		if (lastPoint!=NULL) lastPoint->setUpdateTime(timestamp);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   161
	};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   162
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   163
};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   164
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   165
#endif