Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        void Start()
        {
            _graph       = CreateGrid(_countX, _countY);
            _vertexState = new int[_graph.Vertices.Count];

            _currVertex  = _graph.Vertices[0];
            _currHedge   = _currVertex.First;
            _initialized = true;
        }
Ejemplo n.º 2
0
        // Use this for initialization
        void Start()
        {
            // create a graph
            _graph = CreateGrid(_countX, _countY);

            // create array of vertex states
            _vertexStates = new int[_graph.Vertices.Count];

            // set current vertex & halfedge
            _currVertex = _graph.Vertices[0];
            _currHedge  = _currVertex.First;

            _initialized = true;
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        void Update()
        {
            if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                _currHedge = _currHedge.PreviousAtStart;
            }

            if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                _currHedge = _currHedge.NextAtStart;
            }

            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                _currHedge  = _currHedge.Twin;
                _currVertex = _currHedge.Start;
            }

            UpdateNeighborhood();
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        HeGraph3d CreateGrid(int countX, int countY)
        {
            HeGraph3d graph = new HeGraph3d();

            // add vertices
            for (int i = 0; i < countY; i++)
            {
                for (int j = 0; j < countX; j++)
                {
                    HeGraph3d.Vertex v = graph.AddVertex();
                    v.Position = new Vec3d(i, j, 0);
                    // v.Normal = blah;
                }
            }

            // add edges
            int index = 0;

            for (int i = 0; i < countY; i++)
            {
                for (int j = 0; j < countX; j++)
                {
                    if (j > 0)
                    {
                        graph.AddEdge(index, index - 1);
                    }

                    if (i > 0)
                    {
                        graph.AddEdge(index, index - countX);
                    }

                    index++;
                }
            }

            return(graph);
        }
Ejemplo n.º 5
0
        // Update is called once per frame
        void Update()
        {
            if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                _currHedge = _currHedge.PreviousAtStart;
            }

            if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                _currHedge = _currHedge.NextAtStart;
            }

            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                _currHedge  = _currHedge.Twin;
                _currVertex = _currHedge.Start;
            }

            UpdateVertexStates();

            var target = (Vector3)_currVertex.Position;

            CameraPivot.position = Vector3.Lerp(CameraPivot.position, target, Time.deltaTime * _cameraStiffness);
        }