public void AddData(VertexPositionNormalTexture[] VertexList, short[] IndexList) { int _count = this.VertexList.Count; this.VertexList.AddRange(VertexList.ToList<VertexPositionNormalTexture>()); foreach (short index in IndexList) { this.IndexList.Add((short)(index + _count)); } }
public void ComputeShadowMesh(Vector3 lightWorldPosition) { List<VertexBuffer> vertexBuffers; List<IndexBuffer> indexBuffers; _gameWorld.GetRenderables(out vertexBuffers, out indexBuffers); for (int i = 0; i < vertexBuffers.Count; ++i) { _shadowMeshIndices.Clear(); _shadowVertices.Clear(); _shadowIndices.Clear(); VertexPositionNormalTexture[] vertexData = new VertexPositionNormalTexture[vertexBuffers[i].VertexCount]; vertexBuffers[i].GetData<VertexPositionNormalTexture>(vertexData); UInt32[] vertexIndices = new UInt32[indexBuffers[i].IndexCount]; indexBuffers[i].GetData<UInt32>(vertexIndices); foreach (VertexPositionNormalTexture vertex in vertexData) { _shadowVertices.Add(vertex.Position); } foreach (UInt32 index in vertexIndices) { _shadowIndices.Add(index); } Shadows.CreateShadowVolumeMesh(vertexData.ToList(), _shadowIndices, Vector3.Zero - lightWorldPosition, ref _shadowMeshIndices, ref _shadowMeshVertices); IndexBuffer shadowIndexBuffer = new IndexBuffer(GraphicsDevice, IndexElementSize.ThirtyTwoBits, _shadowMeshIndices.Count, BufferUsage.None); shadowIndexBuffer.SetData(_shadowMeshIndices.ToArray()); _shadowIndexList.Add(shadowIndexBuffer); List<VertexPositionColor> shadowVertices = new List<VertexPositionColor>(); foreach(Vector3 vertexPos in _shadowMeshVertices) { shadowVertices.Add(new VertexPositionColor(vertexPos, Color.White)); } VertexBuffer shadowVertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionColor), shadowVertices.Count, BufferUsage.None); shadowVertexBuffer.SetData(shadowVertices.ToArray()); _shadowVertexBufferList.Add(shadowVertexBuffer); } }
public VertexIndexData(VertexPositionNormalTexture[] VertexList, short[] IndexList) { this.VertexList = VertexList.ToList<VertexPositionNormalTexture>(); this.IndexList = IndexList.ToList<short>(); }