Inheritance: MonoBehaviour
Exemplo n.º 1
0
        public override ChartBase GetChart(Visualization viz)
        {
            ChartBase chart = null;

            switch (viz)
            {
            case Visualization.None:
                break;

            case Visualization.Table:
                break;

            case Visualization.LineSingleRegimen:
            case Visualization.LineSingleTumor:
            case Visualization.LineMultiTumorMultiRegimen:
                chart = new IRLineChartGroup(viz);
                break;

            case Visualization.StackedBar:
                chart = new IRStackedBarChart();
                break;

            case Visualization.Pie:
                chart = new IRPieChartGroup();
                break;

            default:
                break;
            }

            return(chart);
        }
Exemplo n.º 2
0
    public override void Draw(Visualization Canvas)
    {
        Pen pen = new Pen(Color.Black);

        int numPoints = 5;

        Point[] pts = new Point[numPoints];
        double  rx  = width / 2;
        double  ry  = height / 2;
        double  cx  = x + rx;
        double  cy  = y + ry;

        double theta  = -Math.PI / 2;
        double dtheta = 4 * Math.PI / numPoints;
        int    i;

        for (i = 0; i < numPoints; i++)
        {
            pts [i] = new Point(
                Convert.ToInt32(cx + rx * Math.Cos(theta)),
                Convert.ToInt32(cy + ry * Math.Sin(theta)));
            theta += dtheta;
        }

        for (i = 0; i < numPoints; i++)
        {
            Canvas.DrawLine(pen, pts[i].X,
                            pts[i].Y,
                            pts[(i + 1) % numPoints].X,
                            pts[(i + 1) % numPoints].Y);
        }
    }
    protected Visualization createVisualization(Dataset dataset, Transform parent)
    {
        GameObject go = new GameObject();
        //string folderName = new DirectoryInfo(rootFolder).Name;
        Visualization v = go.AddComponent <Visualization>();

        go.name             = dataset.csvMetadataFile.name;
        go.transform.parent = parent;

        AutographerParser parser = go.AddComponent <AutographerParser>();

        //parser.allowInterp = this.GetComponent<AutographerParser>().allowInterp;
        //parser.imageResolution = this.GetComponent<AutographerParser>().imageResolution;

        v.projectName     = dataset.csvMetadataFile.name;
        v.csvMetadataFile = dataset.csvMetadataFile;
        v.imageDirectory  = dataset.imageDirectory;
        v.imageExtension  = dataset.imageExtension;
        //v.tb = this;
        v.targetMetadataParser = v.GetComponent <MetadataParser>();
        //v.pather = this.pather;
        //v.DoubleSidedMesh = this.DoubleSidedMesh;
        //v.quadTemplate = this.quadTemplate;
        v.quadTemplates = dataset.quadTemplates;
        v.tvisLayout    = this.tvisLayout;
        v.usePhotos     = this.usePhotos;
        //v.transform.parent = this.sceneParent;
        return(v);
    }
 //Constructor
 public Game()
 {
     //Load data if exists
     if (!LoadData())
     {
         SetNewGame();
     }
     else
     {
         //Opcion de cargar juego previo
         Visualization.ClearConsole();
         //Mostar opciones, cargar o juego nuevo
         Visualization.ShowListOptions(new List <string>()
         {
             "No, I was losing", "Load previous game"
         }, "You have a previous game, continue?");
         if (Visualization.GetUserInput(1) == 1)
         {
             decks             = actualData["decks"] as List <Deck>;
             captains          = actualData["captains"] as List <SpecialCard>;
             players           = actualData["players"] as Player[];
             ActivePlayer      = actualData["activePlayer"] as Player;
             boardGame         = actualData["board"] as Board;
             turn              = (int)actualData["turn"];
             bothPlayersPlayed = (bool)actualData["bothPlayersPlayed"];
         }
         else
         {
             SetNewGame();
         }
     }
 }
        /// <summary>
        /// Converts the specified CameraSpacePoint into a 2-D point.
        /// </summary>
        /// <param name="position">The CameraSpacePoint to convert.</param>
        /// <param name="visualization">The type of the conversion (color, depth, or infrared).</param>
        /// <param name="coordinateMapper">The CoordinateMapper to make the conversion.</param>
        /// <returns>The corresponding 2-D point.</returns>
        public static Point ToPoint(this CameraSpacePoint position, Visualization visualization, CoordinateMapper coordinateMapper)
        {
            Point point;

            switch (visualization)
            {
            case Visualization.Color:
            {
                ColorSpacePoint colorPoint = coordinateMapper.MapCameraPointToColorSpace(position);
                point.X = float.IsInfinity(colorPoint.X) ? 0.0 : colorPoint.X;
                point.Y = float.IsInfinity(colorPoint.Y) ? 0.0 : colorPoint.Y;
            }
            break;

            case Visualization.Depth:
            case Visualization.Infrared:
            {
                DepthSpacePoint depthPoint = coordinateMapper.MapCameraPointToDepthSpace(position);
                point.X = float.IsInfinity(depthPoint.X) ? 0.0 : depthPoint.X;
                point.Y = float.IsInfinity(depthPoint.Y) ? 0.0 : depthPoint.Y;
            }
            break;

            default:
                break;
            }

            return(point);
        }
Exemplo n.º 6
0
        protected override void OnBindingContextChanged()
        {
            base.OnBindingContextChanged();

            if (BindingContext != null)
            {
                DynamicFrame li = null;

                if (this.BindingContext is EbDataRow row)
                {
                    li = new DynamicFrame(row, Visualization, false);
                    if (Visualization.HasLink())
                    {
                        SetTapGestureEvent(li);
                    }
                }
                else if (this.BindingContext is EbMobileStaticListItem item)
                {
                    li = new StaticLSFrame(item, Visualization, false);
                    if (item.HasLink())
                    {
                        SetTapGestureEvent(li);
                    }
                }

                if (li != null)
                {
                    SetItemColoring(li);
                    this.View = li;
                }
            }
        }
        private void Tick(object sender, EventArgs e)
        {
            mCurFrame++;
            if (mCurFrame == mFrameCount)
            {
                // reset
                mCurX     = mInitialX;
                mCurY     = mInitialY;
                mCurZ     = mInitialZ;
                mCurFrame = 0;
            }
            else
            {
                mCurX = (mCurX + 360 + mDeltaX) % 360;
                mCurY = (mCurY + 360 + mDeltaY) % 360;
                mCurZ = (mCurZ + 360 + mDeltaZ) % 360;
            }

            // We use the dimensions of the Border surrounding the ViewBox, rather than the
            // ViewBox itself, because on the first iteration the ViewBox has a size of zero.
            double dim = Math.Floor(Math.Min(testBorder.ActualWidth, testBorder.ActualHeight));

            wireframePath.Data = Visualization.GenerateWireframePath(mWireObj, dim,
                                                                     mCurX, mCurY, mCurZ, mDoPersp, mDoBfc, mDoRecenter);
        }
        private void RemoveButton_Click(object sender, RoutedEventArgs e)
        {
            Visualization item  = (Visualization)visualizationGrid.SelectedItem;
            int           index = visualizationGrid.SelectedIndex;

            VisualizationList.RemoveAt(index);

            // Keep selection at same index, unless we just removed the item at the end.
            if (index == VisualizationList.Count)
            {
                index--;
            }
            if (index >= 0)
            {
                visualizationGrid.SelectedIndex = index;
            }

            RemovedSerials.Add(item.SerialNumber);

            // Update any animations in this set.  Animations in other sets will be updated later.
            // (This is a bit awkward because we can't modify VisualizationList while iterating
            // through it, and there's no simple "replace entry" operation on an observable
            // collection.  Fortunately we don't do this often and the data sets are small.)
            List <VisualizationAnimation> needsUpdate = new List <VisualizationAnimation>();

            foreach (Visualization vis in VisualizationList)
            {
                if (vis is VisualizationAnimation)
                {
                    VisualizationAnimation visAnim = (VisualizationAnimation)vis;
                    if (visAnim.ContainsSerial(item.SerialNumber))
                    {
                        needsUpdate.Add(visAnim);
                    }
                }
            }
            foreach (VisualizationAnimation visAnim in needsUpdate)
            {
                VisualizationAnimation newAnim;
                if (VisualizationAnimation.StripEntries(visAnim,
                                                        new List <int>(1)
                {
                    item.SerialNumber
                }, out newAnim))
                {
                    if (newAnim.Count == 0)
                    {
                        VisualizationList.Remove(visAnim);
                    }
                    else
                    {
                        newAnim.GenerateImage(CreateEditedSetList());
                        index = VisualizationList.IndexOf(visAnim);
                        VisualizationList.Remove(visAnim);
                        VisualizationList.Insert(index, newAnim);
                    }
                }
            }
        }
Exemplo n.º 9
0
        public override void Initialize()
        {
            base.Initialize();

            organRenderer  = Visualization.CreateRenderer <OrganRenderer>();
            muscleRenderer = Visualization.CreateRenderer <MuscleRenderer>();
            boneRenderer   = Visualization.CreateRenderer <BoneRenderer>();
        }
Exemplo n.º 10
0
        public override void Initialize()
        {
            base.Initialize();

            worldRenderer = Visualization.CreateVisualizationComponent(() => new WorldRenderer(Visualization.World));

            lastMouseState = Visualization.InputManager.MouseState;
        }
Exemplo n.º 11
0
    protected void BaseStart()
    {
        leftHand  = GameObject.Find("leftHand");
        rightHand = GameObject.Find("rightHand");
        viz       = GameObject.Find("airTraffic").GetComponent <Visualization>();

        CreateSelectorObjects();
    }
Exemplo n.º 12
0
        private void ExportButton_Click(object sender, RoutedEventArgs e)
        {
            Visualization       vis = PrepResultVis();
            ExportVisualization dlg = new ExportVisualization(this, vis, mWireObj,
                                                              "vis" + mSetOffset.ToString("x6")); // tag may not be valid filename, use offset

            dlg.ShowDialog();
        }
Exemplo n.º 13
0
    void OnVideoFrameArrived(Texture2D image, Visualization visualization, ColorFrameResolution resolution, BodyWrapper body, Face face)
    {
        frameView.FrameTexture = image;

        this.body = body;

        RefreshFrame(body);
    }
Exemplo n.º 14
0
 void Start()
 {
     currentSong    = null;
     gameController = GetComponent <GameController>();
     audioSource    = GetComponent <AudioSource>();
     uiController   = GetComponent <UIController>();
     visualization  = GetComponent <Visualization>();
 }
Exemplo n.º 15
0
 /// <summary>
 /// Initializes the component by getting the reference to the visualization
 /// </summary>
 private void Awake()
 {
     visualization = GetComponent <Visualization>();
     if (visualization == null)
     {
         SpecialDebugMessages.LogComponentNotFoundError(this, nameof(Visualization), gameObject);
     }
 }
Exemplo n.º 16
0
        private void ApplySURF()
        {
            List <VectorOfKeyPoint> keyPointsList;
            SURFDetector            surfCPU;
            Tuple <Image <Bgr, byte>, HomographyMatrix>  homo1;
            Tuple <Image <Bgr, byte>, Rectangle, double> tup;

            Stopwatch         watch = Stopwatch.StartNew();
            Image <Bgr, Byte> pTest;
            Tuple <Image <Bgr, byte>, float[]> drawResult = null;
            ArrayList allMatches = new ArrayList();
            int       x, y, counter;

            string[] filePaths = Directory.GetFiles(_intermediatePath, "*.jpg");
            foreach (string path in filePaths)
            {
                GetImageParameters(out x, out y, out counter, path);
                pTest = new Image <Bgr, byte>(path);

                keyPointsList = _descriptor.SURF_BruteForceMatcher(_gElement, pTest.Convert <Gray, Byte>(), _hessianThreshould, out surfCPU);
                homo1         = _machineLearning.SURFMatcher_KNN(_gElement, pTest.Convert <Gray, Byte>(), surfCPU, keyPointsList, _uniquenessThresh, _tm);
                drawResult    = _machineLearning.ApplyHistogramMatching(out tup, homo1, _gElement, pTest.Convert <Gray, Byte>(), _test, _inputPath, counter, x, y, _histogramMatchingScore);

                if (drawResult != null)
                {
                    if (drawResult.Item2[2] > 0)
                    {
                        allMatches.Add(drawResult.Item2);
                        _log.WriteLine(string.Format("\n\tSW2 location: ({0}, {1})\n\tHistogram score: {2}]", drawResult.Item2[0], drawResult.Item2[1], drawResult.Item2[2]));
                    }
                }
            }
            if (allMatches != null)
            {
                _log.WriteLine("The count before consolidation: " + allMatches.Count);



                ////////  Consolidate
                //HashSet<float[]> hash0 = Consolidation.Consolidate(allMatches, _gElement.Width - 1, _gElement.Height - 1, _log);
                //ArrayList al = new ArrayList();

                //foreach (float[] i in hash0)
                //    al.Add(i);

                //HashSet<float[]> hash = Consolidation.Consolidate(al, _gElement.Width - 1, _gElement.Height - 1, _log);


                ///////Drawing
                //_log.WriteLine("The count after consolidation: " + hash.Count);
                //Visualization.DrawingResults(hash, _gElement, _test, _inputPath);
                Visualization.DrawingResults(allMatches, _gElement, _test, _inputPath);
            }

            watch.Stop();
            _log.WriteLine(watch.Elapsed);
            _log.Close();
        }
Exemplo n.º 17
0
        public override bool Process()
        {
            // Create Visualization
            Visualization.GetComponent <GenericVisualization>().CreateVisualization();
            // Enable Interaction Script

            SetOutputData(GetRawInputData()); // Visualization does not change data
            return(true);
        }
Exemplo n.º 18
0
 public void Start()
 {
     audioController         = GetComponent <AudioController>();
     uiController            = GetComponent <UIController>();
     visualization           = GetComponent <Visualization>();
     optimalBlockHitLocation = activatePlane.position.z / 2;
     optimalLine.position    = new Vector3(0, -3, optimalBlockHitLocation);
     duration = (1.0f / blockSpeed) * spawnDistance;
 }
        public async Task Visualize(Visualization visualization)
        {
            if (customerRepository.ExistsVisualization(visualization))
            {
                throw new DuplicateEntryException();
            }

            await customerRepository.AddVisualizationAsync(visualization);
        }
Exemplo n.º 20
0
    public override void Draw(Visualization Canvas)
    {
        Pen pen = new Pen(Color.Black);

        Canvas.DrawLine(pen, x, y, x + width, y);
        Canvas.DrawLine(pen, x + width, y, x + width, y + height);
        Canvas.DrawLine(pen, x + width, y + height, x, y + height);
        Canvas.DrawLine(pen, x, y + height, x, y);
    }
Exemplo n.º 21
0
        public void Play()
        {
            int userInput         = 0;
            int firstOrSecondUser = ActivePlayer.Id == 0 ? 0 : 1;


            //turno 0 o configuracion
            if (turn == 0)
            {
                for (int _ = 0; _ < Players.Length; _++)
                {
                    ActivePlayer = Players[firstOrSecondUser];
                    Visualization.ClearConsole();
                    //Mostrar mensaje de inicio
                    Visualization.ShowProgramMessage($"Player {ActivePlayer.Id+1} select Deck and Captain:");
                    //Preguntar por deck
                    Visualization.ShowDecks(this.Decks);
                    userInput = Visualization.GetUserInput(this.Decks.Count - 1);
                    Deck deck = new Deck();
                    deck.Cards        = new List <Card>(Decks[userInput].Cards);
                    ActivePlayer.Deck = deck;
                    //Preguntar por capitan
                    Visualization.ShowCaptains(Captains);
                    userInput = Visualization.GetUserInput(this.Captains.Count - 1);
                    ActivePlayer.ChooseCaptainCard(new SpecialCard(Captains[userInput].Name, Captains[userInput].Type, Captains[userInput].Effect));
                    //Asignar mano
                    ActivePlayer.FirstHand();
                    //Mostrar mano
                    Visualization.ShowHand(ActivePlayer.Hand);
                    //Mostar opciones, cambiar carta o pasar
                    Visualization.ShowListOptions(new List <string>()
                    {
                        "Change Card", "Pass"
                    }, "Change 3 cards or ready to play:");
                    userInput = Visualization.GetUserInput(1);
                    if (userInput == 0)
                    {
                        Visualization.ClearConsole();
                        Visualization.ShowProgramMessage($"Player {ActivePlayer.Id+1} change cards:");
                        Visualization.ShowHand(ActivePlayer.Hand);
                        for (int i = 0; i < DEFAULT_CHANGE_CARDS_NUMBER; i++)
                        {
                            Visualization.ShowProgramMessage($"Input the numbers of the cards to change (max {DEFAULT_CHANGE_CARDS_NUMBER}). To stop enter -1");
                            userInput = Visualization.GetUserInput(ActivePlayer.Hand.Cards.Count, true);
                            if (userInput == -1)
                            {
                                break;
                            }
                            ActivePlayer.ChangeCard(userInput);
                            Visualization.ShowHand(ActivePlayer.Hand);
                        }
                    }
                    firstOrSecondUser = ActivePlayer.Id == 0 ? 1 : 0;
                }
                turn += 1;
            }
        }
Exemplo n.º 22
0
    //------------------------------------------------------------------//
    void Awake()
    {
        for (int i = 0; i < Bags.Length; i++)
        {
            Bags[i] = null;
        }

        MiVisualizacion = GetComponent <Visualization>();
    }
Exemplo n.º 23
0
    // Use this for initialization
    void Start()
    {
        // AssetDatabase.ImportPackage("/packages/UnityToolkit",false);

        #region Instantiate HandData and DepthData
        if (WithDepth)
        {
            DepthData = new HumanRobotInteraction.DepthData(); // Configure and setting of the getting of the depth data
        }

        HandsData = new HandsData(MaxHands, MaxJoints); // Configure and setting of the getting of the hand data
        #endregion

        #region Instantiate the SARI Algorithm
        /* Instantiation of the SARI and initializing the filters */
        for (int i = 0; i < MaxHands; i++)
        {
            Sari[i] = new SARI(MaxJoints);
            Sari[i].InitializeFilter();
        }
        SariPlane = new SARI();
        #endregion

        #region Instatiate the visualization
        for (int i = 0; i < MaxHands; i++)
        {
            VisPredicted[i] = new Visualization("Hand Predicted " + (i + 1).ToString(), MaxJoints, new Color(0, 0, 1), new Color(0, 0, 1), new Color(0, 0, 1), new Color(0.47f, 0.108f, 0.221f));
            VisFiltered[i]  = new Visualization("Hand Filtered " + (i + 1).ToString(), MaxJoints, new Color(0.65f, 0.22f, 0f), new Color(0.9f, 0.62f, 0.43f), new Color(0.65f, 0.22f, 0f), new Color(1, 0, 0));
            VisRaw[i]       = new Visualization("Hand Raw " + (i + 1).ToString(), MaxJoints, new Color(0.65f, 0.22f, 0f), new Color(0.9f, 0.62f, 0.43f), new Color(0.65f, 0.22f, 0f), new Color(1, 0, 0));
        }

        VisPlane = new Visualization("Plane");

        #endregion

        #region Prepare arrays for coordinates
        /* Declaration of the array for the hand data*/
        for (int i = 0; i < MaxHands; i++)
        {
            RawCoord[i]       = new HandCoord(6, MaxJoints);
            FilteredCoord[i]  = new HandCoord(6, MaxJoints);
            PredictedCoord[i] = new HandCoord(6, MaxJoints);
        }
        for (int i = 0; i < 10000; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                RecordedData[j, i] = new HandCoord(6, MaxJoints);
            }
            if (i < 200)
            {
                CalibrationData[i] = new HandCoord(6, MaxJoints);
            }
        }
        #endregion
    }
Exemplo n.º 24
0
    public void updateYAxes(Axis y, ref List <Visualization> SP_ImAxes)
    {
        YAxes.Add(y);
        previousY = y;
        Update3DSPLOM(ref SP_ImAxes);
        //hide the histogram on the Axis
        Visualization v = SP_ImAxes.Single(vis => vis.axes.Count == 1 && vis.axes[0] == y);

        v.ShowHistogram(false);
    }
Exemplo n.º 25
0
        public ChartResult GetChartAuditData(NaturalLanguageQuestion question)
        {
            var caResult = new ChartResult();

            try
            {
                logger.Info("trying to predict query");
                ruleEngine.TimeSeriesBoundary = GetMonthPastDataAvailableTill();
                PredictQuery(question);
                caResult.RealizedQuery = RealizedQuery;
                using (var dt = ExecuteQuery(DbQuery, chartEngine))
                {
                    var dataSlices = GetDataSlicesFromDataTable(dt);
                    if (!dataSlices.AnyOrNotNull())
                    {
                        throw new ChartAuditNoDataException();
                    }
                    Visualization chartType = Visualization.None;
                    try
                    {
                        chartType = ruleEngine.ResolveChartTypeFromActualData(dataSlices);
                    }
                    catch (ChartAuditMultiTumorMultiRegimenTimeSeriesException ex)
                    {
                        if (question.Options != null && question.Options.SkipMultiDimError)
                        {
                            chartType = Visualization.LineMultiTumorMultiRegimen;
                        }
                        else
                        {
                            throw ex;
                        }
                    }
                    var chart = chartEngine.GetChart(chartType) as CAChartBase;
                    chart.IsPanTumor   = (ruleEngine as CARuleEngine).IsPanTumor;
                    chart.TumorNames   = GetTumorNames(dt);
                    chart.RegimenNames = GetRegimenNames(dt);
                    chart.Populate(dataSlices);
                    caResult.Status = 0;
                    caResult.Chart  = chart;
                }
            }
            catch (ChartAuditExceptionBase caEx)
            {
                caResult.Status = (int)caEx.ErrorCode;
            }
            catch (Exception ex)
            {
                caResult.Status = -1;
                //caResult.RealizedQuery = ex.Message;
            }

            return(caResult);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Zeichne eine Linie in den Graphen
        /// </summary>
        /// <param name="graphStart">Start-Koordinate</param>
        /// <param name="graphEnd">End-Koordinate</param>
        /// <param name="fillColor">Füllfarbe</param>
        /// <param name="is_redraw"><para>True: Linie wird nicht gespeichert</para><para></para><para>False: Linie wird gespeichert</para></param>
        public void PlotLine(GraphCoord graphStart, GraphCoord graphEnd, Color fillColor, bool is_redraw = false)
        {
            if (!is_redraw && RememberDrawing)
            {
                LineMemory.Add(new SimpleLine(graphStart, graphEnd, fillColor));
            }
            ImageCoord start = Graph2Image(graphStart);
            ImageCoord end   = Graph2Image(graphEnd);

            Visualization.DrawLine(start, end, fillColor);
        }
Exemplo n.º 27
0
        public UserInfo(Socket socket, int id, Visualization.ShapeDrawer shapedrawer)
        {
            Socket = socket;
            Id = id;
            Name = "Client " + id;

            ControlBox = new DrawingControl();
            ControlBox.SetShapDrawer(shapedrawer);
            ControlBox.ControlMode = ControlMode.CreateShape;
            ControlBox.Visible = false;
        }
        private void DownButton_Click(object sender, RoutedEventArgs e)
        {
            Visualization item  = (Visualization)visualizationGrid.SelectedItem;
            int           index = visualizationGrid.SelectedIndex;

            Debug.Assert(index >= 0 && index < VisualizationList.Count - 1);
            VisualizationList.RemoveAt(index);
            VisualizationList.Insert(index + 1, item);
            visualizationGrid.SelectedIndex = index + 1;
            visualizationGrid.ScrollIntoView(item);
        }
Exemplo n.º 29
0
 bool RPCP1_Distance(Visualization a, Visualization b)
 {
     if (a != null && b != null)
     {
         return(Vector3.Distance(a.transform.position, b.transform.position) > PCP_DISTANCE);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 30
0
    public void updateZAxes(Axis z, ref List <Visualization> SP_ImAxes)
    {
        print("ADDED >> Z");
        ZAxes.Add(z);
        previousZ = z;
        Update3DSPLOM(ref SP_ImAxes);
        //hide the histogram on the Axis
        Visualization v = SP_ImAxes.Single(vis => vis.axes.Count == 1 && vis.axes[0] == z);

        v.ShowHistogram(false);
    }
Exemplo n.º 31
0
    public void Rotate(bool clockwise, bool smooth = true, int increment = 90)
    {
        float amount = (clockwise ? increment : -increment);

        if (smooth)
        {
            amount *= Time.deltaTime;
        }

        Visualization.Rotate(Vector3.up * amount);
    }
	// Update is called once per frame
	void Update () {

		if (mState == States.NONE)
		{
			/* Press F to start fading */
			if (Input.GetKeyDown(KeyCode.F))
			{
				mVisManager = gameObject.GetComponent<VisualizerManager>();
				mVisualizations = mVisManager.visualizations;
				mCurrentVis = mVisualizations[mVisManager.currentlySelectedVis];
				timeSincePathStart = 0;
				//firstPersonTransform.position = mCurrentVis.targetMetadataParser.output[0].transform.position;
				mState = States.FADING;
			}	
		}
		else if (mState == States.FADING)
		{
			/* Press F again to stop fading */
			if (Input.GetKeyDown(KeyCode.F))
			{
				mState = States.NONE;
			}	

			int prevIndex;
			int nextIndex;
			timeSincePathStart += Time.deltaTime;

			prevIndex = (int)Mathf.Floor(timeSincePathStart * picsPerSecond);
			nextIndex = (int)Mathf.Ceil(timeSincePathStart * picsPerSecond);

			mCurrentVis.targetMetadataParser.output[prevIndex].material.color = new Color(1.0f, 1.0f, 1.0f, (timeSincePathStart * picsPerSecond) - prevIndex);
			try {
				if (fadeOut)
				{
					float alpha = 1 - ((timeSincePathStart * picsPerSecond) - prevIndex);
					if (alpha < fadeOutMin)
						alpha = fadeOutMin;

					mCurrentVis.targetMetadataParser.output[prevIndex - beforeFadeOut].material.color = new Color(1.0f, 1.0f, 1.0f, alpha);
					mCurrentVis.targetMetadataParser.output[prevIndex - beforeFadeOut - 1].material.color = new Color(1.0f, 1.0f, 1.0f, fadeOutMin);
				}
			} 
			catch (Exception e) 
			{
				//Debug.Log ("exception" + e);
			}

		
		}
	}
	// Update is called once per frame
	void Update () {

		if (mState == States.NONE)
		{
			/* Press SPACE to start path following */
			if (Input.GetKeyDown(KeyCode.Space))
			{
				mVisManager = gameObject.GetComponent<VisualizerManager>();
				mVisualizations = mVisManager.visualizations;
				mCurrentVis = mVisualizations[mVisManager.currentlySelectedVis];
				timeSincePathStart = 0;
				firstPersonTransform.position = mCurrentVis.targetMetadataParser.output[0].transform.position;
				mState = States.FOLLOWING;
			}	
		}
		else if (mState == States.FOLLOWING)
		{
			/* Press SPACE again to stop following */
			if (Input.GetKeyDown(KeyCode.Space))
			{
				mState = States.NONE;
			}	

			int prevIndex;
			int nextIndex;
			timeSincePathStart += Time.deltaTime;

			prevIndex = (int)Mathf.Floor(timeSincePathStart * picsPerSecond);
			nextIndex = (int)Mathf.Ceil(timeSincePathStart * picsPerSecond);

			if (prevIndex == nextIndex)
			{
				/* If we're right on a waypoint use that waypoint ...*/
				firstPersonTransform.position = mCurrentVis.targetMetadataParser.output[prevIndex].transform.position;
			}
			else
			{
				/* ... otherwise lerp between adjacent waypoints */
				Vector3 diff = mCurrentVis.targetMetadataParser.output[nextIndex].transform.position -
					mCurrentVis.targetMetadataParser.output[prevIndex].transform.position;
				firstPersonTransform.position = mCurrentVis.targetMetadataParser.output[prevIndex].transform.position + 
					(diff * ((timeSincePathStart * picsPerSecond) - prevIndex));
			}
		}
	}
Exemplo n.º 34
0
        private Tracker(GTCommands commands)
        {
            log.Info("Constructing Tracker...");
            this.commands = commands;
            detectionManager = new DetectionManager();
            calibration = new Calibration.Calibration();
            recalibration = new Recalibration();
            eyeMovement = new Classifier();
            exponentialSmoother = new ExponentialSmoother(Settings.Instance.EyeMovement.SmoothNumberOfSamples, 0, (int)Math.Ceiling(Settings.Instance.EyeMovement.SmoothLevel / 5.0));
            visualization = new Visualization();
            server = new UDPServer();
            gazeDataRaw = new GTGazeData();
            gazeDataSmoothed = new GTGazeData();
            gazeDazaExtended = new GTExtendedData();
            processingDone = true;
            timerCalibrationDelay = new DispatcherTimer();
            timerCalibrationDelay.Interval = TimeSpan.FromMilliseconds(calibrationDelayMilliseconds);
            timerCalibrationDelay.Tick += TimerCalibrationTick;
            logGaze = new Logger();
            logGaze.Server = server; // Used to send messages back to client (log start/stop etc.)
            log.Info( "Looking up LoggingEnabled in FileSettings" );
            logGaze.IsEnabled = Settings.Instance.FileSettings.LoggingEnabled;

            log.Info( "Setting RecalibrationAvailableHandler" );
            recalibration.RecalibrationAvailable += new Recalibration.RecalibrationAvailableHandler( recalibration_RecalibrationAvailable );
            //recalibration.OnRecalibrationAvailable +=new Recalibration.RecalibrationAvailable(recalibration_OnRecalibrationAvailable);
            Settings.Instance.Processing.PropertyChanged += ProcessingSettingsPropertyChanged;
            timerCalibrationDelay.Tick += TimerCalibrationTick;

            if ( GTHardware.Camera.Instance.Device != null )
            {
                log.Info( "Setting GTHardware device OnImage EventHandler" );
                GTHardware.Camera.Instance.Device.OnImage += new EventHandler<GTHardware.Cameras.ImageEventArgs>( Device_OnImage );
            }

            log.Info("Completed constructing Tracker");
        }
	// Update is called once per frame
	void Update () {

		bool changeVis = false;
		int changeTo = -1;

		if (Input.GetKeyDown(KeyCode.Alpha0)) {
			changeVis = true;
			changeTo = 0;
		} else if (Input.GetKeyDown(KeyCode.Alpha1)) {
			changeVis = true;
			changeTo = 1;
		} else if (Input.GetKeyDown(KeyCode.Alpha2)) {
			changeVis = true;
			changeTo = 2;
		} else if (Input.GetKeyDown(KeyCode.Alpha3)) {
			changeVis = true;
			changeTo = 3;
		} else if (Input.GetKeyDown(KeyCode.Alpha4)) {
			changeVis = true;
			changeTo = 4;
		} else if (Input.GetKeyDown(KeyCode.Alpha5)) {
			changeVis = true;
			changeTo = 5;
		} else if (Input.GetKeyDown(KeyCode.Alpha6)) {
			changeVis = true;
			changeTo = 6;
		} 

		if (changeVis)
		{
			mVisManager = gameObject.GetComponent<VisualizerManager>();
			mVisualizations = mVisManager.visualizations;
			mCurrentVis = mVisualizations[mVisManager.currentlySelectedVis];

			if (changeTo == 0)
			{
				/* All paths visible */
				foreach (Visualization vis in mVisualizations) {
					foreach (MetaDataItem mdi in vis.targetMetadataParser.output) {
						mdi.quad.renderer.enabled = true;
					}
				}
			} else {
				/* All paths invisible */
				foreach (Visualization vis in mVisualizations) {
					foreach (MetaDataItem mdi in vis.targetMetadataParser.output) {
						mdi.quad.renderer.enabled = false;
					}
				}
				/* make selected path visible */
				try {
					foreach (MetaDataItem mdi in mVisualizations[changeTo - 1].targetMetadataParser.output) {
						mdi.quad.renderer.enabled = true;
					}
				} catch (Exception e) {
					Debug.Log ("Could not make path " + changeTo + " visible.");
				}
				mVisManager.setCurrentVisualization(changeTo - 1);
			}
		}	
	}
Exemplo n.º 36
0
 /// <summary>
 /// Converts the specified CameraSpacePoint into a 2-D point.
 /// </summary>
 /// <param name="position">The CameraSpacePoint to convert.</param>
 /// <param name="visualization">The type of the conversion (color, depth, or infrared).</param>
 /// <returns>The corresponding 2-D point.</returns>
 public static Point ToPoint(this CameraSpacePoint position, Visualization visualization)
 {
     return position.ToPoint(visualization, KinectSensor.GetDefault().CoordinateMapper);
 }
Exemplo n.º 37
0
        /// <summary>
        /// Converts the specified CameraSpacePoint into a 2-D point.
        /// </summary>
        /// <param name="position">The CameraSpacePoint to convert.</param>
        /// <param name="visualization">The type of the conversion (color, depth, or infrared).</param>
        /// <param name="coordinateMapper">The CoordinateMapper to make the conversion.</param>
        /// <returns>The corresponding 2-D point.</returns>
        public static Point ToPoint(this CameraSpacePoint position, Visualization visualization, CoordinateMapper coordinateMapper)
        {
            Point point = new Point();

            switch (visualization)
            {
                case Visualization.Color:
                    {
                        ColorSpacePoint colorPoint = coordinateMapper.MapCameraPointToColorSpace(position);
                        point.X = float.IsInfinity(colorPoint.X) ? 0.0 : colorPoint.X;
                        point.Y = float.IsInfinity(colorPoint.Y) ? 0.0 : colorPoint.Y;
                    }
                    break;
                case Visualization.Depth:
                case Visualization.Infrared:
                    {
                        DepthSpacePoint depthPoint = coordinateMapper.MapCameraPointToDepthSpace(position);
                        point.X = float.IsInfinity(depthPoint.X) ? 0.0 : depthPoint.X;
                        point.Y = float.IsInfinity(depthPoint.Y) ? 0.0 : depthPoint.Y;
                    }
                    break;
                default:
                    break;
            }

            return point;
        }
 private void Infrared_Click(object sender, RoutedEventArgs e)
 {
     _mode = Visualization.Infrared;
 }
 private void Color_Click(object sender, RoutedEventArgs e)
 {
     _mode = Visualization.Color;
 }
 private void Depth_Click(object sender, RoutedEventArgs e)
 {
     _mode = Visualization.Depth;
 }