Esempio n. 1
0
        /// <summary>
        /// Initializes une nouvelle instance de la classe AvateeringXNA.
        /// </summary>
        public AvateeringXNA()
        {
            this.Window.Title = "Avateering";
            this.IsFixedTimeStep = false;
            this.IsMouseVisible = true;

            // Configure le périphérique graphique pour le rendu
            this.graphics = new GraphicsDeviceManager(this);
            this.SetScreenMode();
            this.graphics.PreparingDeviceSettings += this.GraphicsDevicePreparingDeviceSettings;
            this.graphics.SynchronizeWithVerticalRetrace = true;

            Content.RootDirectory = "Content";

            //Le capteur de la kinect utilisera 640*480 pour le flux de couleur (par défaut) et 320*240 pour la profondeur
            this.chooser = new KinectChooser(this, ColorImageFormat.RgbResolution640x480Fps30, DepthImageFormat.Resolution320x240Fps30);
            this.Services.AddService(typeof(KinectChooser), this.chooser);

            // Met Optionellement le mode de près pour vue de près (de 0.4m à 3m)
            this.chooser.NearMode = false;

            // Pour Optionnellement régler le mode assis pour le haut du corps seulement (généralement utilisé avec le mode de près de la caméra)
            this.chooser.SeatedMode = false;

            // Ajouter ces objets comme des composants de jeux XNA établit des appels automatiques aux méthodes LoadContent, Update, etc..
            this.Components.Add(this.chooser);

            // Créele plan sur lequel se tient le modèle.
            this.planarXzGrid = new GridXz(this, new Vector3(0, 0, 0), new Vector2(500, 500), new Vector2(10, 10), Color.Black);
            this.Components.Add(this.planarXzGrid);
            this.drawGrid = true;

            this.worldAxes = new CoordinateCross(this, 500);
            this.Components.Add(this.worldAxes);

            // Crée l'animateur du modèle.
            this.animator = new AvatarAnimator(this, this.RetargetMatrixHierarchyToAvatarMesh, AvateeringXNA.SkeletonTranslationScaleFactor);
            this.Components.Add(this.animator);

            // Options de dessin.
            this.setSeatedPostureInSeatedMode = true;
            this.drawAvatarOnlyWhenPlayerDetected = true;
            this.skeletonDetected = false;
            this.leanAdjust = true;

            // Ici, on peut forcer l'avatar à être dessiné à une hauteur fixe dans le monde virtuel XNA.
            // La raison pour laquelle on utilise ceci est que la hauteur par rapport au plancher n'est pas toujours connue,
            // et si l'avatar n'est pas correctement placé, il ne fera que sautiller.
            this.fixAvatarHipCenterDrawHeight = true;
            this.avatarHipCenterDrawHeight = 0.8f;  // in meters

            // Met en place le flux de profondeur.
            this.depthStream = new DepthStreamRenderer(this);

            //Pour la couleur
            this.colorStream = new ColorStreamRenderer(this);

            // Met en place le flux du squelette.
            this.skeletonStream = new SkeletonStreamRenderer(this, this.SkeletonToDepthMap);

            //Met à jour la profondeur, la taille du squelette et la location
            this.UpdateStreamSizeAndLocation();

            this.previousKeyboard = Keyboard.GetState();
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the XnaBasics class.
        /// </summary>
        public XnaBasics()
        {
            this.IsFixedTimeStep = false;
            this.IsMouseVisible = true;
            this.Window.Title = "Xna Basics";
            this.Window.AllowUserResizing = true;

            // This sets the width to the desired width
            // It also forces a 4:3 ratio for height
            // Adds 110 for header/footer
            this.graphics = new GraphicsDeviceManager(this);
            this.graphics.PreferredBackBufferWidth = Width;
            this.graphics.PreferredBackBufferHeight = ((Width / 4) * 3) + 110;
            this.graphics.PreparingDeviceSettings += this.GraphicsDevicePreparingDeviceSettings;
            this.graphics.SynchronizeWithVerticalRetrace = true;
            this.viewPortRectangle = new Rectangle(10, 80, Width - 20, ((Width - 2) / 4) * 3);

            Content.RootDirectory = "Content";

            // The Kinect sensor will use 640x480 for both streams
            // To make your app handle multiple Kinects and other scenarios,
            // it is recommended to use KinectSensorChooser provided in Microsoft.Kinect.Toolkit
            this.chooser = new KinectChooser(this, ColorImageFormat.RgbResolution640x480Fps30, DepthImageFormat.Resolution640x480Fps30);
            this.Services.AddService(typeof(KinectChooser), this.chooser);

            // Default size is the full viewport
            this.colorStream = new ColorStreamRenderer(this);

            // Calculate the minimized size and location
            this.depthStream = new DepthStreamRenderer(this);
            this.depthStream.Size = new Vector2(this.viewPortRectangle.Width / 4, this.viewPortRectangle.Height / 4);
            this.depthStream.Position = new Vector2(Width - this.depthStream.Size.X - 15, 85);

            // Store the values so we can animate them later
            this.minSize = this.depthStream.Size;
            this.depthSmallPosition = this.depthStream.Position;
            this.colorSmallPosition = new Vector2(15, 85);

            this.Components.Add(this.chooser);

            this.previousKeyboard = Keyboard.GetState();
        }