public void CreateBillboardVertices() { if (_items==null || !_items.Any()) return; var billboardVertices = new StaticBillboardVertex[_items.Count * 6]; var i = 0; var random = new Random(); foreach (var t in _items) createOne( ref i, billboardVertices, t.Item1 + _world.TranslationVector, t.Item2, t.Item3); _items = null; _vertexBuffer = Buffer.Vertex.New(Effect.GraphicsDevice, billboardVertices); _vertexInputLayout = VertexInputLayout.FromBuffer(0, _vertexBuffer); }
private void createOne( ref int i, StaticBillboardVertex[] bv, Vector3 p, Vector3 n, Vector3 front) { n.Normalize(); bv[i++] = new StaticBillboardVertex(p, n, front, new Vector2(0, 0)); bv[i++] = new StaticBillboardVertex(p, n, front, new Vector2(1, 0)); bv[i++] = new StaticBillboardVertex(p, n, front, new Vector2(1, 1)); bv[i++] = new StaticBillboardVertex(p, n, front, new Vector2(0, 0)); bv[i++] = new StaticBillboardVertex(p, n, front, new Vector2(1, 1)); bv[i++] = new StaticBillboardVertex(p, n, front, new Vector2(0, 1)); }