Exemple #1
0
        private bool Get3DSettings()
        {
            bool getstatus = mProtocol.Get3Dsettings();

            if (getstatus)
            {
                mUpAxis = mProtocol.Settings3D.axisUpwards;

                Rotation.ECoordinateAxes xAxis, yAxis, zAxis;
                Rotation.GetCalibrationAxesOrder(mUpAxis, out xAxis, out yAxis, out zAxis);

                mCoordinateSystemChange = Rotation.GetAxesOrderRotation(xAxis, yAxis, zAxis);

                // Save marker settings
                mMarkers.Clear();
                foreach (Settings3DLabel marker in mProtocol.Settings3D.labels3D)
                {
                    LabeledMarker newMarker = new LabeledMarker();
                    newMarker.Label    = marker.Name;
                    newMarker.Position = Vector3.zero;
                    newMarker.Color.r  = (marker.ColorRGB) & 0xFF;
                    newMarker.Color.g  = (marker.ColorRGB >> 8) & 0xFF;
                    newMarker.Color.b  = (marker.ColorRGB >> 16) & 0xFF;

                    newMarker.Color /= 255;

                    newMarker.Color.a = 1F;

                    Markers.Add(newMarker);
                }

                // Save bone settings
                if (mProtocol.Settings3D.bones != null)
                {
                    Bones.Clear();

                    //Save bone settings
                    foreach (var settingsBone in mProtocol.Settings3D.bones)
                    {
                        Bone bone = new Bone();
                        bone.From       = settingsBone.from;
                        bone.FromMarker = GetMarker(settingsBone.from);
                        bone.To         = settingsBone.to;
                        bone.ToMarker   = GetMarker(settingsBone.to);
                        bone.Color.r    = (settingsBone.color) & 0xFF;
                        bone.Color.g    = (settingsBone.color >> 8) & 0xFF;
                        bone.Color.b    = (settingsBone.color >> 16) & 0xFF;
                        bone.Color     /= 255;
                        bone.Color.a    = 1F;
                        mBones.Add(bone);
                    }
                }

                return(true);
            }
            return(false);
        }
Exemple #2
0
        // Update is called once per frame
        void Update()
        {
            if (rtClient == null)
            {
                rtClient = RTClient.GetInstance();
            }

            marker = rtClient.GetMarker(MarkerName);
            if (marker != null)
            {
                this.applyMarkerTransform();
            }
        }
        static bool Get3DSettings(RTState state, RTProtocol mProtocol)
        {
            bool getstatus = mProtocol.Get3dSettings();

            if (getstatus)
            {
                state.upAxis = mProtocol.Settings3D.AxisUpwards;
                state.coordinateSystemChange = Rotation.GetCoordinateSystemRotation(state.upAxis);

                // Save marker settings
                state.markers.Clear();
                foreach (Settings3DLabel marker in mProtocol.Settings3D.Labels)
                {
                    LabeledMarker newMarker = new LabeledMarker();
                    newMarker.Name     = marker.Name;
                    newMarker.Position = Vector3.zero;
                    newMarker.Residual = 0;
                    newMarker.Color.r  = (marker.ColorRGB) & 0xFF;
                    newMarker.Color.g  = (marker.ColorRGB >> 8) & 0xFF;
                    newMarker.Color.b  = (marker.ColorRGB >> 16) & 0xFF;
                    newMarker.Color   /= 255;
                    newMarker.Color.a  = 1F;

                    state.markers.Add(newMarker);
                }

                // Save bone settings
                if (mProtocol.Settings3D.Bones != null)
                {
                    state.bones.Clear();

                    foreach (var settingsBone in mProtocol.Settings3D.Bones)
                    {
                        Bone bone = new Bone();
                        bone.From       = settingsBone.From;
                        bone.FromMarker = state.GetMarker(settingsBone.From);
                        bone.To         = settingsBone.To;
                        bone.ToMarker   = state.GetMarker(settingsBone.To);
                        bone.Color.r    = (settingsBone.Color) & 0xFF;
                        bone.Color.g    = (settingsBone.Color >> 8) & 0xFF;
                        bone.Color.b    = (settingsBone.Color >> 16) & 0xFF;
                        bone.Color     /= 255;
                        bone.Color.a    = 1F;
                        state.bones.Add(bone);
                    }
                }

                return(true);
            }
            return(false);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="body"></param>
        protected override void applyBodyTransform(SixDOFBody body)
        {
            if (useObjectOrientation)
            {
                base.applyBodyTransform(body);
            }

            // Avoid position is NaN
            if (body.Position.magnitude > 0)
            {
                bodyPosition = body.Position;
                bodyRotation = body.Rotation;
            }

            // Get the body markers, of which the 6DOF body consists
            markers = rtClient.Markers;
            if (markers == null || markers.Count == 0)
            {
                return;
            }

            if (markerGOs == null)
            {
                InitiateMarkers();
            }

            foreach (GameObject markerGO in markerGOs)
            {
                LabeledMarker marker = rtClient.GetMarker(markerGO.name);

                // Show and update existing markers
                if (marker != null && marker.Position.magnitude > 0)
                {
                    markerGO.transform.localPosition = Quaternion.Inverse(bodyRotation) * (marker.Position - bodyPosition);
                    markerGO.transform.localScale    = Vector3.one * markerScale;
                    markerGO.SetActive(true);
                    markerGO.GetComponent <Renderer>().enabled        = visibleMarkers;
                    markerGO.GetComponent <Renderer>().material.color = marker.Color;
                }
                else
                {
                    // Hide not existing markers.
                    markerGO.SetActive(false);
                }
            }
        }
        private bool Get3DSettings()
        {
            bool getstatus = mProtocol.Get3Dsettings();
            if (getstatus)
            {
                mUpAxis = mProtocol.Settings3D.axisUpwards;

                Rotation.ECoordinateAxes xAxis, yAxis, zAxis;
                Rotation.GetCalibrationAxesOrder(mUpAxis, out xAxis, out yAxis, out zAxis);

                mCoordinateSystemChange = Rotation.GetAxesOrderRotation(xAxis, yAxis, zAxis);

                // Save marker settings
                mMarkers.Clear();
                foreach (Settings3DLabel marker in mProtocol.Settings3D.labels3D)
                {
                    LabeledMarker newMarker = new LabeledMarker();
                    newMarker.Label = marker.Name;
                    newMarker.Position = Vector3.zero;
                    newMarker.Color.r = (marker.ColorRGB) & 0xFF;
                    newMarker.Color.g = (marker.ColorRGB >> 8) & 0xFF;
                    newMarker.Color.b = (marker.ColorRGB >> 16) & 0xFF;

                    newMarker.Color /= 255;

                    newMarker.Color.a = 1F;

                    Markers.Add(newMarker);
                }

                // Save bone settings
                if (mProtocol.Settings3D.bones != null)
                {
                    Bones.Clear();

                    //Save bone settings
                    foreach (var settingsBone in mProtocol.Settings3D.bones)
                    {
                        Bone bone = new Bone();
                        bone.From = settingsBone.from;
                        bone.FromMarker = GetMarker(settingsBone.from);
                        bone.To = settingsBone.to;
                        bone.ToMarker = GetMarker(settingsBone.to);
                        bone.Color.r = (settingsBone.color) & 0xFF;
                        bone.Color.g = (settingsBone.color >> 8) & 0xFF;
                        bone.Color.b = (settingsBone.color >> 16) & 0xFF;
                        bone.Color /= 255;
                        bone.Color.a = 1F;
                        mBones.Add(bone);
                    }
                }

                return true;
            }
            return false;
        }