예제 #1
0
 public static Gem.Gui.UIItem CreateGuiSprite(Rectangle Position, int TileIndex, TileSheet TileSheet)
 {
     return new Gem.Gui.UIItem(
         Gem.Gui.Shape.CreateSprite(Position.X, Position.Y, Position.Width, Position.Height),
         new Gem.Gui.GuiProperties
         {
             Image = TileSheet.Texture,
             ImageTransform = TileSheet.TileMatrix(TileIndex)
         });
 }
예제 #2
0
        private static void MorphBlockTextureCoordinates(TileSheet Tiles, BlockTemplate Template, Gem.Geo.Mesh cube)
        {
            Gem.Geo.Gen.MorphEx(cube, (inV) =>
            {
                var r = inV;

                var top = Template.Top;
                var bottom = Template.Bottom == -1 ? Template.Top : Template.Bottom;
                var sideA = Template.SideA == -1 ? Template.Top : Template.SideA;
                var sideB = Template.SideB == -1 ? sideA : Template.SideB;

                if (r.Normal.Z > 0.1f)
                    r.TextureCoordinate = Vector2.Transform(r.TextureCoordinate,
                        Tiles.TileMatrix(bottom));
                else if (r.Normal.Z < -0.1f)
                    r.TextureCoordinate = Vector2.Transform(r.TextureCoordinate,
                        Tiles.TileMatrix(top));
                else
                {

                    if (r.Normal.X != 0)
                        r.TextureCoordinate = Vector2.Transform(r.TextureCoordinate, Tiles.TileMatrix(sideA));
                    else
                        r.TextureCoordinate = Vector2.Transform(r.TextureCoordinate, Tiles.TileMatrix(sideB));
                }

                return r;
            });
        }
예제 #3
0
        private static Gem.Geo.Mesh CreateMarkerBlockMesh(TileSheet Tiles, int MarkerTile)
        {
            var cube = Gem.Geo.Gen.CreateTexturedFacetedCube();
            Gem.Geo.Gen.Transform(cube, Matrix.CreateScale(1.02f)); // Make cube slightly larger.
            Gem.Geo.Gen.Transform(cube, Matrix.CreateTranslation(0.5f, 0.5f, 0.5f)); // re-origin cube.

            //Morph cube texture coordinates
            Gem.Geo.Gen.MorphEx(cube, (inV) =>
            {
                var r = inV;
                r.TextureCoordinate = Vector2.Transform(r.TextureCoordinate, Tiles.TileMatrix(MarkerTile));
                return r;
            });

            return cube;
        }