Inheritance: MonoBehaviour
Exemplo n.º 1
0
        static void Main(string[] args)
        {
            for (int i = 0; i < args.Length && i < 3; i++)
            {
                if (i == 0)
                {
                    dstIP = args[i];
                }
                else if (i == 1)
                {
                    sendToPort = int.Parse(args[i]);
                }
                else if (i == 2)
                {
                    listenToPort = int.Parse(args[i]);
                }
            }

            Console.WriteLine("current IP is " + dstIP + ",sendToPort:" + sendToPort + ",listenToPort:" + listenToPort);

            udpManager = new UDPPacketIO();
            udpManager.init(dstIP, sendToPort, listenToPort);
            oscManager = new Osc();
            oscManager.init(udpManager);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MultipleWiimoteForm());
        }
Exemplo n.º 2
0
	//	float lastTime=0;

	void Start () {
		
		udp  = this.GetComponent<UDPPacketIO>();
		udp.init(UDPHost, broadcastPort, listenerPort);
		oscHandler = this.gameObject.AddComponent<Osc>();
		oscHandler.init(udp);
	}
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        GameObject monomeSquare = (GameObject) Resources.Load("Square");
        int row = 0;
        while (row < amountRows) {
            for (int i=0; i < amountPerRow; i++) {
                Vector3 pos = new Vector3((-i*1.2f),0, row*1.2f);
                GameObject clone = Instantiate(monomeSquare, gameObject.transform.position + pos, Quaternion.identity) as GameObject;
                clone.transform.parent = gameObject.transform;
                clone.SendMessage("SetID", (row * amountPerRow) + (i+1));
                clone.tag = "col" + (i+1);
            }
            row++;
        }

        if(udp = (UDPPacketIO) gameObject.GetComponent("UDPPacketIO")) {
            udp.init(OSCHost, SendToPort, ListenerPort);

            handler = (Osc) gameObject.GetComponent("Osc");
            handler.init(udp);
            handler.SetAddressHandler("/press", IncomingValues);
            handler.SetAddressHandler("/sync", ResetTime);
        }

        OSCHandler.Instance.Init();

        startTime = Time.time;
    }
 void Start()
 {
     udp = GetComponent<UDPPacketIO>();
     handler = GetComponent<Osc>();
     udp.init(RemoteIP, SendToPort, ListenerPort);
     handler.init(udp);
     handler.SetAddressHandler("/htrack/",Ta_filler0);
 }
Exemplo n.º 5
0
	public void init(UDPPacketIO oscPacketIO){
		OscPacketIO = oscPacketIO;
		AddressTable = new Hashtable();
		ReadThread = new Thread(Read);
		ReaderRunning = true;
		ReadThread.IsBackground = true;
		ReadThread.Start();
	}
Exemplo n.º 6
0
	public void Cancel() {
		if (ReaderRunning) {
			ReaderRunning = false;
			ReadThread.Abort();
		}
		if (OscPacketIO != null && OscPacketIO.IsOpen()) {
			OscPacketIO.Close();
			OscPacketIO = null;
		}
	}
    /* ----- SETUP ----- */
    void Start()
    {
        // Set up OSC connection
        udp = (UDPPacketIO)GetComponent("UDPPacketIO");
        udp.init(RemoteIP, outgoingPort, incomingPort);
        handler = (Osc)GetComponent("Osc");
        handler.init(udp);

        // Listen to the channels set in the Processing sketch
        handler.SetAddressHandler("/data", ListenEvent);
    }
Exemplo n.º 8
0
	public void init(UDPPacketIO oscPacketIO){
	  OscPacketIO = oscPacketIO;

      // Create the hashtable for the address lookup mechanism
      AddressTable = new Hashtable();

      ReadThread = new Thread(Read);
      ReaderRunning = true;
      ReadThread.IsBackground = true;
      ReadThread.Start();
	}
Exemplo n.º 9
0
 public void Cancel()
 {
     //Debug.Log("Osc Cancel start");
     if (ReaderRunning)
     {
         ReaderRunning = false;
         ReadThread.Abort();
     }
     if (OscPacketIO != null && OscPacketIO.IsOpen())
     {
         OscPacketIO.Close();
         OscPacketIO = null;
     }
     //Debug.Log("Osc Cancel finished");
 }
Exemplo n.º 10
0
    void Start()
    {
        osceletonNames = new string[] { //standard non-mirrored
            "head", "neck", "torso", "l_shoulder", "l_elbow", "l_hand", "r_shoulder", "r_elbow", "r_hand", "l_hip", "l_knee", "l_foot", "r_hip", "r_knee", "r_foot"
        };
        pos = new Vector3[osceletonNames.Length];
        //target = new Transform[osceletonNames.Length];

        //Initializes on start up to listen for messages
        //make sure this game object has both UDPPackIO and OSC script attached
        udp = (UDPPacketIO) GetComponent("UDPPacketIO");
        udp.init(RemoteIP, SendToPort, ListenerPort);
        handler = (Osc) GetComponent("Osc");
        handler.init(udp);

        handler.SetAddressHandler("/joint", Example1);
        handler.SetAddressHandler("/example2", Example2);
    }
Exemplo n.º 11
0
	// Use this for initialization
	void Start () {

		//Initializes on start up to listen for messages
		udp = new UDPPacketIO ();
		udp.init(RemoteIP, SendToPort, ListenerPort);
		handler = new Osc ();
		handler.init(udp);
		handler.SetAllMessageHandler(AllMessageHandler);
		Debug.Log ("OSC Connection initialized");

		// builds a list of OSCAnimation scripts that are attached to objects in receiverGameObjects array
		for (int i = 0; i< receiverGameObjects.Length; i++) {

			OSCAnimation[] scripts = receiverGameObjects [i].GetComponents<OSCAnimation> ();
			scriptsToCall.AddRange(scripts );

		}
	
	}
Exemplo n.º 12
0
    void Awake()
    {
        //print("Opening OSC listener on port " + inPort);

        OscPacketIO  = new UDPPacketIO(outIP, outPort, inPort);
        AddressTable = new Hashtable();

        messagesReceived = new ArrayList();

        buffer = new byte[4096];


        ReadThread              = new Thread(Read);
        ReaderRunning           = true;
        ReadThread.IsBackground = true;
        ReadThread.Start();

#if UNITY_EDITOR
        //UnityEditor.EditorApplication.playmodeStateChanged = HandleOnPlayModeChanged;
        UnityEditor.EditorApplication.playModeStateChanged += HandleOnPlayModeChanged;  //FIX FOR UNITY POST 2017
#endif
    }
Exemplo n.º 13
0
    /*
     * void HandleOnPlayModeChanged(UnityEditor.PlayModeStateChange state)
     * {
     *      // This method is run whenever the playmode state is changed.
     *
     #if UNITY_EDITOR
     *              paused = UnityEditor.EditorApplication.isPaused;
     *              //print ("editor paused "+paused);
     *              // do stuff when the editor is paused.
     #endif
     * }
     */



    void Awake()
    {
        //print("Opening OSC listener on port " + inPort);
//		if(PlayerPrefs.HasKey("portNumber")){
//			inPort = PlayerPrefs.GetInt("portNumber");
//		} else {
//			PlayerPrefs.SetInt ("portNumber",  6969);
//		}
//
//		if(PlayerPrefs.HasKey("ipAddress")){
//			outIP = PlayerPrefs.GetString("ipAddress");
//		} else {
//			PlayerPrefs.SetString ("ipAddress",  "127.0.0.1");
//		}
        //GameObject[] nubis = GameObject.FindGameObjectsWithTag("Player");
        //inPort  = 6969 + nubis.Length;

        inPort = 6969;
        //Debug.Log("Inport set to: " + inPort);

        OscPacketIO  = new UDPPacketIO(outIP, outPort, inPort);
        AddressTable = new Hashtable();

        messagesReceived = new ArrayList();

        buffer = new byte[1000];

        /* Read Thread
         *          ReadThread = new Thread(Read);
         *          ReaderRunning = true;
         *          ReadThread.IsBackground = true;
         *          ReadThread.Start();
         */

                #if UNITY_EDITOR
        //UnityEditor.EditorApplication.playmodeStateChanged = HandleOnPlayModeChanged;
        //UnityEditor.EditorApplication.playModeStateChanged += HandleOnPlayModeChanged;
                #endif
    }
Exemplo n.º 14
0
    void Awake()
    {
        print("Opening OSC listener on port " + inPort);

        // udpIO(remote host, remote ip, local ip)
        OscPacketIO  = new UDPPacketIO(remoteIP, outPort, inPort);
        AddressTable = new Hashtable();

        messagesReceived = new ArrayList();

        buffer = new byte[1000];


        ReadThread              = new Thread(Read);
        ReaderRunning           = true;
        ReadThread.IsBackground = true;
        ReadThread.Start();

#if UNITY_EDITOR
        //UnityEditor.EditorApplication.playmodeStateChanged = HandleOnPlayModeChanged;
        EditorApplication.playModeStateChanged += HandleOnPlayModeChanged;
#endif
    }
Exemplo n.º 15
0
    public void init(UDPPacketIO oscPacketIO)
    {
        OscPacketIO = oscPacketIO;

          // Create the hashtable for the address lookup mechanism
          AddressTable = new Hashtable();

          ReadThread = new Thread(Read);
          ReaderRunning = true;
          ReadThread.IsBackground = lowPriority; //defaults to false; true originally
          ReadThread.Start();
    }
Exemplo n.º 16
0
 void Awake()
 {
     udp     = gameObject.AddComponent <UDPPacketIO>() as UDPPacketIO;
     handler = gameObject.AddComponent <Osc>() as Osc;
 }
Exemplo n.º 17
0
 public void Cancel()
 {
     if (OscPacketIO != null && OscPacketIO.IsOpen()) {
         OscPacketIO.Close();
         OscPacketIO = null;
     }
 }
Exemplo n.º 18
0
    void Start()
    {
        // initialize udp and osc stuff (both necessary for OSC network communication)
        UDPPacketIO udp = new UDPPacketIO ();
        udp.init(oscSenderIp, sendToPort, listenerPort);

        oscHandler = new Osc ();
        oscHandler.init(udp);

        // oscHandler.SetAddressHandler("/rigidbody", onRigidBody);
        oscHandler.SetAllMessageHandler (onOscMessage);

        // the rigidBodyObject attribute shouldn't logically be part of this class, but is added as
        // a convenience property to quick and easily visualize the mocap rigid bodies by just specifieing
        // an object to visually represent the rigid bodies. We'll outsource all the logic to the
        // MoCapRigidBodiesCloner class whose tasks is exactly this.
        if (rigidBodyObject) {
            // create a GameObject to hold all the rigid bodies
            GameObject go = new GameObject();
            go.name = "GeneratedRigidBodies";
            // add the cloner component
            MoCapRigidBodiesCloner cloner = go.AddComponent<MoCapRigidBodiesCloner>();
            // give it the specified object and let it take care of the rest
            cloner.rigidBodyObject = rigidBodyObject;
        }
    }
Exemplo n.º 19
0
 public void init(UDPPacketIO oscPacketIO)
 {
     OscPacketIO = oscPacketIO;
 }
Exemplo n.º 20
0
    public void setup(int inPort, string localIP, int outPort)

    {
        OscPacketIO = new UDPPacketIO(localIP, outPort, inPort);
    }
Exemplo n.º 21
0
    public void setup(int inPort, int outPort)

    {
        OscPacketIO = new UDPPacketIO(broadcastHost, outPort, inPort);
    }
Exemplo n.º 22
0
    void Start()
    {
        pos = new Vector3[oscInputNames.Length];
        ppos = new Vector3[oscInputNames.Length];

        //Initializes on start up to listen for messages
        //make sure this game object has both UDPPackIO and OSC script attached
        udp = (UDPPacketIO) GetComponent("UDPPacketIO");
        udp.init(RemoteIP, SendToPort, ListenerPort);
        handler = (Osc) GetComponent("Osc");
        handler.init(udp);

        /*
        handler.SetAddressHandler("/objects/ID-centralXYZ", receiveKinectA); //KinectA blob tracker
        handler.SetAddressHandler("/skeletons/ID-centralXYZ", receiveKinectA); //KinectA blob tracker

        handler.SetAddressHandler("/tracker", receiveSoniskel); //Processing SimpleOpenNI skeleton tracker

        handler.SetAddressHandler("/kinect/blobs", receiveKvl); //KVL blob tracker
        */

        handler.SetAddressHandler("/joint", receiveOsceleton); //OSCeleton skeleton tracker

        //handler.SetAddressHandler("/wii/1/accel/pry", receiveWiimoteAccel); //Osculator Wiimote tracker
        handler.SetAddressHandler("/wii/1/accel/xyz", receiveWiimoteAccel);
        //handler.SetAddressHandler("/wii/1/motion/angles", receiveWiimoteAccel);
        //handler.SetAddressHandler("/wii/1/motion/velo", receiveWiimoteAccel);

        //handler.SetAddressHandler("/wii/1/ir", receiveWiimoteIR);
    }