Пример #1
0
        /// <summary>
        /// Funkcja ta przestawia punkt zero z miednicy na poziom glowy
        /// </summary>
        /// <param name="rightHanded"></param>
        /// <param name="skeleton"></param>
        /// <returns></returns>
        private Joint normalizeJoint(bool rightHanded, TrackedSkeleton skeleton)
        {
            Joint head  = skeleton.getJoint(JointType.ShoulderCenter);
            Joint wrist = skeleton.getJoint(JointType.WristRight);

            Joint newJoint = new Joint();

            SkeletonPoint newPoint = new SkeletonPoint()
            {
                X = wrist.Position.X,
                Y = wrist.Position.Y - head.Position.Y
            };

            newJoint.Position = newPoint;

            return(newJoint);
        }
Пример #2
0
        public void updateByKinect(TrackedSkeleton skeleton)
        {
            if (!isEnabled)
            {
                return;
            }

            if (skeleton.getJoint(JointType.WristRight).Position.X == 0 && skeleton.getJoint(JointType.WristRight).Position.Y == 0)
            {
                return;
            }

            //Bazujac na pozycji prawej reki, dopasowuje wspolrzedne
            Microsoft.Kinect.Vector4 newPos = PointerAdjustment.AdjustToScreen(normalizeJoint(true, skeleton));
            posPointer = new Vector2(newPos.X, newPos.Y);

            rectanglePointer = new Rectangle((int)posPointer.X, (int)posPointer.Y, txPointer.Width, txPointer.Height);
        }
Пример #3
0
        //-------------------------------------------

        public LearnAndPlayGame()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            //----------------------------------------//
            //           PIERWSZY EKRAN               //
            //----------------------------------------//
            if (Settings.PROJECT_STATE == Settings.Environment.DEVELOPMENT)
            {
                activeScreen = Settings.STARTING_SCREEN;
            }
            else
            {
                activeScreen = GameType.LoadingScreen;
            }
            //----------------------------------------//

            //Kursor widoczny na ekranie
            pointer = new Pointer();

            //Czcionki dostepne w aplikacji
            fonts = new Fonts();

            //InfoBox wyswietlany w trakcie gry
            infoBox = new InfoBox(fonts);
            infoBox.Disable();
            infoBox.Invisible();

            //Sledzony szkielet
            trackedSkeleton = new TrackedSkeleton();

            //Chmura
            cloud = new Cloud.Services();

            //----------------------------------------------------------------------------------------------------------------------
            //                                                  USTAWIENIA OKNA
            //----------------------------------------------------------------------------------------------------------------------
            //Ustawienie nazwy okna
            this.Window.Title = "Ucz siê i baw z Kinectem!";

            this.graphics.PreferredBackBufferWidth       = Settings.WINDOW_WIDTH;
            this.graphics.PreferredBackBufferHeight      = Settings.WINDOW_HEIGHT;
            this.graphics.PreparingDeviceSettings       += this.GraphicsDevicePreparingDeviceSettings;
            this.graphics.SynchronizeWithVerticalRetrace = true;

            //----------------------------------------------------------------------------------------------------------------------
            //                                       INICJALIZACJA KINECTA I USTAWIENIA
            //----------------------------------------------------------------------------------------------------------------------
            this.viewPortRectangle = new Rectangle((int)infoBox.getPosition().X, (int)infoBox.getPosition().Y, 130, 130);

            // Sensor bedzie uzywal rozdzielczosci 640x480 dla obu strumieni
            this.chooser = new KinectChooser(this, ColorImageFormat.RgbResolution640x480Fps30, DepthImageFormat.Resolution640x480Fps30);
            this.Services.AddService(typeof(KinectChooser), this.chooser);

            // ColorStream - pozycja i rozmiar
            this.colorStream          = new ColorStreamRenderer(this);
            this.colorStream.Size     = new Vector2(this.viewPortRectangle.Width, this.viewPortRectangle.Height);
            this.colorStream.Position = new Vector2(infoBox.getPosition().X + 160, infoBox.getPosition().Y + 10);

            // DepthStream - pozycja i rozmiar
            this.depthStream          = new DepthStreamRenderer(this);
            this.depthStream.Size     = new Vector2(this.viewPortRectangle.Width, this.viewPortRectangle.Height);
            this.depthStream.Position = new Vector2(infoBox.getPosition().X + 150, infoBox.getPosition().Y);

            this.Components.Add(this.chooser);

            //Licznik klatek
            if (Settings.PROJECT_STATE == Settings.Environment.DEVELOPMENT)
            {
                this.Components.Add(new FrameRateCounter(this));
            }

            speech = new KinectSpeech(chooser.Sensor);
            //----------------------------------------------------------------------------------------------------------------------
        }