private void DrawSide(BlockSide side, SideTile part, Vector3 offset, bool isLid) { if (part.Sprite > 0) { if (_isCol && (!part.Wall && !isLid)) { if (_block.SlopeType.Slope != MapGeometry.SLOPE_DIAGONAL_DOWNLEFT && _block.SlopeType.Slope != MapGeometry.SLOPE_DIAGONAL_DOWNRIGHT && _block.SlopeType.Slope != MapGeometry.SLOPE_DIAGONAL_UPLEFT && _block.SlopeType.Slope != MapGeometry.SLOPE_DIAGONAL_UPRIGHT) { return; } } BlockSide modifiedSide = ModifySide(side, part); ushort sprite = part.Sprite; string materialName = string.Format("gbh/bil/{0}", sprite); Material material = MaterialManager.FindMaterial(materialName); var bank = GetBank(material.BaseName); bank.ReserveSpace(side.Vertices.Length, (side.Vertices.Length == 4) ? 6 : 4); int vertIndex = bank.numVertex; bank.vertices[bank.numVertex++] = GetVertex(modifiedSide, 0, offset, part, material); bank.vertices[bank.numVertex++] = GetVertex(modifiedSide, 1, offset, part, material); bank.vertices[bank.numVertex++] = GetVertex(modifiedSide, 2, offset, part, material); bank.indices[bank.numIndex++] = (short)(vertIndex + 0); bank.indices[bank.numIndex++] = (short)(vertIndex + 1); bank.indices[bank.numIndex++] = (short)(vertIndex + 2); if (side.Vertices.Length == 4) { bank.vertices[bank.numVertex++] = GetVertex(modifiedSide, 3, offset, part, material); bank.indices[bank.numIndex++] = (short)(vertIndex + 2); bank.indices[bank.numIndex++] = (short)(vertIndex + 3); bank.indices[bank.numIndex++] = (short)(vertIndex + 0); } } }
public static void RenderPass(GraphicsDevice device, Effect effect, Camera camera) { // set up the effect device.DepthStencilState = DepthStencilState.Default; device.RasterizerState = _normalState; effect.Parameters["World"].SetValue(Matrix.Identity); foreach (var cell in CellManager.ActivatedCells) { if (camera.BoundingFrustum.Intersects(cell.Bounds)) { foreach (var bankStuff in cell.Banks) { //var image = ImageManager.FindImage(bankStuff.Key); var material = MaterialManager.FindMaterial(bankStuff.Key); var bank = bankStuff.Value; effect.Parameters["ColorMap"].SetValue(material.DiffuseImage.Texture); effect.Techniques[0].Passes[0].Apply(); if (bank.vertexBuffer != null) { device.Indices = bank.indexBuffer; device.SetVertexBuffer(bank.vertexBuffer); device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, bank.vertices.Length, 0, bank.indices.Length / 3); } else { if (bank.vertices.Length >= 3) { device.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, bank.vertices, 0, bank.vertices.Length, bank.indices, 0, bank.indices.Length / 3); } } } } } }
public override RenderEntity GetRenderEntity() { return(new RenderEntity() { Position = Position, Heading = Rotation.Z, Size = new Vector2(0.5f, 0.5f), Sprite = MaterialManager.FindMaterial("x1") }); }