Exemplo n.º 1
0
 private void PcRelative_OnValueChanged(PointControl obj)
 {
     PcAbsolute.X = PcRelative.X + PcZero.X;
     PcAbsolute.Y = PcRelative.Y + PcZero.Y;
     PcArchor.X   = PcAbsolute.X;
     PcArchor.Y   = PcAbsolute.Y;
 }
Exemplo n.º 2
0
        public bool initializeSensor(String xmlPath)
        {
            try

            {
                pbuffer   = new  Point[6];
                openpalm  = new OpenPalm();
                scrHeight = SystemInformation.PrimaryMonitorSize.Height;
                scrWidth  = SystemInformation.PrimaryMonitorSize.Width;

                mouseSpeed       = SystemInformation.MouseSpeed * 0.15;
                pointCollections = new PointCollection();
                /*OpenNI objects - Context, DepthGenerator and DepthMetaData are initialized here*/
                cxt              = new Context(xmlPath);
                depthGen         = cxt.FindExistingNode(NodeType.Depth) as DepthGenerator;
                gsHandsGenerator = cxt.FindExistingNode(NodeType.Hands) as HandsGenerator;
                gsHandsGenerator.SetSmoothing(0.1f);
                depthMeta = new DepthMetaData();
                if (depthGen == null)
                {
                    return(false);
                }

                xRes = depthGen.MapOutputMode.XRes;
                yRes = depthGen.MapOutputMode.YRes;

                /*NITE objects - Session manager, PointControl is initialized here*/
                sessionMgr = new SessionManager(cxt, "Wave", "RaiseHand");

                pointCtrl      = new PointControl("PointTracker");
                steadydetector = new SteadyDetector();
                flrouter       = new FlowRouter();
                brodcaster     = new Broadcaster();
                steadydetector.DetectionDuration = 200;

                steadydetector.Steady    += new EventHandler <SteadyEventArgs>(steadydetector_Steady);
                steadydetector.NotSteady += new EventHandler <SteadyEventArgs>(steadydetector_NotSteady);

                /*  pointCtrl.PrimaryPointCreate += new EventHandler<HandFocusEventArgs>(pointCtrl_PrimaryPointCreate);
                 * pointCtrl.PrimaryPointUpdate += new EventHandler<HandEventArgs>(pointCtrl_PrimaryPointUpdate);
                 * pointCtrl.PrimaryPointDestroy += new EventHandler<IdEventArgs>(pointCtrl_PrimaryPointDestroy);*/
                pointCtrl.PointCreate  += new EventHandler <HandEventArgs>(pointCtrl_PointCreate);
                pointCtrl.PointUpdate  += new EventHandler <HandEventArgs>(pointCtrl_PointUpdate);
                pointCtrl.PointDestroy += new EventHandler <IdEventArgs>(pointCtrl_PointDestroy);


                sessionMgr.AddListener(steadydetector);
                sessionMgr.AddListener(pointCtrl); //make the session manager listen to the point control

                isActive = false;                  //set lifecycle flag to false
                //fill the handpoint coordinates with invalid values
                //initialize the clipping matrix

                HandPointBuffer = new ArrayList();
            }
            catch (Exception e) { return(false); }

            return(true);
        }
Exemplo n.º 3
0
        private void PcZero_OnValueChanged(PointControl obj)
        {
            ArchorSettingContext.ZeroX = obj.X;
            ArchorSettingContext.ZeroY = obj.Y;

            PcRelative.X = _dev.PosX - obj.X;
            PcRelative.Y = _dev.PosZ - obj.Y;
        }
 /// Method to add a listener
 ///
 /// This method is used to add a new listener to the hand tracker.
 /// @note it is the responsibility of the caller to later call @ref RemoveListener
 /// @param newListener the listener to add
 /// @return true on success, false on failure (for example because we are not valid)
 public bool AddListener(PointControl newListener)
 {
     if (Valid == false)
     {
         return(false);
     }
     m_pointControlSmoothFilter.AddListener(newListener);
     return(true);
 }
    void Awake()
    {
        myControl = new PointControl();
        myControl.PrimaryPointUpdate += new System.EventHandler<HandEventArgs>(myControl_PrimaryPointUpdate);
        myControl.PrimaryPointCreate += new System.EventHandler<HandFocusEventArgs>(myControl_PrimaryPointCreate);
        myControl.PrimaryPointDestroy += new System.EventHandler<IdEventArgs>(myControl_PrimaryPointDestroy);

        AddListener(myControl);
    }
    void Awake()
    {
        myControl = new PointControl();
        myControl.PrimaryPointUpdate  += new System.EventHandler <HandEventArgs>(myControl_PrimaryPointUpdate);
        myControl.PrimaryPointCreate  += new System.EventHandler <HandFocusEventArgs>(myControl_PrimaryPointCreate);
        myControl.PrimaryPointDestroy += new System.EventHandler <IdEventArgs>(myControl_PrimaryPointDestroy);

        AddListener(myControl);
    }
 /// Method to remove a previously added listener a listener
 ///
 /// This method is used to remove a previously added listener.
 /// @note it is the responsibility of the caller to @ref AddListener to call this.
 /// @param oldListener the listener to remove
 /// @return true on success, false on failure (for example because we are not valid)
 public bool RemoveListener(PointControl oldListener)
 {
     if (Valid == false)
     {
         return(false);
     }
     m_pointControlSmoothFilter.RemoveListener(oldListener);
     return(true);
 }
Exemplo n.º 8
0
        public flip(PointControl p) : base(5, 0, "Flip")
        {
            points = p;

            output = "Flip.exe\n" +
                     "Accessing Oppponent Wifi...\n" +
                     "Accessing Direction.log...\n" +
                     "Flipping Horizontal Input...\n" +
                     "Hack Successful\n";
        }
Exemplo n.º 9
0
        public reverse(PointControl p) : base(15, 4, "Reverse")
        {
            points = p;

            output = "Reverse.exe\n" +
                     "Accessing Car Wifi...\n" +
                     "Accessing Direction.log...\n" +
                     "Flipping Vertical Input...\n" +
                     "Hack Successful\n";
        }
Exemplo n.º 10
0
        public dropPoint(PointControl p) : base(20, 6, "Drop Point")
        {
            points = p;

            output = "DropPoint.exe\n" +
                     "Accessing Car Wifi...\n" +
                     "Accessing Inventory.py...\n" +
                     "Set hasPoint to False...\n" +
                     "Hack Succesful\n";
        }
Exemplo n.º 11
0
        public slowDown(PointControl p) : base(5, 1, "Slow")
        {
            points = p;

            output = "SlowDown.exe\n" +
                     "Accessing Car Wifi...\n" +
                     "Accessing Movement.py...\n" +
                     "Speed = Speed/2...\n" +
                     "Hack Succesful\n";
        }
Exemplo n.º 12
0
        /// <summary>
        /// Adds a new Point-field to the control, if there are less than 5 present.
        /// </summary>
        public void AddPoint()
        {
            if (points.Count >= MAX_POINTS)
            {
                return;
            }
            PointControl p = new PointControl();

            flowLayoutPanel.Controls.Add(p);
            points.Add(p);
        }
Exemplo n.º 13
0
 public Stuck(PointControl p) : base(12, 1, "Stuck")
 {
     points = p;
     //update
     output = "Kill.exe\n" +
              "Accessing Car Wifi...\n" +
              "Accessing Data.log...\n" +
              "Increasing Temperature Variable...\n" +
              "Beaglebone Quits Due to High Temp...\n" +
              "Hack Successful\n";
 }
Exemplo n.º 14
0
 public void OnOccupy(PointControl pc, int team)
 {
     foreach (var tc in tanks)
     {
         var teamMark = tc.GetComponent <TeamMark>();
         if (team == teamMark.team)
         {
             //inform
         }
     }
 }
Exemplo n.º 15
0
        public freeze(PointControl p) : base(10, 2, "Freeze")
        {
            points = p;

            output = "Freeze.exe/n" +
                     "Accessing Car Wifi.../n" +
                     "Accessing BeagleBone Terminal.../n" +
                     "Running 'shutdown' in Terminal.../n" +
                     "Restarting Beaglebone.../n" +
                     "Hack Successful/n";
        }
Exemplo n.º 16
0
        public TrackingClusterDataSource(Context context, DepthGenerator depthGenerator, IDepthPointerDataSource dataSource)
            : base(dataSource)
        {
            this.context        = context;
            this.depthGenerator = depthGenerator;
            this.size           = dataSource.Size;
            this.CurrentValue   = new ClusterCollection();

            this.sessionManager = new SessionManager(context, "Wave", "RaiseHand");
            this.pointControl   = new PointControl();
            this.pointControl.PrimaryPointUpdate += new EventHandler <HandEventArgs>(pointControl_PrimaryPointUpdate);
            this.sessionManager.AddListener(this.pointControl);
        }
Exemplo n.º 17
0
    /// @brief Initialize the hand control
    ///
    /// This method provides the initialization for the hands control initializing all internal objects.
    /// It assumes the context is already valid (otherwise we fail).
    /// @note - Since we use a singleton pattern, multiple initializations will simply delete the old
    /// objects and create new ones!
    /// @note - It is the responsibility of the initializer to call @ref Dispose.
    /// @param context the context to use
    /// @param focusGesture the gesture used for focusing (i.e. this is aimed to set the hand which we will follow)
    /// @param refocusGesture the gesture used for refocus (when we lose focus temporarily)
    /// @param logger the logger object we will enter logs into
    /// @return true on success, false on failure.
    public bool Init(NIEventLogger logger, NIContext context, string focusGesture, string refocusGesture)
    {
        Dispose(); // to make sure we are not initialized
        if (InitWithContext(logger, context) == false)
        {
            return(false);
        }
        // we will create the user gestures and hands which are needed for the session manager
        // but are not needed externally (as we never access them directly).
        ProductionNode node = context.CreateNode(NodeType.Gesture);

        if (node == null)
        {
            Dispose();
            return(false);
        }
        m_internalNodes.Add(node);
        node = context.CreateNode(NodeType.Hands) as HandsGenerator;
        if (node == null)
        {
            Dispose();
            return(false);
        }
        m_internalNodes.Add(node);
        try
        {
            NINITECheckVersion.Instance.ValidatePrerequisite();
            m_sessionManager = new SessionManager(context.BasicContext, focusGesture, refocusGesture);
            if (refocusGesture.CompareTo("") == 0)
            {
                m_sessionManager.QuickRefocusTimeout = 0;
            }
            else
            {
                m_sessionManager.QuickRefocusTimeout = 15000;
            }
            m_sessionManager.SessionStart += new System.EventHandler <PositionEventArgs>(HandsControlSessionStart);
            m_sessionManager.SessionEnd   += new System.EventHandler(HandsControlSessionEnd);
            m_pointControl = new PointControl();
            m_sessionManager.AddListener(m_pointControl);
            m_pointControl.PrimaryPointDestroy += new System.EventHandler <IdEventArgs>(SessionLostFocus);
        }
        catch (System.Exception ex)
        {
            Log("failed to create session manager with error " + ex.Message, NIEventLogger.Categories.Errors, NIEventLogger.Sources.Hands);
            Dispose();
            return(false);
        }

        return(true);
    }
Exemplo n.º 18
0
        public Kill(PointControl p, ScoreBoard sb, GameObject fire) : base(100, 1, "Kill")
        {
            this.sb   = sb;
            this.fire = fire;

            points = p;

            output = "Kill.exe\n" +
                     "Accessing Car Wifi...\n" +
                     "Accessing Data.log...\n" +
                     "Increasing Temperature Variable...\n" +
                     "Beaglebone Quits Due to High Temp...\n" +
                     "Hack Successful\n";
        }
Exemplo n.º 19
0
    IEnumerator FindTargetLoop()
    {
        while (true)
        {
            yield return(0);

            if (!attackTarget || attackTarget.isDestroyed || !Visible(attackTarget) || refindTimer < 0)
            {
                refindTimer  = 10;
                attackTarget = FindTankTarget();
                if (attackTarget == null)
                {
                    yield return(new WaitForSeconds(2));

                    captureTarget = FindPointTarget();
                }
            }
        }
    }
    /// an internal method to initialize the internal structures
    /// @note in most cases, inheriting methods should NOT override the base InitTracking but
    /// rather override this method.
    /// @return true on success and false otherwise.
    protected override bool InitInternalStructures()
    {
        if (m_context == null || m_context.Valid == false)
        {
            return(false); // we need hands for this...
        }
        m_handsManager = FindObjectOfType(typeof(NITEHandsManager)) as NITEHandsManager;
        if (m_handsManager == null || m_handsManager.ValidWithInit == false)
        {
            throw new System.Exception("There is no NITEHandsManager in the scene!");
        }
        // need to make sure we don't get errors in initialization
        try
        {
            NINITECheckVersion.Instance.ValidatePrerequisite();
            // set up the raw control point (to get raw data)
            m_pointControlRaw = new PointControl();
            m_handsManager.Hands.SessionManager.AddListener(m_pointControlRaw);

            // set up the denoiser filter
            m_pointControlSmoothFilter = new PointDenoiser();
            m_handsManager.Hands.SessionManager.AddListener(m_pointControlSmoothFilter);
            // set up the smoothed control point (to get smoothed data).
            m_pointControlSmooth = new PointControl();
            m_pointControlSmoothFilter.AddListener(m_pointControlSmooth);

            // register the relevant callbacks
            m_pointControlRaw.PrimaryPointUpdate    += new System.EventHandler <HandEventArgs>(myControl_PrimaryPointUpdate);
            m_pointControlRaw.PrimaryPointCreate    += new System.EventHandler <HandFocusEventArgs>(myControl_PrimaryPointCreate);
            m_pointControlRaw.PrimaryPointDestroy   += new System.EventHandler <IdEventArgs>(myControl_PrimaryPointDestroy);
            m_pointControlSmooth.PrimaryPointUpdate += new System.EventHandler <HandEventArgs>(myControl_PrimaryPointUpdateSmooth);
        }
        catch (System.Exception ex)
        {
            Debug.Log("failed to initialize. Error=" + ex.Message);
            StopTracking();
            return(false);
        }
        m_lastFrameCurPoint    = new NIPositionTrackerFrameManager();
        m_lastFrameCurPointRaw = new NIPositionTrackerFrameManager();
        return(true);
    }
Exemplo n.º 21
0
    PointControl FindPointTarget()
    {
        float        minDistance = 10000;
        PointControl min         = null;

        foreach (var pointControl in PointControl.allPoints)
        {
            var occupyStat = pointControl.progress;
            if (occupyStat * GetComponent <TeamMark>().team < 0.999)
            {// is not ours
                var distance = (pointControl.transform.position - transform.position).magnitude;
                if (distance < minDistance)
                {
                    minDistance = distance;
                    min         = pointControl;
                }
            }
        }
        return(min);
    }
Exemplo n.º 22
0
        private void CreateAndRun()
        {
            m_context        = new Context(@"data\openNI.xml");
            m_imageGenerator = new ImageGenerator(m_context);
            m_depthGenerator = new DepthGenerator(m_context);

            SessionManager sessionManager = new SessionManager(m_context, "Wave", "RaiseHand");

            // update the state
            Dispatcher.BeginInvoke(() => { State = SessionState.Idle; });

            sessionManager.SessionStart += SessionManager_SessionStart;
            sessionManager.SessionEnd   += SessionManager_SessionEnd;

            PointControl pointControl = new PointControl();

            pointControl.PrimaryPointCreate  += PointControl_PrimaryPointCreate;
            pointControl.PrimaryPointDestroy += PointControl_PrimaryPointDestroy;
            pointControl.PrimaryPointUpdate  += PointControl_PrimaryPointUpdate;

            SwipeDetector swipeDetector = new SwipeDetector();

            swipeDetector.UseSteady   = true;
            swipeDetector.SwipeLeft  += SwipeDetector_SwipeLeft;
            swipeDetector.SwipeRight += SwipeDetector_SwipeRight;

            PointDenoiser denoiser = new PointDenoiser();

            denoiser.AddListener(pointControl);
            denoiser.AddListener(swipeDetector);
            sessionManager.AddListener(denoiser);

            while (m_running)
            {
                m_context.WaitAndUpdateAll();
                sessionManager.Update(m_context);
            }
        }
Exemplo n.º 23
0
    // Use this for initialization
    void Awake()
    {
        gui = GetComponent <PlayerGUI>();

        buttons[0] = b1;
        buttons[1] = b2;
        buttons[2] = b3;
        buttons[3] = b4;

        Debug.Log("Instantiating Hacks");

        PointControl   points  = player.GetComponent <PointControl>();
        PlayerMovement control = player.GetComponent <PlayerMovement>();

        hacks[4] = new flip(points);
        hacks[5] = new freeze(points);
        hacks[6] = new reverse(points);
        hacks[0] = new dropPoint(points);
        hacks[1] = new slowDown(points);
        hacks[2] = new Delay(points);
        hacks[7] = new Kill(points, sb, fire);
        hacks[3] = new Stuck(points);
        reset    = new Reset(control);
    }
        public bool initializeSensor(String xmlPath)
        {
            try

            {

                pbuffer =new  Point[6];
                openpalm = new OpenPalm();
                scrHeight = SystemInformation.PrimaryMonitorSize.Height;
                scrWidth = SystemInformation.PrimaryMonitorSize.Width;

                mouseSpeed = SystemInformation.MouseSpeed * 0.15;
                pointCollections = new PointCollection();
                /*OpenNI objects - Context, DepthGenerator and DepthMetaData are initialized here*/
                cxt = new Context(xmlPath);
                depthGen = cxt.FindExistingNode(NodeType.Depth) as DepthGenerator;
                gsHandsGenerator = cxt.FindExistingNode(NodeType.Hands) as HandsGenerator;
                gsHandsGenerator.SetSmoothing(0.1f);
                depthMeta = new DepthMetaData();
                if (depthGen == null) return false;

                xRes = depthGen.MapOutputMode.XRes;
                yRes = depthGen.MapOutputMode.YRes;

                /*NITE objects - Session manager, PointControl is initialized here*/
                sessionMgr = new SessionManager(cxt, "Wave", "RaiseHand");

                pointCtrl = new PointControl("PointTracker");
                steadydetector = new SteadyDetector();
                flrouter = new FlowRouter();
                brodcaster = new Broadcaster();
                steadydetector.DetectionDuration = 200;

                steadydetector.Steady+=new EventHandler<SteadyEventArgs>(steadydetector_Steady);
                steadydetector.NotSteady+=new EventHandler<SteadyEventArgs>(steadydetector_NotSteady);
              /*  pointCtrl.PrimaryPointCreate += new EventHandler<HandFocusEventArgs>(pointCtrl_PrimaryPointCreate);
                pointCtrl.PrimaryPointUpdate += new EventHandler<HandEventArgs>(pointCtrl_PrimaryPointUpdate);
                pointCtrl.PrimaryPointDestroy += new EventHandler<IdEventArgs>(pointCtrl_PrimaryPointDestroy);*/
                pointCtrl.PointCreate += new EventHandler<HandEventArgs>(pointCtrl_PointCreate);
                pointCtrl.PointUpdate += new EventHandler<HandEventArgs>(pointCtrl_PointUpdate);
                pointCtrl.PointDestroy += new EventHandler<IdEventArgs>(pointCtrl_PointDestroy);

                sessionMgr.AddListener(steadydetector);
               sessionMgr.AddListener(pointCtrl);  //make the session manager listen to the point control

                isActive = false;                   //set lifecycle flag to false
                            //fill the handpoint coordinates with invalid values
                         //initialize the clipping matrix

                HandPointBuffer = new ArrayList();

            }
            catch (Exception e) { return false; }

            return true;
        }
Exemplo n.º 25
0
        private void CreateAndRun()
        {
            m_context = new Context(@"data\openNI.xml");
            m_imageGenerator = new ImageGenerator(m_context);
            m_depthGenerator = new DepthGenerator(m_context);

            SessionManager sessionManager = new SessionManager(m_context, "Wave", "RaiseHand");

            // update the state
            Dispatcher.BeginInvoke(() => { State = SessionState.Idle; });

            sessionManager.SessionStart += SessionManager_SessionStart;
            sessionManager.SessionEnd += SessionManager_SessionEnd;

            PointControl pointControl = new PointControl();
            pointControl.PrimaryPointCreate += PointControl_PrimaryPointCreate;
            pointControl.PrimaryPointDestroy += PointControl_PrimaryPointDestroy;
            pointControl.PrimaryPointUpdate += PointControl_PrimaryPointUpdate;

            SwipeDetector swipeDetector = new SwipeDetector();
            swipeDetector.UseSteady = true;
            swipeDetector.SwipeLeft += SwipeDetector_SwipeLeft;
            swipeDetector.SwipeRight += SwipeDetector_SwipeRight;

            PointDenoiser denoiser = new PointDenoiser();
            denoiser.AddListener(pointControl);
            denoiser.AddListener(swipeDetector);
            sessionManager.AddListener(denoiser);

            while (m_running)
            {
                m_context.WaitAndUpdateAll();
                sessionManager.Update(m_context);
            }
        }