예제 #1
0
        private VertexPositionNormalTexture[] GetVertices(Vector3 position, TextureTile texture)
        {
            var vertices = new VertexPositionNormalTexture[TILE_FACE_VERTICES];

            for (int i = 0; i < TILE_FACE_VERTICES; i++)
            {
                vertices[i].Position          = position + Vectors[i];
                vertices[i].Normal            = Normals[i];
                vertices[i].TextureCoordinate = texture.GetPosition(new Vector2(vertices[i].Position.X, vertices[i].Position.Z));
            }
            float xLength  = Math.Abs((vertices[1].Position - vertices[0].Position).Length());
            float yLength  = Math.Abs((vertices[3].Position - vertices[0].Position).Length());
            float dxLength = Math.Abs((vertices[2].Position - vertices[3].Position).Length());
            float dyLength = Math.Abs((vertices[2].Position - vertices[1].Position).Length());

            var start = new Vector2(vertices[0].Position.X, vertices[0].Position.Z);

            /*vertices[0].TextureCoordinate = texture.GetPosition(start + new Vector2(0, 0));
             * vertices[1].TextureCoordinate = texture.GetPosition(start + new Vector2(xLength, 0));
             * vertices[2].TextureCoordinate = texture.GetPosition(start + new Vector2(dxLength, dyLength));
             * //vertices[2].TextureCoordinate = texture.GetPosition(start + new Vector2(xLength, yLength));
             * vertices[3].TextureCoordinate = texture.GetPosition(start + new Vector2(0, yLength));*/
            vertices[0].TextureCoordinate = texture.GetPosition(start + new Vector2(0, 0));
            vertices[1].TextureCoordinate = texture.GetPosition(start + new Vector2(1, 0));
            vertices[2].TextureCoordinate = texture.GetPosition(start + new Vector2(1, 1));
            vertices[3].TextureCoordinate = texture.GetPosition(start + new Vector2(0, 1));
            return(vertices);
        }
예제 #2
0
        static private VertexPositionNormalTexture[] GetVertices(Vector3 position, List <TextureTile> textures)
        {
            var vertices   = new VertexPositionNormalTexture[CUBE_VERTICES_COUNT];
            int face       = -1;
            int faceVertex = CUBE_FACE_VERTICES - 1;
//			int faceRotation = 0;
            TextureTile texture = null;

            for (int i = 0; i < CUBE_VERTICES_COUNT; i++)
            {
                if (++faceVertex == CUBE_FACE_VERTICES)
                {
                    texture    = textures[++face];
                    faceVertex = 0;
//					faceRotation = FaceTextureRotation[face];
                }
                var cornerVector = Vectors[i];
                vertices[i].Position          = position + cornerVector;
                vertices[i].Normal            = Normal[i];
                vertices[i].TextureCoordinate = texture.GetPosition(TextureCoordinates[faceVertex]);
            }
            return(vertices);
        }
예제 #3
0
 private static Vector2 GetTextureCoordinates(TextureTile texture, VertexPositionNormalTexture distance)
 {
     return(texture.GetPosition(new Vector2(distance.Position.X, distance.Position.Z)));
 }