# HG changeset patch # User bastiena # Date 1331814925 -3600 # Node ID f4e52a4c34b3b1f7e137b54d059ea53e11839904 # Parent 92f19af390245aa51b258946d2c350180e7d0b6c Removing jars and cs unused classes. diff -r 92f19af39024 -r f4e52a4c34b3 front_processing/extern/TUIO_JAVA/TuioDemo.jar Binary file front_processing/extern/TUIO_JAVA/TuioDemo.jar has changed diff -r 92f19af39024 -r f4e52a4c34b3 front_processing/extern/TUIO_JAVA/libTUIO.jar Binary file front_processing/extern/TUIO_JAVA/libTUIO.jar has changed diff -r 92f19af39024 -r f4e52a4c34b3 front_processing/extern/TUIO_PROCESSING/src/LICENSE.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_processing/extern/TUIO_PROCESSING/src/LICENSE.txt Thu Mar 15 13:35:25 2012 +0100 @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff -r 92f19af39024 -r f4e52a4c34b3 front_processing/extern/TUIO_PROCESSING/src/TUIO/TuioProcessing.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_processing/extern/TUIO_PROCESSING/src/TUIO/TuioProcessing.java Thu Mar 15 13:35:25 2012 +0100 @@ -0,0 +1,285 @@ +/* + TUIO processing library - part of the reacTIVision project + http://reactivision.sourceforge.net/ + + Copyright (c) 2005-2009 Martin Kaltenbrunner + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +package TUIO; + +import java.awt.event.*; +import java.lang.reflect.*; +import processing.core.*; +import java.util.*; + +public class TuioProcessing implements TuioListener { + + private PApplet parent; + private Method addTuioObject, removeTuioObject, updateTuioObject, addTuioCursor, removeTuioCursor, updateTuioCursor, addTuioString, removeTuioString, updateTuioString, refresh; + private TuioClient client; + + public TuioProcessing(PApplet parent) { + this(parent,3333); + } + + public TuioProcessing(PApplet parent, int port) { + this.parent = parent; + parent.registerDispose(this); + + try { refresh = parent.getClass().getMethod("refresh",new Class[] { TuioTime.class } ); } + catch (Exception e) { + System.out.println("TUIO: missing or wrong 'refresh(TuioTime bundleTime)' method implementation"); + refresh = null; + } + + try { addTuioObject = parent.getClass().getMethod("addTuioObject", new Class[] { TuioObject.class }); } + catch (Exception e) { + System.out.println("TUIO: missing or wrong 'addTuioObject(TuioObject tobj)' method implementation"); + addTuioObject = null; + } + + try { removeTuioObject = parent.getClass().getMethod("removeTuioObject", new Class[] { TuioObject.class }); } + catch (Exception e) { + System.out.println("TUIO: missing or wrong 'removeTuioObject(TuioObject tobj)' method implementation"); + removeTuioObject = null; + } + + try { updateTuioObject = parent.getClass().getMethod("updateTuioObject", new Class[] { TuioObject.class }); } + catch (Exception e) { + System.out.println("TUIO: missing or wrong 'updateTuioObject(TuioObject tobj)' method implementation"); + updateTuioObject = null; + } + + try { addTuioCursor = parent.getClass().getMethod("addTuioCursor", new Class[] { TuioCursor.class }); } + catch (Exception e) { + System.out.println("TUIO: missing or wrong 'addTuioCursor(TuioCursor tcur)' method implementation"); + addTuioCursor = null; + } + + try { removeTuioCursor = parent.getClass().getMethod("removeTuioCursor", new Class[] { TuioCursor.class }); } + catch (Exception e) { + System.out.println("TUIO:missing or wrong 'removeTuioCursor(TuioCursor tcur)' method implementation"); + removeTuioCursor = null; + } + + try { updateTuioCursor = parent.getClass().getMethod("updateTuioCursor", new Class[] { TuioCursor.class }); } + catch (Exception e) { + System.out.println("TUIO: missing or wrong 'updateTuioCursor(TuioCursor tcur)' method implementation"); + updateTuioCursor = null; + } + + try { addTuioString = parent.getClass().getMethod("addTuioString", new Class[] { TuioString.class }); } + catch (Exception e) { + System.out.println("TUIO: missing or wrong 'addTuioString(TuioString tstr)' method implementation"); + addTuioString = null; + } + + try { removeTuioString = parent.getClass().getMethod("removeTuioString", new Class[] { TuioString.class }); } + catch (Exception e) { + System.out.println("TUIO:missing or wrong 'removeTuioString(TuioString tstr)' method implementation"); + removeTuioString = null; + } + + try { updateTuioString = parent.getClass().getMethod("updateTuioString", new Class[] { TuioString.class }); } + catch (Exception e) { + System.out.println("TUIO: missing or wrong 'updateTuioString(TuioString tstr)' method implementation"); + updateTuioString = null; + } + + client = new TuioClient(port); + client.addTuioListener(this); + client.connect(); + } + + public void addTuioObject(TuioObject tobj) { + if (addTuioObject!=null) { + try { + addTuioObject.invoke(parent, new Object[] { tobj }); + } + catch (IllegalAccessException e) {} + catch (IllegalArgumentException e) {} + catch (InvocationTargetException e) {} + } + } + + public void updateTuioObject(TuioObject tobj) { + + if (updateTuioObject!=null) { + try { + updateTuioObject.invoke(parent, new Object[] { tobj }); + } + catch (IllegalAccessException e) {} + catch (IllegalArgumentException e) {} + catch (InvocationTargetException e) {} + } + } + + public void removeTuioObject(TuioObject tobj) { + if (removeTuioObject!=null) { + try { + removeTuioObject.invoke(parent, new Object[] { tobj }); + } + catch (IllegalAccessException e) {} + catch (IllegalArgumentException e) {} + catch (InvocationTargetException e) {} + } + } + + public void addTuioCursor(TuioCursor tcur) { + if (addTuioCursor!=null) { + try { + addTuioCursor.invoke(parent, new Object[] { tcur }); + } + catch (IllegalAccessException e) {} + catch (IllegalArgumentException e) {} + catch (InvocationTargetException e) {} + } + } + + public void updateTuioCursor(TuioCursor tcur) { + if (updateTuioCursor!=null) { + try { + updateTuioCursor.invoke(parent, new Object[] { tcur }); + } + catch (IllegalAccessException e) {} + catch (IllegalArgumentException e) {} + catch (InvocationTargetException e) {} + } + } + + public void removeTuioCursor(TuioCursor tcur) { + if (removeTuioCursor!=null) { + try { + removeTuioCursor.invoke(parent, new Object[] { tcur }); + } + catch (IllegalAccessException e) {} + catch (IllegalArgumentException e) {} + catch (InvocationTargetException e) {} + } + } + + public void addTuioString(TuioString tstr) { + if (addTuioString!=null) { + try { + addTuioString.invoke(parent, new Object[] { tstr }); + } + catch (IllegalAccessException e) {} + catch (IllegalArgumentException e) {} + catch (InvocationTargetException e) {} + } + } + + public void updateTuioString(TuioString tstr) { + if (updateTuioString!=null) { + try { + updateTuioString.invoke(parent, new Object[] { tstr }); + } + catch (IllegalAccessException e) {} + catch (IllegalArgumentException e) {} + catch (InvocationTargetException e) {} + } + } + + public void removeTuioString(TuioString tstr) { + if (removeTuioString!=null) { + try { + removeTuioString.invoke(parent, new Object[] { tstr }); + } + catch (IllegalAccessException e) {} + catch (IllegalArgumentException e) {} + catch (InvocationTargetException e) {} + } + } + + public void refresh(TuioTime bundleTime) { + if (refresh!=null) { + try { + refresh.invoke(parent,new Object[] { bundleTime }); + } + catch (IllegalAccessException e) {} + catch (IllegalArgumentException e) {} + catch (InvocationTargetException e) {} + } + } + + public Vector getTuioObjects() { + return client.getTuioObjects(); + } + + public Vector getTuioCursors() { + return client.getTuioCursors(); + } + + public Vector getTuioStrings() { + return client.getTuioStrings(); + } + + public TuioObject getTuioObject(long s_id) { + return client.getTuioObject(s_id); + } + + public TuioCursor getTuioCursor(long s_id) { + return client.getTuioCursor(s_id); + } + + public TuioString getTuioString(long s_id) { + return client.getTuioString(s_id); + } + + public void pre() { + //method that's called just after beginFrame(), meaning that it + //can affect drawing. + } + + public void draw() { + //method that's called at the end of draw(), but before endFrame(). + } + + public void mouseEvent(MouseEvent e) { + //called when a mouse event occurs in the parent applet + } + + public void keyEvent(KeyEvent e) { + //called when a key event occurs in the parent applet + } + + public void post() { + //method called after draw has completed and the frame is done. + //no drawing allowed. + } + + public void size(int width, int height) { + //this will be called the first time an applet sets its size, but + //also any time that it's called while the PApplet is running. + } + + public void stop() { + //can be called by users, for instance movie.stop() will shut down + //a movie that's being played, or camera.stop() stops capturing + //video. server.stop() will shut down the server and shut it down + //completely, which is identical to its "dispose" function. + } + + public void dispose() { + + if (client.isConnected()) client.disconnect(); + + //this should only be called by PApplet. dispose() is what gets + //called when the host applet is stopped, so this should shut down + //any threads, disconnect from the net, unload memory, etc. + } +} diff -r 92f19af39024 -r f4e52a4c34b3 front_processing/extern/TUIO_PROCESSING/src/compile.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_processing/extern/TUIO_PROCESSING/src/compile.bat Thu Mar 15 13:35:25 2012 +0100 @@ -0,0 +1,10 @@ +rem javac -O -source 1.4 -target 1.4 -cp TUIO\libTUIO.jar:TUIO\core.jar TUIO\*.java +rem javaw -Dfile.encoding=Cp1252 -classpath C:\Users\bastiena\Documents\processing-1.5.1-windows-expert\processing-1.5.1\lib\core.jar;..\TUIO_JAVA\libTUIO.jar processing.core.PApplet + +javac -O -source 1.4 -target 1.4 -cp ..\library\libTUIO.jar;..\..\..\..\..\IDILL\DEV\TUIO_Processing-1.4\TUIO_Processing\library\core.jar TUIO\*.java +jar cfm ..\library\TUIO.jar manifest.inc TUIO\*.class +del TUIO\*.class + +rem javac -O -source 1.4 -target 1.4 -cp ..\library\libTUIO.jar:core.jar TUIO\*.java +rem jar cfm ..\library\libTUIO.jar manifest.inc TUIO\*.class +rem del TUIO\*.class \ No newline at end of file diff -r 92f19af39024 -r f4e52a4c34b3 front_processing/extern/TUIO_PROCESSING/src/compile.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_processing/extern/TUIO_PROCESSING/src/compile.sh Thu Mar 15 13:35:25 2012 +0100 @@ -0,0 +1,4 @@ +#!/bin/sh +javac -Xlint:unchecked -O -source 1.4 -target 1.4 -cp ../library/libTUIO.jar:core.jar TUIO/*.java +jar cfm ../library/TUIO.jar manifest.inc TUIO/*.class +rm -f TUIO/*.class diff -r 92f19af39024 -r f4e52a4c34b3 front_processing/extern/TUIO_PROCESSING/src/manifest.inc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_processing/extern/TUIO_PROCESSING/src/manifest.inc Thu Mar 15 13:35:25 2012 +0100 @@ -0,0 +1,1 @@ +Class-Path: libTUIO.jar diff -r 92f19af39024 -r f4e52a4c34b3 front_processing/src/Trakers/code/TUIO.jar Binary file front_processing/src/Trakers/code/TUIO.jar has changed diff -r 92f19af39024 -r f4e52a4c34b3 front_processing/src/Trakers_gestures/Trakers_gestures.pde --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/front_processing/src/Trakers_gestures/Trakers_gestures.pde Thu Mar 15 13:35:25 2012 +0100 @@ -0,0 +1,63 @@ +import TUIO.*; +TuioProcessing tuioClient; + +/*FONCTION D'INITIALISATION +Entrée : +Sortie : Création de la fenêtre et du client TUIO*/ +void setup() +{ + size (640, 480); + showMask(); + tuioClient = new TuioProcessing(this, 80); + textAlign(CENTER); + imageMode(CENTER); + smooth(); +} + +/*FONCTION DE DESSIN +Entrée : +Sortie : Appel à la fonction de traitement d'input du serveur toutes les n millisecondes*/ +void draw() +{ + fill(0); + tuioStringInput(); + noStroke(); +} + +/*FONCTION DE GENERATION DU MASQUE +Entrée : +Sortie : Place des rectangles autour de la zone de dessin*/ +void showMask() +{ + background(0); + fill(255); + rect(0, 80, width, height-130); +} + +/*FONCTION DE RECEPTION DES MESSAGES OSC +Entrée : +Sortie : Appel aux différentes fonctions de dessin si un message est reçu*/ +void tuioStringInput() +{ + fill(255); + Vector tuioStringList = tuioClient.getTuioStrings(); + if(tuioStringList == null || tuioStringList.size() <= 0) + { + showMask(); + text("Gesture non détectée.", width/2 - 20, 20); + } + else + { + showMask(); + showGestureMessage((TuioString)tuioStringList.elementAt(0)); + } +} + +/*FONCTION D'AFFICHAGE DU CODE DE LA GESTURE DETECTEE +Entree : +Sortie : Affichage du code de la gesture*/ +void showGestureMessage(TuioString tstr) +{ + text("Gesture détectée : " + tstr.getMessage(), width/2 - 20, 20); +} + diff -r 92f19af39024 -r f4e52a4c34b3 middleware/extern/TuioServer/TuioServer/TuioString.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/middleware/extern/TuioServer/TuioServer/TuioString.cs Thu Mar 15 13:35:25 2012 +0100 @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Media.Media3D; + +namespace Tuio +{ + /// + /// TUIO cursor. + /// + /// (c) 2010 by Dominik Schmidt (schmidtd@comp.lancs.ac.uk) + /// + public class TuioString + { + #region properties + + public int Id { get; private set; } + + public String message { get; set; } + + #endregion + + #region constructors + + public TuioString(int id, String msg) + { + Id = id; + message = msg; + } + + #endregion + + } +} diff -r 92f19af39024 -r f4e52a4c34b3 middleware/src/Communication/TuioCursor.cs --- a/middleware/src/Communication/TuioCursor.cs Thu Mar 15 13:33:21 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; - -namespace Tuio -{ - /// - /// TUIO cursor. - /// - /// (c) 2010 by Dominik Schmidt (schmidtd@comp.lancs.ac.uk) - /// - public class TuioCursor - { - #region properties - - public int Id { get; private set; } - - public PointF Location { get; set; } - - public PointF Speed { get; set; } - - public float MotionAcceleration { get; set; } - - #endregion - - #region constructors - - public TuioCursor(int id, PointF location) - { - Id = id; - Location = location; - } - - #endregion - - } -} diff -r 92f19af39024 -r f4e52a4c34b3 middleware/src/Communication/TuioServer.cs --- a/middleware/src/Communication/TuioServer.cs Thu Mar 15 13:33:21 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,186 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Net; -using System.Text; - -using Bespoke.Common.Osc; - -namespace Tuio -{ - /// - /// Simple, still uncomplete implementation of a TUIO server in C#. - /// - /// Current shortcomings: - /// Object support missing. - /// Does not implement frame times. - /// Only supports external TUIO cursors. - /// Allways commits all cursors. - /// - /// (c) 2010 by Dominik Schmidt (schmidtd@comp.lancs.ac.uk) - /// - public class TuioServer - { - #region constants - - private const string _cursorAddressPattern = "/tuio/2Dcur"; - - private const string _objectAddressPattern = "/tuio/2Dobj"; - - #endregion - - #region fields - - private IPEndPoint _ipEndPoint; - - private Dictionary _cursors; - - private int _currentFrame; - - #endregion - - #region constructors - - /// - /// Creates a new server with and endpoint at localhost, port 3333. - /// - public TuioServer() : this("127.0.0.1", 3333) { } - - /// - /// Creates a new server. - /// - /// Endpoint host - /// Endpoint port - public TuioServer(string host, int port) - { - _cursors = new Dictionary(); - _ipEndPoint = new IPEndPoint(IPAddress.Parse(host), port); - _currentFrame = 0; - } - - #endregion - - #region frame related methods - - /// - /// Initialized a new frame and increases the frame counter. - /// - public void InitFrame() - { - _currentFrame++; - } - - /// - /// Commits the current frame. - /// - public void CommitFrame() - { - GetFrameBundle().Send(_ipEndPoint); - } - - #endregion - - #region cursor related methods - - /// - /// Adds a TUIO cursor. A new id, not used before, must be provided. - /// - /// New id - /// Location - public void AddTuioCursor(int id, PointF location) - { - lock(_cursors) - if(!_cursors.ContainsKey(id)) - _cursors.Add(id, new TuioCursor(id, location)); - } - - /// - /// Updates a TUIO cursor. An id of an existing cursor must be provided. - /// - /// Id - /// Location - public void UpdateTuioCursor(int id, PointF location) - { - TuioCursor cursor; - if(_cursors.TryGetValue(id, out cursor)) - cursor.Location = location; - } - - /// - /// Deletes a TUIO cursor. An id of an existing cursor must be provided. - /// - /// Id - public void DeleteTuioCursor(int id) - { - lock (_cursors) - _cursors.Remove(id); - } - - #endregion - - #region osc message assembly - - private OscBundle GetFrameBundle() - { - OscBundle bundle = new OscBundle(_ipEndPoint); - - bundle.Append(GetAliveMessage()); - foreach (OscMessage msg in GetCursorMessages()) - bundle.Append(msg); - bundle.Append(GetSequenceMessage()); - - return bundle; - } - - private OscMessage GetAliveMessage() - { - OscMessage msg = new OscMessage(_ipEndPoint, _cursorAddressPattern); - - msg.Append("alive"); - lock (_cursors) - foreach (TuioCursor cursor in _cursors.Values) - msg.Append((Int32)cursor.Id); - - return msg; - } - - private OscMessage GetSequenceMessage() - { - OscMessage msg = new OscMessage(_ipEndPoint, _cursorAddressPattern); - - msg.Append("fseq"); - msg.Append((Int32)_currentFrame); - - return msg; - } - - private OscMessage GetCursorMessage(TuioCursor cursor) - { - OscMessage msg = new OscMessage(_ipEndPoint, _cursorAddressPattern); - - msg.Append("set"); - msg.Append((Int32)cursor.Id); - msg.Append(cursor.Location.X); - msg.Append(cursor.Location.Y); - msg.Append(cursor.Speed.X); - msg.Append(cursor.Speed.Y); - msg.Append(cursor.MotionAcceleration); - - return msg; - } - - private IEnumerable GetCursorMessages() - { - List msgs = new List(); - - lock (_cursors) - foreach (TuioCursor cursor in _cursors.Values) - msgs.Add(GetCursorMessage(cursor)); - - return msgs.AsEnumerable(); - } - - #endregion - } -} diff -r 92f19af39024 -r f4e52a4c34b3 middleware/src/Tracking/Events/JumpEventArgs.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/middleware/src/Tracking/Events/JumpEventArgs.cs Thu Mar 15 13:35:25 2012 +0100 @@ -0,0 +1,37 @@ +/* + * Projet : TraKERS + * Module : MIDDLEWARE + * Sous-Module : Tracking/Events + * Classe : JumpEventArgs + * + * Auteur : alexandre.bastien@iri.centrepompidou.fr + * + * Fonctionnalités : Cette classe contient les membres utilisés lors de l'appel au listener correspondant + * à l'événement : L'utilisateur a sauté. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Trakers.Communication; + +namespace Trakers.Tracking.Events +{ + public class JumpEventArgs : EventArgs + { + //Fenêtre de debug. + public readonly Debug.DebugWindow debug; + //Serveur TUIO. + public readonly Server server; + + /* + * Constructeur : Il prend l'affichage de debug et le serveur TUIO. + */ + public JumpEventArgs(Debug.DebugWindow _debug, Server _server) + { + debug = _debug; + server = _server; + } + } +} diff -r 92f19af39024 -r f4e52a4c34b3 middleware/src/Tracking/Events/JumpListener.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/middleware/src/Tracking/Events/JumpListener.cs Thu Mar 15 13:35:25 2012 +0100 @@ -0,0 +1,36 @@ +/* + * Projet : TraKERS + * Module : MIDDLEWARE + * Sous-Module : Tracking/Events + * Classe : JumpListener + * + * Auteur : alexandre.bastien@iri.centrepompidou.fr + * + * Fonctionnalités : Ce listener écoute l'événement du type : L'utilisateur a sauté. + * Il contient le code a être éxecuté au cas où cet événement survient, à savoir : + * - On affiche un visuel dans le debug. + * - On notifie le serveur TUIO. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Trakers.Tracking.Events +{ + public class JumpListener + { + /* + * Méthode appelée lorsque on a l'événement : L'utilisateur a sauté. + */ + public void ShowOnScreen(object o, JumpEventArgs e) + { + //On l'indique dans le debug. + //e.debug.showSwipe(e); + //e.debug.ExceptionLbl.Content = "SWIPE"; + //On notifie le serveur TUIO. + //e.server.LeftHandQuit(o, e); + } + } +} diff -r 92f19af39024 -r f4e52a4c34b3 middleware/src/Tracking/Events/PushEventArgs.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/middleware/src/Tracking/Events/PushEventArgs.cs Thu Mar 15 13:35:25 2012 +0100 @@ -0,0 +1,44 @@ +/* + * Projet : TraKERS + * Module : MIDDLEWARE + * Sous-Module : Tracking/Events + * Classe : PushEventArgs + * + * Auteur : alexandre.bastien@iri.centrepompidou.fr + * + * Fonctionnalités : Cette classe contient les membres utilisés lors de l'appel au listener correspondant + * à l'événement : L'utilisateur a effectué un push. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Trakers.Communication; +using Trakers.Tracking.Gestures; + +namespace Trakers.Tracking.Events +{ + public class PushEventArgs : EventArgs + { + //Fenêtre de debug. + public readonly Debug.DebugWindow debug; + //Serveur TUIO. + public readonly Server server; + //Direction du push. + public readonly PushDetector.Direction direction; + //Main ayant réalisé le push. + public readonly PushDetector.Hand hand; + + /* + * Constructeur : Il prend l'affichage de debug, le serveur TUIO et la direction du swipe. + */ + public PushEventArgs(Debug.DebugWindow _debug, Server _server, PushDetector.Direction _direction, PushDetector.Hand _hand) + { + debug = _debug; + server = _server; + direction = _direction; + hand = _hand; + } + } +} diff -r 92f19af39024 -r f4e52a4c34b3 middleware/src/Tracking/Events/PushListener.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/middleware/src/Tracking/Events/PushListener.cs Thu Mar 15 13:35:25 2012 +0100 @@ -0,0 +1,37 @@ +/* + * Projet : TraKERS + * Module : MIDDLEWARE + * Sous-Module : Tracking/Events + * Classe : PushListener + * + * Auteur : alexandre.bastien@iri.centrepompidou.fr + * + * Fonctionnalités : Ce listener écoute l'événement du type : L'utilisateur a effectué un push. + * Il contient le code a être éxecuté au cas où cet événement survient, à savoir : + * - On affiche un visuel dans le debug. + * - On notifie le serveur TUIO. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Trakers.Tracking.Events +{ + public class PushListener + { + /* + * Méthode appelée lorsque on a l'événement : L'utilisateur a effectué un push. + */ + public void ShowOnScreen(object o, PushEventArgs e) + { + //Console.Out.WriteLine("3"); + //On l'indique dans le debug. + e.debug.showPush(e); + //e.debug.ExceptionLbl.Content = "SWIPE"; + //On notifie le serveur TUIO. + e.server.Pull(o, e); + } + } +} diff -r 92f19af39024 -r f4e52a4c34b3 middleware/src/Tracking/Events/SwipeEventListener.cs --- a/middleware/src/Tracking/Events/SwipeEventListener.cs Thu Mar 15 13:33:21 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; - -namespace Trakers.Tracking.Events -{ - public class SwipeEventListener - { - /* - * Méthode appelée lorsque on a l'événement : L'utilisateur a effectué un swipe. - */ - public void ShowOnScreen(object o, SwipeEventArgs e) - { - //On l'indique dans le debug. - e.debug.showSwipe(); - //e.debug.ExceptionLbl.Content = "SWIPE"; - //On notifie le serveur TUIO. - //e.server.LeftHandQuit(o, e); - } - } -} diff -r 92f19af39024 -r f4e52a4c34b3 middleware/src/Tracking/Events/SwipeListener.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/middleware/src/Tracking/Events/SwipeListener.cs Thu Mar 15 13:35:25 2012 +0100 @@ -0,0 +1,37 @@ +/* + * Projet : TraKERS + * Module : MIDDLEWARE + * Sous-Module : Tracking/Events + * Classe : SwipeListener + * + * Auteur : alexandre.bastien@iri.centrepompidou.fr + * + * Fonctionnalités : Ce listener écoute l'événement du type : L'utilisateur a effectué un swipe. + * Il contient le code a être éxecuté au cas où cet événement survient, à savoir : + * - On affiche un visuel dans le debug. + * - On notifie le serveur TUIO. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; + +namespace Trakers.Tracking.Events +{ + public class SwipeListener + { + /* + * Méthode appelée lorsque on a l'événement : L'utilisateur a effectué un swipe. + */ + public void ShowOnScreen(object o, SwipeEventArgs e) + { + //On l'indique dans le debug. + e.debug.showSwipe(e); + //e.debug.ExceptionLbl.Content = "SWIPE"; + //On notifie le serveur TUIO. + e.server.Swipe(o, e); + } + } +} diff -r 92f19af39024 -r f4e52a4c34b3 middleware/src/Tracking/Gestures/JumpDetector.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/middleware/src/Tracking/Gestures/JumpDetector.cs Thu Mar 15 13:35:25 2012 +0100 @@ -0,0 +1,123 @@ +/* + * Projet : TraKERS + * Module : MIDDLEWARE + * Sous-Module : Tracking/Gestures + * Classe : JumpDetector + * + * Auteur : alexandre.bastien@iri.centrepompidou.fr + * + * Fonctionnalités : Permet de détecter si l'utilisateur a sauté, en se basant sur + * des règles appliquées à la positions des noeuds dans le temps. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Kinect; + +namespace Trakers.Tracking.Gestures +{ + public class JumpDetector : GestureDetector + { + Debug.DebugWindow debug; + static int n = 0; + + public JumpDetector(Debug.DebugWindow _d) : base() + { + debug = _d; + gesturePeriod = (float)1; + indexesPerSecond = 30; + indexesToCheck = (int)(gesturePeriod * indexesPerSecond); + } + + /* + * Lit les noeuds de l'historique du squelette afin de détecter un Jump. + * Règles : + * . + */ + public bool CheckForJump() + { + //Crée un historique de squelette local, puisque l'historique est mis à jour toutes les ~1/30 s. + List> localHistory = new List>(history); + + //Si il n'y a pas assez de positions dans l'historique local pour vérifier le geste. + if (localHistory.Count < indexesToCheck) + return false; + + /* (HeadBelowBaseLine || LeftKneeBelowBaseLine || RightKneeBelowBaseLine || + * LeftAnkleBelowBaseLine || RightAnkleBelowBaseLine || BodyFaceUpwards + * + * NOT + * + * AND + * + * HeadAboveBaseLine && LeftKneeAboveBaseLine && RightKneeAboveBaseLine && + * LegsStraightPreviouslyBent) + * + * OR + * + * HeadFarAboveBaseLine + */ + + //La distance de référence est ici la distance entre le milieu du dos et le milieu des épaules. + refDistance = Math.Abs(localHistory[0][spineID].Position.Y - localHistory[0][shoulderCenterID].Position.Y); + //On commence la position pour les indexesToCheck dernières postures (celle à l'index 0 étant la dernière). + + int beginIdx = localHistory.Count - indexesToCheck + 1; + int middleIdx = localHistory.Count - indexesToCheck / 2; + + bool middleOK = true, topOfJump = false; + + + + //De la position p1 à pn, on suit l'algorithme. + for (int i = beginIdx ; i < localHistory.Count ; i++) + { + + if (localHistory[i][handRightID].Position.Y < localHistory[beginIdx][handRightID].Position.Y + refDistance && + localHistory[i - 1][handRightID].Position.Y < localHistory[i][handRightID].Position.Y) + { + topOfJump = true; + //Console.Out.WriteLine("TOP"); + } + + if (localHistory[i - 1][handRightID].Position.Y > localHistory[i][handRightID].Position.Y && !topOfJump) + return false; + + //Si la position Y de la main est plus haute que la tête + //OU si la position Y de la main est plus basse que la hanche + //OU si la nouvelle position Z de la main est moins profonde que la précédente + //OU si la nouvelle position X de la main est plus éloignée de la distance N par rapport à la première position X + //OU si la nouvelle position Y de la main est plus éloignée de la distance N par rapport à la première position Y + //Alors la main en question ne fait pas de push. + if (localHistory[i-1][handRightID].Position.Y > localHistory[i][handRightID].Position.Y && + topOfJump || localHistory[i - 1][handRightID].Position.Y < localHistory[i][handRightID].Position.Y && + !topOfJump) + return false; + } + + //Console.Out.WriteLine("OK"); + + //Si la distance en Z du geste a été plus courte que la distance N + //Alors on retourne faux. + //float dist = (localHistory[localHistory.Count - 1][handRightID].Position.X - localHistory[localHistory.Count - indexesToCheck][handRightID].Position.X); + + //Console.WriteLine(Math.Abs(localHistory[0][handLeftID].Position.Z - localHistory[localHistory.Count - indexesToCheck][handLeftID].Position.Z) * 100 + " " + refDistance); + + //Si la dernière position de la main droite/gauche est sur le côté gauche/droit du corps + //OU si la première position calculée de la main droite/gauche est sur le côté gauche/droit du corps + //Alors on retourne faux. + + //if( + + //On supprime l'historique local. + //localHistory.Clear(Math.Abs(localHistory[i-1][handRightID].Position.Y)); + + debug.ExceptionLbl.Background = System.Windows.Media.Brushes.Yellow; + Console.WriteLine("{" + n++ + "}" + "JUMP"); + + return false; + } + } +} diff -r 92f19af39024 -r f4e52a4c34b3 middleware/src/Tracking/Gestures/PushDetector.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/middleware/src/Tracking/Gestures/PushDetector.cs Thu Mar 15 13:35:25 2012 +0100 @@ -0,0 +1,291 @@ +/* + * Projet : TraKERS + * Module : MIDDLEWARE + * Sous-Module : Tracking/Gestures + * Classe : PushDetector + * + * Auteur : alexandre.bastien@iri.centrepompidou.fr + * + * Fonctionnalités : Permet de détecter si l'utilisateur a effectué un Push, en se basant sur + * des règles appliquées à la positions des noeuds dans le temps. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Kinect; + +namespace Trakers.Tracking.Gestures +{ + public class PushDetector : GestureDetector + { + public enum Direction { PUSH, PULL }; + public enum Hand { LEFT, RIGHT, BOTH, NONE }; + + Debug.DebugWindow debug; + + public PushDetector(Debug.DebugWindow _d) : base() + { + debug = _d; + gesturePeriod = (float)0.3; + indexesPerSecond = 30; + indexesToCheck = (int)(gesturePeriod * indexesPerSecond); + } + + /* + * Lit les noeuds de l'historique du squelette afin de détecter un Push. + * Règles : + * Se fait avec une main (gauche ou droite). + * Chaque nouvelle position de la main doit être plus profonde que la précédente. + * Chaque nouvelle position de la main ne doit pas dévier trop de l'axe perpendiculaire au plan (X, Y). + * Le geste doit mesurer en profondeur une certaine distance. + */ + public Hand CheckForPush() + { + //Crée un historique de squelette local, puisque l'historique est mis à jour toutes les ~1/30 s. + List> localHistory = new List>(history); + + //Si il n'y a pas assez de positions dans l'historique local pour vérifier le geste. + if (localHistory.Count < indexesToCheck + 1) + return Hand.NONE; + + //La distance de référence est ici la distance entre le milieu du dos et le milieu des épaules. + refDistance = Math.Abs(localHistory[0][spineID].Position.Y - localHistory[0][shoulderCenterID].Position.Y); + //On commence la position pour les indexesToCheck dernières postures (celle à l'index 0 étant la dernière). + SkeletonPoint startPointLeft = localHistory[localHistory.Count - indexesToCheck][handLeftID].Position; + SkeletonPoint startPointRight = localHistory[localHistory.Count - indexesToCheck][handRightID].Position; + + //Booléens indiquant si le mouvement serait valide pour la main gauche ou droite. + bool leftHandOK = true, rightHandOK = true; + + //De la position p1 à pn, on suit l'algorithme. + for (int i = localHistory.Count - indexesToCheck + 1; i < localHistory.Count; i++) + { + if (localHistory[i][handRightID].Position.Y > localHistory[i][headID].Position.Y) + debug.R1.Fill = System.Windows.Media.Brushes.Blue; + else + debug.R1.Fill = System.Windows.Media.Brushes.DarkGray; + + if (localHistory[i][handRightID].Position.Y < localHistory[i][hipCenterID].Position.Y) + debug.R2.Fill = System.Windows.Media.Brushes.Blue; + else + debug.R2.Fill = System.Windows.Media.Brushes.DarkGray; + + if (localHistory[i][handRightID].Position.Z < localHistory[i - 1][handRightID].Position.Z) + debug.R3.Fill = System.Windows.Media.Brushes.Blue; + else + debug.R3.Fill = System.Windows.Media.Brushes.DarkGray; + + //Console.Out.WriteLine(Math.Abs(localHistory[i][handRightID].Position.X - startPointRight.X) + " " + Math.Abs(localHistory[i][handRightID].Position.Y - startPointRight.Y) + " " + refDistance / 10); + + if (Math.Abs(localHistory[i][handRightID].Position.X - startPointRight.X) < refDistance / 5 && + Math.Abs(localHistory[i][handRightID].Position.Y - startPointRight.Y) < refDistance / 5) + debug.R4.Fill = System.Windows.Media.Brushes.Blue; + else + debug.R4.Fill = System.Windows.Media.Brushes.DarkGray; + + //Si la position Y de la main est plus haute que la tête + //OU si la position Y de la main est plus basse que la hanche + //OU si la nouvelle position Z de la main est moins profonde que la précédente + //OU si la nouvelle position X de la main est plus éloignée de la distance N par rapport à la première position X + //OU si la nouvelle position Y de la main est plus éloignée de la distance N par rapport à la première position Y + //Alors la main en question ne fait pas de push. + if (localHistory[i][handLeftID].Position.Y < localHistory[i][headID].Position.Y || + localHistory[i][handLeftID].Position.Y > localHistory[i][hipCenterID].Position.Y || + localHistory[i][handLeftID].Position.Z > localHistory[i - 1][handLeftID].Position.Z || + Math.Abs(localHistory[i][handLeftID].Position.X - startPointLeft.X) > refDistance / 5 || + Math.Abs(localHistory[i][handLeftID].Position.Y - startPointLeft.Y) > refDistance / 5) + leftHandOK = false; + if (localHistory[i][handRightID].Position.Y < localHistory[i][headID].Position.Y || + localHistory[i][handRightID].Position.Y > localHistory[i][hipCenterID].Position.Y || + localHistory[i][handRightID].Position.Z > localHistory[i - 1][handRightID].Position.Z || + Math.Abs(localHistory[i][handRightID].Position.X - startPointRight.X) > refDistance / 5 || + Math.Abs(localHistory[i][handRightID].Position.Y - startPointRight.Y) > refDistance / 5) + rightHandOK = false; + + if (!leftHandOK && !rightHandOK) + return Hand.NONE; + } + + //Console.Out.WriteLine("OK"); + + if (Math.Abs(localHistory[localHistory.Count - 1][handRightID].Position.Z - localHistory[localHistory.Count - indexesToCheck][handRightID].Position.Z) * 100 > 20) + debug.R5.Fill = System.Windows.Media.Brushes.Blue; + else + debug.R5.Fill = System.Windows.Media.Brushes.DarkGray; + + if (localHistory[localHistory.Count - 1][handRightID].Position.X > localHistory[localHistory.Count - 1][hipCenterID].Position.X || + localHistory[localHistory.Count - indexesToCheck][handRightID].Position.X > localHistory[localHistory.Count - 1][hipCenterID].Position.X) + debug.R6.Fill = System.Windows.Media.Brushes.Blue; + else + debug.R6.Fill = System.Windows.Media.Brushes.DarkGray; + + //Si la distance en Z du geste a été plus courte que la distance N + //Alors on retourne faux. + //float dist = (localHistory[localHistory.Count - 1][handRightID].Position.X - localHistory[localHistory.Count - indexesToCheck][handRightID].Position.X); + + //Console.WriteLine(Math.Abs(localHistory[0][handLeftID].Position.Z - localHistory[localHistory.Count - indexesToCheck][handLeftID].Position.Z) * 100 + " " + refDistance); + + if (Math.Abs(localHistory[localHistory.Count - 1][handLeftID].Position.Z - localHistory[localHistory.Count - indexesToCheck][handLeftID].Position.Z) * 100 < 20) + leftHandOK = false; + if (Math.Abs(localHistory[localHistory.Count - 1][handRightID].Position.Z - localHistory[localHistory.Count - indexesToCheck][handRightID].Position.Z) * 100 < 20) + rightHandOK = false; + + /*if(rightHandOK || leftHandOK) + Console.Out.WriteLine("000000000");*/ + + //Si la dernière position de la main droite/gauche est sur le côté gauche/droit du corps + //OU si la première position calculée de la main droite/gauche est sur le côté gauche/droit du corps + //Alors on retourne faux. + if (localHistory[localHistory.Count - 1][handLeftID].Position.X > localHistory[localHistory.Count - 1][hipCenterID].Position.X || + localHistory[localHistory.Count - indexesToCheck][handLeftID].Position.X > localHistory[localHistory.Count - 1][hipCenterID].Position.X) + leftHandOK = false; + if (localHistory[localHistory.Count - 1][handRightID].Position.X < localHistory[localHistory.Count - 1][hipCenterID].Position.X || + localHistory[localHistory.Count - indexesToCheck][handRightID].Position.X < localHistory[localHistory.Count - 1][hipCenterID].Position.X) + rightHandOK = false; + + /*if (rightHandOK || leftHandOK) + Console.Out.WriteLine("11111111111");*/ + + if (!leftHandOK && !rightHandOK) + return Hand.NONE; + + /*if (rightHandOK || leftHandOK) + Console.Out.WriteLine("================");*/ + + //On supprime l'historique local. + localHistory.Clear(); + + debug.ExceptionLbl.Background = System.Windows.Media.Brushes.White; + //Console.WriteLine("PUSH"); + //Console.Read(); + + //Si on est arrivé jusqu'ici, toutes les conditions pour un push ont été remplies. + if (leftHandOK && rightHandOK) + return Hand.BOTH; + else if (leftHandOK) + return Hand.LEFT; + else if (rightHandOK) + return Hand.RIGHT; + + return Hand.NONE; + } + + /* + * Lit les noeuds de l'historique du squelette afin de détecter un Pull. + * Règles : + * Se fait avec une main. + * Chaque nouvelle position de la main doit être moins profonde que la précédente. + * Chaque nouvelle position de la main ne doit pas dévier trop de l'axe perpendiculaire au plan (X, Y). + * Le geste doit mesurer en profondeur une certaine distance. + */ + public Hand CheckForPull() + { + //Crée un historique de squelette local, puisque l'historique est mis à jour toutes les ~1/30 s. + List> localHistory = new List>(history); + + //Si il n'y a pas assez de positions dans l'historique local pour vérifier le geste. + if (localHistory.Count < indexesToCheck + 1) + return Hand.NONE; + + //La distance de référence est ici la distance entre le milieu du dos et le milieu des épaules. + refDistance = Math.Abs(localHistory[0][spineID].Position.Y - localHistory[0][shoulderCenterID].Position.Y); + //On commence la position pour les indexesToCheck dernières postures (celle à l'index 0 étant la dernière). + SkeletonPoint startPointLeft = localHistory[localHistory.Count - indexesToCheck][handLeftID].Position; + SkeletonPoint startPointRight = localHistory[localHistory.Count - indexesToCheck][handRightID].Position; + + //Booléens indiquant si le mouvement serait valide pour la main gauche ou droite. + bool leftHandOK = true, rightHandOK = true; + + //De la position p1 à pn, on suit l'algorithme. + for (int i = localHistory.Count - indexesToCheck + 1; i < localHistory.Count; i++) + { + //Si la position Y de la main est plus haute que la tête + //OU si la position Y de la main est plus basse que la hanche + //OU si la nouvelle position Z de la main est plus profonde que la précédente + //OU si la nouvelle position X de la main est plus éloignée de la distance N par rapport à la première position X + //OU si la nouvelle position Y de la main est plus éloignée de la distance N par rapport à la première position Y + //Alors la main en question ne fait pas de push. + if (localHistory[i][handLeftID].Position.Y < localHistory[i][headID].Position.Y || + localHistory[i][handLeftID].Position.Y > localHistory[i][hipCenterID].Position.Y || + localHistory[i][handLeftID].Position.Z < localHistory[i - 1][handLeftID].Position.Z || + Math.Abs(localHistory[i][handLeftID].Position.X - startPointLeft.X) > refDistance / 5 || + Math.Abs(localHistory[i][handLeftID].Position.Y - startPointLeft.Y) > refDistance / 5) + leftHandOK = false; + if (localHistory[i][handRightID].Position.Y < localHistory[i][headID].Position.Y || + localHistory[i][handRightID].Position.Y > localHistory[i][hipCenterID].Position.Y || + localHistory[i][handRightID].Position.Z < localHistory[i - 1][handRightID].Position.Z || + Math.Abs(localHistory[i][handRightID].Position.X - startPointRight.X) > refDistance / 5 || + Math.Abs(localHistory[i][handRightID].Position.Y - startPointRight.Y) > refDistance / 5) + rightHandOK = false; + + if (!leftHandOK && !rightHandOK) + return Hand.NONE; + } + + //Console.Out.WriteLine("OK"); + + if (Math.Abs(localHistory[localHistory.Count - 1][handRightID].Position.Z - localHistory[localHistory.Count - indexesToCheck][handRightID].Position.Z) * 100 > 20) + debug.R5.Fill = System.Windows.Media.Brushes.Blue; + else + debug.R5.Fill = System.Windows.Media.Brushes.DarkGray; + + if (localHistory[localHistory.Count - 1][handRightID].Position.X > localHistory[localHistory.Count - 1][hipCenterID].Position.X || + localHistory[localHistory.Count - indexesToCheck][handRightID].Position.X > localHistory[localHistory.Count - 1][hipCenterID].Position.X) + debug.R6.Fill = System.Windows.Media.Brushes.Blue; + else + debug.R6.Fill = System.Windows.Media.Brushes.DarkGray; + + //Si la distance en Z du geste a été plus courte que la distance N + //Alors on retourne faux. + //float dist = (localHistory[localHistory.Count - 1][handRightID].Position.X - localHistory[localHistory.Count - indexesToCheck][handRightID].Position.X); + + //Console.WriteLine(Math.Abs(localHistory[0][handLeftID].Position.Z - localHistory[localHistory.Count - indexesToCheck][handLeftID].Position.Z) * 100 + " " + refDistance); + + if (Math.Abs(localHistory[localHistory.Count - 1][handLeftID].Position.Z - localHistory[localHistory.Count - indexesToCheck][handLeftID].Position.Z) * 100 < 20) + leftHandOK = false; + if (Math.Abs(localHistory[localHistory.Count - 1][handRightID].Position.Z - localHistory[localHistory.Count - indexesToCheck][handRightID].Position.Z) * 100 < 20) + rightHandOK = false; + + /*if (rightHandOK || leftHandOK) + Console.Out.WriteLine("000000000");*/ + + //Si la dernière position de la main droite/gauche est sur le côté gauche/droit du corps + //OU si la première position calculée de la main droite/gauche est sur le côté gauche/droit du corps + //Alors on retourne faux. + if (localHistory[localHistory.Count - 1][handLeftID].Position.X > localHistory[localHistory.Count - 1][hipCenterID].Position.X || + localHistory[localHistory.Count - indexesToCheck][handLeftID].Position.X > localHistory[localHistory.Count - 1][hipCenterID].Position.X) + leftHandOK = false; + if (localHistory[localHistory.Count - 1][handRightID].Position.X < localHistory[localHistory.Count - 1][hipCenterID].Position.X || + localHistory[localHistory.Count - indexesToCheck][handRightID].Position.X < localHistory[localHistory.Count - 1][hipCenterID].Position.X) + rightHandOK = false; + + /*if (rightHandOK || leftHandOK) + Console.Out.WriteLine("11111111111");*/ + + if (!leftHandOK && !rightHandOK) + return Hand.NONE; + + /*if (rightHandOK || leftHandOK) + Console.Out.WriteLine("================");*/ + + //On supprime l'historique local. + localHistory.Clear(); + + debug.ExceptionLbl.Background = System.Windows.Media.Brushes.Black; + //Console.WriteLine("PUSH"); + //Console.Read(); + + //Si on est arrivé jusqu'ici, toutes les conditions pour un push ont été remplies. + if (leftHandOK && rightHandOK) + return Hand.BOTH; + else if (leftHandOK) + return Hand.LEFT; + else if (rightHandOK) + return Hand.RIGHT; + + return Hand.NONE; + } + } +}