public void AddLine(Vector3 startPoint, Color4 startColor, Vector3 endPoint, Color4 endColor) { if (startColor.Alpha == 0 && endColor.Alpha == 0) { return; } vertices.Add(new VertexColor(startPoint, startColor)); vertices.Add(new VertexColor(endPoint, endColor)); }
private void CreateBatch(PositionTexCoordNormalVertex[] vertices, short[] indices, Renderer renderer) { Debug.Assert(vertices != null && indices != null); int vertexBufferSize = PositionTexCoordNormalVertex.SizeInBytes * vertices.Length; var verticesData = new DataStream(vertexBufferSize, true, true); verticesData.WriteRange(vertices); verticesData.Seek(0, SeekOrigin.Begin); var vertexBuffer = new Buffer(renderer.Device, verticesData, vertexBufferSize, ResourceUsage.Default, BindFlags.VertexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None); verticesData.Close(); int indexBufferSize = sizeof(short) * indices.Length; var indicesData = new DataStream(indexBufferSize, true, true); indicesData.WriteRange(indices); indicesData.Seek(0, SeekOrigin.Begin); var indexBuffer = new Buffer(renderer.Device, indicesData, indexBufferSize, ResourceUsage.Default, BindFlags.IndexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None); indicesData.Close(); // Create batch var vertexBufferBinding = new VertexBufferBinding(vertexBuffer, PositionTexCoordNormalVertex.SizeInBytes, 0); var inputLayout = new InputLayout(renderer.Device, PositionTexCoordNormalVertex.InputElements, effect.GetTechniqueByIndex(0).GetPassByIndex(0).Description.Signature); batch = new DrawIndexedBatch(renderer.Device, effect, new[] { vertexBufferBinding }, inputLayout, indexBuffer, Format.R16_UInt, indices.Length, 0, 0); batches.Add(batch); }
public void AddItem(Batch item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } ItemDataCollection.Add(item); CreateNode(item); }
public void Add(Vector2 pos, Color4 color) { float size = 2; Vector3 position = new Vector3(pos.X, 0, pos.Y); Vector3 d1, d2, d3; d1 = fixPointWater(map_info, position); Vector3 v = new Vector3(pos.X + (size * 0.5f), position.Y, pos.Y + (size * 0.5f)); v = fixPointWater(map_info, v); if (SceneManager.Camera.Frustum.Contains(v) == ContainmentType.Disjoint) { return; } d2 = fixPointWater(map_info, position + new Vector3(size, 0, size)); d3 = fixPointWater(map_info, position + new Vector3(0, 0, size)); vertices.Add(new VertexColor(d1, color)); vertices.Add(new VertexColor(d2, color)); vertices.Add(new VertexColor(d3, color)); d3 = fixPointWater(map_info, position + new Vector3(size, 0, 0)); vertices.Add(new VertexColor(d1, color)); vertices.Add(new VertexColor(d3, color)); vertices.Add(new VertexColor(d2, color)); }
protected override Entity OnAdd() { var newItem = new Dll.SchoolYear.Batch(); using (var frm = new frmBatch_Add()) { frm.ItemData = newItem; if (frm.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return(null); } } App.LogAction("School Year.Batch", "Created Batch : " + newItem.BatchName); ItemDataCollection.Add(newItem); return(newItem); }
public static void Draw(Texture texture, Vector2 position, Vector2 size, SharpDX.Rectangle?rect, Color4 color, Vector2 center, float rotation = 0) { if (lastTexture != texture) { Push(); lastTexture = texture; } Matrix trans = Matrix.Translation(-center.X, -center.Y, 0) * Matrix.Scaling(size.X, size.Y, 0) * Matrix.RotationZ(rotation) * Matrix.Translation(position.X, position.Y, 0); Vector2 sizeConverted = new Vector2(); sizeConverted.X = texture.Width; sizeConverted.Y = texture.Height; Vector4 cut = new Vector4(0, 0, 1, 1); if (rect.HasValue) { cut.X = ((float)rect.Value.Left / texture.Width); cut.Y = ((float)rect.Value.Top / texture.Height); cut.Z = ((float)rect.Value.Right / texture.Width); cut.W = ((float)rect.Value.Bottom / texture.Height); sizeConverted.X = rect.Value.Width; sizeConverted.Y = rect.Value.Height; } vertices.Add(new Vertex2D(Vector2.Transform(new Vector2(0, 0), trans), new Vector2(cut.X, cut.Y), color)); vertices.Add(new Vertex2D(Vector2.Transform(new Vector2(sizeConverted.X, 0), trans), new Vector2(cut.Z, cut.Y), color)); vertices.Add(new Vertex2D(Vector2.Transform(new Vector2(0, sizeConverted.Y), trans), new Vector2(cut.X, cut.W), color)); vertices.Add(new Vertex2D(Vector2.Transform(new Vector2(sizeConverted.X, sizeConverted.Y), trans), new Vector2(cut.Z, cut.W), color)); spritesDrawn++; }
public void AddDot(Vector3 point, Color4 color) { vertices.Add(new VertexColor(point, color)); }