public static List <TextureVertex> BuildQuad(Vector3[] orderedVertices, bool splitFromTopLeft /*Determines whether quad is split into tris from top left corner or top right*/, Vector3 normal, TextureName topTriTexture, TextureName bottomTriTexture) { //Quad: //0-----1 // | | // | | // 3-----2 List <TextureVertex> result = new List <TextureVertex>(); //NOTE: Retrieve texture Coords from texture atlas. Need to check if not null Vector2[] textureCoordinatesTopTriangle = TextureAtlas.GetInstance().GetTextureCoordinates(topTriTexture); //new Vector2[4]; Vector2[] textureCoordinatesBottomTriangle = TextureAtlas.GetInstance().GetTextureCoordinates(bottomTriTexture); //new Vector2[4]; if (orderedVertices.Length == 4) //Must have 4 vertices for a quad { //Determine if quad is split 0-2 (top left) of 1-3 (top right) if (splitFromTopLeft) { for (int i = 0; i <= 2; i++)//Top right triangle { result.Add(new TextureVertex(new VertexPositionNormalTexture(orderedVertices[i], normal, textureCoordinatesTopTriangle[i]), topTriTexture)); } //NOTE: Include all in loop //Bottom left triangle result.Add(new TextureVertex(new VertexPositionNormalTexture(orderedVertices[2], normal, textureCoordinatesBottomTriangle[2]), bottomTriTexture)); result.Add(new TextureVertex(new VertexPositionNormalTexture(orderedVertices[3], normal, textureCoordinatesBottomTriangle[3]), bottomTriTexture)); result.Add(new TextureVertex(new VertexPositionNormalTexture(orderedVertices[0], normal, textureCoordinatesBottomTriangle[0]), bottomTriTexture)); } else { //Top Left triangle result.Add(new TextureVertex(new VertexPositionNormalTexture(orderedVertices[3], normal, textureCoordinatesTopTriangle[3]), topTriTexture)); result.Add(new TextureVertex(new VertexPositionNormalTexture(orderedVertices[0], normal, textureCoordinatesTopTriangle[0]), topTriTexture)); result.Add(new TextureVertex(new VertexPositionNormalTexture(orderedVertices[1], normal, textureCoordinatesTopTriangle[1]), topTriTexture)); //Bottom right triangle for (int i = 1; i <= 3; i++) { result.Add(new TextureVertex(new VertexPositionNormalTexture(orderedVertices[i], normal, textureCoordinatesBottomTriangle[i]), bottomTriTexture)); } } } return(result); }