Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        List <RigidBodyGeneric> rbs = new List <RigidBodyGeneric>();
        List <Vector3>          unidentifiedMarkerPositions = new List <Vector3>();

        if (mocapServer == MocapServer.Cube_QualisysTrackManager)
        {
            QTMInterface.Report(ref rbs, ref unidentifiedMarkerPositions);
        }
        else if (mocapServer == MocapServer.Perform_OptitrackMotiveBody)
        {
            //OMBInterface.Update();
            OMBInterface.Report(ref rbs);
        }

        // iterate over the rigid bodies to adjust transform
        for (int i = 0; i < rbs.Count; i++)
        {
            Vector3 pos = new Vector3();
            pos    = rbs [i].position;
            pos.x /= scaleX;
            pos.x += offsetX;
            pos.y /= scaleY;
            pos.y += offsetY;
            pos.z /= scaleZ;
            pos.z += offsetZ;
            RigidBodyGeneric rb = new RigidBodyGeneric();
            rb.position = pos;
            rb.rotation = rbs [i].rotation;
            rb.name     = rbs [i].name;
            rbs [i]     = rb;
        }

        // iterate over the incoming rigid bodies.  if a Unity user has registered a delegate to associate with the name/ID of the incoming rigid body, call that delegate and pass it the established parameters
        //Debug.Log("rbs.Count: " + rbs.Count);
        for (int i = 0; i < rbs.Count; i++)
        {
            List <RegisteredRigidBodyDelegate> delegates;
            if (registeredRigidBodyDelegatesByName.TryGetValue(rbs [i].name, out delegates))
            {
                for (int delegateCounter = 0; delegateCounter < delegates.Count; delegateCounter++)
                {
                    delegates [delegateCounter] (rbs [i].position, rbs[i].rotation);
                }
            }
        }

        // iterate over the incoming unidentified markers, passing them to all event callers
        for (int i = 0; i < registeredUnidentifiedMarkersDelegates.Count; i++)
        {
            registeredUnidentifiedMarkersDelegates [i] (unidentifiedMarkerPositions);
        }
    }