public void addTuioObject(TuioObject tobj) { Console.WriteLine("add obj " + tobj.getSymbolID() + " " + tobj.getSessionID() + " " + tobj.getX() + " " + tobj.getY() + " " + tobj.getAngle()); }
public void updateTuioObject(TuioObject tobj) { Console.WriteLine("set obj " + tobj.getSymbolID() + " " + tobj.getSessionID() + " " + tobj.getX() + " " + tobj.getY() + " " + tobj.getAngle() + " " + tobj.getMotionSpeed() + " " + tobj.getRotationSpeed() + " " + tobj.getMotionAccel() + " " + tobj.getRotationAccel()); }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { //if any of the inputs has changed //recompute the outputs if (FTUIOPacketInput.PinIsChanged) { string currentPacket; FTUIOPacketInput.GetString(0, out currentPacket); if (currentPacket == "" || currentPacket == null) { return; } int tuioPosition = currentPacket.IndexOf("#bundle"); if (tuioPosition == -1) { return; } while ((tuioPosition = currentPacket.IndexOf("#bundle")) >= 0) { int nextpos = currentPacket.IndexOf("#bundle", tuioPosition + 1); string currentSeperatedPacket = ""; if (nextpos == -1) { currentSeperatedPacket = currentPacket; currentPacket = ""; } else { currentSeperatedPacket = currentPacket.Substring(tuioPosition, nextpos - tuioPosition); currentPacket = currentPacket.Substring(nextpos); } OSC.NET.OSCPacket packet = OSC.NET.OSCPacket.Unpack(Encoding.Default.GetBytes(currentSeperatedPacket)); if (packet.IsBundle()) { ArrayList messages = packet.Values; for (int i = 0; i < messages.Count; i++) { FTuioClient.ProcessMessage((OSC.NET.OSCMessage)messages[i]); } } else { FTuioClient.ProcessMessage((OSC.NET.OSCMessage)packet); } } } List <TuioCursor> cursors = FTuioClient.getTuioCursors(); List <TuioObject> objects = FTuioClient.getTuioObjects(); List <TuioBlob> blobs = FTuioClient.getTuioBlobs(); int slicecount = cursors.Count + objects.Count + blobs.Count; FSessionIDOut.SliceCount = slicecount; FClassIDOut.SliceCount = slicecount; FUniqueIDOut.SliceCount = slicecount; FPosXOut.SliceCount = slicecount; FPosYOut.SliceCount = slicecount; FWidthOut.SliceCount = slicecount; FHeightOut.SliceCount = slicecount; FAreaOut.SliceCount = slicecount; FAngleOut.SliceCount = slicecount; FMovementXOut.SliceCount = slicecount; FMovementYOut.SliceCount = slicecount; FMotionAccelerationOut.SliceCount = slicecount; FRotationAccelerationOut.SliceCount = slicecount; FMotionSpeedOut.SliceCount = slicecount; FRotationSpeedOut.SliceCount = slicecount; int curindex = 0; for (int i = 0; i < cursors.Count; i++) { TuioCursor cur = cursors[i]; FSessionIDOut.SetValue(curindex, cur.getSessionID()); FClassIDOut.SetValue(curindex, 0); FUniqueIDOut.SetValue(curindex, cur.getFingerID()); FPosXOut.SetValue(curindex, cur.getPosition().getX() * 2 - 1); FPosYOut.SetValue(curindex, -cur.getPosition().getY() * 2 + 1); FAngleOut.SetValue(curindex, 0); FMovementXOut.SetValue(curindex, cur.getXSpeed()); FMovementYOut.SetValue(curindex, cur.getYSpeed()); FMotionAccelerationOut.SetValue(curindex, cur.getMotionAccel()); FRotationAccelerationOut.SetValue(curindex, 0); FMotionSpeedOut.SetValue(curindex, cur.getMotionSpeed()); FRotationSpeedOut.SetValue(curindex, 0); curindex++; } int objectOffset = 1000; for (int i = 0; i < objects.Count; i++) { TuioObject obj = objects[i]; FSessionIDOut.SetValue(curindex, obj.getSessionID()); FClassIDOut.SetValue(curindex, 1); FUniqueIDOut.SetValue(curindex, obj.getFiducialID() + objectOffset); FPosXOut.SetValue(curindex, obj.getPosition().getX() * 2 - 1); FPosYOut.SetValue(curindex, -obj.getPosition().getY() * 2 + 1); FAngleOut.SetValue(curindex, 1 - ((obj.getAngle()) / (Math.PI + Math.PI))); FMovementXOut.SetValue(curindex, obj.getXSpeed()); FMovementYOut.SetValue(curindex, obj.getYSpeed()); FMotionAccelerationOut.SetValue(curindex, obj.getMotionAccel()); FRotationAccelerationOut.SetValue(curindex, obj.getRotationAccel()); FMotionSpeedOut.SetValue(curindex, obj.getMotionSpeed()); FRotationSpeedOut.SetValue(curindex, obj.getRotationSpeed()); curindex++; } int blobOffset = 2000; for (int i = 0; i < blobs.Count; i++) { TuioBlob blb = blobs[i]; FSessionIDOut.SetValue(curindex, blb.getSessionID()); FClassIDOut.SetValue(curindex, 2); FUniqueIDOut.SetValue(curindex, blb.getBlobID() + blobOffset); FPosXOut.SetValue(curindex, blb.getPosition().getX() * 2 - 1); FPosYOut.SetValue(curindex, -blb.getPosition().getY() * 2 + 1); FWidthOut.SetValue(curindex, blb.getWidth()); FHeightOut.SetValue(curindex, blb.getHeight()); FAreaOut.SetValue(curindex, blb.getArea()); FAngleOut.SetValue(curindex, 1 - ((blb.getAngle()) / (Math.PI + Math.PI))); FMovementXOut.SetValue(curindex, blb.getXSpeed()); FMovementYOut.SetValue(curindex, blb.getYSpeed()); FMotionAccelerationOut.SetValue(curindex, blb.getMotionAccel()); FRotationAccelerationOut.SetValue(curindex, blb.getRotationAccel()); FMotionSpeedOut.SetValue(curindex, blb.getMotionSpeed()); FRotationSpeedOut.SetValue(curindex, blb.getRotationSpeed()); curindex++; } }