Esempio n. 1
0
        private void KinectSensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            using (var frame = e.OpenSkeletonFrame())
            {
                if (frame == null || frame.SkeletonArrayLength == 0)
                {
                    return;
                }
                frame.CopySkeletonDataTo(_skeletons);

                var skeleton = GetPrimarySkeleton(_skeletons);
                if (skeleton == null)
                {
                    ErrorGridVisibility = Visibility.Visible;
                    ErrorGridMessage    = "No detectado esqueleto pierde o su posición." + Environment.NewLine +
                                          "Espera un minuto y compruebe si está de pie a una distancia apropiada del dispositivo.";
                    ClothesAreaVisibility = Visibility.Hidden;

                    return;
                }
                if (ClothesAreaVisibility == Visibility.Hidden)
                {
                    ErrorGridVisibility   = Visibility.Collapsed;
                    ClothesAreaVisibility = Visibility.Visible;
                }

                /*Hand.UpdateHandCursor(skeleton, Kinect, Width, Height);
                 * ClothingManager.Instance.UpdateItemPosition(skeleton, Kinect, Width, Height);*/

                Brush brush = Brushes.Coral;
                SkeletonManager.DrawSkeleton(_skeletons, brush, _kinectSensor, Width, Height);
            }
        }
Esempio n. 2
0
        // TODO: Class is currently unused because displaying persistent Characters in the editor is not yet supported

        /// <summary>
        /// Initializes a new instance of the <see cref="EditorCharacter"/> class.
        /// </summary>
        /// <param name="table">The <see cref="ICharacterTable"/> describing the character.</param>
        /// <param name="map">The <see cref="Map"/> to place the character on.</param>
        /// <exception cref="ArgumentNullException"><paramref name="table" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="map" /> is <c>null</c>.</exception>
        public EditorCharacter(ICharacterTable table, EditorMap map)
        {
            if (table == null)
            {
                throw new ArgumentNullException("table");
            }
            if (map == null)
            {
                throw new ArgumentNullException("map");
            }

            _table       = table;
            _characterID = table.ID;

            var dbController = DbControllerBase.GetInstance();

            var charInfo = dbController.GetQuery <SelectCharacterByIDQuery>().Execute(_characterID);

            BodyID = charInfo.BodyID;
            Teleport(new Vector2(charInfo.RespawnX, charInfo.RespawnY));
            Resize(BodyInfo.Size);
            Name = charInfo.Name;

            Initialize(map, SkeletonManager.Create(ContentPaths.Build));
        }
Esempio n. 3
0
	void Update () {
		if (SkeletonManager == null) return;
		skeletonManager = SkeletonManager.GetComponent<SkeletonManager>();
		if (skeletonManager == null) return;
		
		Kinect.Body[] data = skeletonManager.GetData();
		if (data == null) return;
		
		List<ulong> trackingIds = new List<ulong> ();
		foreach (var body in data) {
			if(body == null) continue;
			if(body.IsTracked) trackingIds.Add(body.TrackingId);
		}

		if (!trackingIds.Contains (body_id)) {
			Destroy(body); body = null;
			body_id = 0;
		}
		
		foreach (var _body in data) {
			if (body_id == 0) body_id = _body.TrackingId;
			
			if (body_id == _body.TrackingId) {
				if (_body == null) continue;
				
				if (_body.IsTracked) {
					if (body == null)
						body = CreateBodyObject (body_id);
					RefreshBodyObject (_body, body);
				}
			}
		}
	}
Esempio n. 4
0
        /// <summary>
        /// Handles SkeletonFrameReady event
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">Arguments containing SkeletonFrame</param>
        private void KinectSensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            using (var frame = e.OpenSkeletonFrame())
            {
                if (frame == null || frame.SkeletonArrayLength == 0)
                {
                    return;
                }
                frame.CopySkeletonDataTo(_skeletons);

                var skeleton = GetPrimarySkeleton(_skeletons);
                if (skeleton == null)
                {
                    ErrorGridVisibility = Visibility.Visible;
                    ErrorGridMessage    = "Nie wykryto szkieletu lub utracono jego położenie." + Environment.NewLine +
                                          "Poczekaj chwilę i sprawdź, czy stoisz w odpowiedniej odległości od urządzenia.";
                    ClothesAreaVisibility = Visibility.Hidden;
                    return;
                }
                if (ClothesAreaVisibility == Visibility.Hidden)
                {
                    ErrorGridVisibility   = Visibility.Collapsed;
                    ClothesAreaVisibility = Visibility.Visible;
                }
                Hand.UpdateHandCursor(skeleton, Kinect, Width, Height);
                ClothingManager.Instance.UpdateItemPosition(skeleton, Kinect, Width, Height);
#if DEBUG
                Brush brush = Brushes.Coral;
                SkeletonManager.DrawSkeleton(_skeletons, brush, _kinectSensor, Width, Height);
#endif
            }
        }
Esempio n. 5
0
        public static SkeletonManager getSingleton()
        {
            SkeletonManager ret = new SkeletonManager(OgrePINVOKE.SkeletonManager_getSingleton(), false);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Esempio n. 6
0
        //Inicializa Instancias
        public void Initialize()
        {
            //Hand = new HandTracking();
#if DEBUG
            SkeletonManager = new SkeletonManager();
#endif
            ErrorGridVisibility   = Visibility.Hidden;
            ClothesAreaVisibility = Visibility.Visible;
            DiscoverKinectSensors();
        }
Esempio n. 7
0
        /// <summary>
        /// Initializes the Character.
        /// </summary>
        /// <param name="map">The Map to place the Character on.</param>
        /// <param name="skelManager">The SkeletonManager to use for the Character's skeletons.</param>
        public virtual void Initialize(Map map, SkeletonManager skelManager)
        {
            // HACK: This is quite a dirty way to do this
            _map = map;
            _interpolator.Teleport(Position);

            _characterSprite = CreateCharacterSprite(this, this, skelManager);

            CharacterSprite.SetSet(BodyInfo.Stand, BodyInfo.Size);
            CharacterSprite.SetBody(BodyInfo.Body);
        }
    private void OnEnable()
    {
        if (Instance != this)
        {
            if (Instance != null)
            {
                Destroy(Instance);
            }

            Instance = this;
        }
    }
Esempio n. 9
0
    void Update()
    {
        if (SkeletonManager == null)
        {
            return;
        }
        skeletonManager = SkeletonManager.GetComponent <SkeletonManager>();
        if (skeletonManager == null)
        {
            return;
        }

        Kinect.Body[] data = skeletonManager.GetData();
        if (data == null)
        {
            return;
        }

        List <ulong> trackingIds = new List <ulong> ();

        foreach (var body in data)
        {
            if (body == null)
            {
                continue;
            }
            if (body.IsTracked)
            {
                trackingIds.Add(body.TrackingId);
            }
        }

        if (!trackingIds.Contains(body_id))
        {
            Destroy(body); body = null;
            body_id             = 0;
        }

        foreach (var _body in data)
        {
            if (body_id == 0)
            {
                body_id = _body.TrackingId;
            }

            if (body_id == _body.TrackingId)
            {
                if (_body == null)
                {
                    continue;
                }

                if (_body.IsTracked)
                {
                    if (body == null)
                    {
                        body = CreateBodyObject(body_id);
                    }
                    RefreshBodyObject(_body, body);
                }
            }
        }
    }
Esempio n. 10
0
        /// <summary>
        /// Creates the <see cref="ICharacterSprite"/> to be used by a <see cref="Character"/>.
        /// </summary>
        /// <param name="getTime">The <see cref="IGetTime"/> provider.</param>
        /// <param name="entity">The <see cref="Entity"/> the sprite is for (usually the <see cref="Character"/>).</param>
        /// <param name="skeletonManager">The <see cref="SkeletonManager"/> to use (ignored in TopDown builds).</param>
        /// <returns>The <see cref="ICharacterSprite"/> instance.</returns>
        public static ICharacterSprite CreateCharacterSprite(IGetTime getTime, Entity entity, SkeletonManager skeletonManager)
        {
#if !TOPDOWN
            return(new SkeletonCharacterSprite(getTime, entity, skeletonManager, GameData.AnimationSpeedModifier));
#else
            return(new GrhCharacterSprite(entity, "Character.Top Down"));
#endif
        }
Esempio n. 11
0
        /// <summary>
        /// Creates the <see cref="ICharacterSprite"/> to be used by a <see cref="Character"/>.
        /// </summary>
        /// <param name="getTime">The <see cref="IGetTime"/> provider.</param>
        /// <param name="entity">The <see cref="Entity"/> the sprite is for (usually the <see cref="Character"/>).</param>
        /// <param name="skeletonManager">The <see cref="SkeletonManager"/> to use (ignored in TopDown builds).</param>
        /// <returns>The <see cref="ICharacterSprite"/> instance.</returns>
        public static ICharacterSprite CreateCharacterSprite(IGetTime getTime, Entity entity, SkeletonManager skeletonManager)
        {
#if SKELETON_SPRITES
            return(new SkeletonCharacterSprite(getTime, entity, skeletonManager, GameData.AnimationSpeedModifier));
#else
            return(new GrhCharacterSprite(entity, "Character"));
#endif
        }
Esempio n. 12
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SkeletonManager obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }