Esempio n. 1
0
 public BBInputController()
 {
     client = new TuioClient(3333);
     client.addTuioListener(this);
     client.connect();
     cursorDidChange = false;
 }
Esempio n. 2
0
 public mtCntrConnector()
 {
     client = new TuioClient(3333);
     client.addTuioListener(this);
     client.connect();
     Debug.Log("Commencing TUIO connection");
 }
Esempio n. 3
0
 // Use this for initialization
 void Start()
 {
     client = new TuioClient(port);
     client.addTuioListener(this);
     client.connect();
     Debug.Log (client.isConnected());
 }
Esempio n. 4
0
    public TuioDemo(int port)
    {
        verbose = false;
            fullscreen = false;
            width = window_width;
            height = window_height;

            this.ClientSize = new System.Drawing.Size(width, height);
            this.Name = "TuioDemo";
            this.Text = "TuioDemo";

            this.Closing+=new CancelEventHandler(Form_Closing);
            this.KeyDown +=new KeyEventHandler(Form_KeyDown);

            this.SetStyle( ControlStyles.AllPaintingInWmPaint |
                            ControlStyles.UserPaint |
                            ControlStyles.DoubleBuffer, true);

            objectList = new Dictionary<long,TuioDemoObject>(128);
            cursorList = new Dictionary<long,TuioCursor>(128);

            client = new TuioClient(port);
            client.addTuioListener(this);
            client.connect();
    }
Esempio n. 5
0
        public override void Init()
        {
            base.Init();

            _client = new TuioClient(_port);
            _client.addTuioListener(this);
            _client.connect();
        }
Esempio n. 6
0
 public void Start()
 {
     client = new TuioClient();
     listener = new Listener(this);
     client.addTuioListener(listener);
     client.connect();
     IsRunning = true;
 }
Esempio n. 7
0
 public mtConnector(mtManager mang)
 {
     client = new TuioClient(3333);
     client.addTuioListener(this);
     client.connect();
     cursorDidChange = false;
     activeCursors = client.getTuioCursors();
     Debug.Log("Commencing TUIO connection");
     mtM = mang;
 }
Esempio n. 8
0
        public TuioManager()
        {
            if (m_Instance != null)
            {
                Debug.LogError("Trying to create two instances of singleton.");
                return;
            }

            m_Instance = this;

            m_Client = new TuioClient();
            m_Client.addTuioListener(this);

            //init members
            this.m_TUIOObjects = new List<TuioObject>();
        }
Esempio n. 9
0
    public static void Main(String[] argv)
    {
        TuioDump demo = new TuioDump();
            TuioClient client = null;

            switch (argv.Length) {
                case 1:
                    int port = 0;
                    port = int.Parse(argv[0],null);
                    if(port>0) client = new TuioClient(port);
                    break;
                case 0:
                    client = new TuioClient();
                    break;
            }

            if (client!=null) {
                client.addTuioListener(demo);
                client.connect();
                Console.WriteLine("listening to TUIO messages at port " + client.getPort());

            } else Console.WriteLine("usage: java TuioDump [port]");
    }
        /// <summary>
        /// Allows the game 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.
        /// </summary>
        protected override void Initialize()
        {
            // Moves starting window location
            myForm = (System.Windows.Forms.Form)System.Windows.Forms.Control.FromHandle(this.Window.Handle);
            myForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            myForm.Location = new System.Drawing.Point(0, 0);

            // Explicitly set number of samples for antialiasing; may not be necessary
            //GraphicsDevice.PresentationParameters.MultiSampleCount = 16;
            //Debug.WriteLine(graphicsDevice.PresentationParameters.MultiSampleCount);

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            //planktonTarget = new RenderTarget2D(GraphicsDevice, (int)(CIRCLE_RADIUS + CIRCLE_RADIUS_OVERSCAN) * 2, (int)(Game1.CIRCLE_RADIUS + Game1.CIRCLE_RADIUS_OVERSCAN) * 2);

            // Create a new renderTarget to prerender before drawing on screen.
            PresentationParameters pp = GraphicsDevice.PresentationParameters;
            fullScreenTarget = new RenderTarget2D(GraphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight, true, GraphicsDevice.DisplayMode.Format, DepthFormat.Depth24);

            maskTextureArray = new Color[(int)((Settings.CIRCLE_RADIUS + Settings.CIRCLE_RADIUS_OVERSCAN) * 2 * (Settings.CIRCLE_RADIUS + Settings.CIRCLE_RADIUS_OVERSCAN) * 2)];

            subtractAlpha = new BlendState();
            subtractAlpha.AlphaBlendFunction = BlendFunction.ReverseSubtract;
            subtractAlpha.AlphaSourceBlend = Blend.One;
            subtractAlpha.AlphaDestinationBlend = Blend.One;
            subtractAlpha.ColorBlendFunction = BlendFunction.ReverseSubtract;
            subtractAlpha.ColorSourceBlend = Blend.One;
            subtractAlpha.ColorDestinationBlend = Blend.One;

            // Initialize tools
            for (int i = 0; i < Settings.NUM_NUTRIENTTOOLS; i++)
            {
                nutrientTools.Enqueue(new NutrientTool(new Vector2(50, 350 + 100 * i)));
            }

            for (int i = 0; i < Settings.NUM_TEMPTOOLS; i++)
            {
                tempTools.Enqueue(new TempTool(new Vector2(50, 150 + i * 100)));
            }

            // Add datanames to the list
            //"T", "SiO2", "POSi"
            dataNames = new List<string>() { "PhyGrp1", "PhyGrp3", "PhyGrp4", "PhyGrp5" }; // PhyGrp data needs to be the first four
            if (Settings.SHOW_LIGHT)
                dataNames.Add("PAR");
            if (Settings.SHOW_NITRATE)
                dataNames.Add("NO3");
            if (Settings.SHOW_TEMP || Settings.NUM_TEMPTOOLS > 0)
                dataNames.Add("T");
            if (Settings.SHOW_SILICA || Settings.NUM_NUTRIENTTOOLS > 0)
                dataNames.Add("SiO2");

            // Set up data structure for all the data
            for (int i = 0; i < dataNames.Count; i++)
                theData.Add(dataNames[i], new Dictionary<int, byte[]>());

            // Draw a loading rectangle
            GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin();
            spriteBatch.DrawRectangle(new Rectangle(0, 0, 100, 100), Color.White);
            spriteBatch.End();
            base.Draw(new GameTime());

            // Load data from files
            FileStream[] fileStreams = new FileStream[dataNames.Count];
            for (int timestamp = 52704; timestamp <= 210384; timestamp += 1080)
            {
                Debug.WriteLine(string.Format("Reading data, {0}% complete...", ((float)timestamp - 52704.0) * 100.0 / (210384.0 - 52704.0)));

                for (int i = 0; i < dataNames.Count; i++)
                {
                    //// Read data from file into a float array
                    //float[] floats = new float[583200/4];
                    //byte[] fourBytes = new byte[4];
                    //fileStreams[i] = new FileStream(string.Format("Data\\{0}_{1}.data", dataNames[i], timestamp), FileMode.Open);
                    //Debug.WriteLine(string.Format("Reading {0}_{1}.data...", dataNames[i], timestamp));

                    //for (int j = 0; j < 583200/4; j++)
                    //{
                    //    // Read four bytes from the file
                    //    for (int k = 0; k < 4; k++)
                    //        fourBytes[k] = (byte)fileStreams[i].ReadByte();

                    //    // Convert four bytes to float (big-endian, so reverse it)
                    //    floats[j] = BitConverter.ToSingle(fourBytes.Reverse().ToArray(), 0);

                    //    // Check for NaN's
                    //    if (float.IsNaN(floats[j]))
                    //        floats[j] = 0;
                    //}

                    //// Add float data to the data structure
                    //theData[dataNames[i]].Add(timestamp, floats);

                    //// Done with this file
                    //fileStreams[i].Close();

                    // Read data from file
                    byte[] bytes = new byte[583200];
                    float[] floats = new float[583200 / 4];
                    byte[] fourBytes = new byte[4];
                    fileStreams[i] = new FileStream(string.Format("Data\\{0}_{1}.data", dataNames[i], timestamp), FileMode.Open);

                    // Read data from file into a byte array
                    fileStreams[i].Read(bytes, 0, 583200);

                    // Done with this file
                    fileStreams[i].Close();

                    //// Convert byte array to float array
                    //for (int j = 0; j < 583200 / 4; j++)
                    //{
                    //    // Read four bytes from the file
                    //    for (int k = 0; k < 4; k++)
                    //        fourBytes[k] = bytes[j*4+k];

                    //    // Convert four bytes to float (big-endian, so reverse it)
                    //    floats[j] = BitConverter.ToSingle(fourBytes.Reverse().ToArray(), 0);

                    //    // Check for NaN's
                    //    if (float.IsNaN(floats[j]))
                    //        floats[j] = 0;
                    //}

                    // Add byte array to the data structure
                    theData[dataNames[i]].Add(timestamp, bytes);

                }
                //Debug.WriteLine(timestamp);

                //// Save phytoplankton group distributions in a dictionary of timestamps
                //byte[][] values = new byte[4][];
                //for (int i = 0; i < 4; i++)
                //{
                //    values[i] = new byte[583200];
                //    fileStreams[i].Read(values[i], 0, 583200);
                //    fileStreams[i].Close();
                //}

                //phygrpData.Add(timestamp, values);

                // Load landmask data from file
                FileStream landmaskFS = new FileStream("Data\\landmask-2-540x270.data", FileMode.Open);
                landmaskFS.Read(landmaskArray, 0, 583200);
                landmaskFS.Close();
            }

            base.Initialize();

            // Initialize a TUIO client and set this LivingLiquid instance as a listener
            tuioClient = new TuioClient(3333);
            //Debug.WriteLine("Removing all TUIO listeners...");
            //tuioClient.removeAllTuioListeners();
            //Debug.WriteLine("Disconnecting TUIO client...is connected: " + tuioClient.isConnected());
            //tuioClient.disconnect();
            Debug.WriteLine("Adding TUIO listener......is connected: " + tuioClient.isConnected());
            tuioClient.addTuioListener(this);
            Debug.WriteLine("Connecting TUIO client...is connected: " + tuioClient.isConnected());
            tuioClient.connect();
            Debug.WriteLine("TUIO client connected: " + tuioClient.isConnected());

            // Initialize Tuio Time
            TuioTime.initSession();

            // Flag ready for input
            this.readyForInput = true;

            // Because the movie has greater than a 2:1 aspect ratio, need to vertically center on screen
            // This section locates a rectangle on screen where the movie should be displayed
            // (unless we're using a really weird narrow screen, in which case, redo this section)
            movieScale = (float)GraphicsDevice.Viewport.Width / (float)(video.Width);
            float movieScaledHeight = (float)(video.Height * movieScale);
            movieVerticalOffset = (GraphicsDevice.Viewport.Height - movieScaledHeight) / 2;
            movieDestination = new Rectangle(GraphicsDevice.Viewport.X,
                (int)(GraphicsDevice.Viewport.Y + movieVerticalOffset),
                GraphicsDevice.Viewport.Width,
                (int)movieScaledHeight);

            InitializeCircles();
        }
Esempio n. 11
0
        public TuioDemo(int port)
        {
            //  InitializeComponent();
            this.button1 = new System.Windows.Forms.Button();
            this.button2 = new System.Windows.Forms.Button();
            this.button3 = new System.Windows.Forms.Button();
            this.textBox1 = new System.Windows.Forms.TextBox();
            InitializeQueueArray(code);
            InitializeQueueArray(prev_code);
            int x = 5;
            int y = 5;
            mainGrid = new Grid(x, y, this);

            //Button 1
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(75, 23);
            this.button1.TabIndex = 0;
            this.button1.Text = "Register";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            //Button 2
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(75, 23);
            this.button2.TabIndex = 1;
            this.button2.Text = "Finish";
            this.button2.UseVisualStyleBackColor = true;
            this.button2.Click += new System.EventHandler(this.button2_Click);
            //Button 3
            this.button3.Name = "button3";
            this.button3.Size = new System.Drawing.Size(75, 23);
            this.button3.TabIndex = 2;
            this.button3.Text = "Authenticate";
            this.button3.UseVisualStyleBackColor = true;
            this.button3.Click += new System.EventHandler(this.button3_Click);
            //Textbox
            this.textBox1.ForeColor = System.Drawing.Color.Red;
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(286, 20);
            this.textBox1.TabIndex = 3;

            this.Controls.Add(this.textBox1);
            this.Controls.Add(this.button3);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.button1);

            verbose = false;
            fullscreen = false;
            width = mainGrid.getWidth();       //Used important, used for positioning cursors and such
            height = mainGrid.getHeight();     //Used important, used for positioning cursors and such

            this.ClientSize = new System.Drawing.Size(width, height);
            this.Name = "TuioDemo";     //cut
            this.Text = "TuioDemo";     //cut

            this.Closing += new CancelEventHandler(Form_Closing);//keep
            this.KeyDown += new KeyEventHandler(Form_KeyDown);//keep

            this.SetStyle(ControlStyles.AllPaintingInWmPaint |//keep
                            ControlStyles.UserPaint |
                            ControlStyles.DoubleBuffer, true);

            objectList = new Dictionary<long, TuioDemoObject>(128);//keep
            cursorList = new Dictionary<long, TuioCursor>(128);//keep

            client = new TuioClient(port);//keep
            client.addTuioListener(this);//keep
            client.connect();//keep
        }
Esempio n. 12
0
File: Form1.cs Progetto: solson/DSAE
        void Form1_Load(object sender, EventArgs e)
        {
            if (Program.kinectEnabled)
                kinectClient.RecalculateTable();

            // Set up GT
            var config = new DefaultClientConfiguration();
            client = new GT.Net.Client(config);

            client.ErrorEvent += delegate(ErrorSummary es)
            {
                Console.WriteLine(es);

                if (es.Context is GT.Net.CannotConnectException)
                {
                    Cursor.Show();
                    MessageBox.Show(this, "Could not connect to server. Make sure the ClientRepeater is started.");
                    quitting = true;
                }
            };

            client.ConnexionRemoved += client_ConnexionRemoved;
            client.Start();

            updates = client.OpenSessionChannel(host, port, SessionUpdatesChannelId,
                ChannelDeliveryRequirements.SessionLike);
            updates.MessagesReceived += updates_SessionMessagesReceived;

            coords = client.OpenStreamedTuple<int, int>(host, port, PointersChannelId,
                TimeSpan.FromMilliseconds(25),
                ChannelDeliveryRequirements.AwarenessLike);
            coords.StreamedTupleReceived += coords_StreamedTupleReceived;

            control = client.OpenStringChannel(host, port, ControlChannelId,
                ChannelDeliveryRequirements.CommandsLike);
            control.MessagesReceived += control_MessagesReceived;

            clicks = client.OpenStringChannel(host, port, ClickChannelId,
                ChannelDeliveryRequirements.CommandsLike);
            clicks.MessagesReceived += clicks_MessagesReceived;

            armImages = client.OpenObjectChannel(host, port, ArmImageChannelId,
                ChannelDeliveryRequirements.AwarenessLike);
            armImages.MessagesReceived += armImages_MessagesReceived;

            origins = client.OpenStreamedTuple<int, int>(host, port, OriginsChannelId,
                TimeSpan.FromMilliseconds(25),
                ChannelDeliveryRequirements.AwarenessLike);
            origins.StreamedTupleReceived += origins_StreamedTupleReceived;

            showArms = client.OpenStreamedTuple<bool>(host, port, ShowArmsChannelId,
                TimeSpan.FromMilliseconds(25),
                ChannelDeliveryRequirements.AwarenessLike);
            showArms.StreamedTupleReceived += showArms_StreamedTupleReceived;

            kinectCalibrationChannel = client.OpenObjectChannel(host, port, KinectCalibrationChannelId,
                ChannelDeliveryRequirements.CommandsLike);
            kinectCalibrationChannel.MessagesReceived += kinectCalibrationChannel_MessagesReceived;

            boxGrabChannel = client.OpenObjectChannel(host, port, BoxGrabChannelId,
                ChannelDeliveryRequirements.CommandsLike);
            boxGrabChannel.MessagesReceived += boxGrabChannel_MessagesReceived;

            if (Program.useTouch)
            {
                tuioClient = new TuioClient();
                tuioClient.addTuioListener(this);
                tuioClient.connect();
            }
        }
Esempio n. 13
0
		private void Stop()
		{
			_pointerTouchInfos.Clear();
			InjectPointerTouchInfos();

			if (_tuioClient != null)
			{
				_tuioClient.disconnect();
				_tuioClient.removeTuioListener(this);
				_tuioClient = null;
			}
		}
Esempio n. 14
0
        public void StartTuio(int port)
        {
            verbose = false;
            fullscreen = false;
            width = window_width;
            height = window_height;

            // this.ClientSize = new System.Drawing.Size(width, height);
            // this.Name = "TuioDemo";
            // this.Text = "TuioDemo";

            this.SetStyle(  ControlStyles.AllPaintingInWmPaint |
                            ControlStyles.UserPaint |
                            ControlStyles.DoubleBuffer, true);

            objectList = new Dictionary<long,TuioDemoObject>(128);
            cursorList = new Dictionary<long,TuioCursor>(128);

            client = new TuioClient(port);
            client.addTuioListener(this);
            client.connect();
        }
Esempio n. 15
0
        public void addtuioclient()
        {
            client = null;
            client = new TuioClient(Convert.ToInt32(tuio_port.Text));

            if (client != null)
            {
                client.addTuioListener(Listener);
                client.connect();
                Console.WriteLine("listening to TUIO messages at port " + client.getPort());
                timer1 = new Timer();
                timer1.Interval = 100;
                timer1.Enabled = true;
                timer1.Tick += new System.EventHandler(OnTimerEvent);
            }
            else Console.WriteLine("usage: java TuioDump [port]");
        }
Esempio n. 16
0
        private void bttConnect_Click(object sender, RoutedEventArgs e)
        {
            if (client == null)
            {
                try
                {
                    client = new TuioClient(int.Parse(txtPort.Text));
                    client.addTuioListener(this);
                    client.connect();
                    bttConnect.Content = "Disconnect";
                    lblContent.Content = "Simulator has working !";
                    DrawLogSystem("Simulator has working!");

                }
                catch (Exception e2)
                {
                    lblContent.Content = "Can't connect to TUIO host!\nPlease change another port !";
                    client = null;

                    DrawLogSystem("Simulator can't connect to TUIO host!");
                }
            }
            else
            {
                client.disconnect();
                client = null;
                lblContent.Content = "Simulator has stop working !";
                bttConnect.Content = "Connect...";
                DrawLogSystem("Simulator has stop working!");
            }
        }
Esempio n. 17
0
		private void Start()
		{
			if (_tuioClient != null) 
			{ 
				Stop(); 
			}

			TouchInjection.Initialize(MAX_CONTACTS, this.IsContactVisible ? TouchFeedback.INDIRECT : TouchFeedback.NONE);

			_tuioClient = new TuioClient(this.Port);
			_tuioClient.addTuioListener(this);
			try
			{
				_tuioClient.connect();
			}
			catch (Exception e)
			{
				this.IsEnabled = false;
				if (e is SocketException)
				{
					SocketException se = (SocketException)e;
					MessageBox.Show(string.Format("{0}\r\n\r\nError Code: {1} ({2})", se.Message, se.ErrorCode, se.SocketErrorCode), "Error: SocketException", MessageBoxButton.OK, MessageBoxImage.Error);
				}
			}
		}
Esempio n. 18
0
 public TuioUnityListener()
 {
     client = new TuioClient();
     client.addTuioListener(this);
     client.connect();
 }
Esempio n. 19
0
    // Use this for initialization
    void Start()
    {
        verbose = true;

        objectList = new Dictionary<long,TuioObject>(128);
        cursorList = new Dictionary<long,TuioCursor>(128);
        blobList = new Dictionary<long,TuioBlob>(128);

        client = new TuioClient(port);
        client.addTuioListener(this);
        client.connect();
    }
Esempio n. 20
0
        static void Main(String[] argv)
        {
            float x = 0, y = 0, w = 10, h = 10, a = 0;

            int port = 3333;
            switch (argv.Length)
            {
                case 0:
                    break;

                case 1:
                    port = int.Parse(argv[0], null);
                    if (port == 0) goto default;
                    break;

                case 5:
                    x = float.Parse(argv[0], null);
                    y = float.Parse(argv[1], null);
                    w = float.Parse(argv[2], null);
                    h = float.Parse(argv[3], null);
                    a = float.Parse(argv[4], null);
                    break;

                case 6:
                    x = float.Parse(argv[1], null);
                    y = float.Parse(argv[2], null);
                    w = float.Parse(argv[3], null);
                    h = float.Parse(argv[4], null);
                    a = float.Parse(argv[5], null);
                    goto case 1;

                default:
                    Console.WriteLine("Usage: [mono] GrafitiGenericDemo [port] [x y w h a]");
                    System.Environment.Exit(0);
                    break;
            }

            // Force compilation of GR classes
            new PinchingGR();
            new BasicMultiFingerGR();
            new MultiTraceGR();
            new CircleGR();
            new LazoGR();
            new RemovingLinkGR();

            // instantiate viewer
            s_viewer = new Viewer(x, y, w, h, a);

            // instantiate Grafiti
            s_grafitiSurface = Surface.Initialize(s_viewer);

            // instantiate objects' manager
            s_demoObjectManager = new DemoObjectManager(s_viewer);

            // Tuio connections
            s_client = new TuioClient(port);
            s_client.addTuioListener(s_grafitiSurface);
            s_client.addTuioListener(s_demoObjectManager);
            s_client.addTuioListener(s_viewer);
            s_client.connect();

            // initialize glut library
            Glut.glutInit();

            // initialize viewer's graphic
            s_viewer.Init();

            // register callback functions
            Glut.glutKeyboardFunc(new Glut.KeyboardCallback(S_KeyPressed));
            Glut.glutSpecialFunc(new Glut.SpecialCallback(S_SpecialKeyPressed));
            Glut.glutDisplayFunc(new Glut.DisplayCallback(S_Display));
            Glut.glutReshapeFunc(new Glut.ReshapeCallback(S_Reshape));
            Glut.glutTimerFunc(40, new Glut.TimerCallback(S_Timer), 0);

            // main loop
            try
            {
                Glut.glutMainLoop();
            }
            catch (ThreadAbortException e)
            {
                Exit();
            }
        }