private void AddVertex(float x, float y, float texCoord1, float texCoord2) { Verticies.Add(x); Verticies.Add(y); Verticies.Add(texCoord1); Verticies.Add(texCoord2); }
public void AddQuad(Vector3 topLeft, Vector3 topRight, Vector3 bottomRight, Vector3 bottomLeft, bool backFace) { var index = Verticies.Count; Verticies.Add(topLeft); Verticies.Add(topRight); Verticies.Add(bottomRight); Verticies.Add(bottomLeft); if (backFace) { Indexes.Add(index); Indexes.Add(index + 1); Indexes.Add(index + 2); Indexes.Add(index + 2); Indexes.Add(index + 3); Indexes.Add(index); } else { Indexes.Add(index); Indexes.Add(index + 3); Indexes.Add(index + 2); Indexes.Add(index + 2); Indexes.Add(index + 1); Indexes.Add(index); } }
public Quad(XElement element) { Verticies.Add(GetVertFromXmlAttribute(element, FIRST_VERTEX_ID)); Verticies.Add(GetVertFromXmlAttribute(element, SECOND_VERTEX_ID)); Verticies.Add(GetVertFromXmlAttribute(element, THIRD_VERTEX_ID)); Verticies.Add(GetVertFromXmlAttribute(element, FOURTH_VERTEX_ID)); }
public Vertex AddVertex(string vertexName) { Vertex vertex = new Vertex(vertexName); Verticies.Add(vertex); return(vertex); }
public override void UploadDataToGPU() { Vao.ChangeData(BufferTarget.ArrayBuffer, Verticies.ToArray()); this.ChangeAttribute(BufferTarget.ArrayBuffer, "position", 2, VertexAttribPointerType.Float, false, 6 * sizeof(float), 0); this.ChangeAttribute(BufferTarget.ArrayBuffer, "vertexColor", 4, VertexAttribPointerType.Float, false, 6 * sizeof(float), 2 * sizeof(float)); }
public Vertex AddVertex(int vertexVal) { Vertex vertex = new Vertex(string.Empty, vertexVal); Verticies.Add(vertex); return(vertex); }
/// <summary> /// Uploads the data to GPU. /// </summary> public override void UploadDataToGPU() { Vao.ChangeData(BufferTarget.ArrayBuffer, Verticies.ToArray()); ChangeAttribute(BufferTarget.ArrayBuffer, "position", 2, VertexAttribPointerType.Float, true, 4 * sizeof(float), 0); ChangeAttribute(BufferTarget.ArrayBuffer, "texcoord", 2, VertexAttribPointerType.Float, true, 4 * sizeof(float), 2 * sizeof(float)); }
public Vertex AddSingleVertex(long id) { if (Verticies.ContainsKey(id)) { return(Verticies[id]); } Verticies[id] = new Vertex(id); return(Verticies[id]); }
public MeshData clone() { MeshData MD = new MeshData(); MD.Verticies = new List <MeshPoint>(Verticies.Select(x => x.clone())); MD.Triangles = new List <int>(Triangles); MD.target_TRANS = this.target_TRANS; MD.UV_poss = UV_poss; return(MD); }
public static int BufferShaderGeometry(Verticies geometry, out int vbo_interleaved, out int NumVerticies) { Vertex[] _interleaved = geometry.ToArray(); Console.WriteLine("Buffering Verticies.."); vbo_interleaved = GL.GenBuffer(); //GL.GenBuffers(1, out vbo_interleaved); GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_interleaved); // InterleavedArrayFormat.T2fC4fN3fV3f GL.BufferData <Vertex>(BufferTarget.ArrayBuffer, (IntPtr)(_interleaved.Length * Vertex.SizeInBytes), _interleaved, BufferUsageHint.StaticDraw); Console.WriteLine("[done]"); // Each vertex in the interleaved structure is defined as follows.. // // In x3d-finely-sharpened, each field 'f' is a floating point value. // The size of a float is 4 bytes, the size of a vertex structure is calculated as follows: // // 'p' position field is 12 bytes (3 fields * 4 bytes = 12 bytes) // 'n' normal field is 12 bytes (3 fields * 4 bytes = 12 bytes) // 'c' color field is 16 bytes (4 fields * 4 bytes = 16 bytes) // 'tc' texture coordinate field is 8 bytes (2 fields * 4 bytes = 8 bytes) // The STRIDE is the number of bytes between each interleaved structure // stride = Pf + Nf + Cf + TCf // stride = 12 + 12 + 16 + 8 // stride = 48 bytes // // Luckily this new implementation doesnt require calculation of stride // however it is important to keep to this structure. // Floating point values must used uniformally for each field. // 'c' color field must be composed of 4 floating point values // otherwise if there is no alpha channel OpenGL pads the color to 16 bytes // automatically. This creates uneven structures and results in undesired operation. // // If any new fields need to be added to the Vertex structure, // this model needs updating to reflect the changes // new fields must be floating point values, // finally Vertex.SizeInBytes should be checked to see // if it returns the same value as the calculation above. // // P N C TC // [f f f] [f f f] [f f f f] [f f] // 12 13 24 25 40 41 50 NumVerticies = _interleaved.Length; GL.BindBuffer(BufferTarget.ArrayBuffer, 0); return(vbo_interleaved); }
public void Write(AssetsWriter writer) { Verticies.Write(writer); UV.Write(writer); Normals.Write(writer); Tangents.Write(writer); Weights.Write(writer); NormalSigns.Write(writer); TangentSigns.Write(writer); FloatColors.Write(writer); BoneIndicies.Write(writer); Triangles.Write(writer); writer.Write(UVInfo); }
//This works only for directed graph because for undirected graph we can end up adding edges two times to allEdges public void AddVertex(Vertex vertex) { if (Verticies.ContainsKey(vertex.Id)) { return; } Verticies[vertex.Id] = vertex; foreach (Edge edge in vertex.Edges) { Edges.Add(edge); } }
public void RemoveById(int id) { if (Verticies.ContainsKey(id)) { Verticies.Remove(id); if (VertexOfEdgesById.ContainsKey(id)) { VertexOfEdgesById.Remove(id); } } if (Edges.ContainsKey(id)) { var e = Edges[id]; VertexOfEdgesById.Remove(e.FromId); VertexOfEdgesById.Remove(e.ToId); Edges.Remove(id); } }
public void AddTask(Color color, IList <float> positions) { if (positions.Count != 8) { throw new ArgumentException("Positions array should have 8 elements"); } _colorVector.X = color.R * ColorFloat; _colorVector.Y = color.G * ColorFloat; _colorVector.Z = color.B * ColorFloat; _colorVector.W = color.A * ColorFloat; for (int i = 0; i < 4; i++) { Verticies.Add(positions[i * 2]); Verticies.Add(positions[i * 2 + 1]); Verticies.Add(_colorVector.X); Verticies.Add(_colorVector.Y); Verticies.Add(_colorVector.Z); Verticies.Add(_colorVector.W); } }
public void AddTask(float x, float y, float width, float height, float border, Color color) { float widthMax = width + border + 5.0f; //+5 for AA support float heightMax = height + border + 5.0f; float xc = x + width / 2.0f; float yc = y + height / 2.0f; Verticies.Add(xc - widthMax / 2.0f); Verticies.Add(yc - heightMax / 2.0f); Verticies.Add(xc + widthMax / 2.0f); Verticies.Add(yc - heightMax / 2.0f); Verticies.Add(xc + widthMax / 2.0f); Verticies.Add(yc + heightMax / 2.0f); Verticies.Add(xc - widthMax / 2.0f); Verticies.Add(yc + heightMax / 2.0f); _uniformData.Add(new EllipseData { Color = color, Xc = xc, Yc = yc, Xr = width / 2.0f, Yr = height / 2.0f, Border = border }); }
public Ngon(double[][] edgeVectors) { this.EdgeVectors = encodeArray(edgeVectors); this.Verticies = new List <Vertex>(); this.Edges = new List <Edge>(); double[] cumulative = new double[] { 0, 0 }; foreach (double[] entry in edgeVectors) { Vertex from = new Vertex(cumulative[0], cumulative[1]); Verticies.Add(from); cumulative[0] += entry[0]; cumulative[1] += entry[1]; Vertex to = new Vertex(cumulative[0], cumulative[1]); Edges.Add(new Edge(to, from, entry)); } if (Math.Round(cumulative[0], 8) != 0 && Math.Round(cumulative[1], 8) != 0) { throw (new Exception("Ngon is not closed!")); } calculateAngles(); this.Type = getType(); }
public bool IsDirectedAcyclicGraph() { int visitCount = 0; IEnumerable <long> IteratorI = Verticies.Keys; int noOfVertices = Verticies.Count - 1; foreach (int srcVertex in IteratorI) { if (visitCount == noOfVertices) { return(true); } List <Vertex> srcAdjList = Verticies[srcVertex].Adjacents; if (srcAdjList.Count == 0) { visitCount++; Console.WriteLine("Target Node - " + srcVertex); IEnumerable <long> iteratorJ = Verticies.Keys; foreach (long adjVertex in iteratorJ) { List <Vertex> adjList = Verticies[adjVertex].Adjacents; if (adjList.Contains(Verticies[srcVertex])) { adjList.Remove(Verticies[srcVertex]); Console.WriteLine("Deleting edge between target node " + srcVertex + " - " + adjVertex + " "); } } Vertex v = new Vertex(0); Verticies.TryRemove(srcVertex, out v); IteratorI = Verticies.Keys; } } return(false); }
public void AddEdge(long id1, long id2, int weight) { Vertex vertex1 = null; if (Verticies.ContainsKey(id1)) { vertex1 = Verticies[id1]; } else { vertex1 = new Vertex(id1); Verticies[id1] = vertex1; } Vertex vertex2 = null; if (Verticies.ContainsKey(id2)) { vertex2 = Verticies[id2]; } else { vertex2 = new Vertex(id2); Verticies[id2] = vertex2; } Edge edge = new Edge(vertex1, vertex2, IsDirected, weight); Edges.Add(edge); vertex1.AddAdjacentVertex(edge, vertex2); if (!IsDirected) { vertex2.AddAdjacentVertex(edge, vertex1); } }
public void AddEdge(int edgeId, int vertexVal1, int vertexVal2, int weight) { Vertex vertex1 = Verticies.FirstOrDefault(item => item.Id == vertexVal1); Edge edge = new Edge(edgeId); if (vertex1 != null) { vertex1 = Verticies[vertexVal1]; } else { vertex1 = new Vertex(vertexVal1); Verticies.Add(vertex1); } Vertex vertex2 = Verticies.FirstOrDefault(item => item.Id == vertexVal2); if (vertex2 != null) { vertex2 = Verticies[vertexVal2]; } else { vertex2 = new Vertex(vertexVal2); Verticies.Add(vertex2); } edge.StartVertex = vertexVal1; edge.EndVertex = vertexVal2; edge.Weight = weight; Edges.Add(edge); vertex1.ForwardEdges.Add(edge.Id); vertex2.BackwardEdges.Add(edge.Id); Console.WriteLine(edgeId + ". " + vertexVal1 + " - " + vertexVal2 + " - " + weight); }
public override void Render() { var v1 = Verticies.First(); var v2 = Verticies.Last(); new Quad { Verticies = { new Vector3(v1.X, v1.Y, v1.Z), new Vector3(v1.X, v1.Y, v2.Z), new Vector3(v1.X, v2.Y, v2.Z), new Vector3(v1.X, v2.Y, v1.Z), } }.Render(); new Quad { Verticies = { new Vector3(v1.X, v1.Y, v1.Z), new Vector3(v1.X, v1.Y, v2.Z), new Vector3(v2.X, v1.Y, v2.Z), new Vector3(v2.X, v1.Y, v1.Z), } }.Render(); new Quad { Verticies = { new Vector3(v2.X, v1.Y, v1.Z), new Vector3(v2.X, v1.Y, v2.Z), new Vector3(v2.X, v2.Y, v2.Z), new Vector3(v2.X, v2.Y, v1.Z), } }.Render(); new Quad { Verticies = { new Vector3(v1.X, v2.Y, v1.Z), new Vector3(v1.X, v2.Y, v2.Z), new Vector3(v2.X, v2.Y, v2.Z), new Vector3(v2.X, v2.Y, v1.Z), } }.Render(); new Quad { Verticies = { new Vector3(v2.X, v1.Y, v1.Z), new Vector3(v1.X, v1.Y, v1.Z), new Vector3(v1.X, v2.Y, v1.Z), new Vector3(v2.X, v2.Y, v1.Z) } }.Render(); new Quad { Verticies = { new Vector3(v1.X, v1.Y, v2.Z), new Vector3(v1.X, v2.Y, v2.Z), new Vector3(v2.X, v2.Y, v2.Z), new Vector3(v2.X, v1.Y, v2.Z), } }.Render(); }
public void Clear() { Verticies.Clear(); IsDirected = false; IsWeighted = false; }
public Box(XElement element) { Verticies.Add(GetVertFromXmlAttribute(element, FIRST_CORNER_ID)); Verticies.Add(GetVertFromXmlAttribute(element, SECOND_CORNER_ID)); }
public void Clear() { Verticies.Clear(); Indexes.Clear(); }
public bool ContainsVerticies(int id) { return(Verticies.ContainsKey(id)); }
public void sort_vert() { Triangles = new List <int>(); Verticies.Sort((x, y) => x.CompareTo(y, center_pos)); Triangles = tria_regener(Verticies.Count); }
public void AddVertex(Vertex v) { Verticies.Add(v.Id, v); }
public void CreateFromMatrix(int[,] matrix, bool display = true, bool isDirected = false) { Clear(); this.IsDirected = isDirected; this.IsWeighted = IsWeighted; for (int lpRCnt = 0; lpRCnt < matrix.GetLength(0); lpRCnt++) { Verticies.Add(new Vertex() { Name = NameValues[lpRCnt], Value = lpRCnt }); } for (int lpRCnt = 0; lpRCnt < matrix.GetLength(0); lpRCnt++) { for (int lpCCnt = 0; lpCCnt < matrix.GetLength(1); lpCCnt++) { if (matrix[lpRCnt, lpCCnt] != 0) { if (Verticies[lpRCnt].Adjacents == null) { Verticies[lpRCnt].Adjacents = new List <Edge>(); } Verticies[lpRCnt].Adjacents.Add(new Edge(Verticies[lpCCnt], matrix[lpRCnt, lpCCnt])); if (isDirected == false) { if (Verticies[lpCCnt].Adjacents == null) { Verticies[lpCCnt].Adjacents = new List <Edge>(); } Verticies[lpCCnt].Adjacents.Add(new Edge(Verticies[lpRCnt], matrix[lpRCnt, lpCCnt])); } } } } //if (isDirected == false) //{ // for (int lpRCnt = 0; lpRCnt < matrix.GetLength(0); lpRCnt++) // { // for (int lpCCnt = 0; lpCCnt < matrix.GetLength(1); lpCCnt++) // { // if (matrix[lpRCnt, lpCCnt] != 0) // { // if (Verticies[lpRCnt].Adjacents == null) // Verticies[lpRCnt].Adjacents = new List<Edge>(); // Verticies[lpCCnt].Adjacents.Add(new Edge(Verticies[lpRCnt], matrix[lpRCnt, lpCCnt])); // } // } // } //} if (display == true) { for (int lpRCnt = 0; lpRCnt < matrix.GetLength(0); lpRCnt++) { for (int lpCCnt = 0; lpCCnt < matrix.GetLength(1); lpCCnt++) { Console.Write(matrix[lpRCnt, lpCCnt] + " "); } Console.WriteLine(); } } }
/// <summary> /// Adds the given vertex to the mesh /// </summary> /// <param name="Vertex">The vertex to add to the mesh</param> public void AddVertex(SEModelVertex Vertex) { // Add it Verticies.Add(Vertex); }