Exemplo n.º 1
0
        private async Task SendPacketsAsync(OscPacket packet, CancellationToken cancellationToken)
        {
            try
            {
                int transmissionCount = 0;

                while (cancellationToken.IsCancellationRequested == false)
                {
                    IPEndPoint sourceEndPoint = new IPEndPoint(Program.ipAddress, Properties.Settings.Default.Port);
                    OscMessage labelMessage   = new OscMessage(sourceEndPoint, "/NuvoControl/ZoneName", String.Format("Hello {0}", transmissionCount));
                    labelMessage.Send(sourceEndPoint);

                    Console.Clear();
                    Console.WriteLine("Osc Transmitter: Udp");
                    Console.WriteLine("with IP Address={0} on Port={1}", sourceEndPoint.Address, sourceEndPoint.Port);
                    Console.WriteLine("IsBundle={0}", labelMessage.IsBundle);
                    if (!packet.IsBundle)
                    {
                        Console.WriteLine("Packet={0}", labelMessage.ToString());
                    }
                    Console.WriteLine("Transmission Count: {0}\n", ++transmissionCount);
                    Console.WriteLine("Press any key to exit.");

                    await Task.Delay(1000);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 2
0
 // Send QTM OSC Command to server
 private void SendCommand(string cmd)
 {
     qtmCommand.ClearData();
     qtmCommand.Append(cmd);
     LogMessage(qtmCommand);
     qtmCommand.Send(serverEndPoint);
 }
Exemplo n.º 3
0
    void DoSendCommand(string command, params object[] args)
    {
        var endPoint = new IPEndPoint(IPAddress.Parse(address), port);

        var oscMessage = new OscMessage(endPoint, "/" + command);

        foreach (var arg in args)
        {
            if (arg is int)
            {
                oscMessage.Append <int> ((int)arg);
            }
            else if (arg is float)
            {
                oscMessage.Append <float> ((float)arg);
            }
            else
            {
                oscMessage.Append <string> (arg.ToString());
            }
        }

        // Spam a few of the same message, effectively solves UDP unreliability in a clunky way
        for (int i = 0; i < 5; i++)
        {
            oscMessage.Send(endPoint);
        }
    }
Exemplo n.º 4
0
        /// <summary>
        /// 回転角や位置情報をOSCにより送信
        /// </summary>
        /// <param name="rotHeadXYZ"></param>
        /// <param name="posHeadXYZ"></param>
        /// <param name="posHandRightXYZ"></param>
        /// <param name="posHandLeftXYZ"></param>
        private void SendOSCMessage(Vector3DF rotHeadXYZ, Vector3DF posHeadXYZ, Vector3DF posHandRightXYZ, Vector3DF posHandLeftXYZ)
        {
            // OSCメッセージ生成
            OscMessage rotHeadOsc      = new OscMessage(from, "/head_rot", null);
            OscMessage posHeadOsc      = new OscMessage(from, "/head_pos", null);
            OscMessage posHandRightOsc = new OscMessage(from, "/hand_r", null);
            OscMessage posHandLeftOsc  = new OscMessage(from, "/hand_l", null);

            // 情報の追加
            rotHeadOsc.Append <float>(rotHeadXYZ.x);
            rotHeadOsc.Append <float>(rotHeadXYZ.y);
            rotHeadOsc.Append <float>(rotHeadXYZ.z);
            posHeadOsc.Append <float>(posHeadXYZ.x);
            posHeadOsc.Append <float>(posHeadXYZ.y);
            posHeadOsc.Append <float>(posHeadXYZ.z);
            posHandRightOsc.Append <float>(posHandRightXYZ.x);
            posHandRightOsc.Append <float>(posHandRightXYZ.y);
            posHandRightOsc.Append <float>(posHandRightXYZ.z);
            posHandLeftOsc.Append <float>(posHandLeftXYZ.x);
            posHandLeftOsc.Append <float>(posHandLeftXYZ.y);
            posHandLeftOsc.Append <float>(posHandLeftXYZ.z);

            // 送信
            rotHeadOsc.Send(toExp);
            posHeadOsc.Send(toExp);
            posHandRightOsc.Send(toExp);
            posHandLeftOsc.Send(toExp);
        }
Exemplo n.º 5
0
        private void SendMessage(Action <OscMessage> appendAction)
        {
            var message = new OscMessage(endPoint, "/");

            appendAction(message);

            message.Send(endPoint);
        }
Exemplo n.º 6
0
        private void SendMessage(Action<OscMessage> appendAction)
        {
            var message = new OscMessage(endPoint, "/");

            appendAction(message);

            message.Send(endPoint);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Sends an OSC message to the remote host.
        /// </summary>
        public void Send(string message, params float[] args)
        {
            var msg = new OscMessage(OSCSettings.SourceEndPoint, message);

            foreach (var f in args)
            {
                msg.Append(f);
            }
            msg.Send(Target);
        }
Exemplo n.º 8
0
        private static void SendMessage(string messageText)
        {
            var message = new OscMessage(endPoint, "/");

            foreach (var item in messageText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
            {
                message.Append(item);
            }

            message.Send(endPoint);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Send message to osc device.
        /// </summary>
        /// <param name="address">Address where to send the message.</param>
        /// <param name="value">List of Message(s) or value(s) to send.</param>
        /// <param name="ipAddress">IP address of the osc device.</param>
        /// <param name="port">Port of the osc device.</param>
        private void sendOscMessage(string address, IList <object> data, IPAddress ipAddress, int port)
        {
            IPEndPoint sourceEndPoint = new IPEndPoint(ipAddress, port);
            OscMessage oscMessage     = new OscMessage(sourceEndPoint, address);

            foreach (object value in data)
            {
                oscMessage.Append(value);
            }
            oscMessage.Send(sourceEndPoint);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Sends an OSC message to all connected Ableton Live sessions.
        /// </summary>
        public void Send(string message, params float[] args)
        {
            var msg = new OscMessage(SourceEndPoint, message);

            foreach (var f in args)
            {
                msg.Append(f);
            }
            foreach (var target in Targets)
            {
                msg.Send(target);
            }
        }
Exemplo n.º 11
0
        private void Broadcast(string person)
        {
            foreach (IPAddress address in forwardingIPAddresses)
            {
                Task.Run(() =>
                {
                    IPEndPoint ipEndPoint = new IPEndPoint(address, 9999);

                    OscMessage message = new OscMessage(ipEndPoint, person);

                    message.Send(ipEndPoint);
                });
            }
        }
Exemplo n.º 12
0
        private void SendMessage(string address, int[] values = null)
        {
            OscMessage msg = new OscMessage(source, string.Format(MESSAGE_FORMAT, address));

            if (values != null)
            {
                foreach (object v in values)
                {
                    msg.Append(v);
                }
            }

            msg.Send(dest);
        }
Exemplo n.º 13
0
        private void DispatchTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            foreach (IPAddress address in forwardingIPAddresses)
            {
                Task.Run(() =>
                {
                    IPEndPoint ipEndPoint = new IPEndPoint(address, 9999);

                    foreach (string oscAddress in processor.Addresses)
                    {
                        int value = processor[oscAddress];

                        OscMessage message = new OscMessage(ipEndPoint, oscAddress);

                        message.Append(value);

                        message.Send(ipEndPoint);
                    }
                });
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 送信
        /// </summary>
        /// <param name="skeleton">スケルトンデータ</param>
        /// <param name="userNo">ユーザー No(Kinect で認識された人物を識別する番号)</param>
        /// <param name="blenderOptions">Blender 側へ反映する際のオプション</param>
        /// <param name="jointsOption">Joint 単位の設定</param>
        public void Send(Skeleton skeleton, uint userNo, BlenderOptions blenderOptions, JointsOption jointsOption)
        {
            double sizeProportionX = blenderOptions.SizeProportionX;
            double sizeProportionY = blenderOptions.SizeProportionY;
            double sizeProportionZ = blenderOptions.SizeProportionZ;
            double centerX         = blenderOptions.CenterX;
            double centerY         = blenderOptions.CenterY;
            double centerZ         = blenderOptions.CenterZ;
            bool   mirror          = blenderOptions.Mirror;

            OscMessage message = new OscMessage(_sourceEndPoint, "/skeleton");

            message.Append(userNo.ToString());

            foreach (Joint joint in skeleton.Joints)
            {
                if (joint.TrackingState == JointTrackingState.NotTracked)
                {
                    continue;
                }

                JointType jointType = joint.JointType;

                double originX = jointsOption.GetOriginX(jointType);
                double originY = jointsOption.GetOriginY(jointType);
                double originZ = jointsOption.GetOriginZ(jointType);

                if (mirror)
                {
                    if (jointType == JointType.ShoulderRight)
                    {
                        jointType = JointType.ShoulderLeft;
                    }
                    else if (jointType == JointType.ShoulderLeft)
                    {
                        jointType = JointType.ShoulderRight;
                    }
                    else if (jointType == JointType.ElbowRight)
                    {
                        jointType = JointType.ElbowLeft;
                    }
                    else if (jointType == JointType.ElbowLeft)
                    {
                        jointType = JointType.ElbowRight;
                    }
                    else if (jointType == JointType.WristRight)
                    {
                        jointType = JointType.WristLeft;
                    }
                    else if (jointType == JointType.WristLeft)
                    {
                        jointType = JointType.WristRight;
                    }
                    else if (jointType == JointType.HandRight)
                    {
                        jointType = JointType.HandLeft;
                    }
                    else if (jointType == JointType.HandLeft)
                    {
                        jointType = JointType.HandRight;
                    }
                    else if (jointType == JointType.HipRight)
                    {
                        jointType = JointType.HipLeft;
                    }
                    else if (jointType == JointType.HipLeft)
                    {
                        jointType = JointType.HipRight;
                    }
                    else if (jointType == JointType.KneeRight)
                    {
                        jointType = JointType.KneeLeft;
                    }
                    else if (jointType == JointType.KneeLeft)
                    {
                        jointType = JointType.KneeRight;
                    }
                    else if (jointType == JointType.AnkleRight)
                    {
                        jointType = JointType.AnkleLeft;
                    }
                    else if (jointType == JointType.AnkleLeft)
                    {
                        jointType = JointType.AnkleRight;
                    }
                    else if (jointType == JointType.FootRight)
                    {
                        jointType = JointType.FootLeft;
                    }
                    else if (jointType == JointType.FootLeft)
                    {
                        jointType = JointType.FootRight;
                    }
                }

                if (jointsOption.GetEnable(jointType))
                {
                    message.Append(jointsOption.GetName(jointType));

                    // Kinect
                    // x 軸: 横(右が正)
                    // y 軸: 高さ(上が正)
                    // z 軸: 奥行き(人間から見てカメラがある方向が正)
                    //
                    //  ↓
                    //
                    // Blender
                    // x 軸: 横
                    // y 軸: 奥行き
                    // z 軸: 高さ

                    double locationX = 0;
                    double locationY = 0;
                    double locationZ = 0;
                    if (!mirror)
                    {
                        locationX = (joint.Position.X - centerX - originX) * sizeProportionX;
                        locationY = (joint.Position.Z - centerZ - originZ) * sizeProportionZ;
                        locationZ = (joint.Position.Y - centerY - originY) * sizeProportionY;
                    }
                    else
                    {
                        locationX = (joint.Position.X - centerX - originX) * sizeProportionX * -1;
                        locationY = (joint.Position.Z - centerZ - originZ) * sizeProportionZ * -1;
                        locationZ = (joint.Position.Y - centerY - originY) * sizeProportionY;
                    }

                    message.Append(locationX.ToString());
                    message.Append(locationY.ToString());
                    message.Append(locationZ.ToString());
                }
            }
            message.Send(_destinationEndPoint);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Retrieves the latest gesture detection results from the sensor
        /// </summary>
        public void UpdateGestureData()
        {
            using (var frame = this.vgbFrameReader.CalculateAndAcquireLatestFrame())
            {
                if (frame != null)
                {
                    // gets all discrete and continuous gesture results that arrived with the latest frame
                    var discreteResults   = frame.DiscreteGestureResults;
                    var continuousResults = frame.ContinuousGestureResults;

                    if (discreteResults != null)
                    {
                        bool scrollUp    = this.GestureResultView.GoUp;
                        bool scrollDown  = this.GestureResultView.GoDown;
                        bool scrollRight = this.GestureResultView.GoRight;
                        bool scrollLeft  = this.GestureResultView.GoLeft;

                        float scrollProgress     = this.GestureResultView.ScrollProgress;
                        float scrollSideProgress = this.GestureResultView.ScrollSideProgress;

                        bool zoomIn  = this.GestureResultView.GoClose;
                        bool zoomOut = this.GestureResultView.GoFar;

                        float zoomProgress = this.GestureResultView.ZoomProgress;
                        bool  upButton     = this.GestureResultView.UpButton;
                        bool  downButton   = this.GestureResultView.DownButton;
                        bool  middleButton = this.GestureResultView.MiddleButton;
                        bool  startApp     = this.GestureResultView.StartApp;


                        foreach (var gesture in this.vgbFrameSource.Gestures)
                        {
                            if (gesture.GestureType == GestureType.Discrete)
                            {
                                DiscreteGestureResult result = null;
                                discreteResults.TryGetValue(gesture, out result);

                                if (result != null)
                                {
                                    if (gesture.Name.Equals(this.scrollUpGestureName))
                                    {
                                        scrollUp = result.Detected;


                                        if (scrollUp = result.Detected)
                                        {
                                            OscMessage OSCmessageScrollUp = new OscMessage(myDetector, "/ScrollUp", 1.0f);

                                            OSCmessageScrollUp.Send(myDetector);
                                        }
                                    }
                                    else if (gesture.Name.Equals(this.scrollDownGestureName))
                                    {
                                        scrollDown = result.Detected;

                                        if (scrollDown = result.Detected)
                                        {
                                            OscMessage OSCmessageScrollDown = new OscMessage(myDetector, "/ScrollDown", 1.0f);

                                            OSCmessageScrollDown.Send(myDetector);
                                        }
                                    }

                                    else if (gesture.Name.Equals(this.scrollRightGestureName))
                                    {
                                        scrollRight = result.Detected;

                                        if (scrollRight = result.Detected)
                                        {
                                            OscMessage OSCmessageScrollRight = new OscMessage(myDetector, "/ScrollRight", 1.0f);

                                            OSCmessageScrollRight.Send(myDetector);
                                        }
                                    }

                                    else if (gesture.Name.Equals(this.scrollLeftGestureName))
                                    {
                                        scrollLeft = result.Detected;

                                        if (scrollLeft = result.Detected)
                                        {
                                            OscMessage OSCmessageScrollLeft = new OscMessage(myDetector, "/ScrollLeft", 1.0f);

                                            OSCmessageScrollLeft.Send(myDetector);
                                        }
                                    }



                                    else if (gesture.Name.Equals(this.zoomInGestureName))
                                    {
                                        zoomIn = result.Detected;

                                        if (zoomIn = result.Detected)
                                        {
                                            OscMessage OSCmessageZoomIn = new OscMessage(myDetector, "/ZoomIn", 1.0f);

                                            OSCmessageZoomIn.Send(myDetector);
                                        }
                                    }
                                    else if (gesture.Name.Equals(this.zoomOutGestureName))
                                    {
                                        zoomOut = result.Detected;

                                        if (zoomOut = result.Detected)
                                        {
                                            OscMessage OSCmessageZoomOut = new OscMessage(myDetector, "/ZoomOut", 1.0f);

                                            OSCmessageZoomOut.Send(myDetector);
                                        }
                                    }



                                    else if (gesture.Name.Equals(this.pointUpGestureName))
                                    {
                                        upButton = result.Detected;

                                        if (upButton = result.Detected)
                                        {
                                            OscMessage OSCmessagePointUp = new OscMessage(myDetector, "/PointUp", 1.0f);

                                            OSCmessagePointUp.Send(myDetector);

                                            System.Threading.Thread.Sleep(1000);
                                        }
                                    }
                                    else if (gesture.Name.Equals(this.pointDownGestureName))
                                    {
                                        downButton = result.Detected;

                                        if (downButton = result.Detected)
                                        {
                                            OscMessage OSCmessagePointDown = new OscMessage(myDetector, "/PointDown", 1.0f);

                                            OSCmessagePointDown.Send(myDetector);

                                            System.Threading.Thread.Sleep(1000);
                                        }
                                    }
                                    else if (gesture.Name.Equals(this.pointMiddleGestureName))
                                    {
                                        middleButton = result.Detected;

                                        if (middleButton = result.Detected)
                                        {
                                            OscMessage OSCmessagePointMiddle = new OscMessage(myDetector, "/PointMiddle", 1.0f);

                                            OSCmessagePointMiddle.Send(myDetector);

                                            System.Threading.Thread.Sleep(1000);
                                        }
                                    }

                                    else if (gesture.Name.Equals(this.startGestureName))
                                    {
                                        startApp = result.Detected;

                                        if (startApp = result.Detected)
                                        {
                                            OscMessage OSCmessageStart = new OscMessage(myDetector, "/Start", 1.0f);

                                            OSCmessageStart.Send(myDetector);

                                            System.Threading.Thread.Sleep(1000);
                                        }
                                    }
                                }
                            }
                            // It gives a value for each continuous gesture ZOOMING & SCROLLING
                            if (continuousResults != null)
                            {
                                if (gesture.Name.Equals(this.scrollProgressGestureName) && gesture.GestureType == GestureType.Continuous)
                                {
                                    ContinuousGestureResult result = null;
                                    continuousResults.TryGetValue(gesture, out result);


                                    if (result != null)
                                    {
                                        scrollProgress = result.Progress;

                                        if (scrollUp || scrollDown)
                                        {
                                            OscMessage OSCmessagescrollProgress = new OscMessage(myDetector, "/ScrollProgress", scrollProgress);

                                            OSCmessagescrollProgress.Send(myDetector);
                                        }
                                    }
                                }
                                if (gesture.Name.Equals(this.scrollSideProgressGestureName) && gesture.GestureType == GestureType.Continuous)
                                {
                                    ContinuousGestureResult result = null;
                                    continuousResults.TryGetValue(gesture, out result);


                                    if (result != null)
                                    {
                                        scrollSideProgress = result.Progress;

                                        if (scrollRight || scrollLeft)
                                        {
                                            OscMessage OSCmessagescrollSideProgress = new OscMessage(myDetector, "/ScrollSideProgress", scrollProgress);

                                            OSCmessagescrollSideProgress.Send(myDetector);
                                        }
                                    }
                                }


                                if (gesture.Name.Equals(this.zoomProgressGestureName) && gesture.GestureType == GestureType.Continuous)
                                {
                                    ContinuousGestureResult result = null;
                                    continuousResults.TryGetValue(gesture, out result);


                                    if (result != null)
                                    {
                                        zoomProgress = result.Progress;

                                        if (zoomIn || zoomOut)
                                        {
                                            OscMessage OSCmessagezoomProgress = new OscMessage(myDetector, "/ZoomProgress", zoomProgress);

                                            OSCmessagezoomProgress.Send(myDetector);
                                        }
                                    }
                                }
                            }
                        }


                        // clamp the progress value between 0 and 1
                        if (scrollProgress < 0)
                        {
                            scrollProgress = 0;
                        }
                        else if (scrollProgress > 1)
                        {
                            scrollProgress = 1;
                        }

                        if (scrollSideProgress < 0)
                        {
                            scrollSideProgress = 0;
                        }
                        else if (scrollSideProgress > 1)
                        {
                            scrollSideProgress = 1;
                        }


                        // clamp the progress value between 0 and 1
                        if (zoomProgress < 0)
                        {
                            zoomProgress = 0;
                        }
                        else if (zoomProgress > 1)
                        {
                            zoomProgress = 1;
                        }

                        // Continuous gestures will always report a value while the body is tracked.
                        // We need to provide context to this value by mapping it to one or more discrete gestures.
                        // For this sample, we will ignore the progress value whenever the user is not performing any of the discrete gestures.
                        if (!zoomIn && !zoomOut)
                        {
                            zoomProgress = -1;
                        }

                        if (!scrollUp && !scrollDown)
                        {
                            scrollProgress = -1;
                        }

                        if (!scrollRight && !scrollLeft)
                        {
                            scrollSideProgress = -1;
                        }

                        // update the UI with the latest gesture detection results
                        this.GestureResultView.UpdateGestureResult(false, false, false, false, false, -1.0f, -1.0f, false, false, -1.0f, false, false, false, false);
                    }
                }
            }
        }
Exemplo n.º 16
0
 private void limboViewerSendUserTracked()
 {
     OscMessage msg = new OscMessage(limboViewerIP, "/view/user");
     msg.Append("tracked");
     msg.Send(limboViewerIP);
 }
Exemplo n.º 17
0
 private void limboViewerPlaySlideView()
 {
     OscMessage msg = new OscMessage(limboViewerIP, "/view");
     msg.Append("slideview");
     msg.Send(limboViewerIP);
 }
Exemplo n.º 18
0
 private void limboViewerIsAlive()
 {
     OscMessage msg = new OscMessage(limboViewerIP, "/view");
     msg.Append("test");
     msg.Send(limboViewerIP);
 }
Exemplo n.º 19
0
 private void limboViewerCaptureFree(int _userCount , int _cellPhoneNumber)
 {
     OscMessage msg = new OscMessage(limboViewerIP, "/view/picture");
     msg.Append(_userCount.ToString() + "_0" + _cellPhoneNumber.ToString());
     msg.Send(limboViewerIP);
 }
Exemplo n.º 20
0
 private void limboStandReset()
 {
     OscMessage msg = new OscMessage(limboStandIP, "/stand");
     msg.Append("reset");
     msg.Send(limboStandIP);
 }
Exemplo n.º 21
0
        //Send an OSC Message
        //Either a playNote mssg if note is cued or an errorNote message if note is played erroneously
        private bool sendNoteOsc(int idx)
        {
            bool isCued = false;
            OscMessage m;

            if (FreePlayMode)
            {
                m = new OscMessage(src, "/soundBored/playNote");
                m.Append<int>(idx);
                m.Send(dst);
                return true;
            }

            if (CuedButtonNo != EIdx)
            {
                return false;
            }

            if (CuedButtonNo == idx)
            {
                LastPlayedTime = DateTime.Now;
                m = new OscMessage(src, "/soundBored/playNote");
                isCued = true;
                Console.WriteLine("playNote " + idx);
                IsPlayed = true;

                //May Have Solved Multihit MultiNote problem with this as well as original problem which was error notes on hitting ellipse more than once per note duration...
                CuedButtonNo = -1;

                //NECESSARY CRAP IF YOU WANT TO MODIFY ANY CONTROL THAT'S OWNED BY THE MAIN THREAD
                E.Dispatcher.Invoke(
                    System.Windows.Threading.DispatcherPriority.Normal,
                    new Action(
                        delegate()
                        {
                            E.Fill = new System.Windows.Media.SolidColorBrush(Color.FromArgb(0xA0, 0x1E, 0x90, 0xFF));
                        }
                    ));
            }
            else
            {
                m = new OscMessage(src, "/soundBored/errorNote");

                MadeErrorOnLastNote = true;
                NoOfErrorsOnLastNote++;

                Console.WriteLine("errorNote " + idx);
            }

            m.Append<int>(idx);
            
            try
            {
                m.Send(dst);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            return isCued;
        }
Exemplo n.º 22
0
        void CalculateAndSendOSC(Skeleton skel)
        {
            try
            {
                Joint hipCenter = skel.Joints[JointType.HipCenter];
                Joint kneeLeft = skel.Joints[JointType.KneeLeft];
                Joint kneeRight = skel.Joints[JointType.KneeRight];

                // To compensate sensor tilt ( y axis rotation)
                transformMatrix = new Matrix3D(1, 0, 0, 0, 0, Math.Cos(DegreeToRadian(kinectAngle)), -1 * Math.Sin(DegreeToRadian(kinectAngle)), 0, 0, Math.Sin(DegreeToRadian(kinectAngle)), Math.Cos(DegreeToRadian(kinectAngle)), 0, 0, 0, 0, 1);

                float LRMove = hipCenter.Position.X * -1;
                LRMoveTextBox.Text = LRMove.ToString();

                //float FBMove = (hipCenter.Position.Z - (float)2.9) *(float) Math.Cos(23 *Math.PI / 180.0) *(float)(-1.0);
                //FBMoveTextBox.Text = FBMove.ToString();
                Vector3D skelVec = new Vector3D(skel.Position.X, skel.Position.Y, skel.Position.Z);
                Vector3D transSkel = Vector3D.Multiply(skelVec, transformMatrix);
                userPosition = kinectOffset - skelVec.Z;

                float FBMove = (float)userPosition;
                //float FBMove = (float)(3.0)-(float)Math.Sqrt(Math.Pow(skel.Position.X,2)+Math.Pow(skel.Position.Y,2)+Math.Pow(skel.Position.Z,2));
                FBMoveTextBox.Text = FBMove.ToString();

                Vector3D hipCenterVec = new Vector3D(hipCenter.Position.X, hipCenter.Position.Y, hipCenter.Position.Z);
                Vector3D transHipCenter = Vector3D.Multiply(hipCenterVec, transformMatrix);
                transHipCenter.Y = kinectHeight + transHipCenter.Y;
                UDMoveTextBox.Text = transHipCenter.Y.ToString();
                //float UDMove = hipCenter.Position.Y;
                //UDMoveTextBox.Text = UDMove.ToString();

                //float kneeHeight = (float)(1.0)+(kneeLeft.Position.Y + kneeRight.Position.Y) / 2;
                Vector3D kneeRightVec = new Vector3D(kneeRight.Position.X, kneeRight.Position.Y, kneeRight.Position.Z);
                Vector3D transkneeRight = Vector3D.Multiply(kneeRightVec, transformMatrix);

                //float kneeHeight = (kneeLeft.Position.Y + kneeRight.Position.Y) / 2;
                //kneeHeight = kneeHeight - FBMove * (float)Math.Sin(23 * Math.PI / 180.0);
                //kneeHeightTextBox.Text = kneeHeight.ToString();
                transkneeRight.Y = kinectHeight + transkneeRight.Y;
                kneeHeightTextBox.Text = transkneeRight.Y.ToString();
                //kneeHeightTextBox.Text = kneeRight.Position.Y.ToString();

                double FBAngle = GetFBAngle(skel);
                backBendingTextBox.Text = FBAngle.ToString();

                double LRAngle = GetLRAngle(skel);
                rightBendingTextBox.Text = LRAngle.ToString();

                double shoulderRotation = GetShoulderRotation(skel);
                upperTwistAngleTextBox.Text = shoulderRotation.ToString();

                double bodyRotation = GetBodyRotation(skel);
                bodyTwistAngleTextBox.Text = bodyRotation.ToString();

                if (OSCCheckBox.IsChecked == true)
                {
                    if (userPosition <= startPosition)
                    {
                        outFlag = true;

                    }
                    if (userPosition > startPosition && userPosition < endPosition)
                    {
                        inFlag = true;
                        if (FBAngle == Double.NaN) { FBAngle = 15; }
                        if (LRAngle == Double.NaN) { LRAngle = 0; }
                        if (shoulderRotation == Double.NaN) { shoulderRotation = 0; }
                        if (bodyRotation == Double.NaN) { bodyRotation = 0; }

                        kinectMsg = new OscMessage(kinectServerIP, kinectMsgAddr);
                        kinectMsg.Append((float)LRMove);
                        kinectMsg.Append((float)FBMove);
                        kinectMsg.Append((float)transHipCenter.Y);
                        kinectMsg.Append((float)FBAngle);
                        kinectMsg.Append((float)LRAngle);
                        kinectMsg.Append((float)shoulderRotation);
                        kinectMsg.Append((float)bodyRotation);
                        kinectMsg.Append((float)transkneeRight.Y);
                        kinectMsg.Send(kinectServerIP);
                    }

                    if (userPosition >= endPosition)
                    {
                        // let main controller know
                        outFlag = true;

                    }
                }
            }
            catch(Exception ex)
            {
                Trace.WriteLine(ex.ToString());
            }
        }
Exemplo n.º 23
0
        private void dispatcherTimer_Tick(object sender, EventArgs e)
        {
            if (inFlag)
            {
                inFlag = false;
                OscMessage msg = new OscMessage(cmdServerIP, kinectMsgAddr);
                msg.Append("in");
                msg.Send(cmdServerIP);

            }

            if (outFlag)
            {
                outFlag = false;
                OscMessage msg = new OscMessage(cmdServerIP, kinectMsgAddr);
                msg.Append("out");
                msg.Send(cmdServerIP);
            }
        }
Exemplo n.º 24
0
        private void oscCmdReceiver_MessageReceived(object sender, OscMessageReceivedEventArgs e)
        {
            sMessagesReceivedCount++;

            OscMessage message = e.Message;

            Console.WriteLine(string.Format("\nMessage Received [{0}]: {1}", message.SourceEndPoint.Address, message.Address));
            Console.WriteLine(string.Format("Message contains {0} objects.", message.Data.Count));

            if (kinectID == 1)
            {
                if (message.Address == "/kinect/1")
                {
                    if (message.Data[0].ToString() == "on")
                    {
                        this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                        {
                            InfraredEmitterCheckbox.IsChecked = false;
                            this.sensor.ForceInfraredEmitterOff = false;
                        }));

                    }
                    else
                        if (message.Data[0].ToString() == "off")
                        {
                            this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                            {
                                InfraredEmitterCheckbox.IsChecked = true;
                                this.sensor.ForceInfraredEmitterOff = true;
                            }));

                        }
                        else
                            if (message.Data[0].ToString() == "test")
                            {
                                OscMessage msg = new OscMessage(cmdServerIP, "/kinect/1");
                                msg.Append("ok");
                                msg.Send(cmdServerIP);
                            }
                }
            }

            if (kinectID == 2)
            {
                if (message.Address == "/kinect/2")
                {
                    if (message.Data[0].ToString() == "on")
                    {
                        this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                        {
                            InfraredEmitterCheckbox.IsChecked = false;
                            this.sensor.ForceInfraredEmitterOff = false;
                        }));

                    }
                    else
                    if (message.Data[0].ToString() == "off")
                    {
                        this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                        {
                            InfraredEmitterCheckbox.IsChecked = true;
                            this.sensor.ForceInfraredEmitterOff = true;
                        }));

                    }
                    else if (message.Data[0].ToString() == "test")
                    {
                        OscMessage msg = new OscMessage(cmdServerIP, "/kinect/2");
                        msg.Append("ok");
                        msg.Send(cmdServerIP);
                    }

                }
            }

            for (int i = 0; i < message.Data.Count; i++)
            {
                string dataString;

                if (message.Data[i] == null)
                {
                    dataString = "Nil";
                }
                else
                {
                    dataString = (message.Data[i] is byte[] ? BitConverter.ToString((byte[])message.Data[i]) : message.Data[i].ToString());
                }
                Console.WriteLine(string.Format("[{0}]: {1}", i, dataString));
            }

            Console.WriteLine("Total Messages Received: {0}", sMessagesReceivedCount);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Event handler for Kinect sensor's SkeletonFrameReady event
        /// </summary>
        /// <param name="sender">object sending the event</param>
        /// <param name="e">event arguments</param>
        private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            Skeleton[] skeletons = new Skeleton[0];
            using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
            {
                if (skeletonFrame != null)
                {
                    skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                    skeletonFrame.CopySkeletonDataTo(skeletons);
                }
            }

            if (this.sensor != null && this.sensor.SkeletonStream != null)
            {
                float closestDistance = 10000f; // Start with a far enough distance
                int closestID = 0;

                if (!this.sensor.SkeletonStream.AppChoosesSkeletons)
                {
                    this.sensor.SkeletonStream.AppChoosesSkeletons = true; // Ensure AppChoosesSkeletons is set
                }

                foreach (Skeleton skel in skeletons)
                {

                    // find the closest skeleton
                    if (skel.TrackingState != SkeletonTrackingState.NotTracked)
                    {
                        if (skel.Position.Z < closestDistance)
                        {
                            closestDistance = skel.Position.Z;
                            closestID = skel.TrackingId;
                        }
                    }
                }
                if (closestID > 0  )
                {
                    this.sensor.SkeletonStream.ChooseSkeletons(closestID);
                }
            }

            try
            {
                using (DrawingContext dc = this.drawingGroup.Open())
                {
                    // Draw a transparent background to set the render size
                    dc.DrawRectangle(Brushes.Black, null, new Rect(0.0, 0.0, RenderWidth, RenderHeight));

                    if (skeletons.Length != 0)
                    {
                        foreach (Skeleton skel in skeletons)
                        {
                            RenderClippedEdges(skel, dc);

                            if (skel.TrackingState == SkeletonTrackingState.Tracked)
                            {
                                if (isAllJointsTracked(skel))
                                {
                                    allTrackedText.Text = "All Tracked";
                                    OscMessage msg = new OscMessage(cmdServerIP, kinectMsgAddr);
                                    msg.Append("tracked");
                                    msg.Send(cmdServerIP);
                                }
                                else
                                {
                                    allTrackedText.Text = "Not All";
                                }
                                this.DrawBonesAndJoints(skel, dc);

                                //Calculate angles and send OSC msg
                                this.Dispatcher.BeginInvoke(new Action(() =>
                                {
                                    // if this slows down, do below only every other frames
                                    CalculateAndSendOSC(skel);
                                }), DispatcherPriority.Background);
                            }
                            //else if (skel.TrackingState == SkeletonTrackingState.PositionOnly)
                            //{
                            //  dc.DrawEllipse(
                            //    this.centerPointBrush,
                            //    null,
                            //    this.SkeletonPointToScreen(skel.Position),
                            //    BodyCenterThickness,
                            //    BodyCenterThickness
                            //  );
                            //}
                        }
                    }

                    // prevent drawing outside of our render area
                    this.drawingGroup.ClipGeometry = new RectangleGeometry(new Rect(0.0, 0.0, RenderWidth, RenderHeight));
                }
            }
            catch(Exception ex)
            {
                Trace.WriteLine("FETM: "+ ex.ToString());
            }

            UpdateFrameRate();
            frameRateText.Text = FrameRate.ToString();
            if (InfraredEmitterCheckbox.IsChecked == true)
            {
                kinectRunStatus.Background = new SolidColorBrush(Colors.Black);
                kinectRunStatus.Foreground = new SolidColorBrush(Colors.Blue);
                kinectRunStatus.Content = "Not Running";
            }
            else
            {
                kinectRunStatus.Background = new SolidColorBrush(Colors.Red);
                kinectRunStatus.Foreground = new SolidColorBrush(Colors.Yellow);
                kinectRunStatus.Content = "Running";
            }

            frameCount++;
        }
Exemplo n.º 26
0
        public void sendSkeletonData(Skeleton skeleton_data, int i )
        {
            IPEndPoint sourceEndPoint = new IPEndPoint(IPAddress.Loopback, Port);
            OscBundle sBundle = new OscBundle(sourceEndPoint);
            //OscMessage sMessage = new OscMessage(sourceEndPoint, "/skeleton", client);

            foreach (Joint joint in skeleton_data.Joints)
            {
                if (this.oscCheck.IsChecked.HasValue && this.oscCheck.IsChecked.Value)
                {
                    OscMessage oscMessage = new OscMessage(sourceEndPoint, "/skeleton", client);
                    oscMessage.Append(joint.JointType.ToString());
                    oscMessage.Append(i.ToString());
                    oscMessage.Append(joint.Position.X.ToString());
                    oscMessage.Append(joint.Position.Y.ToString());
                    oscMessage.Append(joint.Position.Z.ToString());
                    oscMessage.Send(Destination);
                }

            }
        }
Exemplo n.º 27
0
        // Kinect Message Send
        private void kinectOn(int kinect)
        {
            string addr = "/kinect/" + kinect.ToString();

            if(kinect == 1)
            {
                OscMessage msg = new OscMessage(kinectFrontIP, addr); ;
                msg.Append("on");
                msg.Send(kinectFrontIP);
            }
            else if (kinect == 2)
            {
                OscMessage msg = new OscMessage(kinectBackIP, addr); ;
                msg.Append("on");
                msg.Send(kinectBackIP);
            }
            else
            {
                return;
            }
        }
Exemplo n.º 28
0
 private void limboStandIsAlive()
 {
     OscMessage msg = new OscMessage(limboStandIP, "/stand");
     msg.Append("test");
     msg.Send(limboStandIP);
 }
Exemplo n.º 29
0
            /// <summary>
            /// Updates the face tracking information for this skeleton
            /// </summary>
            ///

            public void OnFrameReady(KinectSensor kinectSensor, ColorImageFormat colorImageFormat, byte[] colorImage, DepthImageFormat depthImageFormat, short[] depthImage, Skeleton skeletonOfInterest)
            {
                //No Touchy
                this.skeletonTrackingState = skeletonOfInterest.TrackingState;
                if (this.skeletonTrackingState != SkeletonTrackingState.Tracked)
                {
                    return;
                }
                if (faceTracker == null)
                {
                    faceTracker = new FaceTracker(kinectSensor);
                }
                frame = this.faceTracker.Track(
                    colorImageFormat, colorImage, depthImageFormat, depthImage, skeletonOfInterest);
                this.lastFaceTrackSucceeded = frame.TrackSuccessful;
                if (this.lastFaceTrackSucceeded)
                {
                    if (faceTriangles == null)
                    {
                        faceTriangles = frame.GetTriangles();
                    }
                    this.facePoints = frame.GetProjected3DShape();



                    //Touchy

                    //Assign Reference points
                    this.absfacePoints = frame.Get3DShape();
                    leftForehead       = this.absfacePoints[FeaturePoint.TopLeftForehead];
                    rightForehead      = this.absfacePoints[FeaturePoint.TopRightForehead];
                    jaw           = this.absfacePoints[FeaturePoint.BottomOfChin];
                    faceRotationX = frame.Rotation.X;
                    faceRotationY = frame.Rotation.Y;
                    faceRotationZ = frame.Rotation.Z;

                    //Calculate Reference Points
                    foreheadReferencePointX = ((rightForehead.X - leftForehead.X) / 2);
                    foreheadReferencePointY = ((rightForehead.Y - leftForehead.Y) / 2);
                    foreheadReferencePointZ = ((rightForehead.Z - leftForehead.Z) / 2);

                    //Set Animation Units
                    AUCoeff        = frame.GetAnimationUnitCoefficients();
                    jawLowererAU   = AUCoeff[AnimationUnit.JawLower];
                    lipStretcherAU = AUCoeff[AnimationUnit.LipStretcher];
                    browRaiserAU   = AUCoeff[AnimationUnit.BrowRaiser];
                    setJawData(jaw.Y, leftForehead.Y, rightForehead.Y, jawLowererAU, lipStretcherAU);

                    rotations = new float[5];
                    //set up matlab
                    matlab = new MLApp.MLApp();
                    matlab.Execute(@"cd C:\Users\Bala\Documents\MATLAB");
                    result = null;

                    //get rotation values
                    rotations[0] = faceRotationX;
                    rotations[1] = faceRotationY;
                    rotations[2] = faceRotationZ;
                    rotations[3] = jawLowererAU;
                    rotations[4] = lipStretcherAU;
                    //Set up GlovePie
                    OscPacket.LittleEndianByteOrder = false;
                    IPEndPoint myapp    = new IPEndPoint(IPAddress.Loopback, 1944);
                    IPEndPoint glovepie = new IPEndPoint(IPAddress.Loopback, 1945);
                    Console.WriteLine(browRaiserAU);

                    matlab.Feval("nnW", 1, out result, rotations[0]);
                    object[] resW = result as object[];
                    nnoutput = (int)((float)resW[0] + 0.5f);
                    if (nnoutput == 1)
                    {
                        commandtoSend = 1;
                    }
                    else
                    {
                        result = null;
                        matlab.Feval("nnA", 1, out result, rotations[1]);
                        object[] resA = result as object[];
                        nnoutput = (int)((float)resA[0] + 0.5f);
                        if (nnoutput == 1)
                        {
                            commandtoSend = 2;
                        }
                        else
                        {
                            result = null;
                            matlab.Feval("nnS", 1, out result, rotations[0]);
                            object[] resS = result as object[];
                            nnoutput = (int)((float)resS[0] + 0.5f);
                            if (nnoutput == 1)
                            {
                                commandtoSend = 3;
                            }
                            else
                            {
                                result = null;
                                matlab.Feval("nnd", 1, out result, rotations[1]);
                                object[] resD = result as object[];
                                nnoutput = (int)((float)resD[0] + 0.5f);
                                if (nnoutput == 1)
                                {
                                    commandtoSend = 4;
                                }
                                else
                                {
                                    result = null;
                                    matlab.Feval("nnLC", 1, out result, rotations[2]);
                                    object[] resLC = result as object[];
                                    nnoutput = (int)((float)resLC[0] + 0.5f);
                                    if (nnoutput == 1)
                                    {
                                        commandtoSend = 5;
                                    }
                                    else
                                    {
                                        result = null;
                                        matlab.Feval("nnRC", 1, out result, rotations[2]);
                                        object[] resRC = result as object[];
                                        nnoutput = (int)((float)resRC[0] + 0.5f);
                                        if (nnoutput == 1)
                                        {
                                            commandtoSend = 6;
                                        }
                                        else
                                        {
                                            result = null;
                                            if (jawLowererAU > 0.7)
                                            {
                                                commandtoSend = 7;
                                            }

                                            /*
                                             * matlab.Feval("nnSpace", 1, out result, rotations[3]);
                                             * object[] resSpace = result as object[];
                                             * nnoutput = (int)((float)resSpace[0] + 0.5f);
                                             * if (nnoutput == 1)
                                             * {
                                             *  commandtoSend = 7;
                                             * }*/
                                            else
                                            {
                                                result = null;
                                                if (browRaiserAU > 0.4)
                                                {
                                                    commandtoSend = 8;
                                                }
                                                else
                                                {
                                                    result        = null;
                                                    commandtoSend = 0;
                                                }

                                                /*result = null;
                                                 * matlab.Feval("nnMiddle", 1, out result, lipStretcherAU);
                                                 * object[] resMiddle = result as object[];
                                                 * nnoutput = (int)((float)resMiddle[0] + 0.5f);
                                                 * if (nnoutput == 1)
                                                 * {
                                                 *  commandtoSend = 8;
                                                 * }
                                                 * else
                                                 * {
                                                 *  result = null;
                                                 *  commandtoSend = 0;
                                                 * }*/
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //Console.WriteLine("Iteration Complete");
                    switch (commandtoSend)
                    {
                    case 0:
                        msg = new OscMessage(myapp, "/move/w", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/a", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/s", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/d", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/lc", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/rc", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/middle", 0.0f);
                        msg.Send(glovepie);
                        break;

                    case 1:
                        msg = new OscMessage(myapp, "/move/w", 10.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/a", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/s", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/d", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/lc", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/rc", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/space", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/middle", 0.0f);
                        msg.Send(glovepie);
                        break;

                    case 2:
                        msg = new OscMessage(myapp, "/move/w", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/a", 10.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/s", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/d", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/lc", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/rc", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/space", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/middle", 0.0f);
                        msg.Send(glovepie);
                        break;

                    case 3:
                        msg = new OscMessage(myapp, "/move/w", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/a", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/s", 10.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/d", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/lc", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/rc", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/space", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/middle", 0.0f);
                        msg.Send(glovepie);
                        break;

                    case 4:
                        msg = new OscMessage(myapp, "/move/w", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/a", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/s", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/d", 10.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/lc", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/rc", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/space", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/middle", 0.0f);
                        msg.Send(glovepie);
                        break;

                    case 5:
                        msg = new OscMessage(myapp, "/move/w", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/a", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/s", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/d", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/lc", 10.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/rc", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/space", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/middle", 0.0f);
                        msg.Send(glovepie);
                        break;

                    case 6:
                        msg = new OscMessage(myapp, "/move/w", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/a", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/s", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/d", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/lc", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/rc", 10.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/space", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/middle", 0.0f);
                        msg.Send(glovepie);
                        break;

                    case 7:
                        msg = new OscMessage(myapp, "/move/w", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/a", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/s", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/d", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/lc", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/rc", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/space", 10.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/middle", 0.0f);
                        msg.Send(glovepie);
                        break;

                    case 8:
                        msg = new OscMessage(myapp, "/move/w", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/a", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/s", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/d", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/lc", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/rc", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/space", 0.0f);
                        msg.Send(glovepie);
                        msg = new OscMessage(myapp, "/move/middle", 10.0f);
                        msg.Send(glovepie);
                        break;
                    }
                }
            }
Exemplo n.º 30
0
 // Limbo Stand Message Send
 private void limboStandSetStandHeight(int _standHeight)
 {
     OscMessage msg = new OscMessage(limboStandIP, "/stand");
     msg.Append(_standHeight);
     msg.Send(limboStandIP);
 }
Exemplo n.º 31
0
 private void imageServerIsAlive()
 {
     OscMessage msg = new OscMessage(imageServerIP, "/image");
     msg.Append("test");
     msg.Send(imageServerIP);
 }
Exemplo n.º 32
0
 private void limboViewerGetImageFromServer(int _userCount, int _cellPhoneNumber)
 {
     OscMessage msg = new OscMessage(limboViewerIP, "/view/merge");
     msg.Append(_userCount.ToString() + "_0" + _cellPhoneNumber.ToString());
     msg.Send(limboViewerIP);
 }
Exemplo n.º 33
0
 // Image Server Message Send
 private void imageServerMergeImage()
 {
     OscMessage msg = new OscMessage(imageServerIP, "/image");
     msg.Append("merge");
     msg.Send(imageServerIP);
 }
Exemplo n.º 34
0
 private void limboViewerPlayCountDown()
 {
     OscMessage msg = new OscMessage(limboViewerIP, "/view");
     msg.Append("countdown");
     msg.Send(limboViewerIP);
 }
Exemplo n.º 35
0
 private void imageServerTakePhoto(int _userCount, int _cellPhoneNumber)
 {
     OscMessage msg = new OscMessage(imageServerIP, "/image/picture");
     msg.Append(_userCount.ToString()+"_0"+_cellPhoneNumber.ToString());
     msg.Send(imageServerIP);
 }
Exemplo n.º 36
0
        private void limboViewerSendSuccess(bool successStatus)
        {
            OscMessage msg = new OscMessage(limboViewerIP, "/view");
            if (successStatus)
            {
                msg.Append("success");
            }
            else
            {
                msg.Append("fail");
            }

            msg.Send(limboViewerIP);
        }
Exemplo n.º 37
0
 private void iPadIsAlive()
 {
     OscMessage msg = new OscMessage(ipadIP, "/ipad");
     msg.Append("test");
     msg.Send(ipadIP);
 }
Exemplo n.º 38
0
 // Limbo Viewer Message Send
 private void limboViewerSetScene(int sceneNumber)
 {
     OscMessage msg = new OscMessage(limboViewerIP, "/view/scene");
     msg.Append(sceneNumber);
     msg.Send(limboViewerIP);
 }
Exemplo n.º 39
0
 // iPad Message Send
 //private void iPadSendPicture(int _userCount)
 //{
 //    OscMessage msg = new OscMessage(ipadIP, "/ipad/picture");
 //    msg.Append(_userCount);
 //    msg.Send(ipadIP);
 //}
 private void iPadNextUserReady()
 {
     OscMessage msg = new OscMessage(ipadIP, "/ipad");
     msg.Append("ready");
     msg.Send(ipadIP);
 }
Exemplo n.º 40
0
 private void iPadTestButton_Click(object sender, RoutedEventArgs e)
 {
     msg = new OscMessage(ipadIP, iPadMsgAddr);
     msg.Append(iPadMsgArg);
     msg.Send(ipadIP);
 }
Exemplo n.º 41
0
        /// <summary>
        /// 送信
        /// </summary>
        /// <param name="skeleton">スケルトンデータ</param>
        /// <param name="userNo">ユーザー No(Kinect で認識された人物を識別する番号)</param>
        /// <param name="blenderOptions">Blender 側へ反映する際のオプション</param>
        /// <param name="jointsOption">Joint 単位の設定</param>
        public void Send(Skeleton skeleton, uint userNo, BlenderOptions blenderOptions, JointsOption jointsOption)
        {
            double sizeProportionX = blenderOptions.SizeProportionX;
            double sizeProportionY = blenderOptions.SizeProportionY;
            double sizeProportionZ = blenderOptions.SizeProportionZ;
            double centerX = blenderOptions.CenterX;
            double centerY = blenderOptions.CenterY;
            double centerZ = blenderOptions.CenterZ;
            bool mirror = blenderOptions.Mirror;

            OscMessage message = new OscMessage(_sourceEndPoint, "/skeleton");
            message.Append(userNo.ToString());

            foreach (Joint joint in skeleton.Joints)
            {
                if (joint.TrackingState == JointTrackingState.NotTracked)
                {
                    continue;
                }

                JointType jointType = joint.JointType;

                double originX = jointsOption.GetOriginX(jointType);
                double originY = jointsOption.GetOriginY(jointType);
                double originZ = jointsOption.GetOriginZ(jointType);

                if (mirror)
                {
                    if (jointType == JointType.ShoulderRight) { jointType = JointType.ShoulderLeft; }
                    else if (jointType == JointType.ShoulderLeft) { jointType = JointType.ShoulderRight; }
                    else if (jointType == JointType.ElbowRight) { jointType = JointType.ElbowLeft; }
                    else if (jointType == JointType.ElbowLeft) { jointType = JointType.ElbowRight; }
                    else if (jointType == JointType.WristRight) { jointType = JointType.WristLeft; }
                    else if (jointType == JointType.WristLeft) { jointType = JointType.WristRight; }
                    else if (jointType == JointType.HandRight) { jointType = JointType.HandLeft; }
                    else if (jointType == JointType.HandLeft) { jointType = JointType.HandRight; }
                    else if (jointType == JointType.HipRight) { jointType = JointType.HipLeft; }
                    else if (jointType == JointType.HipLeft) { jointType = JointType.HipRight; }
                    else if (jointType == JointType.KneeRight) { jointType = JointType.KneeLeft; }
                    else if (jointType == JointType.KneeLeft) { jointType = JointType.KneeRight; }
                    else if (jointType == JointType.AnkleRight) { jointType = JointType.AnkleLeft; }
                    else if (jointType == JointType.AnkleLeft) { jointType = JointType.AnkleRight; }
                    else if (jointType == JointType.FootRight) { jointType = JointType.FootLeft; }
                    else if (jointType == JointType.FootLeft) { jointType = JointType.FootRight; }
                }

                if (jointsOption.GetEnable(jointType))
                {
                    message.Append(jointsOption.GetName(jointType));

                    // Kinect
                    // x 軸: 横(右が正)
                    // y 軸: 高さ(上が正)
                    // z 軸: 奥行き(人間から見てカメラがある方向が正)
                    //
                    //  ↓
                    //
                    // Blender
                    // x 軸: 横
                    // y 軸: 奥行き
                    // z 軸: 高さ

                    double locationX = 0;
                    double locationY = 0;
                    double locationZ = 0;
                    if (!mirror)
                    {
                        locationX = (joint.Position.X - centerX - originX) * sizeProportionX;
                        locationY = (joint.Position.Z - centerZ - originZ) * sizeProportionZ;
                        locationZ = (joint.Position.Y - centerY - originY) * sizeProportionY;
                    }
                    else
                    {
                        locationX = (joint.Position.X - centerX - originX) * sizeProportionX * -1;
                        locationY = (joint.Position.Z - centerZ - originZ) * sizeProportionZ * -1;
                        locationZ = (joint.Position.Y - centerY - originY) * sizeProportionY;
                    }

                    message.Append(locationX.ToString());
                    message.Append(locationY.ToString());
                    message.Append(locationZ.ToString());
                }
            }
            message.Send(_destinationEndPoint);
        }