void EngageUser(ZigTrackedUser user) {
		if (null == engagedTrackedUser) {
            engagedTrackedUser = user;
            foreach (GameObject go in EngagedUsers) user.AddListener(go);
            SendMessage("UserEngaged", this, SendMessageOptions.DontRequireReceiver);
		}
	}
Beispiel #2
0
 void Zig_UpdateUser(ZigTrackedUser user)
 {
     if (mUpdateUserDelegate != null)
     {
         mUpdateUserDelegate(user);
     }
 }
	void DisengageUser(ZigTrackedUser user)	{
        if (user == engagedTrackedUser) {
            foreach (GameObject go in EngagedUsers) user.RemoveListener(go);
            engagedTrackedUser = null;
            SendMessage("UserDisengaged", this, SendMessageOptions.DontRequireReceiver);
        }
	}
Beispiel #4
0
 void Zig_UserFound(ZigTrackedUser user)
 {
     GameObject o = Instantiate(InstantiatePerUser) as GameObject;
     objects[user.Id] = o;
     Debug.Log (objects [user.Id]);
     user.AddListener(o);
 }
Beispiel #5
0
    void Zig_UserFound(ZigTrackedUser user)
    {
        GameObject o = Instantiate(InstantiatePerUser) as GameObject;

        objects[user.Id] = o;
        user.AddListener(o);
    }
    void Zig_UserFound(ZigTrackedUser user) {
        // create gameobject to listen for events for this user
        GameObject go = new GameObject("WaitForEngagement" + user.Id);
        go.transform.parent = transform;
        objects[user.Id] = go;

        ZigHandSessionDetector hsd = go.AddComponent<ZigHandSessionDetector>();        

        hsd.SessionBounds = SessionBounds;
        hsd.SessionBoundsOffset = SessionBoundsOffset;
        hsd.StartOnSteady = StartOnSteady;
        hsd.StartOnWave = StartOnWave;
        hsd.RotateToUser = RotateToUser;    
        
        hsd.SessionStart += delegate {
            Debug.Log("EngageSingleSession: Session start");
            if (EngageUser(user)) {
                foreach (GameObject listener in listeners) {
                    hsd.AddListener(listener);
                }
            }
        };
        hsd.SessionEnd += delegate {
            Debug.Log("EngageSingleSession: Session end");
            if (DisengageUser(user)) {
                foreach (GameObject listener in listeners) {
                    hsd.RemoveListener(listener);
                }
            }
        };

        user.AddListener(go);
    }
 void Zig_Detach(ZigTrackedUser user)
 {
     user.RemoveListener(leftHandDetector);
     user.RemoveListener(rightHandDetector);
     EndSession();
     trackedUser = null;
 }
    IEnumerator JointUpdate(ulong userId, Kinect.Joint joint)
    {
        string     jointName;
        float      x, y, z;
        Vector3    vec = GetVector3FromJoint(joint);
        Quaternion q   = Quaternion.identity;
        ZigJointId jointId;

        // argStr: user,jointName,x,y,z
        jointName = joint.ToString();

        jointId = _kinectToZigMapping[joint.JointType];
        if (joint.JointType == Kinect.JointType.Head)
        {
            headP = vec;
            headQ = q;
            UpdateLgTrackedUser(userId, headP);
        }
        ZigTrackedUser tUser      = _Bodies[userId];
        ZigInputJoint  inputJoint = new ZigInputJoint(jointId, vec, q, true);

        inputJoint.GoodPosition      = true;
        inputJoint.GoodRotation      = true;
        tUser.Skeleton[(int)jointId] = inputJoint;

        yield return(1);
    }
Beispiel #9
0
 void Zig_UserLost(ZigTrackedUser user)
 {
     if (Verbose)
     {
         Debug.Log("Zig: Lost user " + user.Id);
     }
     notifyListeners("Zig_UserLost", user);
 }
Beispiel #10
0
 void Zig_UserFound(ZigTrackedUser user)
 {
     if (Verbose)
     {
         Debug.Log("Zig: Found user  " + user.Id);
     }
     notifyListeners("Zig_UserFound", user);
 }
 bool EngageUser(ZigTrackedUser user) {
     if (null == engagedTrackedUser) {
         engagedTrackedUser = user;
         if (null != EngagedUser) user.AddListener(EngagedUser);
         SendMessage("UserEngaged", this, SendMessageOptions.DontRequireReceiver);
         return true;
     }
     return false;
 }
 bool DisengageUser(ZigTrackedUser user) {
     if (user == engagedTrackedUser) {
         if (null != EngagedUser) user.RemoveListener(EngagedUser);
         engagedTrackedUser = null;
         SendMessage("UserDisengaged", this, SendMessageOptions.DontRequireReceiver);
         return true;
     }
     return false;
 }
Beispiel #13
0
    /// <summary>
    /// Update the logic for the window.
    /// </summary>
    protected void Update()
    {
        if (isNUIOn && ZigEditorInput.Instance.ReaderInited)
        {
            // Update Device
            ZigEditorInput.Instance.Update();

            // Get the tracked user
            ZigTrackedUser user = null;
            foreach (KeyValuePair <int, ZigTrackedUser> trackedUser in ZigEditorInput.Instance.TrackedUsers)
            {
                user = trackedUser.Value;
            }

            // Update viewers
            if (viewerType == NUIViewerType.DepthViewer)
            {
                depthViewer.Update(ZigEditorInput.Depth, user, viewNodes);
            }
            else if (viewerType == NUIViewerType.ImageViewer)
            {
                imageViewer.Update(ZigEditorInput.Image, kinectCaptureResolution, user, viewNodes);
            }
            //else if (viewerType == NUIViewerType.DepthAndImageViewer)
            //{
            //    mixedViewer.Update(ZigEditorInput.Image, ZigEditorInput.Depth, kinectCaptureResolution);
            //}

            // Check if in pre-recording state
            if (captureState == RecordingState.PreRecording)
            {
                long timeLeft = (delaySeconds * 1000) - stopwatch.ElapsedMilliseconds;
                if (timeLeft <= 0)
                {
                    // Begin recording data
                    BeginRecording();
                }
            }

            // Add a keyframe if in recording state
            if (user != null && captureData != null && user.SkeletonTracked && captureState == RecordingState.Recording)
            {
                captureData.AddKeyframe(user.Skeleton, stopwatch.ElapsedMilliseconds);
            }

            // Pose the preview model
            if (inputMapper != null && cinema_mocap_humanoid_instance != null && user != null && user.SkeletonTracked)
            {
                RealtimeHumanoidPosing poser = cinema_mocap_humanoid_instance.GetComponent <RealtimeHumanoidPosing>();
                poser.SetRotations(inputMapper.GetRotations(user.Skeleton));
                poser.SetWorldPosition(inputMapper.GetHipPosition(user.Skeleton));
            }

            Repaint();
        }
    }
 void Zig_UserLost(ZigTrackedUser user) {
     if (user == leftTrackedUser) {
         leftTrackedUser = null;
         SendMessage("UserDisengagedLeft", this, SendMessageOptions.DontRequireReceiver);
     }
     if (user == rightTrackedUser) {
         rightTrackedUser = null;
         SendMessage("UserDisengagedRight", this, SendMessageOptions.DontRequireReceiver);
     }
 }
Beispiel #15
0
    public void Zig_UpdateUser(ZigTrackedUser user)
    {
        ZgTrackedUser zguser = new ZgTrackedUser(user.Id);

        zguser.Position        = user.Position;
        zguser.PositionTracked = user.PositionTracked;
        zguser.SkeletonTracked = user.SkeletonTracked;
        zguser.Skeleton        = user.Skeleton.Select(e => ToZgInputJoint(e)).ToArray();
        ManagerManager.Manager.mZigManager.Zig_UpdateUser(zguser);
    }
    private void Kinect_UpdateUser()
    {
        ulong          userId = trackedUserId();
        ZigTrackedUser tUser  = _Bodies[userId];

        _engagedTrackedUser = tUser;
        foreach (GameObject go in EngagedUsers)
        {
            go.SendMessage("Zig_UpdateUser", tUser, SendMessageOptions.DontRequireReceiver);
        }
    }
 void Zig_Detach(ZigTrackedUser user)
 {
     user.RemoveListener(leftHandDetector);
     user.RemoveListener(rightHandDetector);
     if (InSession)
     {
         InSession = false;
         OnSessionEnd();
     }
     trackedUser = null;
 }
 void Zig_UserLost(ZigTrackedUser user)
 {
     if (Network.isServer || Network.isClient)
     {
         Network.Destroy(objects[user.Id]);
     }
     else
     {
         Destroy(objects[user.Id]);
     }
     objects.Remove(user.Id);
 }
 bool DisengageUser(ZigTrackedUser user) {
     if (user == engagedTrackedUser) {
         if (null != user) { // force end session for a user on disengage
             objects[user.Id].GetComponent<ZigHandSessionDetector>().EndSession();
         }
         if (null != EngagedUser) user.RemoveListener(EngagedUser);
         engagedTrackedUser = null;
         SendMessage("UserDisengaged", this, SendMessageOptions.DontRequireReceiver);
         return true;
     }
     return false;
 }
 void EngageUser(ZigTrackedUser user)
 {
     if (null == engagedTrackedUser)
     {
         engagedTrackedUser = user;
         foreach (GameObject go in EngagedUsers)
         {
             user.AddListener(go);
         }
         SendMessage("UserEngaged", this, SendMessageOptions.DontRequireReceiver);
     }
 }
 void DisengageUser(ZigTrackedUser user)
 {
     if (user == engagedTrackedUser)
     {
         foreach (GameObject go in EngagedUsers)
         {
             user.RemoveListener(go);
         }
         engagedTrackedUser = null;
         SendMessage("UserDisengaged", this, SendMessageOptions.DontRequireReceiver);
     }
 }
 void Zig_UserLost(ZigTrackedUser user)
 {
     if (user == leftTrackedUser)
     {
         leftTrackedUser = null;
         SendMessage("UserDisengagedLeft", this, SendMessageOptions.DontRequireReceiver);
     }
     if (user == rightTrackedUser)
     {
         rightTrackedUser = null;
         SendMessage("UserDisengagedRight", this, SendMessageOptions.DontRequireReceiver);
     }
 }
    void UserLost(ulong userId)
    {
        Debug.Log("UserFound(Kinect User Lost): " + userId + ", index = " + ((userId + 1) % 6));
        ZigTrackedUser tUser = _Bodies[userId];

        if (trackedId == userId)
        {
            _engagedTrackedUser = null;
            trackedId           = 0;
        }
        zig.SendMessage("Zig_UserLost", tUser);
        _Bodies.Remove(userId);
    }
 bool EngageUser(ZigTrackedUser user)
 {
     if (null == engagedTrackedUser)
     {
         engagedTrackedUser = user;
         if (null != EngagedUser)
         {
             user.AddListener(EngagedUser);
         }
         SendMessage("UserEngaged", this, SendMessageOptions.DontRequireReceiver);
         return(true);
     }
     return(false);
 }
 bool DisengageUser(ZigTrackedUser user)
 {
     if (user == engagedTrackedUser)
     {
         if (null != EngagedUser)
         {
             user.RemoveListener(EngagedUser);
         }
         engagedTrackedUser = null;
         SendMessage("UserDisengaged", this, SendMessageOptions.DontRequireReceiver);
         return(true);
     }
     return(false);
 }
    //! --------------------------------------------------------------------------
    //! METHODS
    //! --------------------------------------------------------------------------
    void EngageUser(ZigTrackedUser arriving_user)
    {
        // if not currently tracking
        if (engagedTrackedUser == null)
        {
            // -- addition!
            exercise.foundUser();
            // --

            engagedTrackedUser = arriving_user;
            foreach (GameObject go in EngagedUsers)
                arriving_user.AddListener (go);
            SendMessage ("UserEngaged", this, SendMessageOptions.DontRequireReceiver);
        }
    }
Beispiel #27
0
 void Zig_UpdateUser(ZigTrackedUser user)
 {
     if (user.SkeletonTracked)
     {
         foreach (ZigInputJoint joint in user.Skeleton)
         {
             if (joint.Id == ZigJointId.Waist)
             {
                 var pos = joint.Position;
                 GameController.Instance.UserRelativePosition = new Vector3(pos.z, pos.y, pos.x);
             }
         }
     }
     //Debug.Log("Tracked: " + tracked + " untracked: " + untracked);
 }
    void DisengageUser(ZigTrackedUser departing_user)
    {
        // if the disengaged user was the currently tracked users
        if (departing_user == engagedTrackedUser)
        {
            // -- addition!
            exercise.lostUser();
            // --

            foreach (GameObject go in EngagedUsers)
                departing_user.RemoveListener (go);
            engagedTrackedUser = null;
            SendMessage ("UserDisengaged", this, SendMessageOptions.DontRequireReceiver);
        }
    }
    void Zig_UpdateUser(ZigTrackedUser user) {
        if (!InSession && user.SkeletonTracked && joint != ZigJointId.None) {
            InSession = true;
            SendMessage("Session_Start", user.Skeleton[(int)joint].Position, SendMessageOptions.DontRequireReceiver);
        }

        if (InSession) {
            if (!user.SkeletonTracked) {
                SendMessage("Session_End", SendMessageOptions.DontRequireReceiver);
                InSession = false;
            }
            else {
                SendMessage("Session_Update", user.Skeleton[(int)joint].Position, SendMessageOptions.DontRequireReceiver);
            }
        }
    }
Beispiel #30
0
    void Zig_UpdateUser(ZigTrackedUser user)
    {
        ZigInputJoint torso = user.Skeleton[(int)ZigJointId.Torso];
        ZigInputJoint head = user.Skeleton[(int)ZigJointId.Head];
        ZigInputJoint elbow = user.Skeleton[(int)ZigJointId.LeftElbow];
        ZigInputJoint hand = user.Skeleton[(int)ZigJointId.LeftHand];

        Vector3 armDirection = (hand.Position - elbow.Position).normalized;
        Vector3 torsoDirection = (head.Position - torso.Position).normalized;
        double angle = Math.Acos(Vector3.Dot(armDirection, torsoDirection)) * 180 / Math.PI;
        hand_pos_ = hand.Position;
        if(angle < 30 && !track_hand_)
        {
            //Debug.Log(angle+"hand raise");
            //focusPoint = hand_pos_;
            Renderer[] allChildren = catcher_.GetComponentsInChildren<Renderer>();
            foreach (Renderer child in allChildren)
            {
           				child.enabled = true;
            }
            net_.renderer.enabled = true;
            track_hand_ = true;
        }
        //Debug.Log(bounds.x + " "+ bounds.y + " " + bounds.z );
        Vector3 pos = hand.Position - focusPoint;
        desiredPos = ClampVector(Vector3.Scale(pos, Scale) + bias, -0.5f * bounds, 0.5f * bounds);
        if(track_hand_ )
        {
            //Debug.Log("hand_pos_");

            //Vector3 pos = hand_pos_ - focusPoint; ;
            //desiredPos = ClampVector(Vector3.Scale(pos, Scale) + bias, -0.5f * bounds, 0.5f * bounds);
            //hand_pos_.x /= 200.0f;
            //hand_pos_.y /= 200.0f;
            //hand_pos_.z /= 500.0f;
            //transform.localPosition = hand_pos_;
            Quaternion rot = hand.Rotation;
            //rot.y = -rot.y;
            //rot.z = -rot.z;
            this.transform.localPosition = Vector3.Lerp(this.transform.localPosition,  desiredPos, damping * Time.deltaTime);

            if(hand.GoodRotation)
                this.transform.localRotation =  rot;;
                //this.transform.Rotate(Vector3.forward);
            //Debug.Log("catcher pos " + transform.position.x + " "+ transform.position.y + " " + transform.position.z );
        }
    }
        public override void Update()
        {
            if (ZigEditorInput.Instance.ReaderInited)
            {
                // Update Device
                ZigEditorInput.Instance.Update();

                // Get the tracked user
                ZigTrackedUser user   = null;
                int            userId = 0;
                foreach (KeyValuePair <int, ZigTrackedUser> trackedUser in ZigEditorInput.Instance.TrackedUsers)
                {
                    user   = trackedUser.Value;
                    userId = trackedUser.Key;
                }

                // Update viewers
                foreach (Kinect1EditorViewer viewer in viewers)
                {
                    viewer.Update(ZigEditorInput.Instance, userId);
                }

                if (user != null && user.SkeletonTracked)
                {
                    // Encapsulate the important frame data
                    SkeletonFrameData frameData = new SkeletonFrameData();
                    frameData.TrackingId = (ulong)user.Id;
                    frameData.IsTracked  = user.SkeletonTracked;

                    foreach (ZigInputJoint inputJoint in user.Skeleton)
                    {
                        NUIJointType jointType = NUICaptureHelper.ZigToNUIJointMapping(inputJoint.Id);

                        // Convert position from mm to meters
                        Vector3    position    = inputJoint.Position / 1000f;
                        Quaternion orientation = inputJoint.Rotation;

                        frameData.AddJoint(jointType, position, orientation, inputJoint.Inferred ? TrackingState.Inferred : TrackingState.Tracked);
                    }

                    FrameDataEventArgs args = new FrameDataEventArgs(frameData);
                    OnFrameCaptured(args);
                }
            }
        }
    void Zig_UserFound(ZigTrackedUser user)
    {
        if (Network.isServer)
        {
            Debug.Log("Spawned User!");
        }

        //TODO: ensure that arg-heavy network instantiation isn't destroying the start coordinates of the player in real space
        GameObject o = (!Network.isServer) ?
                       Instantiate(InstantiatePerUser) as GameObject :
                       Network.Instantiate(InstantiatePerUser, ZERO, this.transform.rotation, 0) as GameObject;

        GameObject l = Instantiate(UserLamp) as GameObject;

        l.transform.parent = o.transform;
        objects[user.Id]   = o;
        user.AddListener(o);
    }
 bool DisengageUser(ZigTrackedUser user)
 {
     if (user == engagedTrackedUser)
     {
         if (null != user)   // force end session for a user on disengage
         {
             objects[user.Id].GetComponent <ZigHandSessionDetector>().EndSession();
         }
         if (null != EngagedUser)
         {
             user.RemoveListener(EngagedUser);
         }
         engagedTrackedUser = null;
         SendMessage("UserDisengaged", this, SendMessageOptions.DontRequireReceiver);
         return(true);
     }
     return(false);
 }
 private void UpdateUser(ZigTrackedUser inputUser)
 {
     if (inputUser == null)
         return;
     foreach (ZigInputJoint joint in inputUser.Skeleton)
     {
         if (joint.Id == ZigJointId.Torso)
         {
             var normalized = joint.Position.normalized;
             //Debug.Log("Position: x: " + normalized.x + " y: " + normalized.y + " z: " + normalized.z);
             if (objectOnScreen != null)
             {
                 var currentPosition = objectOnScreen.transform.localPosition;
                 objectOnScreen.transform.localPosition = new Vector3(normalized.x, normalized.y, normalized.z) * 7;
             }
         }
     }
 }
	void Zig_UserFound(ZigTrackedUser user) {
        // create gameobject to listen for events for this user
        GameObject go = new GameObject("WaitForEngagement" + user.Id);
        go.transform.parent = transform;
		objects[user.Id] = go;

        // add various detectors & events

        if (RaiseHand) {
            ZigHandRaiseDetector hrd = go.AddComponent<ZigHandRaiseDetector>();
            hrd.HandRaise += delegate {
                EngageUser(user);
            };
        }

        // attach the new object to the new user
		user.AddListener(go);
	}
Beispiel #36
0
 void Zig_UpdateUser(ZigTrackedUser user)
 {
     UpdateRoot(user.Position);
     if (user.SkeletonTracked)
     {
         foreach (ZigInputJoint joint in user.Skeleton)
         {
             if (joint.GoodPosition)
             {
                 UpdatePosition(joint.Id, joint.Position);
             }
             if (joint.GoodRotation)
             {
                 UpdateRotation(joint.Id, joint.Rotation);
             }
         }
     }
 }
    void ZigTrackedUserCenter(KinectOneLabelMap labelmap)
    {
        if (m_engageuser == null || m_engageuser.engagedTrackedUser == null)
        {
            trackedUserIndex = 255;
            return;
        }
        ZigTrackedUser _engagedUser = m_engageuser.engagedTrackedUser;

        Kinect.CameraSpacePoint positionPoint = new Kinect.CameraSpacePoint();
        positionPoint.X = _engagedUser.Position.x;
        positionPoint.Y = _engagedUser.Position.y;
        positionPoint.Z = _engagedUser.Position.z;
        Kinect.DepthSpacePoint depthSpacePoint = _mapper.MapCameraPointToDepthSpace(positionPoint);
        short[] labelData = labelmap.data;
        int     index     = (int)(depthSpacePoint.Y * depthInfo.xres + depthSpacePoint.X);

        trackedUserIndex = (index >= 0 && index < labelData.Length) ? labelData[index] : (short)255;
    }
    //更新所有骨架物件的位置與關節之間的連線。
    private void RefreshBodyObject(Kinect.Body body, ulong userId)
    {
        ZigTrackedUser bodyObject = _Bodies[userId];

        //以迴圈的方式將所有的骨骼一個一個的去計算。
        for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++)
        {
            //抓取到來源關節,以及重置目標關節為空物件。
            Kinect.Joint sourceJoint = body.Joints[jt];
            Kinect.Joint?targetJoint = null;
            if (!_kinectToZigMapping.ContainsKey(sourceJoint.JointType))
            {
                continue;
            }
            //讀取出骨頭線段的出發點,也就是目前關節的位置。
            //Transform jointObj = bodyObject.transform.FindChild(jt.ToString());
            //jointObj.localPosition = GetVector3FromJoint(sourceJoint);
            StartCoroutine(JointUpdate(userId, sourceJoint));
        }
    }
    void Zig_UserFound(ZigTrackedUser user)
    {
        // create gameobject to listen for events for this user
        GameObject go = new GameObject("WaitForEngagement" + user.Id);

        go.transform.parent = transform;
        objects[user.Id]    = go;

        // add various detectors & events

        if (RaiseHand)
        {
            ZigHandRaiseDetector hrd = go.AddComponent <ZigHandRaiseDetector>();
            hrd.HandRaise += delegate {
                EngageUser(user);
            };
        }

        // attach the new object to the new user
        user.AddListener(go);
    }
 void Zig_UpdateUser(ZigTrackedUser user)
 {
     if (InSession)
     {
         // get hand point for this frame, rotate if neccessary
         Vector3 hp = user.Skeleton[(int)jointInSession].Position;
         if (RotateToUser)
         {
             hp = RotateHandPoint(hp);
         }
         // make sure hand point is still within session bounds
         currentSessionBounds.center  = (RotateToUser) ? RotateHandPoint(trackedUser.Position) : trackedUser.Position;
         currentSessionBounds.center += SessionBoundsOffset;
         if (!currentSessionBounds.Contains(hp))
         {
             EndSession();
             return;
         }
         OnSessionUpdate(hp);
     }
 }
Beispiel #41
0
    void Zig_UpdateUser(ZigTrackedUser user)
    {
        if (!InSession && user.SkeletonTracked && joint != ZigJointId.None)
        {
            InSession = true;
            SendMessage("Session_Start", user.Skeleton[(int)joint].Position, SendMessageOptions.DontRequireReceiver);
        }

        if (InSession)
        {
            if (!user.SkeletonTracked)
            {
                SendMessage("Session_End", SendMessageOptions.DontRequireReceiver);
                InSession = false;
            }
            else
            {
                SendMessage("Session_Update", user.Skeleton[(int)joint].Position, SendMessageOptions.DontRequireReceiver);
            }
        }
    }
    public void CaptureFrameFunction(ZigTrackedUser user)
    {
        //create frame
        SerializeScript.SnapshotClass frame =
            new SerializeScript.SnapshotClass();

        foreach (ZigInputJoint joint in user.Skeleton)
        {
            if (joint.GoodRotation)
            {
                UpdateRotation(joint.Id, joint.Rotation);
            }
            if (joint.GoodRotation)
            {
                frame.jointRotations[(int)joint.Id] = joint.Rotation; //store joint?
            }
        }

        recordList.Add(frame);

        isReturningFrame = false; //reset flag
    }
    void Zig_UserFound(ZigTrackedUser user)
    {
        // create gameobject to listen for events for this user
        GameObject go = new GameObject("WaitForEngagement" + user.Id);

        go.transform.parent = transform;
        objects[user.Id]    = go;

        ZigHandSessionDetector hsd = go.AddComponent <ZigHandSessionDetector>();

        hsd.SessionBounds       = SessionBounds;
        hsd.SessionBoundsOffset = SessionBoundsOffset;
        hsd.StartOnSteady       = StartOnSteady;
        hsd.StartOnWave         = StartOnWave;
        hsd.RotateToUser        = RotateToUser;

        hsd.SessionStart += delegate {
            Debug.Log("EngageSingleSession: Session start");
            if (EngageUser(user))
            {
                foreach (GameObject listener in listeners)
                {
                    hsd.AddListener(listener);
                }
            }
        };
        hsd.SessionEnd += delegate {
            Debug.Log("EngageSingleSession: Session end");
            if (DisengageUser(user))
            {
                foreach (GameObject listener in listeners)
                {
                    hsd.RemoveListener(listener);
                }
            }
        };

        user.AddListener(go);
    }
Beispiel #44
0
    void Zig_UserFound(ZigTrackedUser user)
    {
        GameObject o = Instantiate(InstantiatePerUser) as GameObject;
        objects[user.Id] = o;
        user.AddListener(o);

        /*//Changing to Mega Kaiju
        if(GameManager.megaCounter >= GUIMegaScript.buildingsTillMega){
            Destroy(objects[user.Id]);
            objects.Remove (user.Id);
            GameObject mega = Instantiate(MegaInstantiatePerUser) as GameObject;
            objects[user.Id] = mega;
            user.AddListener(mega);
            if (megaCooldown.timeStamp <= Time.deltaTime){
                Destroy(objects[user.Id]);
                objects.Remove (user.Id);
                objects[user.Id] = o;
                user.AddListener(o);
                GameManager.megaCounter = 0f;
            }
        }
        */
    }
    void UpdateLgTrackedUser(ulong user_id, Vector3 vec)
    {
        ZigInputUser inputUser = new ZigInputUser((int)((user_id + 1) % 6), vec);

        inputUser.SkeletonData = new List <ZigInputJoint>();
        if (trackedUserId() == user_id)
        {
            inputUser.Tracked = true;
        }
        ZigTrackedUser tUser;

        try
        {
            tUser = _Bodies[user_id];
            tUser.Update(inputUser);
        }
        catch (System.Exception e)
        {
            tUser            = new ZigTrackedUser(inputUser);
            _Bodies[user_id] = tUser;
        }
        zig.SendMessage("Zig_UserFound", tUser);
    }
    /// <summary>
    /// if the isReturningFrame bool is true, captures current frame and returns it
    /// Overloads the parent class
    /// </summary>
    /// <param name='user'>
    /// User.
    /// </param>
    void Zig_UpdateUser(ZigTrackedUser user)
    {
        UpdateRoot(user.Position);
        if (user.SkeletonTracked)
        {
            foreach (ZigInputJoint joint in user.Skeleton)
            {
                if (joint.GoodPosition)
                {
                    UpdatePosition(joint.Id, joint.Position);
                }
                if (joint.GoodRotation)
                {
                    UpdateRotation(joint.Id, joint.Rotation);
                }
            }
        }

        if (isReturningFrame)
        {
            CaptureFrameFunction(user);
        }
    }
 void Zig_Attach(ZigTrackedUser user)
 {
     trackedUser = user;
     user.AddListener(leftHandDetector);
     user.AddListener(rightHandDetector);
 }
Beispiel #48
0
 void Zig_UserFound(ZigTrackedUser user)
 {
     Debug.Log ("User Found");
 }
Beispiel #49
0
 void Zig_UserLost(ZigTrackedUser user)
 {
     Debug.Log ("Yo all Lost");
 }
Beispiel #50
0
 void Zig_UserLost(ZigTrackedUser user)
 {
     if (Verbose)
                     Debug.Log ("Zig: Lost user " + user.Id);
             notifyListeners ("Zig_UserLost", user);
 }
 void Zig_Detach(ZigTrackedUser user)
 {
     user.RemoveListener(leftHandDetector);
     user.RemoveListener(rightHandDetector);
     EndSession();
     trackedUser = null;
 }
 void Zig_UserLost(ZigTrackedUser user) {
     DisengageUser(user);
     Destroy(objects[user.Id]);
     objects.Remove(user.Id);
 }
Beispiel #53
0
 void Zig_UserFound(ZigTrackedUser user)
 {
     if (Verbose)
                     Debug.Log ("Zig: Found user  " + user.Id);
             notifyListeners ("Zig_UserFound", user);
 }
    /// <summary>
    /// if the isReturningFrame bool is true, captures current frame and returns it
    /// Overloads the parent class
    /// </summary>
    /// <param name='user'>
    /// User.
    /// </param>
    void Zig_UpdateUser(ZigTrackedUser user)
    {
        UpdateRoot(user.Position);
        if (user.SkeletonTracked)
        {
            foreach (ZigInputJoint joint in user.Skeleton)
            {
                if (joint.GoodPosition) UpdatePosition(joint.Id, joint.Position);
                if (joint.GoodRotation) UpdateRotation(joint.Id, joint.Rotation);
            }
        }

        if (isReturningFrame)
        {
            CaptureFrameFunction(user);
        }
    }
Beispiel #55
0
 void Zig_UserFound(ZigTrackedUser user)
 {
     user.AddListener(this.gameObject);
     Debug.Log("Zig: Found user YO  " + user.Id);
 }
Beispiel #56
0
 void Zig_UserLost(ZigTrackedUser user)
 {
     if (Verbose) Debug.Log("Zig: Lost user " + user.Id);
 }
Beispiel #57
0
 void Zig_UpdateUser(ZigTrackedUser user)
 {
     UpdateRoot(user.Position);
     if (user.SkeletonTracked)
     {
         foreach (ZigInputJoint joint in user.Skeleton)
         {
             if (joint.GoodPosition) UpdatePosition(joint.Id, joint.Position);
             if (joint.GoodRotation) UpdateRotation(joint.Id, joint.Rotation);
         }
     }
 }
    public void CaptureFrameFunction(ZigTrackedUser user)
    {
        //create frame
        SerializeScript.SnapshotClass frame =
            new SerializeScript.SnapshotClass();

        foreach (ZigInputJoint joint in user.Skeleton)
        {
            if (joint.GoodRotation) UpdateRotation(joint.Id, joint.Rotation);
            if (joint.GoodRotation)
            {
                frame.jointRotations[(int)joint.Id] = joint.Rotation; //store joint?
            }

        }

        recordList.Add(frame);

        isReturningFrame = false; //reset flag
    }
 void Zig_UpdateUser(ZigTrackedUser user)
 {
     if (InSession) {
         // get hand point for this frame, rotate if neccessary
         Vector3 hp = user.Skeleton[(int)jointInSession].Position;
         if (RotateToUser) hp = RotateHandPoint(hp);
         // make sure hand point is still within session bounds
         currentSessionBounds.center = (RotateToUser) ? RotateHandPoint(trackedUser.Position) : trackedUser.Position;
         currentSessionBounds.center += SessionBoundsOffset;
         if (!currentSessionBounds.Contains(hp)) {
             EndSession();
             return;
         }
         OnSessionUpdate(hp);
     }
 }
 void Zig_Detach(ZigTrackedUser user) {
     user.RemoveListener(leftHandDetector);
     user.RemoveListener(rightHandDetector);
     if (InSession) {
         InSession = false;
         OnSessionEnd();
     }
     trackedUser = null;
 }