void processOscMessage(OscMessage m)
    {
        // process rigid body message
        if (m.Address == "/rigidbody")
        {
            // parse json data to object data
            var        rb       = SimpleJSON.JSON.Parse(m.Values [0].ToString());
            Vector3    position = new Vector3(float.Parse(rb ["position"] [0]), float.Parse(rb ["position"] [1]), float.Parse(rb ["position"] [2]));
            Quaternion rotation = new Quaternion(float.Parse(rb ["orientation"] [0]), float.Parse(rb ["orientation"] [1]), float.Parse(rb ["orientation"] [2]), float.Parse(rb ["orientation"] [3]));
            int        id       = int.Parse(rb ["id"]);

            // find in-memory represnetation of the given rigid body (match by id)
            foreach (MoCapRigidBody current in rigidbodies)
            {
                if (current.id == id)
                {
                    current.Update(position, rotation);                      // update our in-memory representation of the rigid body
                    // the line below is ERROR-ing, not sure why...
                    // OnRigidBodyUpdate(current); // trigger any registered update handlers
                    return;                     // we're done
                }
            }

            // if we reach this point, this means no existing rigid body instance could be found
            // let's create one
            MoCapRigidBody newBody = new MoCapRigidBody(id, position, rotation);
            rigidbodies.Add(newBody);
            OnNewRigidBody(newBody);             // let everybody know we've got a new rigid body
        }
    }
	private void createFollower(MoCapRigidBody rigidbody){
		// create object
		GameObject obj = (GameObject)Instantiate (rigidBodyObject);
		// make it follow the specified rigidbody (always adopt its position and rotation)
		rigidbody.addFollower (obj);
		// make the new object a child of our main object (this)
		obj.transform.SetParent (this.transform);
	}
Exemple #3
0
    private void createFollower(MoCapRigidBody rigidbody)
    {
        // create object
        GameObject obj = (GameObject)Instantiate(rigidBodyObject);

        // make it follow the specified rigidbody (always adopt its position and rotation)
        rigidbody.addFollower(obj);
        // make the new object a child of our main object (this)
        obj.transform.SetParent(this.transform);
    }
	void onNewRigidBody(MoCapRigidBody newBody){
		createFollower(newBody);
	}
    void processOscMessage(OscMessage m)
    {
        // process rigid body message
        if (m.Address == "/rigidbody") {
            // parse json data to object data
            var rb = SimpleJSON.JSON.Parse (m.Values [0].ToString ());
            Vector3 position = new Vector3 (float.Parse (rb ["position"] [0]), float.Parse (rb ["position"] [1]), float.Parse (rb ["position"] [2]));
            Quaternion rotation = new Quaternion (float.Parse (rb ["orientation"] [0]), float.Parse (rb ["orientation"] [1]), float.Parse (rb ["orientation"] [2]), float.Parse (rb ["orientation"] [3]));
            int id = int.Parse (rb ["id"]);

            // find in-memory represnetation of the given rigid body (match by id)
            foreach (MoCapRigidBody current in rigidbodies) {
                if (current.id == id) {
                    current.Update (position, rotation); // update our in-memory representation of the rigid body
                    // the line below is ERROR-ing, not sure why...
                    // OnRigidBodyUpdate(current); // trigger any registered update handlers
                    return; // we're done
                }
            }

            // if we reach this point, this means no existing rigid body instance could be found
            // let's create one
            MoCapRigidBody newBody = new MoCapRigidBody (id, position, rotation);
            rigidbodies.Add (newBody);
            OnNewRigidBody(newBody); // let everybody know we've got a new rigid body
        }
    }
Exemple #6
0
 void onNewRigidBody(MoCapRigidBody newBody)
 {
     createFollower(newBody);
 }