Simple class that describes a vertex position in x/y/z coordinates.
Example #1
0
 public Edge this[Vertex strartVertex, Vertex endVertex]
 {
     get
     {
         return this[strartVertex.Label, endVertex.Label];
     }
 }
Example #2
0
        private void ApplyVelocity(ref Vertex position, ref Vertex velocity)
        {
            float newX = position.X + velocity.X;
            if (newX < 0)
            {
                position.X = -newX;
                velocity.X *= -1;
            }
            else if (newX >  openGLControl1.ActualWidth)
            {
                position.X -= (newX - (float) openGLControl1.ActualWidth);
                velocity.X *= -1;
            }
            else
            {
                position.X = newX;
            }


            float newy = position.Y + velocity.Y;
            if (newy < 0)
            {
                position.Y = -newy;
                velocity.Y *= -1;
            }
            else if (newy > openGLControl1.ActualHeight)
            {
                position.Y -= (newy - (float) openGLControl1.ActualHeight);
                velocity.Y *= -1;
            }
            else
            {
                position.Y = newy;
            }
        }
Example #3
0
        public void VertexAndEdge()
        {
            var graph = new Graph<int>(true);

            var vertex1 = new Vertex<int>(3);

            var vertex2 = new Vertex<int>(4);

            var vertex3 = new Vertex<int>(5);

            graph.AddVertex(vertex1);
            graph.AddVertex(vertex2);
            graph.AddVertex(vertex3);

            graph.AddEdge(vertex2, vertex1);

            vertex2 = SerializeUtil.BinarySerializeDeserialize(vertex1);

            TestIsCopy(vertex1, vertex2);

            Assert.AreEqual(vertex2.IncidentEdges.Count, 1);
            Assert.AreEqual(vertex1.IncidentEdges.Count, 1);

            Assert.AreEqual(vertex2.EmanatingEdges.Count, 0);
            Assert.AreEqual(vertex1.EmanatingEdges.Count, 0);

            TestIsCopy(vertex2.IncidentEdges[0], vertex1.IncidentEdges[0]);
        }
Example #4
0
    public void CutoffRiverPart(Direction direction)
    {
        int maxIndex = -1;
        switch (direction)
        {
            case Direction.up:
                for(int i=0;i<riverPath.Count;i++)
                {
                    if(riverPath[i].z < 0)
                    {
                        maxIndex = i;
                    }
                    botVertex = riverPath[maxIndex + 1];
                }
                break;
            case Direction.down:
                for (int i = 0; i < riverPath.Count; i++)
                {
                    if (riverPath[i].z > terrain.terrainSize)
                    {
                        maxIndex = i;
                    }
                    topVertex = riverPath[maxIndex + 1];
                }
                break;
        }

        for(int i = maxIndex; i >= 0; i--)
        {
            Debug.Log("cutting: " + riverPath[i]);
            riverPath.RemoveAt(i);
        }
    }
Example #5
0
        public static void SetRandomEdge(Vertex[] vertices)
        {
            bool found = false;
            int i = 0;
            int j = 0;

            int count = 0;
            Random random = new Random();

            for (int k = 0; k < vertices.Length; k++)
            {
                for(int l = 0; l < vertices.Length; l++)
                {
                    if (k == l || vertices[k].Vertices.Any(v => v == vertices[l]))
                        continue;

                    count++;
                    if(random.Next(0, count) == 0)
                    {
                        i = k;
                        j = l;
                        found = true;
                    }
                }
            }

            if (found)
                vertices[i].AddDirectedEdge(vertices[j]);
        }
Example #6
0
        public void Simple()
        {
            var graph = new Graph<int>(false);

            var vertices = new Vertex<int>[20];

            for (var i = 0; i < 20; i++)
            {
                vertices[i] = new Vertex<int>(i);
                graph.AddVertex(vertices[i]);
            }

            for (var i = 0; i < 17; i += 2)
            {
                var edge = new Edge<int>(vertices[i], vertices[i + 2], false);
                graph.AddEdge(edge);
            }

            var trackingVisitor = new TrackingVisitor<int>();

            graph.AcceptVisitor(trackingVisitor);

            Assert.AreEqual(trackingVisitor.TrackingList.Count, 20);

            for (var i = 0; i < 20; i++)
            {
                Assert.IsTrue(trackingVisitor.TrackingList.Contains(i));
            }
        }
Example #7
0
        protected void AddVertex(Face face, Vertex vertex)
        {
            base.AddVertex(vertex);
            Faces.Remove(face);

            HalfEdge h1 = face.HalfEdge;
            HalfEdge h2 = h1.Next;
            HalfEdge h3 = h2.Next;

            HalfEdge h4 = new HalfEdge(h1.Origin);
            HalfEdge h5 = new HalfEdge(h2.Origin);
            HalfEdge h6 = new HalfEdge(h3.Origin);
            HalfEdge h7 = new HalfEdge(vertex);
            HalfEdge h8 = new HalfEdge(vertex);
            HalfEdge h9 = new HalfEdge(vertex);
            HalfEdges.AddRange(new List<HalfEdge> {h4, h5, h6, h7, h8, h9});

            h4.Twin = h7;
            h7.Twin = h4;
            h5.Twin = h8;
            h8.Twin = h5;
            h6.Twin = h9;
            h9.Twin = h6;

            // Set all next
            h1.Next = h5;
            h5.Prev = h1;
            h5.Next = h7;
            h7.Prev = h5;
            h7.Next = h1;
            h1.Prev = h7;

            h2.Next = h6;
            h6.Prev = h2;
            h6.Next = h8;
            h8.Prev = h6;
            h8.Next = h2;
            h2.Prev = h8;

            h3.Next = h4;
            h4.Prev = h3;
            h4.Next = h9;
            h9.Prev = h4;
            h9.Next = h3;
            h3.Prev = h9;

            Triangle t1 = new Triangle(h1);
            Triangle t2 = new Triangle(h2);
            Triangle t3 = new Triangle(h3);

            Faces.Add(t1);
            Faces.Add(t2);
            Faces.Add(t3);

            Tree.Add(vertex, t1, t2, t3);

            LogEntry logEntry = new LogEntry("Adding edges.", this);
            logEntry.Objects.Add(vertex);
            Log.Add(logEntry);
        }
Example #8
0
File: DBPath.cs Project: ipbi/sones
        public DBPath(Vertex myStartVertex, Vertex myEndVertex, IEnumerable<Vertex> myVertices, IEnumerable<EdgeLabel> myEdges)
        {
            #region Initial Checks

            if (myStartVertex == null)
                throw new ArgumentNullException();

            if (myEndVertex == null)
                throw new ArgumentNullException();

            if (myVertices == null)
                throw new ArgumentNullException();

            if (myEdges == null)
                throw new ArgumentNullException();

            if (myVertices.Count() != myEdges.Count() - 1)
                throw new ArgumentException();

            #endregion

            StartVertex = myStartVertex;
            EndVertex   = myEndVertex;
            Vertices    = myVertices;
            Edges       = myEdges;
            Length      = (UInt64) myEdges.LongCount();
        }
Example #9
0
        /**
         * collapse vertex u to vertex v
         */
        private void collapse(Vertex u, Vertex v)
        {
            // remove the adjacent face of both vertex u and vertex v
            for (int i = 0; i < u.adjacent_faces.Count; ++i) {
                if (u.adjacent_faces[i].has(v)) {
                    for (int j = 0; j < 3; ++j) {
                        Vertex v_temp = u.adjacent_faces[i].triangle_vertices[j];
                        if (!v_temp.Equals(u)) {
                            for (int k = 0; k < v_temp.adjacent_faces.Count; ++k) {
                                if (v_temp.adjacent_faces[k].Equals(u.adjacent_faces[i])) {
                                    v_temp.adjacent_faces.RemoveAt(k);
                                    break;
                                }
                            }
                        }
                    }
                    u.adjacent_faces.RemoveAt(i);
                    --i;
                }
            }

            // replace vertex u with vertex v in adjacent faces of neighbor vertices of vertex u
            for (int i = 0, i_count = u.neighbor_vertices.Count; i < i_count; ++i) {
                Vertex v_temp = u.neighbor_vertices[i];
                for (int j = 0, j_count = v_temp.adjacent_faces.Count; j < j_count; ++j) {
                    if (v_temp.adjacent_faces[j].has(u)) {
                        v_temp.adjacent_faces[j].replaceVertex(u, v);
                    }
                }
            }

            // replace vertex u with vertex v in adjacent faces of vertex u
            for (int i = 0, count = u.adjacent_faces.Count; i < count; ++i) {
                u.adjacent_faces[i].replaceVertex(u, v);
            }

            // remove vertex u
            vertices.RemoveAt(vertices.IndexOf(u));

            // remove vertex u in neighbor vertices of vertex u
            // add neighbor vertices of vertex u to vertex v
            // add vertex v to neighbor vertices of vertex u
            // update collapse cost at neighbor vertices of vertex u
            for (int i = 0, count = u.neighbor_vertices.Count; i < count; ++i) {
                u.neighbor_vertices[i].neighbor_vertices.Remove(u);
                if (!u.neighbor_vertices[i].Equals(v)) {
                    v.neighbor_vertices.Add(u.neighbor_vertices[i]);
                    u.neighbor_vertices[i].neighbor_vertices.Add(v);
                    distinct(u.neighbor_vertices[i].neighbor_vertices);
                }
                computeEdgeCollapseCostAtVertex(u.neighbor_vertices[i]);
            }
            distinct(v.neighbor_vertices);

            // add new faces to vertex v and update collapse cost of vertex v
            for (int i = 0, count = u.adjacent_faces.Count; i < count; ++i) {
                v.adjacent_faces.Add(u.adjacent_faces[i]);
            }
            computeEdgeCollapseCostAtVertex(v);
        }
Example #10
0
 public VoronoiRegion(Vertex generator)
 {
     this.id = generator.id;
     this.generator = generator;
     this.vertices = new List<Point>();
     this.bounded = true;
 }
Example #11
0
    //this face is one of the srrounding faces attahed to vold
    public void ReplaceVertex(Vertex vold,Vertex vnew)
    {
        for(int i = 0; i < 3; i++)
        {

            if(vertex[i].position == vold.position  )
            {
                vertex[i]  = vnew;
                vold.RemoveFace( this );

                if(vnew!=null)
                vnew.AddFace( this );
                break;
            }
        }

        //remove reff of vold from Neighborhood
                vold.RemoveIfNonNeighbor( vertex[0] );
                vertex[0].RemoveIfNonNeighbor( vold );
           				vold.RemoveIfNonNeighbor( vertex[1] );
           				vertex[1].RemoveIfNonNeighbor( vold );
                vold.RemoveIfNonNeighbor( 	vertex[2] );
                vertex[2].RemoveIfNonNeighbor( vold );

                vertex[0]. AddNeighbor(vertex[1]);
                vertex[0]. AddNeighbor(vertex[2]);

                vertex[1]. AddNeighbor(vertex[0]);
                vertex[1]. AddNeighbor(vertex[2]);

                vertex[2]. AddNeighbor(vertex[0]);
                vertex[2]. AddNeighbor(vertex[1]);
                ComputeNormal();
    }
Example #12
0
        public void DirectedValue()
        {
            var graph = new Graph<int>(true);
            var vertex1 = new Vertex<int>(1);
            var vertex2 = new Vertex<int>(2);
            var vertex3 = new Vertex<int>(3);

            graph.AddVertex(vertex1);
            graph.AddVertex(vertex2);
            graph.AddVertex(vertex3);

            graph.AddEdge(vertex1, vertex2);
            graph.AddEdge(vertex3, vertex2);
            graph.AddEdge(vertex1, vertex3);

            Assert.AreEqual(graph.Edges.Count, 3);
            Assert.AreEqual(graph.Vertices.Count, 3);

            Assert.IsTrue(graph.RemoveVertex(1));

            Assert.AreEqual(graph.Edges.Count, 1);
            Assert.AreEqual(graph.Vertices.Count, 2);

            Assert.IsFalse(graph.RemoveVertex(4));
            Assert.AreEqual(graph.Edges.Count, 1);
            Assert.AreEqual(graph.Vertices.Count, 2);
        }
Example #13
0
File: Ferret.cs Project: 9volt/ld29
 // Update is called once per frame
 void Update()
 {
     // Move towards current target
     if(currentDestination != null && pos != currentDestination){
         if(!rm.Moving){
             pos = next_node;
             if(!occupying){
                 FindTarget();
             }
             List<Vertex> p = rf.FindPath(pos, currentDestination, wg.GetPathfindingCosts());
             if(p != null && p.Count > 1){
                 next_node = p[1];
                 rm.Move(wg.VertexToVector3(next_node));
             } else {
                 currentDestination = pos;
             }
         }
     } else if(currentDestination != null && target != null && pos == currentDestination && !occupying){
         target = wl.OccupyBurrow(pos);
         if(target != null){
             occupying = true;
         }
     } else {
         if(!occupying){
             FindTarget();
         }else{
             UpdateTarget();
         }
     }
 }
Example #14
0
 public TraveledPathData SynchronousSearch(Graph graph, Vertex root, Vertex goal)
 {
     this.graph = graph;
     this.root = root;
     this.goal = goal;
     return this.SyncSearch();
 }
Example #15
0
        public void Undirected()
        {
            var graph = new Graph<int>(false);
            var vertex1 = new Vertex<int>(1);
            var vertex2 = new Vertex<int>(2);
            var vertex3 = new Vertex<int>(3);
            var vertex4 = new Vertex<int>(4);

            graph.AddVertex(vertex1);
            graph.AddVertex(vertex2);
            graph.AddVertex(vertex3);
            graph.AddVertex(vertex4);

            graph.AddEdge(vertex1, vertex2);
            graph.AddEdge(vertex3, vertex2);
            graph.AddEdge(vertex1, vertex3);

            Assert.IsFalse(graph.IsStronglyConnected());

            graph.AddEdge(vertex2, vertex4);

            Assert.IsTrue(graph.IsStronglyConnected());

            graph.RemoveEdge(vertex2, vertex3);

            Assert.IsTrue(graph.IsStronglyConnected());

            graph.RemoveEdge(vertex1, vertex3);

            Assert.IsFalse(graph.IsStronglyConnected());
        }
Example #16
0
 public override void AsynchronousSearch(Graph graph, Vertex root, Vertex goal)
 {
     this.graph = graph;
     this.root = root;
     this.goal = goal;
     new Thread(AsyncSearch).Start();
 }
 public List<Implication> GetImplications(Vertex leaf, int nextTime)
 {
     var triggeredActions = this.GetTriggeredActions(leaf.ActualWorldAction, leaf.ActualState, leaf.Time);
     var possibleFutureStates = this.GetPossibleFutureStates(leaf.ActualWorldAction, leaf.ActualState, leaf.Time);
     return possibleFutureStates.Select(possibleFutureState =>
         new Implication { FutureState = possibleFutureState, TriggeredActions = triggeredActions.ToList() }).ToList();
 }
Example #18
0
        public static Vertex Rung4(GraphData d)
        {
            Vertex v = new Vertex();
            v.Include = Root + "Rung4.html";
            Edge e;

            string NextVertexName = "TraditionalCrises_Rung5";

            e = new Edge(d);
            e.State.VertexName = NextVertexName;
            //e.State.Stakes += 5;
            e.HTML = "A public and irrevocable increase in the stakes";
            v.Edges.Add(e);


            e = new Edge(d);
            e.State.VertexName = NextVertexName;
            //e.State.PublicAwareness += 20;
            e.HTML = "Officially inspire newspaper stories to the effect that the chief of state takes a serious view of the matter.";
            v.Edges.Add(e);

            


            return v;
        }
Example #19
0
        public void TestEquatable()
        {
            var vn = new Vertex(12.34f, -98.7f, 54);
            var vertices = new Vertex[] { new Vertex(), vn, new Vertex(3, 2, 1) };
            var facet = new Facet(vn, vertices);

            IEquatable<Facet> ieqFacet = facet;

            Assert.False(ieqFacet.Equals((Facet)null));

            var facet2 = new Facet();
            Assert.False(ieqFacet.Equals(facet2));

            facet2 = new Facet(new Vertex(12.34f, -98.7f, 54), null);
            Assert.False(ieqFacet.Equals(facet2));

            facet2 = new Facet() { Normal = null };
            Assert.False(ieqFacet.Equals(facet2));

            facet2 = new Facet() { Vertices = null };
            Assert.False(ieqFacet.Equals(facet2));

            facet2 = new Facet(new Vertex(12.34f, -98.7f, 54), vertices);
            Assert.True(ieqFacet.Equals(facet2));

            Assert.True(ieqFacet.Equals(facet));
        }
Example #20
0
 public Dictionary<Vertex, DFSVisitingInfo> DepthFirstSearch(Vertex v)
 {
     var visits = new Dictionary<Vertex, DFSVisitingInfo>();
     visits[v] = new DFSVisitingInfo(null);
     DepthFirstSearch(v, visits);
     return visits;
 }
        public double Compute(Vertex src, Vertex sink)
        {
            m_ResidualEdgeCapacities = new EdgeDoubleDictionary();

            // initializing
            foreach(Vertex u in VisitedGraph.Vertices)
                foreach(Edge e in u.OutEdges)
                    ResidualCapacities[e] = Capacities[e];

            Colors[sink] = GraphColor.Gray;
            while (Colors[sink] != GraphColor.White)
            {
                VertexBuffer Q = new VertexBuffer();
                ResidualEdgePredicate ep = new ResidualEdgePredicate(ResidualCapacities);

                BreadthFirstSearchAlgorithm bfs = new BreadthFirstSearchAlgorithm(resg,Q,Colors);
                PredecessorVisitor pred = new PredecessorVisitor(Predecessors);
                pred.RegisterHandlers(bfs);
                bfs.Compute(src);

                if (Colors[sink] != GraphColor.White)
                    Augment(src, sink, pred.Predecessors);
            } // while

            double flow = 0;
            foreach(Edge e in src.OutEdges)
                flow += (EdgeCapacities[e] - ResidualEdgeCapacities[e]);

            return flow;
        }
Example #22
0
    /// <summary>
    /// returns projection of point on the grid defined by center, width and height
    /// </summary>
    public Vertex GetPointOnGrid(Vertex point)
    {
        int xVal = point.x / stepX;
        int zVal = point.z / stepZ;

        Vertex closestCenter = new Vertex(666, 666);
        for(int xi = -1; xi <= 1; xi++)
        {
            for (int zi = -1; zi <= 1; zi++)
            {
                Vertex centerOnGrid =
                    new Vertex(
                        globalCenter.x + (xVal + xi) * stepX,
                        globalCenter.z + (zVal + zi) * stepZ);

                //Debug.Log(centerOnGrid);
                if (Vector3.Distance(point, centerOnGrid) <
                    Vector3.Distance(point, closestCenter))
                {
                    closestCenter = centerOnGrid;
                }
            }
        }

        return closestCenter;
    }
Example #23
0
    public void AddVertex( Vertex v ) {
        vertices.Add( v );

	  //dja: Add for performance reasons
	  verticesMap.Add( v.name, v );

    }
Example #24
0
        public static Vertex Intro(GraphData d)
        {
            Vertex v = new Vertex();
            v.Include = Root + "Intro.html";
            Edge e;



            e = new Edge(d);
            e.State.VertexName = "SubcrisisManeuvering_Index";
            e.State.Rank1.InHand += 1;
            e.State.Rank2_dipl.InHand += 2;
            e.State.Rank2_econ.InHand += 1;
            e.State.Rank2_poli.InHand += 1;

            e.HTML = "Assume political control over crisis. Communicate with allies' political leaders, confirm a firm leadership position in NATO and with non-NATO allies. Establish continuous high level lines of communication. Summon political advisors.";
            v.Edges.Add(e);

            e = new Edge(d);
            e.State.VertexName = "SubcrisisManeuvering_Index";
            e.Disabled = true;
            e.State.Rank3.InHand += 1;
            e.HTML = "Summon military leadership. Confirm command and control links over allies military leadership. Immediately address the nation.";
            v.Edges.Add(e);

            return v;
        }
Example #25
0
        public TerrainRenderer(World world, WorldRenderer wr)
        {
            this.world = world;
            this.map = world.Map;

            var tileSize = new Size( Game.CellSize, Game.CellSize );
            var tileMapping = new Cache<TileReference<ushort,byte>, Sprite>(
                x => Game.modData.SheetBuilder.Add(world.TileSet.GetBytes(x), tileSize));

            var vertices = new Vertex[4 * map.Bounds.Height * map.Bounds.Width];

            terrainSheet = tileMapping[map.MapTiles.Value[map.Bounds.Left, map.Bounds.Top]].sheet;

            int nv = 0;

            var terrainPalette = wr.Palette("terrain").Index;

            for( int j = map.Bounds.Top; j < map.Bounds.Bottom; j++ )
                for( int i = map.Bounds.Left; i < map.Bounds.Right; i++ )
                {
                    var tile = tileMapping[map.MapTiles.Value[i, j]];
                    // TODO: move GetPaletteIndex out of the inner loop.
                    Util.FastCreateQuad(vertices, Game.CellSize * new float2(i, j), tile, terrainPalette, nv, tile.size);
                    nv += 4;

                    if (tileMapping[map.MapTiles.Value[i, j]].sheet != terrainSheet)
                        throw new InvalidOperationException("Terrain sprites span multiple sheets");
                }

            vertexBuffer = Game.Renderer.Device.CreateVertexBuffer( vertices.Length );
            vertexBuffer.SetData( vertices, nv );
        }
Example #26
0
        public static Vertex[] CalculateSphereVertices(float radius, float height, byte segments, byte rings)
        {
            var data = new Vertex[segments * rings];

            int i = 0;

            for (double y = 0; y < rings; y++)
            {
                double phi = (y / (rings - 1)) * Math.PI; //was /2
                for (double x = 0; x < segments; x++)
                {
                    double theta = (x / (segments - 1)) * 2 * Math.PI;

                    Vector3 v = new Vector3()
                    {
                        X = (float)(radius * Math.Sin(phi) * Math.Cos(theta)),
                        Y = (float)(height * Math.Cos(phi)),
                        Z = (float)(radius * Math.Sin(phi) * Math.Sin(theta)),
                    };
                    Vector3 n = Vector3.Normalize(v);
                    Vector2 uv = new Vector2()
                    {
                        X = (float)(x / (segments - 1))%1,
                        Y = (float)(y / (rings - 1))%1
                    };
                    // Using data[i++] causes i to be incremented multiple times in Mono 2.2 (bug #479506).
                    data[i] = new Vertex() { Position = v, Normal = n, TexCoord = uv };
                    i++;
                }

            }

            return data;
        }
Example #27
0
        public void Undirected()
        {
            var graph = new Graph<int>(false);
            var vertex1 = new Vertex<int>(1);
            var vertex2 = new Vertex<int>(2);
            var vertex3 = new Vertex<int>(3);

            graph.AddVertex(vertex1);
            graph.AddVertex(vertex2);
            graph.AddVertex(vertex3);

            graph.AddEdge(vertex1, vertex2);

            Assert.AreEqual(vertex1.IncomingEdgeCount, 0);
            Assert.AreEqual(vertex2.IncomingEdgeCount, 0);

            graph.AddEdge(vertex3, vertex2);

            Assert.AreEqual(vertex3.IncomingEdgeCount, 0);
            Assert.AreEqual(vertex2.IncomingEdgeCount, 0);

            graph.AddEdge(vertex1, vertex3);

            Assert.AreEqual(vertex1.IncomingEdgeCount, 0);
            Assert.AreEqual(vertex3.IncomingEdgeCount, 0);
        }
Example #28
0
	public Sprite2DBatch( GraphicsContext graphics, int maxSpriteCount )
	{
		int maxVertexCount = maxSpriteCount * 4 ;
		int maxIndexCount = maxSpriteCount * 6 ;

		graphicsContext = graphics ;
		#if !RESIZE_VERTEX_BUFFER
		vertexBuffer = new VertexBuffer( maxVertexCount, maxIndexCount, vertexFormats ) ;
		spriteCapacity = maxSpriteCount ;
		#endif // RESIZE_VERTEX_BUFFER
		vertexData = new Vertex[ maxVertexCount ] ;
		indexData = new ushort[ maxIndexCount ] ;

		spriteList = new Sprite2D[ maxSpriteCount ] ;
		sortedList = new Sprite2D[ maxSpriteCount ] ;
			
		#if ENABLE_SIN_TABLE
		if ( sinTable == null ) {
			sinTable = new float[ 4096 ] ;
			for ( int i = 0 ; i < 4096 ; i ++ ) {
				sinTable[ i ] = FMath.Sin( i * ( FMath.PI / 2048.0f ) ) ;
			}
		}
		#endif // ENABLE_SIN_TABLE
	}
Example #29
0
 public EdgeIfc findsEdge( Vertex theSource,
     Vertex theTarGet)
 {
     //dja: performance improvement
     //        for( Iterator<Vertex> vertexiter = GetVertices(); vertexiter.hasNext(); )
     //         {
     //        Vertex v1 = vertexiter.next( );
     //        for( EdgeIter edgeiter = v1.GetEdges(); edgeiter.hasNext(); )
     //            {
     //                EdgeIfc theEdge = edgeiter.next();
     //            Vertex v2 = theEdge.GetOtherVertex( v1 );
     //              if ( ( v1.GetName().Equals( theSource.GetName() ) &&
     //                       v2.GetName().Equals( theTarGet.GetName() ) ) ||
     //                         ( v1.GetName().Equals( theTarGet.GetName() ) &&
     //                     v2.GetName().Equals( theSource.GetName() ) ) )
     //                    return theEdge;
     //            }
     //        }
     Vertex v1 = theSource;
     for( Iterator<EdgeIfc> edgeiter = v1.GetEdges(); edgeiter.hasNext(); )
         {
             EdgeIfc theEdge = edgeiter.next();
         Vertex v2 = theEdge.GetOtherVertex( v1 );
           if ( ( v1.GetName().Equals( theSource.GetName() ) &&
                    v2.GetName().Equals( theTarGet.GetName() ) ) ||
                      ( v1.GetName().Equals( theTarGet.GetName() ) &&
                  v2.GetName().Equals( theSource.GetName() ) ) )
                 return theEdge;
         }
     return null;
 }
Example #30
-1
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gameEngine">An instance of the <see cref="Tesseract"/> game engine.</param>
        protected override void CreateDeviceResources(Tesseract gameEngine)
        {
            // Create a texture sampler state (in the base class)
            base.CreateDeviceResources(gameEngine);

            // Initialize variables needed to create the vertex & index buffers
            var device = gameEngine.DeviceManager.Device3D;
            Vector3 quadNormal = new Vector3(0, 1, 0);
            Vector2 texCoords = new Vector2(0, 0);
            VertexArray = new Vertex[]
            {
                new Vertex(new Vector3(1, 0,  0), quadNormal, Color.Lime,	texCoords),
                new Vertex(new Vector3(0, 0,  0), quadNormal, Color.Blue,	texCoords),
                new Vertex(new Vector3(0, 0, -1), quadNormal, Color.Red,	texCoords),
                new Vertex(new Vector3(1, 0, -1), quadNormal, Color.Yellow, texCoords),
            };
            IndexArray = new ushort[]
            {
                0, 1, 2, // Front A
                0, 2, 3, // Front B
            };

            // Create the buffers
            VertexBuffer = ToDispose(Buffer.Create(device, BindFlags.VertexBuffer, VertexArray));
            VertexBufferBinding = new VertexBufferBinding(VertexBuffer, Utilities.SizeOf<Vertex>(), 0);
            IndexBuffer = ToDispose(Buffer.Create(device, BindFlags.IndexBuffer, IndexArray));
        }