Beispiel #1
0
 public void initializeSource(int sourceType)
 {
     if (source == 0)
     {
         vrController = GetComponent <VRController>();
     }
     else if (source == 1)
     {
         coilController = GetComponent <CoilController>();
     }
     else if (source == 2)
     {
         qController = GetComponent <QuaternionController>();
     }
 }
Beispiel #2
0
    // Use this for initialization
    void Awake()
    {
        try
        {
            quaternionController = GetComponent <QuaternionController>();
            dataStream           = GetComponent <DataStream>();
            // there are some constraints between tracking systems
            switch (tracker_type)
            {
            case PlTracker.Liberty:
                // liberty is a single tracker system
                max_systems = (max_systems > 1) ? 1 : max_systems;
                max_sensors = (max_sensors > 16) ? 16 : max_sensors;
                break;

            case PlTracker.Patriot:
                max_systems = (max_systems > 1) ? 1 : max_systems;
                max_sensors = (max_sensors > 2) ? 2 : max_sensors;
                break;

            case PlTracker.G4:
                // all G4 hubs (systems) have a maximum of 3 sensors
                max_sensors = (max_sensors > 3) ? 3 : max_sensors;
                break;

            case PlTracker.Fastrak:
                max_systems = (max_systems > 1) ? 1 : max_systems;
                max_sensors = (max_sensors > 4) ? 4 : max_sensors;
                break;

            default:
                throw new Exception("[polhemus] Unknown Tracker selected in PlStream::Awake().");
            }

            // set the number of slots
            max_slots = max_sensors * max_systems;

            // allocate resources for those slots
            active       = new bool[max_slots];
            digio        = new uint[max_slots];
            positions    = new Vector3[max_slots];
            orientations = new Vector4[max_slots];

            // initialize the slots
            for (int i = 0; i < max_slots; ++i)
            {
                active[i]       = false;
                digio[i]        = 0;
                positions[i]    = Vector3.zero;
                orientations[i] = Vector4.zero;
            }

            switch (tracker_type)
            {
            case PlTracker.Liberty:
            case PlTracker.Patriot:
                conThread = new Thread(new ThreadStart(read_liberty));
                break;

            case PlTracker.G4:
                conThread = new Thread(new ThreadStart(read_g4));
                break;

            case PlTracker.Fastrak:
                conThread = new Thread(new ThreadStart(read_fastrak));
                break;

            default:
                throw new Exception("[polhemus] Unknown Tracker selected in PlStream::Awake().");
            }

            // start the read thread
            conThread.Start();
        }
        catch (Exception e)
        {
            Debug.Log(e);
            Debug.Log("[polhemus] PlStream terminated in PlStream::Awake().");
            Console.WriteLine("[polhemus] PlStream terminated in PlStream::Awake().");
        }
    }