Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using SixenseWrapper;
- using System.Threading;
- using System;
- public class SixenseBehavior : MonoBehaviour {
- // Use this for initialization
- void Start () {
- int r = Sixense.Init();
- if (r == Sixense.SUCCESS) {
- int attempts = 0;
- int base_found = 0;
- while (base_found == 0 && attempts < 2) {
- Thread.Sleep(1000);
- base_found = Sixense.IsBaseConnected(0);
- }
- if (base_found == 0) {
- Sixense.Exit();
- throw new Exception("Hydra not attached");
- }
- r = Sixense.SetActiveBase(0);
- }
- else
- throw new Exception("Failed to initialize Hydra");
- }
- // Update is called once per frame
- void Update () {
- Sixense.ControllerData data;
- if (Sixense.GetNewestData(1, out data) == Sixense.SUCCESS)
- {
- float q0 = data.rot_quat0;
- float q1 = data.rot_quat1;
- float q2 = data.rot_quat2;
- float q3 = data.rot_quat3;
- Camera.current.transform.rotation = new Quaternion(q0, q1, q2, q3);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment