// Update is called once per frame void Update() { if (rtClient == null) { rtClient = RTClient.GetInstance(); } SixDOFBody body = rtClient.GetBody(ObjectName); if (body != null) { if (body.Position.magnitude > 0) //just to avoid error when position is NaN { transform.position = body.Position + PositionOffset; if (transform.parent) { transform.position += transform.parent.position; } transform.rotation = body.Rotation * Quaternion.Euler(EulerOffset); if (transform.parent) { transform.rotation *= transform.parent.rotation; } } } }
void Connect() { if (selectedDiscoveryResponse.HasValue) { RTClient.GetInstance().StartConnecting(selectedDiscoveryResponse.Value.IpAddress, portUDP, stream6d, stream3d, stream3dNoLabels, streamGaze, streamAnalog, streamSkeleton); } }
void Update() { var skeleton = RTClient.GetInstance().GetSkeleton(SkeletonName); if (mQtmSkeletonCache != skeleton) { mQtmSkeletonCache = skeleton; if (mQtmSkeletonCache == null) { return; } GameObject rootObject = null; mQtmSegmentIdToGameObject.Clear(); foreach (var segment in mQtmSkeletonCache.Segments) { GameObject go; if (!mSegmentNameToGameObject.TryGetValue(segment.Value.Name, out go)) { Debug.Log("Didn't Find " + RigSegmentPrefix + segment.Value.Name); } else { // First one is assumed to be the root if (rootObject == null) { rootObject = go; } mQtmSegmentIdToGameObject[segment.Value.Id] = go; } } if (rootObject) { rootObject.transform.SetParent(this.transform, false); } return; } if (mQtmSkeletonCache == null) { return; } // Update all the game objects foreach (var segment in mQtmSkeletonCache.Segments) { GameObject gameObject; if (mQtmSegmentIdToGameObject.TryGetValue(segment.Key, out gameObject)) { gameObject.transform.localPosition = segment.Value.Position; gameObject.transform.localRotation = segment.Value.Rotation; } } }
void Update() { var skeleton = RTClient.GetInstance().GetSkeleton(SkeletonName); if (mQtmSkeletonCache != skeleton) { mQtmSkeletonCache = skeleton; if (mQtmSkeletonCache == null) { return; } CreateMecanimToQtmSegmentNames(SkeletonName); if (mStreamedRootObject != null) { GameObject.Destroy(mStreamedRootObject); } mStreamedRootObject = new GameObject(this.SkeletonName); mQTmSegmentIdToGameObject = new Dictionary <uint, GameObject>(mQtmSkeletonCache.Segments.Count); foreach (var segment in mQtmSkeletonCache.Segments) { var gameObject = new GameObject(this.SkeletonName + "_" + segment.Value.Name); gameObject.transform.parent = segment.Value.ParentId == 0 ? mStreamedRootObject.transform : mQTmSegmentIdToGameObject[segment.Value.ParentId].transform; gameObject.transform.localPosition = segment.Value.TPosition; gameObject.transform.localRotation = segment.Value.TRotation; mQTmSegmentIdToGameObject[segment.Value.Id] = gameObject; } mStreamedRootObject.transform.SetParent(this.transform, false); BuildMecanimAvatarFromQtmTPose(); return; } if (mQtmSkeletonCache == null) { return; } //Update all the game objects foreach (var segment in mQtmSkeletonCache.Segments) { GameObject gameObject; if (mQTmSegmentIdToGameObject.TryGetValue(segment.Key, out gameObject)) { gameObject.transform.localPosition = segment.Value.Position; gameObject.transform.localRotation = segment.Value.Rotation; } } if (mSourcePoseHandler != null && mDestiationPoseHandler != null) { mSourcePoseHandler.GetHumanPose(ref mHumanPose); mDestiationPoseHandler.SetHumanPose(ref mHumanPose); } }
void Connect() { if (selectedDiscoveryResponse.HasValue) { RTClient.GetInstance().Connect(selectedDiscoveryResponse.Value, portUDP, true, true, false, true, false, true); } }
void OnDisconnect() { RTClient.GetInstance().Disconnect(); connected = false; connectionStatus = "Disconnected"; }
void OnGUI() { GUIStyle style = new GUIStyle(); style.fontStyle = FontStyle.Bold; style.normal.textColor = Color.white; GUI.Box(new Rect(10, 10, 220, 155), "Qualisys Realtime Streamer"); GUI.Label(new Rect(20, 40, 200, 40), "QTM Server:\n(switch with arrow keys)"); if (discoveryResponses == null) { discoveryResponses = RTClient.GetInstance().GetServers(); } List <GUIContent> serverSelection = new List <GUIContent>(); foreach (var discoveryResponse in discoveryResponses) { serverSelection.Add(new GUIContent(discoveryResponse.HostName + " (" + discoveryResponse.IpAddress + ":" + discoveryResponse.Port + ") " + discoveryResponse.InfoText)); } GUI.Label(new Rect(20, 75, 200, 40), serverSelection[selectedServer], style); if (Input.GetKeyDown(KeyCode.LeftArrow) && !connected) { selectedServer--; if (selectedServer < 0) { selectedServer += serverSelection.Count; } } else if (Input.GetKeyDown(KeyCode.RightArrow) && !connected) { selectedServer++; if (selectedServer > serverSelection.Count - 1) { selectedServer = 0; } } selectedDiscoveryResponse = discoveryResponses[selectedServer]; if (connected) { if (GUI.Button(new Rect(20, 115, 200, 40), "Disconnect")) { OnDisconnect(); } } else { if (GUI.Button(new Rect(20, 115, 200, 40), "Connect")) { OnConnect(); } } GUI.Label(new Rect(20, 90, 200, 40), "Status: " + connectionStatus); }
void Start() { rtClient = RTClient.GetInstance(); bones = new List <LineRenderer>(); allBones = new GameObject("Bones"); allBones.transform.parent = transform; allBones.transform.localPosition = Vector3.zero; material = new Material(Shader.Find("Standard")); }
void OnDestroy() { if (instance != this) { return; } RTClient.GetInstance().Dispose(); instance = null; }
// Use this for initialization void Start() { rtClient = RTClient.GetInstance(); gazeVectors = new List <LineRenderer>(); gazeRoot = new GameObject("GazeVectors"); gazeRoot.transform.parent = transform; gazeRoot.transform.localPosition = Vector3.zero; material = new Material(Shader.Find("Standard")); }
void OnDestroy() { var instance = RTClient.GetInstance(); if (instance.IsConnected()) { instance.Disconnect(); } connected = false; }
void Disconnect() { var instance = RTClient.GetInstance(); if (instance.IsConnected()) { instance.Disconnect(); } connected = false; connectionStatus = "Disconnected"; }
// Update is called once per frame void Update() { if (rtClient == null) { rtClient = RTClient.GetInstance(); } marker = rtClient.GetMarker(MarkerName); if (marker != null) { this.applyMarkerTransform(); } }
// Update is called once per frame void Update() { if (rtClient == null) { rtClient = RTClient.GetInstance(); } body = rtClient.GetBody(ObjectName); if (body != null) { this.applyBody(); } }
void FixedUpdate() { if (instance == null) { instance = this; } if (instance != this) { return; } RTClient.GetInstance().Update(); }
// Update is called once per frame void Update() { if (rtClient == null) { rtClient = RTClient.GetInstance(); } var body = rtClient.GetBody(ObjectName); if (body != null) { applyBodyTransform(body); } }
// Use this for initialization void Start() { init(); rtClient = RTClient.GetInstance(); markers = new List <GameObject>(); markerRoot = gameObject; PlayerPerspective = GameObject.Find("PlayerPerspective"); Plane1 = GameObject.Find("Plane1"); Plane2 = GameObject.Find("Plane2"); Plane3 = GameObject.Find("Plane3"); Plane4 = GameObject.Find("Plane4"); }
private string writePath = @"C:\Ian\Thesis\TextFiles\Debugging.txt";// this is used for debugging // Use this for initialization void Start() { File.WriteAllText(writePath, String.Empty); V_LG = new Matrix4x4(); V_LG = Virtual_LFrame.VLF_LG; RUN = true; rtClient = RTClient.GetInstance(); V_Lframe = new List <GameObject>(); Test = new List <GameObject>(); markers = new List <GameObject>(); markerRoot = gameObject; frame = 0; InitiateCO(); }
// Update is called once per frame void Update() { if (rtClient == null) { rtClient = RTClient.GetInstance(); } if (rtClient.GetStreamingStatus() && !streaming) { InitiateBodies(); streaming = true; } if (!rtClient.GetStreamingStatus() && streaming) { streaming = false; InitiateBodies(); } bodies = rtClient.Bodies; if (bodies == null || bodies.Count == 0) { return; } if (bodiesGO.Count != bodies.Count) { InitiateBodies(); } for (int i = 0; i < bodies.Count; i++) { if (!float.IsNaN(bodies[i].Position.sqrMagnitude)) { bodiesGO[i].name = bodies[i].Name; bodiesGO[i].GetComponent <Renderer>().material.color = bodies[i].Color; bodiesGO[i].transform.localPosition = bodies[i].Position; bodiesGO[i].transform.localRotation = bodies[i].Rotation; bodiesGO[i].SetActive(true); bodiesGO[i].GetComponent <Renderer>().enabled = visibleBodies; bodiesGO[i].transform.localScale = Vector3.one * bodyScale; } else { // Hide markers if we cant find them bodiesGO[i].SetActive(false); } } }
void Update() { if (!visibleBones) { allBones.SetActive(false); return; } if (rtClient == null) { rtClient = RTClient.GetInstance(); } if (!rtClient.GetStreamingStatus()) { return; } var boneData = rtClient.Bones; if (boneData == null || boneData.Count == 0) { return; } if (bones.Count != boneData.Count) { InitiateBones(); } allBones.SetActive(true); for (int i = 0; i < boneData.Count; i++) { if (!float.IsNaN(boneData[i].FromMarker.Position.sqrMagnitude) && !float.IsNaN(boneData[i].ToMarker.Position.sqrMagnitude)) { bones[i].SetPosition(0, boneData[i].FromMarker.Position); bones[i].SetPosition(1, boneData[i].ToMarker.Position); bones[i].startWidth = boneScale; bones[i].endWidth = boneScale; bones[i].gameObject.SetActive(true); } else { //hide bones if we cant find markers. bones[i].gameObject.SetActive(false); } } }
void OnConnect() { if (selectedDiscoveryResponse.HasValue) { connected = RTClient.GetInstance().Connect(selectedDiscoveryResponse.Value, portUDP, true, true, true); } if (connected) { connectionStatus = "Connected"; } else { connectionStatus = "Connection error - check console"; } }
void Connect() { if (selectedDiscoveryResponse.HasValue) { connected = RTClient.GetInstance().Connect(selectedDiscoveryResponse.Value, portUDP, stream6d, stream3d, stream3dNoLabels, streamGaze, streamAnalog, streamSkeleton); } if (connected) { connectionStatus = "Connected"; } else { connectionStatus = "Connection error - " + RTClient.GetInstance().GetErrorString() + " (also check console)"; } }
// Update is called once per frame void Update() { if (rtClient == null) { rtClient = RTClient.GetInstance(); } if (rtClient.GetStreamingStatus() && !streaming) { InitiateMarkers(); streaming = true; } if (!rtClient.GetStreamingStatus() && streaming) { streaming = false; InitiateMarkers(); } markerData = rtClient.Markers; if (markerData == null || markerData.Count == 0) { return; } if (markers.Count != markerData.Count) { InitiateMarkers(); } for (int i = 0; i < markerData.Count; i++) { if (!float.IsNaN(markerData[i].Position.sqrMagnitude)) { markers[i].name = markerData[i].Name; markers[i].GetComponent <Renderer>().material.color = markerData[i].Color; markers[i].transform.localPosition = markerData[i].Position; markers[i].SetActive(true); markers[i].GetComponent <Renderer>().enabled = visibleMarkers; markers[i].transform.localScale = Vector3.one * markerScale; } else { // Hide markers if we cant find them markers[i].SetActive(false); } } }
// Update is called once per frame void Update() { if (rtClient == null) { rtClient = RTClient.GetInstance(); } if (rtClient.GetStreamingStatus() && !streaming) { InitiateGazeVectors(); streaming = true; } if (!rtClient.GetStreamingStatus() && streaming) { streaming = false; InitiateGazeVectors(); } gazeVectorData = rtClient.GazeVectors; if (gazeVectorData == null && gazeVectorData.Count == 0) { return; } if (gazeVectors.Count != gazeVectorData.Count) { InitiateGazeVectors(); } gazeRoot.SetActive(true); for (int i = 0; i < gazeVectorData.Count; i++) { if (gazeVectorData[i].Position.magnitude > 0) { gazeVectors[i].SetPosition(0, gazeVectorData[i].Position); gazeVectors[i].SetPosition(1, gazeVectorData[i].Position + gazeVectorData[i].Direction * gazeVectorLength); gazeVectors[i].startWidth = gazeVectorWidth; gazeVectors[i].endWidth = gazeVectorWidth; gazeVectors[i].gameObject.SetActive(true); } else { gazeVectors[i].gameObject.SetActive(true); } } }
// Update is called once per frame void Update() { if (rtClient == null) { rtClient = RTClient.GetInstance(); } var channel = rtClient.GetAnalogChannel(ChannelName); if (channel != null) { foreach (var value in channel.Values) { // TODO::: What do we do with the analog values for this channel...? } } }
void OnConnect() { if (selectedDiscoveryResponse.HasValue) { connected = RTClient.GetInstance().Connect(selectedDiscoveryResponse.Value, portUDP, stream6d, stream3d, streamgaze); } if (connected) { connectionStatus = "Connected"; availableBodies = RTClient.GetInstance().Bodies; } else { connectionStatus = "Connection error - " + RTClient.GetInstance().GetErrorString() + " (also check console)"; } }
// Use this for initialization void Start() { rtClient = RTClient.GetInstance(); markers = new List <GameObject>(); markerRoot = gameObject; Avatar = new List <GameObject>(); Headset_Position = new Vector3(); test = GameObject.FindObjectsOfType <Camera>(); Headset_Position = test[0].transform.position; headset_name = SteamVR_Camera.FindObjectOfType <GameObject>().name; //using (StreamWriter sw = new StreamWriter(writePath)) //{ // sw.WriteLine(test.Length.ToString()); // sw.WriteLine(test[0].transform.position); //} }
// Update is called once per frame void Update() { if (rtClient == null) { rtClient = RTClient.GetInstance(); } var channels = rtClient.GetAnalogChannels(new List <string>() { ChannelX, ChannelY, ChannelZ, ChannelW }); if (channels != null) { for (int i = 0; i < channels[0].Values.Length; i++) { transform.rotation = new Quaternion(channels[0].Values[i], channels[1].Values[i], channels[2].Values[i], channels[3].Values[i]); } } }
void OnDestroy() { RTClient.GetInstance().Disconnect(); connected = false; }
// Use this for initialization void Start() { rtClient = RTClient.GetInstance(); markers = new List <GameObject>(); markerRoot = gameObject; }