Exemplo n.º 1
0
	private static Texture2D fillTexture(Texture2D texture, int width, int height, TextureAtlas atlas, int[] indices){
		int w = (int)atlas.pixelWidth();
		int h = (int)atlas.pixelHeight();
		texture = ensureSize(texture, width * w, height * h);
		for (int i = 0; i < width * height; i++)
			texture.SetPixels(i % width * w, (height - (i / width) - 1) * h, w, h, atlas.tileData(indices[i]));
		texture.Apply ();
		return texture;
	}
Exemplo n.º 2
0
    // Make a GUIElement, will immediately render
    public FastGUIElement(
		Vector2 screenPos,	// Position on screen (relative to Position)
		Rect	atlasRect, 	// Atlas rectangle in pixels
		Position pos = Position.TOPLEFT)
    {
        // There is a fixed number of possible FastGUIElements
        frontendAtlas = PrimitiveLibrary.Get.m_Atlases[(int)TextureAtlas.AtlasID.FRONTEND];
        if (instanceCount + 1 > frontendAtlas.m_NumElements)
        {
            Debug.LogError ("Need to increase frontendAtlas.m_NumElements and PrimitiveLibrary.g_FrontendBatchSize");
            return;
        }
        textureIdx = instanceCount++;

        // Initialise the UVs
        frontendAtlas.m_UVSet[textureIdx] = new Vector4 (
            atlasRect.x / originalAtlasPixelsWidth,
            ((originalAtlasPixelsHeight - atlasRect.y) - atlasRect.height) / originalAtlasPixelsHeight, // Note quad render has bottom zeroed Vs
            (atlasRect.x + atlasRect.width) / originalAtlasPixelsWidth,
            (((originalAtlasPixelsHeight - atlasRect.y) - atlasRect.height) + atlasRect.height) / originalAtlasPixelsHeight);

        // Setup the quad
        quad = PrimitiveLibrary.Get.GetQuadDefinition (PrimitiveLibrary.QuadBatch.FRONTEND_BATCH);
        quad.m_TextureIdx = textureIdx;
        quad.m_Colour = Color.white;

        // Use UVs for size
        widthNormalised = frontendAtlas.m_UVSet[textureIdx].z - frontendAtlas.m_UVSet[textureIdx].x;
        heightNormalised = frontendAtlas.m_UVSet[textureIdx].w - frontendAtlas.m_UVSet[textureIdx].y;
        width = atlasRect.width;
        height = atlasRect.height;

        // The centre of the quad in world space which is mapped by camera to the safeSceen size
        if (pos == Position.TOPLEFT) {
            quad.m_Position.x = (-safeScreenWidth * .5f + screenPos.x) + (width * .5f);
            quad.m_Position.y = (+safeScreenHeight * .5f - screenPos.y) - (height * .5f);
        }
        else if (pos == Position.XYCENTRED) {
            quad.m_Position.x = (-safeScreenWidth * .5f + screenPos.x);
            quad.m_Position.y = (+safeScreenHeight * .5f - screenPos.y);
        }
        else if (pos == Position.XCENTRED) {
            quad.m_Position.x = (-safeScreenWidth * .5f + screenPos.x);
            quad.m_Position.y = (+safeScreenHeight * .5f - screenPos.y) - (height * .5f);
        }
        else if (pos == Position.YCENTRED) {
            quad.m_Position.x = (-safeScreenWidth * .5f + screenPos.x) + (width * .5f);
            quad.m_Position.y = (+safeScreenHeight * .5f - screenPos.y);
        }
        quad.m_Position.z = 0f;
        quad.m_Scale.x = width;
        quad.m_Scale.y = height;
        UpdatedQuad ();
        children = new List<FastGUIElement>();
    }
Exemplo n.º 3
0
        public Bird(GameWorld gameWorld)
            : base(gameWorld)
        {
            Graphic.LoadContent("gfx/background/bird");
            Graphic.Layer = 0.02f;

            TextureAtlas textureAtlas = new TextureAtlas(Graphic.Texture, 42, 30);
            _flyAnimation = textureAtlas.GetAnimation(0, 10);
            _flyAnimation.FrameRate = 24;
            _flyAnimation.IsRepeating = true;
            _animationPlayer.Play(_flyAnimation);
        }
Exemplo n.º 4
0
        protected override void Load(EntityGUI.GUIFactory factory)
        {
            this.particleProgram = this.Resourses.LoadAsset<ShaderProgram>("Sin.effect");
            this.Panel.BackgroundColor = Color.Gray;

            this.Panel.MouseDown += new EventHandler<EntityGUI.MouseButtonEventArgs>(Panel_MouseDown);
            this.Panel.MouseMove +=new EventHandler<EntityGUI.MouseMoveEventArgs>(Panel_MouseMove);

            particleAtlas = this.Resourses.LoadAsset<TextureAtlas>("Atlases\\Particles.atlas");

            this.systems = new ParticleSystem[10];
            this.emiters = new Emiter2D[10];
            this.Panel_MouseDown(null, null);
        }
Exemplo n.º 5
0
        public AtlasNode(string tileFile, int itemWidth, int itemHeight, int itemsToRender)
        {
            _itemWidth = itemWidth;
            _itemHeight = itemHeight;

            Color = Color.White;

            BlendFunc = BlendFunc.DefaultBlendFunc;

            TextureAtlas = new TextureAtlas(tileFile, itemsToRender);

            UpdateBlendFunc();
            CalculateMaxItems();
            CalculateTexCoordsSteps();
        }
Exemplo n.º 6
0
        public GlyphManager()
        {
            glyphSubTextures = new Dictionary<GlyphId, SubTexture>();
            glyphInfos = new Dictionary<GlyphId, Glyph>();

            textureAtlas = new TextureAtlas(512,PixelFormat.R8G8B8);

            textMaterial = Material.Create(Allocator.GetHeap(), "TextMaterial");
            var mat = textMaterial.Resolve();
            mat.BackfaceCulling = false;
            mat.SetBlending(BlendSource.SourceAlpha, BlendDestination.InverseSourceAlpha);
            mat.SetShader("Text");
            mat.SetTexture(0, textureAtlas.AtlasImageHandle);
            mat.GetTextureUnit(0).WrapMode = TextureWrapMode.ClampToEdge;
        }
Exemplo n.º 7
0
        public Mushroom(Vector2 force, GameWorld gameWorld)
            : base(gameWorld)
        {
            _force = force;
            Graphic.LoadContent("gfx/object/dynamic/mushroom");
            Graphic.Layer = 0.9f;
            Graphic.Offset = new Vector2(Graphic.Texture.Width / 2 - 69, Graphic.Texture.Height / 2 - 55);

            TextureAtlas textureAtlas = new TextureAtlas(Graphic.Texture, 138, 111);
            _bounceAnimation = textureAtlas.GetAnimation(0, 16);
            _bounceAnimation.FrameRate = 24;
            _animationPlayer.Play(_bounceAnimation);

            Body = BodyFactory.CreateCircle(gameWorld.PhysicalWorld, 1.0f, 1.0f);
            Body.BodyType = BodyType.Static;
            Body.OnCollision += Body_OnCollision;
        }
Exemplo n.º 8
0
    /// <summary>
    /// Draw the inspector widget.
    /// </summary>
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeControls(80f);
        mWidget = target as TextureAtlas;

        if (!mInitialized)
        {
            mInitialized = true;
        //			OnInit();
        }

        NGUIEditorTools.DrawSeparator();

        // Check to see if we can draw the widget's default properties to begin with
        if (OnDrawProperties())
        {
            // Draw all common properties next
            DrawCommonProperties();
        }
    }
Exemplo n.º 9
0
    public static Texture2D constructPreview(SerializedProperty spec)
    {
        TextureAtlas atlas = TileSpecList.list.tileset;

        Texture2D tex   = (Texture2D)spec.FindPropertyRelative("view").objectReferenceValue;
        int       index = spec.FindPropertyRelative("index").intValue;

        switch ((TileContext)spec.FindPropertyRelative("context").enumValueIndex)
        {
        case TileContext.None:
            tex = fillTexture(tex, 1, 1, atlas, new int[] { index });
            break;

        case TileContext.PartialContext:
            tex = fillTexture(tex, 3, 3, atlas, new int[] {
                index, index + 1, index + 2,
                index + 4, index + 5, index + 6,
                index + 8, index + 9, index + 10
            });
            break;

        case TileContext.FullContext:
            tex = fillTexture(tex, 5, 5, atlas, new int[] {
                index + 4, index + 34, index + 1, index + 33, index + 6,
                index + 36, index + 22, index + 11, index + 20, index + 39,
                index + 8, index + 25, index + 9, index + 25, index + 10,
                index + 40, index + 6, index + 11, index + 4, index + 43,
                index + 20, index + 46, index + 17, index + 45, index + 22
            });
            break;

        case TileContext.Slope:
            return(null);
        }
        spec.FindPropertyRelative("view").objectReferenceValue = tex;
        spec.serializedObject.ApplyModifiedProperties();
        return(tex);
    }
Exemplo n.º 10
0
        private List <TextureAtlas> loadDirectory(string directoryPath)
        {
            if (!Directory.Exists(directoryPath))
            {
                return(new List <TextureAtlas>());
            }

            List <TextureAtlas> textureAtlasList = new List <TextureAtlas>();

            foreach (FileInfo file in new DirectoryInfo(directoryPath).GetFiles())
            {
                TextAsset text    = null;
                Texture2D texture = null;
                foreach (UnityEngine.Object asset in AssetBundle.LoadFromFile(file.FullName).LoadAllAssets())
                {
                    if (asset is Texture2D)
                    {
                        texture = asset as Texture2D;
                    }
                    else if (asset is TextAsset)
                    {
                        text = asset as TextAsset;
                    }
                }
                if (text == null)
                {
                    DebugUtil.LogWarningArgs(string.Format("could not load atlas file, skipping {0}", file.Name));
                }
                if (texture == null)
                {
                    DebugUtil.LogWarningArgs(string.Format("could not load texture file, skipping {0}", file.Name));
                }
                TextureAtlas atlas = makeTextureAtlas(text, texture);
                atlas.name = file.Name;
                textureAtlasList.Add(atlas);
            }
            return(textureAtlasList);
        }
Exemplo n.º 11
0
        public override void Load(ContentManager content, MapManager _mapManager)
        {
            image = TextureLoader.Load("Textures/Jeff", content);

            var spriteWidth   = spriteSheetData.Width;
            var spriteHeight  = spriteSheetData.Height;
            var objectTexture = image;
            var objectAtlas   = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight);

            var animationFactory = new SpriteSheetAnimationFactory(objectAtlas);

            for (int i = 0; i < spriteSheetData.AnimationName.Count; i++)
            {
                animationFactory.Add(spriteSheetData.AnimationName[i], new SpriteSheetAnimationData(spriteSheetData.FrameArray[i], spriteSheetData.FrameDuration[i], spriteSheetData.IsLooping[i]));
            }

            animatedSprite = new AnimatedSprite(animationFactory, "Down");


            sprite = animatedSprite;

            animatedSprite.Origin = Vector2.Zero;
        }
Exemplo n.º 12
0
        public EnemyShip(GraphicsDevice GraphDev, TextureAtlas TxtrAtlas, ObjectManager ObjManager, Int32 nTargetGroupID, Int32 nAvoidGroupID) : base(GraphDev, TxtrAtlas)
        {
            cObjMgr         = ObjManager;
            cnTargetGroupID = nTargetGroupID;
            cnAvoidGroupID  = nAvoidGroupID;

            cnHealth = 100;

            cnMaxTurn       = (float)(5 * Math.PI / 180);
            cnMaxSpeed      = 5;
            cnMaxStrafeDist = 300;
            cnMinStrafeDist = 150;

            ctHitFlashUntil = 0;
            cbStrafeCW      = true;

            cclrNormalColor = Color.CornflowerBlue;
            TintColor       = cclrNormalColor;

            Drawing += DrawHandle;

            return;
        }
Exemplo n.º 13
0
        public override void Load(ContentManager content)
        {
            base.Load(content);
            // initiliaze sprite
            spriteWidth   = spriteHeight = 32;
            objectTexture = content.Load <Texture2D>("Sprites/" + "enemy");
            objectAtlas   = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight);

            //create animations from sprite sheet
            animationFactory = new SpriteSheetAnimationFactory(objectAtlas);
            objectAtlas      = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight);
            animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0 }));
            animationFactory.Add("walk", new SpriteSheetAnimationData(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, frameDuration: 0.1f, isLooping: true));

            objectAnimated = new AnimatedSprite(animationFactory, "walk");

            objectSprite       = objectAnimated;
            objectSprite.Depth = 0.2F;

            boundingBoxWidth  = 14;
            boundingBoxHeight = 21;
            boundingBoxOffset = new Vector2(9, 6);
        }
Exemplo n.º 14
0
        public static TextureAtlas GetCustomTileAtlas(string filename)
        {
            TextureAtlas textureAtlas = null;

            try
            {
                string path = Path.Combine(ModCommon.Folder, "textures", filename);
                var    data = File.ReadAllBytes(path);
                var    tex  = new Texture2D(2, 2);
                tex.LoadImage(data);
                textureAtlas             = ScriptableObject.CreateInstance <TextureAtlas>();
                textureAtlas.texture     = tex;
                textureAtlas.scaleFactor = ReferenceTileAtlas.scaleFactor;
                textureAtlas.items       = ReferenceTileAtlas.items;
            }
            catch (Exception ex)
            {
                Debug.LogError($"Could not load atlas image: {filename}");
                Debug.LogException(ex);
            }

            return(textureAtlas);
        }
Exemplo n.º 15
0
    private GUIContent getPreview(TextureAtlas tileset, int index, SerializedProperty sequence)
    {
        if (tileset == null)
        {
            return(new GUIContent("No valid Tileset found"));
        }
        if (tileset.texture == null)
        {
            return(new GUIContent("Tileset has no valid texture"));
        }
        if (index == -1)
        {
            return(new GUIContent(tileset.texture));
        }
        index = (index + 1) % sequence.arraySize;
        Texture2D tex = tileset.getSubtexture(null, sequence.GetArrayElementAtIndex(index).intValue % (tileset.width * tileset.height));

        if (style.normal.background != tex)
        {
            style.normal.background = tex;
        }
        return(tex == null ? new GUIContent("Texture cannot be read") : null);
    }
Exemplo n.º 16
0
        protected override void LoadContent()
        {
            _viewportAdapter = new ScalingViewportAdapter(_graphics.GraphicsDevice, 1600, 900);

            _camera      = new OrthographicCamera(_viewportAdapter);
            _spriteBatch = new SpriteBatch(_graphics.GraphicsDevice);

            if (File.Exists(@"Content\allSprites_default.xml"))
            {
                _atlas             = TextureAtlasData.CreateFromFile(Content, @"Content\allSprites_default.xml");
                _projectileFactory = new ProjectileFactory(_entityManager, _atlas);
            }


            var map = Content.Load <TiledMap>("map01");

            _mapRenderer = new TiledMapRenderer(_graphics.GraphicsDevice);
            LoadMap(map);
            _player = _entityManager.AddEntity(
                new Player(_atlas.GetRegion("tankBody_red"), _atlas.GetRegion("tankRed_barrel1"), _projectileFactory)
                );
            _movementController = new MovementController(_player, _camera);
        }
Exemplo n.º 17
0
        private BitmapFont LoadCustomMonospacedFont()
        {
            // this is a way to create a font in pure code without a font file.
            const string characters        = @" !""#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
            var          monospacedTexture = Content.Load <Texture2D>("Fonts/monospaced");
            var          atlas             = TextureAtlas.Create("monospaced-atlas", monospacedTexture, 16, 16);
            var          fontRegions       = new BitmapFontRegion[characters.Length];
            var          index             = 0;

            for (var y = 0; y < monospacedTexture.Height; y += 16)
            {
                for (var x = 0; x < monospacedTexture.Width; x += 16)
                {
                    if (index < characters.Length)
                    {
                        fontRegions[index] = new BitmapFontRegion(atlas[index], characters[index], 0, 0, 16);
                        index++;
                    }
                }
            }

            return(new BitmapFont("monospaced", fontRegions, 16));
        }
Exemplo n.º 18
0
        /// <summary>
        /// Exports a texture atlas
        /// </summary>
        /// <param name="atlas"></param>
        /// <param name="platforms"></param>
        /// <returns></returns>
        public bool Export(TextureAtlas atlas, List <Platform> platforms)
        {
            if (atlas == null)
            {
                return(false);
            }

            foreach (Platform platform in platforms)
            {
                // Determine the destination file
                string destFile = platform.OutputDirectory + "/" + atlas.mFilename;
                if (!System.IO.Path.IsPathRooted(destFile))
                {
                    destFile = GUIProject.CurrentProject.ProjectDirectory + "/" + destFile;
                }

                System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(destFile));

                atlas.Save(destFile);
            }

            return(true);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Exports the given animations into an image sheet and returns the created sheet
        /// </summary>
        /// <param name="exportSettings">The export settings for the sheet</param>
        /// <param name="anims">The list of animations to export</param>
        /// <param name="name">The name for the generated texture atlas. Used for progress reports</param>
        /// <param name="cancellationToken">A cancelation token that is passed to the exporters and can be used to cancel the export process mid-way</param>
        /// <param name="progressHandler">Optional event handler for reporting the export progress</param>
        /// <returns>An image sheet representing the animations passed</returns>
        public async Task <TextureAtlas> GenerateAtlasFromAnimations(AnimationExportSettings exportSettings, Animation[] anims, string name = "", CancellationToken cancellationToken = new CancellationToken(), BundleExportProgressEventHandler progressHandler = null)
        {
            var atlas = new TextureAtlas(exportSettings, name);

            //
            // 1. Add the frames to the texture atlas
            //
            foreach (var anim in anims)
            {
                for (int i = 0; i < anim.FrameCount; i++)
                {
                    atlas.InsertFrame(anim.GetFrameAtIndex(i));
                }
            }

            //
            // 2. Pack the frames into the atlas
            //
            ITexturePacker packer = new DefaultTexturePacker();
            await packer.Pack(atlas, cancellationToken, progressHandler);

            return(atlas);
        }
Exemplo n.º 20
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            _bitmapFont  = Content.Load <BitmapFont>("Fonts/courier-new-32");
            _tiledMap    = Content.Load <TiledMap>("level01");

            var fireballTexture  = Content.Load <Texture2D>("fireball");
            var spriteSheetAtlas = TextureAtlas.Create(fireballTexture, 512, 197);

            _sprite = new Sprite(spriteSheetAtlas.First())
            {
                Position = new Vector2(850, 200),
                Scale    = new Vector2(0.5f)
            };
            _spriteAnimator = new SpriteAnimator(_sprite, spriteSheetAtlas, 15);

            var zombieSheet = Content.Load <TextureAtlas>("zombie-atlas");

            _zombie = new Zombie(zombieSheet)
            {
                Position = new Vector2(300, 900)
            };
        }
Exemplo n.º 21
0
    static void Load()
    {
        var texsdata = Resources.Load(texsfilenameXML, typeof(TextAsset)) as TextAsset;

        var texs = texsdata.text.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

        foreach (var file in texs)
        {
            if (file.Contains("sheet"))
            {
                var tex2  = Resources.Load(file, typeof(TextAsset)) as TextAsset;
                var tdata = TextureAtlas.CreateFromStringXML(tex2.text);
                //selectTex = Resources.Load(filename, typeof(Texture2D)) as Texture2D;

                srcTexs[file]   = null;
                allBlocks[file] = new DetailBlock();
                foreach (var s in tdata.sprites)
                {
                    allBlocks[file].details[s.n.ToLower()] = new Rect((float)s.x / (float)tdata.width, (float)s.y / (float)tdata.height, (float)s.w / (float)tdata.width, (float)s.h / (float)tdata.height);
                }
            }
            else
            {
                var tex2  = Resources.Load(file + ".packet.csv", typeof(TextAsset)) as TextAsset;
                var tdata = TextureAtlas.CreateFromStringCSV(tex2.text);
                //selectTex = Resources.Load(filename, typeof(Texture2D)) as Texture2D;

                srcTexs[file]   = null;
                allBlocks[file] = new DetailBlock();
                foreach (var s in tdata.sprites)
                {
                    allBlocks[file].details[s.n.ToLower()] = new Rect((float)s.x / 8192.0f, (float)s.y / 8192.0f, (float)s.w / 8192.0f, (float)s.h / 8192.0f);
                }
            }
            Debug.Log("add tex=" + file);
        }
    }
Exemplo n.º 22
0
        public Entity CreatePlayer(Vector2 position)
        {
            var dudeTexture = _contentManager.Load <Texture2D>("hero");
            var dudeAtlas   = TextureAtlas.Create("dudeAtlas", dudeTexture, 16, 16);

            var entity           = _world.CreateEntity();
            var animationFactory = new SpriteSheetAnimationFactory(dudeAtlas);

            animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0, 1, 2, 1 }));
            animationFactory.Add("walk", new SpriteSheetAnimationData(new[] { 6, 7, 8, 9, 10, 11 }, frameDuration: 0.1f));
            animationFactory.Add("jump", new SpriteSheetAnimationData(new[] { 10, 12 }, frameDuration: 1.0f, isLooping: false));
            animationFactory.Add("fall", new SpriteSheetAnimationData(new[] { 13, 14 }, frameDuration: 1.0f, isLooping: false));
            animationFactory.Add("swim", new SpriteSheetAnimationData(new[] { 18, 19, 20, 21, 22, 23 }));
            animationFactory.Add("kick", new SpriteSheetAnimationData(new[] { 15 }, frameDuration: 0.3f, isLooping: false));
            animationFactory.Add("punch", new SpriteSheetAnimationData(new[] { 26 }, frameDuration: 0.3f, isLooping: false));
            animationFactory.Add("cool", new SpriteSheetAnimationData(new[] { 17 }, frameDuration: 0.3f, isLooping: false));
            entity.Attach(new AnimatedSprite(animationFactory, "idle"));
            entity.Attach(new Transform2(position, 0, Vector2.One * 4));
            entity.Attach(new Body {
                Position = position, Size = new Vector2(32, 64), BodyType = BodyType.Dynamic
            });
            entity.Attach(new Player());
            return(entity);
        }
Exemplo n.º 23
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            var mpq = new MPQArchive("DIABDAT.MPQ");

            isoView.Level = TownLevel.Load(mpq);

            /*using (var wavStream = mpq.Open("music/dtowne.wav")) {
             *  var wavData = new byte[wavStream.Length];
             *  var wavLen = wavStream.Read(wavData, 0, (int)wavStream.Length);
             *  Debug.Assert(wavLen == wavStream.Length);
             *  music = new SoundEffect(wavData, 22050, AudioChannels.Stereo);
             * }*/

            charAtlas = TextureAtlas.Load(mpq, PlayerGfx.GetAnimPath(
                                              PlayerGfx.Class.Warrior,
                                              PlayerGfx.Armor.Light,
                                              PlayerGfx.Weapon.MaceShield,
                                              PlayerGfx.State.StandingInTown));
            standingAnim = new Animation(new Sprite(charAtlas), 1.0f / 13);

            charAtlas = TextureAtlas.Load(mpq, PlayerGfx.GetAnimPath(
                                              PlayerGfx.Class.Warrior,
                                              PlayerGfx.Armor.Light,
                                              PlayerGfx.Weapon.MaceShield,
                                              PlayerGfx.State.WalkingInTown));
            walkingAnim = new Animation(new Sprite(charAtlas), 1.0f / 13);

            player = new Creature {
                Position         = new CoordF(75.5f, 68.5f),
                CurrentAnimation = standingAnim
            };
            isoView.Level.Creatures.PushBack(player);
            isoView.Level.Map.PlaceCreature(player);
        }
Exemplo n.º 24
0
        public override void initialise()
        {
            sampleClipRectangle._init_(100, 200, 250, 150);

            sampleTexture = Mdx.graphics_.newTexture(Mdx.files_.@internal("mini2Dx.png"));
            sampleRegion  = Mdx.graphics_.newTextureRegion(sampleTexture);
            sampleRegion2 = Mdx.graphics_.newTextureRegion(sampleTexture).split(16, 17)[1][1];
            sampleRegion2.flip(false, true);
            sampleSprite         = Mdx.graphics_.newSprite(sampleTexture);
            sampleNinePatch      = Mdx.graphics_.newNinePatch(Mdx.graphics_.newTexture(Mdx.files_.@internal("ninepatch.png")), 6, 6, 6, 6);
            sampleAtlas          = Mdx.graphics_.newTextureAtlas(Mdx.files_.@internal("packfile.atlas"));
            sampleAtlasRegion    = sampleAtlas.findRegion("tileGreen", 47);
            sampleTilingDrawable = Mdx.graphics_.newTilingDrawable(Mdx.graphics_.newTextureRegion(Mdx.graphics_.newTexture(Mdx.files_.@internal("background.png"))));
            Mdx.graphicsContext_.setColor(Mdx.graphics_.newColor(1f, 1f, 1f, 1f));
            Mdx.graphicsContext_.setBackgroundColor(new MonoGameColor(Color.Blue));
            sampleSprite.setOriginCenter();
            music = Mdx.audio_.newMusic(Mdx.files_.@internal("music.ogg"));
            sound = Mdx.audio_.newSound(Mdx.files_.@internal("sound.wav"));

            Mdx.audio_.addMusicCompletionListener(new AudioCompletionListener());
            Mdx.audio_.addSoundCompletionListener(new AudioCompletionListener());

            Mdx.input_.newXboxGamePad((GamePad)Mdx.input_.getGamePads().get(0)).addListener(new UATInputProcessor(this));

            sampleShader = Mdx.graphics_.newShader("grayscaleShader");
            Mdx.graphicsContext_.setFont(Mdx.fonts_.newBitmapFont(Mdx.files_.@internal("arial24.fnt")));
            Mdx.graphicsContext_.getFont().setColor(Mdx.graphics_.newColor(255, 255, 255, 255));
            sampleFontCache = Mdx.graphicsContext_.getFont().newCache();
            sampleFontCache.setColor(Mdx.graphics_.newColor(255, 255, 255, 255));
            sampleFontCache.addText((Java.Lang.String) "Hello!\nBonjour!\nCiao!\nGuten tag!\nNamaste!", 400, 165, 100, Align.LEFT_, true);
            sampleFontCache.addText((Java.Lang.String) "Hello!\nBonjour!\nCiao!\nGuten tag!\nNamaste!", 500, 165, 100, Align.CENTER_, true);
            sampleFontCache.addText((Java.Lang.String) "Hello!\nBonjour!\nCiao!\nGuten tag!\nNamaste!", 600, 165, 100, Align.RIGHT_, true);
            sampleMap = new TiledMap();
            sampleMap._init_(Mdx.files_.@internal("orthogonal_no_cache.tmx"));
            Mdx.input_.setInputProcessor(new UATInputProcessor(this));
        }
Exemplo n.º 25
0
        //constructor
        public Slider(ref TextureAtlas atlas, string barTexture, string tickTexture)
        {
            if (atlas == null)
            {
                throw new ArgumentNullException("atlas");
            }
            if (barTexture == null)
            {
                throw new ArgumentNullException("barTexture");
            }
            if (tickTexture == null)
            {
                throw new ArgumentNullException("tickTexture");
            }

            inputEngine.MouseDown += onMouseDown;
            inputEngine.MouseUp   += onMouseUp;
            inputEngine.MouseMove += onMouseMove;

            barBitmap    = atlas.GetBitmap(barTexture);
            tickBitmap   = atlas.GetBitmap(tickTexture);
            sliderBitmap = new Bitmap(barBitmap.Width + tickBitmap.Width, Math.Max(barBitmap.Height, tickBitmap.Height));
            drawSlider();
        }
Exemplo n.º 26
0
        public void RemoveSpriteFromAtlas(CCSprite sprite)
        {
            // remove from TextureAtlas
            TextureAtlas.RemoveQuadAtIndex(sprite.AtlasIndex);

            // Cleanup sprite. It might be reused (issue #569)
            sprite.BatchNode = null;

            var uIndex = Descendants.IndexOf(sprite);

            if (uIndex >= 0)
            {
                // update all sprites beyond this one
                var count    = Descendants.Count;
                var elements = Descendants.Elements;

                for (var index = uIndex; index < count; ++index)
                {
                    elements[index].AtlasIndex--;
                }

                Descendants.RemoveAt(uIndex);
            }

            // remove children recursively
            var spriteChildren = sprite.Children;

            if (spriteChildren != null && spriteChildren.Count > 0)
            {
                var elements = spriteChildren.Elements;
                for (int i = 0, count = spriteChildren.Count; i < count; i++)
                {
                    RemoveSpriteFromAtlas((CCSprite)elements[i]);
                }
            }
        }
Exemplo n.º 27
0
        public static TextureAtlas CreateFromFile(ContentManager content, string filepath)
        {
            if (!File.Exists(filepath))
            {
                throw new ArgumentException("Invalid filepath provided!");
            }

            using (var file = new StreamReader(filepath))
            {
                var reader           = new XmlSerializer(typeof(TextureAtlasData));
                var textureAtlasData = (TextureAtlasData)reader.Deserialize(file);

                var sheetPath = textureAtlasData.ImagePath.Replace(".png", "");
                var sheet     = content.Load <Texture2D>(sheetPath);
                var atlas     = new TextureAtlas(sheetPath, sheet);

                foreach (var subTexture in textureAtlasData.SubTextures)
                {
                    atlas.CreateRegion(subTexture.Name.Replace(".png", ""), subTexture.X, subTexture.Y, subTexture.Width, subTexture.Height);
                }

                return(atlas);
            }
        }
Exemplo n.º 28
0
        public Entity CreateBlue(Vector2 position)
        {
            var dudeTexture = _contentManager.Load <Texture2D>("blueguy");
            var dudeAtlas   = TextureAtlas.Create("blueguyAtlas", dudeTexture, 16, 16);

            var entity      = _world.CreateEntity();
            var spriteSheet = new SpriteSheet {
                TextureAtlas = dudeAtlas
            };

            AddAnimationCycle(spriteSheet, "idle", new[] { 0, 1, 2, 3, 2, 1 });
            AddAnimationCycle(spriteSheet, "walk", new[] { 6, 7, 8, 9, 10, 11 });
            AddAnimationCycle(spriteSheet, "jump", new[] { 10, 12 }, false, 1.0f);
            entity.Attach(new AnimatedSprite(spriteSheet, "idle")
            {
                Effect = SpriteEffects.FlipHorizontally
            });
            entity.Attach(new Transform2(position, 0, Vector2.One * 4));
            entity.Attach(new Body {
                Position = position, Size = new Vector2(32, 64), BodyType = BodyType.Dynamic
            });
            entity.Attach(new Enemy());
            return(entity);
        }
Exemplo n.º 29
0
        public override void Load()
        {
            //----------------------------------------------------
            //test only
            TextureAtlas textureAtlas = new TextureAtlas(800, 600);
            int          areaId, x, y;

            for (int i = 0; i < 100; ++i)
            {
                var result2 = textureAtlas.AllocNewRectArea(100, 200, out areaId, out x, out y);
                if (result2 != TextureAtlasAllocResult.Ok)
                {
                }
            }
            //----------------------------------------------------
            FormTestWinGLControl form   = new FormTestWinGLControl();
            CanvasGL2d           canvas = new CanvasGL2d(this.Width, this.Height);

            form.SetGLPaintHandler((o, s) =>
            {
                canvas.Clear(PixelFarm.Drawing.Color.White);
            });
            form.Show();
        }
Exemplo n.º 30
0
        public void RemoveSpriteFromAtlas(CCSprite sprite)
        {
            // remove from TextureAtlas
            TextureAtlas.RemoveQuadAtIndex(sprite.AtlasIndex);

            // Cleanup sprite. It might be reused (issue #569)
            sprite.BatchNode = null;

            int uIndex = Descendants.IndexOf(sprite);

            if (uIndex >= 0)
            {
                Descendants.RemoveAt(uIndex);

                // update all sprites beyond this one
                int        count    = Descendants.Count;
                CCSprite[] elements = Descendants.Elements;

                for (; uIndex < count; ++uIndex)
                {
                    elements[uIndex].AtlasIndex--;
                }
            }

            // remove children recursively
            CCRawList <CCNode> pChildren = sprite.Children;

            if (pChildren != null && pChildren.Count > 0)
            {
                CCNode[] elements = pChildren.Elements;
                for (int i = 0, count = pChildren.Count; i < count; i++)
                {
                    RemoveSpriteFromAtlas((CCSprite)elements[i]);
                }
            }
        }
Exemplo n.º 31
0
        void InsertChild(CCParticleSystem pSystem, int index, int tag)
        {
            pSystem.AtlasIndex = index;

            if (TextureAtlas.TotalQuads + pSystem.TotalParticles > TextureAtlas.Capacity)
            {
                IncreaseAtlasCapacityTo(TextureAtlas.TotalQuads + pSystem.TotalParticles);

                // after a realloc empty quads of textureAtlas can be filled with gibberish (realloc doesn't perform calloc), insert empty quads to prevent it
                TextureAtlas.FillWithEmptyQuadsFromIndex(TextureAtlas.Capacity - pSystem.TotalParticles,
                                                         pSystem.TotalParticles);
            }

            // make room for quads, not necessary for last child
            if (pSystem.AtlasIndex + pSystem.TotalParticles != TextureAtlas.TotalQuads)
            {
                TextureAtlas.MoveQuadsFromIndex(index, index + pSystem.TotalParticles);
            }

            // increase totalParticles here for new particles, update method of particlesystem will fill the quads
            TextureAtlas.IncreaseTotalQuadsWith(pSystem.TotalParticles);

            UpdateAllAtlasIndexes();
        }
Exemplo n.º 32
0
        //constructor
        public Button(ref TextureAtlas atlas, string normalTexture, string downTexture = null, string hoverTexture = null)
        {
            if (atlas == null)
            {
                throw new ArgumentNullException("atlas");
            }
            if (normalTexture == null)
            {
                throw new ArgumentNullException("normalTexture");
            }

            inputEngine.MouseDown += onMouseDown;
            inputEngine.MouseUp   += onMouseUp;
            inputEngine.MouseMove += onMouseMove;

            this.atlas     = atlas;
            _normalTexture = normalTexture;
            _downTexture   = downTexture;
            _hoverTexture  = hoverTexture;

            Texture        = atlas.GetTexture(normalTexture);
            _hitBox.Width  = Width;
            _hitBox.Height = Height;
        }
Exemplo n.º 33
0
        public bool DrawToAtlas(TextureAtlas atlas, AtlasLocation location)
        {
            // Only ever called with a static image:
            Color32[] pixelBlock = Image.GetPixels32();

            int index      = 0;
            int atlasIndex = location.BottomLeftPixel();

            int height = Image.height;
            int width  = Image.width;

            // How many pixels must we add on to the end of the row to get to
            // the start of the row above? This is simply the dimension of the atlas:
            int rowDelta = atlas.Dimension;

            for (int h = 0; h < height; h++)
            {
                Array.Copy(pixelBlock, index, atlas.Pixels, atlasIndex, width);
                index      += width;
                atlasIndex += rowDelta;
            }

            return(true);
        }
Exemplo n.º 34
0
        void LayoutLabel()
        {
            if (FontAtlas == null || string.IsNullOrEmpty(Text))
            {
                ContentSize = CCSize.Zero;
                return;
            }

            TextureAtlas.RemoveAllQuads();
            Descendants.Clear();
            lettersInfo.Clear();

            FontAtlas.PrepareLetterDefinitions(Text);

            var start      = 0;
            var typesetter = new CCTLTextLayout(this);

            var length      = Text.Length;
            var insetBounds = labelDimensions;

            var layoutAvailable = true;

            if (insetBounds == CCSize.Zero)
            {
                insetBounds     = new CCSize(8388608, 8388608);
                layoutAvailable = false;
            }

            var boundsWidth              = insetBounds.Width;
            var contentScaleFactorWidth  = CCLabel.DefaultTexelToContentSizeRatios.Width;
            var contentScaleFactorHeight = CCLabel.DefaultTexelToContentSizeRatios.Height;

            List <CCTLLine> lineList = new List <CCTLLine>();

            while (start < length)// && textPosition.Y < insetBounds.Bottom)
            {
                // Now we ask the typesetter to break off a line for us.
                // This also will take into account line feeds embedded in the text.
                //  Example: "This is text \n with a line feed embedded inside it"
                int count = typesetter.SuggestLineBreak(start, boundsWidth);
                var line  = typesetter.GetLine(start, start + count);
                lineList.Add(line);

                start += count;
            }


            // Calculate our vertical starting position
            var totalHeight       = lineList.Count * LineHeight;
            var nextFontPositionY = totalHeight;

            if (Dimensions.Height > 0)
            {
                var labelHeightPixel = Dimensions.Height * contentScaleFactorHeight;
                if (totalHeight > labelHeightPixel)
                {
                    int numLines = (int)(labelHeightPixel / LineHeight);
                    totalHeight = numLines * LineHeight;
                }
                switch (VerticalAlignment)
                {
                case CCVerticalTextAlignment.Top:
                    nextFontPositionY = labelHeightPixel;
                    break;

                case CCVerticalTextAlignment.Center:
                    nextFontPositionY = (labelHeightPixel + totalHeight) * 0.5f;
                    break;

                case CCVerticalTextAlignment.Bottom:
                    nextFontPositionY = totalHeight;
                    break;

                default:
                    break;
                }
            }


            var   lineGlyphIndex = 0;
            float longestLine    = (labelDimensions.Width > 0) ? labelDimensions.Width : 0;

            // Used for calculating overlapping on last line character
            var lastCharWidth   = 0.0f;
            int lastCharAdvance = 0;

            // Define our horizontal justification
            var flushFactor = (float)HorizontalAlignment / (float)CCTextAlignment.Right;

            // We now loop through all of our line's glyph runs
            foreach (var line in lineList)
            {
                var gliphRun  = line.GlyphRun;
                var lineWidth = line.Bounds.Width * contentScaleFactorWidth;
                var flush     = line.PenOffsetForFlush(flushFactor, boundsWidth);

                foreach (var glyph in gliphRun)
                {
                    var letterPosition = glyph.Position;
                    var letterDef      = glyph.Definition;
                    lastCharWidth     = letterDef.Width * contentScaleFactorWidth;
                    letterPosition.X += flush;
                    letterPosition.Y  = (nextFontPositionY - letterDef.YOffset) / contentScaleFactorHeight;

                    //recordLetterInfo(letterPosition, glyph.def, lineGlyphIndex++);

                    var tmpInfo = new LetterInfo();

                    tmpInfo.Definition         = letterDef;
                    tmpInfo.Position           = letterPosition;
                    tmpInfo.ContentSize.Width  = letterDef.Width;
                    tmpInfo.ContentSize.Height = letterDef.Height;

                    if (lineGlyphIndex >= lettersInfo.Count)
                    {
                        lettersInfo.Add(tmpInfo);
                    }
                    else
                    {
                        lettersInfo[lineGlyphIndex] = tmpInfo;
                    }

                    lineGlyphIndex++;

                    lastCharAdvance = (int)glyph.Definition.XAdvance;
                }

                // calculate our longest line which is used for calculating our ContentSize
                if (lineWidth > longestLine)
                {
                    longestLine = lineWidth;
                }

                nextFontPositionY -= LineHeight;
            }

            CCSize tmpSize;

            // If the last character processed has an xAdvance which is less that the width of the characters image, then we need
            // to adjust the width of the string to take this into account, or the character will overlap the end of the bounding
            // box
            if (lastCharAdvance < lastCharWidth)
            {
                tmpSize.Width = longestLine - lastCharAdvance + lastCharWidth;
            }
            else
            {
                tmpSize.Width = longestLine;
            }

            tmpSize.Height = totalHeight;

            if (Dimensions.Height > 0)
            {
                tmpSize.Height = Dimensions.Height * contentScaleFactorHeight;
            }

            ContentSize = tmpSize / CCLabel.DefaultTexelToContentSizeRatios;

            lineList.Clear();

            CCRect   uvRect;
            CCSprite letterSprite;

            for (int c = 0; c < Children.Count; c++)
            {
                letterSprite = (CCSprite)Children[c];
                int tag = letterSprite.Tag;
                if (tag >= length)
                {
                    RemoveChild(letterSprite, true);
                }
                else if (tag >= 0)
                {
                    if (letterSprite != null)
                    {
                        uvRect = lettersInfo[tag].Definition.Subrect;
                        letterSprite.TextureRectInPixels = uvRect;
                        letterSprite.ContentSize         = uvRect.Size;
                    }
                }
            }

            UpdateQuads();
            UpdateColor();
        }
Exemplo n.º 35
0
 public bool DrawToAtlas(TextureAtlas atlas, AtlasLocation location)
 {
     return(Contents.DrawToAtlas(atlas, location));
 }
Exemplo n.º 36
0
        private void createNewBillboardAtlasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CreateFileDlg fileDlg = new CreateFileDlg();
              fileDlg.Caption = "Create a new Billboard Atlas file";
              fileDlg.Description = "Enter the name of the new atlas file and select the directory to create it in. Then press OK to continue.";
              fileDlg.InitialDirectory = EditorManager.Project.ProjectDir;
              fileDlg.Ext = ".atlas";
              fileDlg.AllowOverwrite = false;
              fileDlg.Filter = new string[] { ".atlas" };
              if (fileDlg.ShowDialog() != DialogResult.OK)
            return;

              TextureAtlas atlas = new TextureAtlas();
              atlas.Filename = EditorManager.Project.MakeRelative(fileDlg.FileName);
              TextureAtlasEditorDlg dlg = new TextureAtlasEditorDlg(true);
              dlg.Atlas = atlas;

              if (dlg.ShowDialog(this) != DialogResult.OK)
            return;
              dlg.Atlas.SaveToFile(null);
        }
Exemplo n.º 37
0
    /// <summary>
    /// Creates a new square texture atlas.
    /// </summary>
    /// <param name="size">The size of one side of the square texture.</param>
    /// <returns></returns>
    private int CreateAtlas()
    {
        TextureAtlas atlas = new TextureAtlas(atlasSize);

        int newIndex = 0;
        while (atlases.ContainsKey(newIndex))
        {
            ++newIndex;
        }

        atlases.Add(newIndex, atlas);

        return newIndex;
    }
Exemplo n.º 38
0
        protected override void Draw()
        {
            Window.DrawManager.BlendFunc(BlendFunc);

            TextureAtlas.DrawNumberOfQuads(QuadsToDraw, 0);
        }
Exemplo n.º 39
0
 public int CompareTo(TextureAtlas.TextureNode b)
 {
     if (this.tileV && b.tileV)
     {
         return -this.packedRect.width.CompareTo(b.packedRect.width);
     }
     if (this.tileV)
     {
         return -1;
     }
     if (b.tileV)
     {
         return 1;
     }
     return -this.packedRect.height.CompareTo(b.packedRect.height);
 }
Exemplo n.º 40
0
 public Sprite(TextureAtlas atlas)
 {
     texture = atlas.Texture;
     rects = atlas.Rects;
 }
        public StarlingGameSpriteBase()
        {
            instance = this;

            gametime.Start();

            this.Content = new Sprite().AttachTo(this);

            this.Content_layer0_ground = new Sprite().AttachTo(this.Content);
            this.Content_layer0_tracks = new Sprite().AttachTo(this.Content);
            this.Content_layer2_shadows = new Sprite().AttachTo(this.Content);
            this.Content_layer3_buildings = new Sprite().AttachTo(this.Content);

            this.Content_layer10_hiddenforgoggles = new Sprite().AttachTo(this.Content);
            this.Content_layer10_hiddenforgoggles.visible = false;

            this.info = new TextField(
                800,
                400,
                "Welcome to Starling!"
                ) { hAlign = HAlign.LEFT, vAlign = VAlign.TOP };


			// i can see text, cannot see images?
			info.AttachTo(this);
            //info.MoveTo(72, 8);





			this.stagescale = internalscale;

            onresize(
                (w, h) =>
                {
                    stagex = w * 0.5;
                    stagey = h * 0.8;
                    stagescale = internalscale * (w) / (800.0);


                }
            );



            #region Source0
            var SourceBitmapData0 = new ScriptCoreLib.ActionScript.flash.display.BitmapData(
                // 28MB
                //64 * 2,
                //64 * 2,

                 // 50 MB
                 2048,
                 2048,
                 true, 0x00000000
            );
            var Source0TextureCount = 0;
            // where to start?
            var Source0TextureTop = 0;
            var Source0TextureLeft = 0;

            // fighting mipmapping
            var Source0Padding = 4;

			// ?
            var Source0 = new XLazy<TextureAtlas>(
                 delegate
                 {
                     var SourceTexture = Texture.fromBitmapData(SourceBitmapData0);
                     var Source = new TextureAtlas(SourceTexture);


                     return Source;
                 }
              );
            #endregion



            #region new_tex_crop
            this.new_tex_crop =
               (asset, alpha, flipx, innersize, adjustAlpha, filter) =>
               {

                   var shape = ScriptCoreLib.ActionScript.Extensions.KnownEmbeddedResources.Default[asset].ToSprite();

                   return new_texsprite_crop(shape, alpha, flipx, innersize, adjustAlpha, filter);
               };


            this.new_texsprite_crop =
               (shape, alpha, flipx, innersize, adjustAlpha, filter) =>
               {


                   //var innersize = 64;
                   // outer 400, inner 64

                   // do we need to wrap?
                   if ((Source0TextureLeft + innersize) >= 2048)
                   {
                       // if so, goto next line
                       Source0TextureTop = Source0TextureMaxBottom;
                       Source0TextureLeft = 0;
                   }

                   var rect = new Rectangle(Source0TextureLeft, Source0TextureTop, innersize, innersize);

                   {

                       if (filter != null)
                           shape.filters = new[] { filter };

                       // this does not work!
                       //shape.alpha = 0.3;



                       // next image will appear right to us + padding to prevent bleed
                       Source0TextureLeft += innersize + Source0Padding;
                       Source0TextureMaxBottom = Source0TextureMaxBottom.Max(Source0TextureTop + innersize + Source0Padding);

                       var m = new Matrix();

                       // flip vertical?
                       if (flipx)
                       {
                           m.translate(-400, 0);
                           m.scale(-1, 1);
                       }

                       m.translate(
                           // where to draw? we need packer algorithm?
                           -(400 - rect.width) / 2 + rect.left,
                           -(400 - rect.height) / 2 + rect.top
                      );



                       // http://stackoverflow.com/questions/8035717/actionscript-3-draw-with-transparency-on-a-bitmap

                       if (adjustAlpha == null)
                           adjustAlpha = new ColorTransform();

                       adjustAlpha.alphaMultiplier = alpha;


                       // public void draw(IBitmapDrawable source, Matrix matrix, ColorTransform colorTransform, string blendMode, Rectangle clipRect);
                       //SourceBitmapData0.draw(shape, m, adjustAlpha, clipRect: rect);
                       SourceBitmapData0.draw(shape, m, adjustAlpha, null, rect);
                   }

                   var TextureIndex = Source0TextureCount;

                   Source0TextureCount++;

                   // Error	5	Cannot convert anonymous method to type 'FlashHeatZeeker.UnitPed.Library.Lazy<starling.textures.TextureAtlas>' because it is not a delegate type	X:\jsc.svn\examples\actionscript\svg\FlashHeatZeeker\FlashHeatZeeker.UnitPed\Library\StarlingGameSpriteWithPed.cs	178	43	FlashHeatZeeker.UnitPed
                   var y = new XLazy<TextureAtlas>(
                       delegate
                       {
                           Source0.Content.addRegion(TextureIndex.ToString(), rect);

                           return Source0.Content;
                       }
                    );


                   // ???
                   return () => y.Content.getTexture(TextureIndex.ToString());
               };
            #endregion


            #region new_tex96
            this.new_tex96 =
               (shape, innersize) =>
               {

                   // outer 400, inner 64

                   // do we need to wrap?
                   if ((Source0TextureLeft + innersize) >= 2048)
                   {
                       // if so, goto next line
                       Source0TextureTop = Source0TextureMaxBottom;
                       Source0TextureLeft = 0;
                   }

                   var rect = new Rectangle(Source0TextureLeft, Source0TextureTop, innersize, innersize);

                   {

                       // this does not work!
                       //shape.alpha = 0.3;



                       // next image will appear right to us
                       Source0TextureLeft += innersize + Source0Padding;
                       Source0TextureMaxBottom = Source0TextureMaxBottom.Max(Source0TextureTop + innersize + Source0Padding);

                       var m = new Matrix();
                       m.translate(
                           // where to draw? we need packer algorithm?
                           rect.left,
                           rect.top
                      );

                       //m.scale(64 / 400.0, 64 / 400.0);

                       // http://stackoverflow.com/questions/8035717/actionscript-3-draw-with-transparency-on-a-bitmap

                       var adjustAlpha = new ColorTransform();
                       adjustAlpha.alphaMultiplier = alpha;


                       SourceBitmapData0.draw(shape, m, adjustAlpha);
                   }

                   var TextureIndex = Source0TextureCount;

                   Source0TextureCount++;

                   // Error	5	Cannot convert anonymous method to type 'FlashHeatZeeker.UnitPed.Library.Lazy<starling.textures.TextureAtlas>' because it is not a delegate type	X:\jsc.svn\examples\actionscript\svg\FlashHeatZeeker\FlashHeatZeeker.UnitPed\Library\StarlingGameSpriteWithPed.cs	178	43	FlashHeatZeeker.UnitPed
                   var y = new XLazy<TextureAtlas>(
                       delegate
                       {
                           Source0.Content.addRegion(TextureIndex.ToString(), rect);

                           return Source0.Content;
                       }
                    );

                   return () => y.Content.getTexture(TextureIndex.ToString());
               };
            #endregion


            //var __bmd = new ScriptCoreLib.ActionScript.flash.display.BitmapData(96, 96, true, 0x00000000);
            //__bmd.draw(new white_jsc());
            var LogoTexture = new_tex96(new white_jsc());

            onbeforefirstframe += delegate
            {
                //var count = 64;
                var count = DefaultLogoCount;

                for (int i = 0; i < count; i++)
                    for (int yi = 0; yi < count; yi++)
                    {
                        var logo = new Image(LogoTexture()) { }.AttachTo(Content);

                        {
                            var cm = new Matrix();
                            cm.rotate(random.NextDouble() * Math.PI);
                            cm.translate(i * 96, yi * 96);

                            logo.transformationMatrix = cm;
                        }
                    }
            };


            // http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display3D/Context3D.html#driverInfo
            //Text = Starling.current.context.driverInfo;
            Text = "driverInfo missing";


            // how expensive is delegate call in a frame?
            onframe +=
                (stage, starling) =>
                {
                    if (this.frameid == 0)
                    {
                        if (this.onbeforefirstframe != null)
                            this.onbeforefirstframe(stage, starling);
                    }

                    this.frameid++;


                    if (!this.DisableDefaultContentDransformation)
                    {
                        var cm = new Matrix();
                        cm.scale(stagescale, stagescale);

                        if (autorotate)
                            cm.rotate(this.gametime.ElapsedMilliseconds * 0.001);

                        cm.translate(stagex, stagey);
                        this.Content.transformationMatrix = cm;
                    }


                    // does this cost us 40FPS??
                    //var texmem = (this.Source0TextureMaxBottom * 100 / 2048) + "%";

                    //this.info.text = new { this.frameid, texmem, this.Text }.ToString();

                };
        }
Exemplo n.º 42
0
        protected override LibGdxAtlas Read(ContentReader reader, LibGdxAtlas existingInstance)
        {
            var atlasContainer = new LibGdxAtlas();
            var numPages       = reader.ReadInt32();

            for (var p = 0; p < numPages; p++)
            {
                var assetName = reader.GetRelativeAssetPath(reader.ReadString());
                var texture   = reader.ContentManager.Load <Texture2D>(assetName);

                var regionCount = reader.ReadInt32();
                var subtextures = new Subtexture[regionCount];
                var regionNames = new string[regionCount];

                for (var i = 0; i < regionCount; i++)
                {
                    var rect = new Rectangle();
                    var name = reader.ReadString();
                    rect.X      = reader.ReadInt32();
                    rect.Y      = reader.ReadInt32();
                    rect.Width  = reader.ReadInt32();
                    rect.Height = reader.ReadInt32();

                    var hasSplits = reader.ReadBoolean();
                    if (hasSplits)
                    {
                        subtextures[i] = new NinePatchSubtexture(texture, rect, reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32());
                    }
                    else
                    {
                        subtextures[i] = new Subtexture(texture, rect);
                    }

                    var hasPads = reader.ReadBoolean();
                    if (hasPads)
                    {
                        ((NinePatchSubtexture)subtextures[i]).HasPadding = true;
                        ((NinePatchSubtexture)subtextures[i]).PadLeft    = reader.ReadInt32();
                        ((NinePatchSubtexture)subtextures[i]).PadRight   = reader.ReadInt32();
                        ((NinePatchSubtexture)subtextures[i]).PadTop     = reader.ReadInt32();
                        ((NinePatchSubtexture)subtextures[i]).PadBottom  = reader.ReadInt32();
                    }

                    var index = reader.ReadInt32();

                    // animation
                    if (index != -1)
                    {
                        List <Subtexture> frames;
                        if (!atlasContainer.Animations.TryGetValue(name, out frames))
                        {
                            frames = new List <Subtexture>();
                            atlasContainer.Animations[name] = frames;
                        }

                        frames.Insert(index, subtextures[i]);
                    }

                    regionNames[i] = name;
                }

                var atlas = new TextureAtlas(regionNames, subtextures);
                atlasContainer.Atlases.Add(atlas);
            }

            return(atlasContainer);
        }
Exemplo n.º 43
0
        private void LoadTextures() {
            Tracer.TraceLine("Start loading textures");
            this.texturesMap = new Dictionary<string, string[]>();
            this.Textures = new TextureAtlas();

            foreach (var materialInfo in this.MaterialProvider.GetAll()) {
                var textures = new List<string>();

                if (materialInfo.Diffuse != null)
                {
                    ProcessMaterialTexture((ImageTextureInfo)materialInfo.Diffuse, textures);
                }

                if (materialInfo.BumpMap != null)
                {
                    ProcessMaterialTexture((ImageTextureInfo)materialInfo.BumpMap, textures);
                }

                if (textures.Any())
                    texturesMap.Add(materialInfo.Name.ToLower(), textures.ToArray());
            }
            Tracer.TraceLine("Complete loading textures");
        }
Exemplo n.º 44
0
 public static bool Overlap(TextureAtlas.TextureNode a, TextureAtlas.TextureNode b)
 {
     if (a.tileV || b.tileV)
     {
         return ((a.packedRect.x <= (b.packedRect.x + b.packedRect.width)) && ((a.packedRect.x + a.packedRect.width) >= b.packedRect.x));
     }
     return ((((a.packedRect.x <= (b.packedRect.x + b.packedRect.width)) && ((a.packedRect.x + a.packedRect.width) >= b.packedRect.x)) && (a.packedRect.y <= (b.packedRect.y + b.packedRect.height))) && ((a.packedRect.y + a.packedRect.height) >= b.packedRect.y));
 }
Exemplo n.º 45
0
        public void LoadContent(ContentManager content)
        {
            Texture2D tileMap = content.Load <Texture2D>("sprites/tileMap");

            groundTileAtlas = new TextureAtlas(tileMap, TILE_COLUMNS, TILE_ROWS, Config.TILE_SIZE, Config.TILE_SIZE);
        }
Exemplo n.º 46
0
        public LatitudeLongitudeGrid()
        {
            Ellipsoid globeShape = Ellipsoid.Wgs84;
            _window = Device.CreateWindow(800, 600, "Chapter 4:  Latitude Longitude Grid");
            _window.Resize += OnResize;
            _window.RenderFrame += OnRenderFrame;
            _sceneState = new SceneState();
            _camera = new CameraLookAtPoint(_sceneState.Camera, _window, globeShape);
            _clearState = new ClearState();

            _sceneState.Camera.PerspectiveNearPlaneDistance = 0.01 * globeShape.MaximumRadius;
            _sceneState.Camera.PerspectiveFarPlaneDistance = 10.0 * globeShape.MaximumRadius;
            _sceneState.Camera.ZoomToTarget(globeShape.MaximumRadius);

            ///////////////////////////////////////////////////////////////////

            IList<GridResolution> gridResolutions = new List<GridResolution>();
            gridResolutions.Add(new GridResolution(
                new Interval(0, 1000000, IntervalEndpoint.Closed, IntervalEndpoint.Open),
                new Vector2D(0.005, 0.005)));
            gridResolutions.Add(new GridResolution(
                new Interval(1000000, 2000000, IntervalEndpoint.Closed, IntervalEndpoint.Open),
                new Vector2D(0.01, 0.01)));
            gridResolutions.Add(new GridResolution(
                new Interval(2000000, 20000000, IntervalEndpoint.Closed, IntervalEndpoint.Open),
                new Vector2D(0.05, 0.05)));
            gridResolutions.Add(new GridResolution(
                new Interval(20000000, double.MaxValue, IntervalEndpoint.Closed, IntervalEndpoint.Open),
                new Vector2D(0.1, 0.1)));

            _globe = new LatitudeLongitudeGridGlobe(_window.Context);
            _globe.Texture = Device.CreateTexture2D(new Bitmap("NE2_50M_SR_W_4096.jpg"), TextureFormat.RedGreenBlue8, false);
            _globe.Shape = globeShape;
            _globe.GridResolutions = new GridResolutionCollection(gridResolutions);

            ///////////////////////////////////////////////////////////////////

            Vector3D vancouver = globeShape.ToVector3D(new Geodetic3D(Trig.ToRadians(-123.06), Trig.ToRadians(49.13), 0));

            TextureAtlas atlas = new TextureAtlas(new Bitmap[]
            {
                new Bitmap("building.png"),
                Device.CreateBitmapFromText("Vancouver", new Font("Arial", 24))
            });

            _vancouverLabel = new BillboardCollection(_window.Context);
            _vancouverLabel.Texture = Device.CreateTexture2D(atlas.Bitmap, TextureFormat.RedGreenBlueAlpha8, false);
            _vancouverLabel.DepthTestEnabled = false;
            _vancouverLabel.Add(new Billboard()
            {
                Position = vancouver,
                TextureCoordinates = atlas.TextureCoordinates[0]
            });
            _vancouverLabel.Add(new Billboard()
            {
                Position = vancouver,
                TextureCoordinates = atlas.TextureCoordinates[1],
                HorizontalOrigin = HorizontalOrigin.Left
            });

            atlas.Dispose();
        }
Exemplo n.º 47
0
    //-----------------------------------------------------------------------------
    // Method:	MakeQuadVB()
    // Desc:	Creates a new quad buffer of maximum size and creates the material
    public static GameObject MakeQuadBatch( int num_quads, TextureAtlas atlas, int atlas_idx, 
		bool rotate, bool uniform_scale, bool additive, int layer )
    {
        GameObject gameObject = new GameObject();
        gameObject.layer = layer;

        gameObject.name = "Primitive" + m_uniqueVBID.ToString() + " [QUADBATCH]";
        m_uniqueVBID++;

        PrimitiveQuadBatchInfo info = gameObject.AddComponent<PrimitiveQuadBatchInfo>();
        info.m_NumQuads = num_quads;
        info.m_QuadSearchCursor = 0;

        info.m_AltasIdx = atlas_idx;

        info.m_Rotating = rotate;
        info.m_UniformScale = uniform_scale;

        info.m_QuadDefs = new BatchedQuadDef[num_quads];

        int numVerts = num_quads*4;
        int numIndices = num_quads*6;

        MeshFilter meshFilter = gameObject.AddComponent<MeshFilter>();
        MeshRenderer meshRenderer = gameObject.AddComponent<MeshRenderer>();

        meshFilter.sharedMesh = new Mesh();
        Mesh mesh = meshFilter.sharedMesh;

        mesh.MarkDynamic();		// Unity4 only
        mesh.Clear();

        info.m_Vertices = new Vector3[numVerts];
        info.m_UVs = new Vector2[numVerts];
        info.m_Colours = new Color[numVerts];
        int[] myTris = new int[numIndices];

        for( int v = 0; v<numVerts; v++ )
        {
            info.m_Colours[v] = new Color( 1.0f, 1.0f, 1.0f, 1.0f );
        }

        int triIdx = 0;
        for( int q = 0; q<num_quads; q++ )
        {
            info.m_QuadDefs[q] = new BatchedQuadDef();

            info.m_QuadDefs[q].m_TextureIdx = 0;

            info.m_QuadDefs[q].m_Position = new Vector3( -1000.0f, -1000.0f, -1000.0f );
            info.m_QuadDefs[q].m_Scale = Vector2.one;

            info.m_QuadDefs[q].m_Rotation = 0.0f;
            info.m_QuadDefs[q].m_Colour = new Color( 1.0f, 1.0f, 1.0f, 1.0f );
            info.m_QuadDefs[q].m_Active = false;

            info.m_Vertices[q*4 + 0] = new Vector3( 1100.0f, 100.0f, 0.0f );
            info.m_UVs[q*4 + 0] = new Vector2( 0.0f, 0.0f );
            info.m_Vertices[q*4 + 1] = new Vector3( 1100.0f, 200.0f, 0.0f );
            info.m_UVs[q*4 + 1] = new Vector2( 0.0f, 1.0f );
            info.m_Vertices[q*4 + 2] = new Vector3( 1200.0f, 200.0f, 0.0f );
            info.m_UVs[q*4 + 2] = new Vector2( 1.0f, 1.0f );
            info.m_Vertices[q*4 + 3] = new Vector3( 1200.0f, 100.0f, 0.0f );
            info.m_UVs[q*4 + 3] = new Vector2( 1.0f, 0.0f );

            int baseIdx = q*4;
            myTris[triIdx++] = baseIdx;
            myTris[triIdx++] = baseIdx + 1;
            myTris[triIdx++] = baseIdx + 2;

            myTris[triIdx++] = baseIdx;
            myTris[triIdx++] = baseIdx + 2;
            myTris[triIdx++] = baseIdx + 3;
        }

        //	Apply the verts to make the plane
        mesh.vertices = info.m_Vertices;
        mesh.uv = info.m_UVs;
        mesh.colors = info.m_Colours;
        mesh.triangles = myTris;

        mesh.RecalculateBounds();
        //		mesh.RecalculateNormals();

        //	Create a unique material with the alpha shader
        string shader = "EchoShader/AlphaBlended";
        if( additive )
            shader = "EchoShader/AlphaAdditive";

        Material newMaterial = new Material( Shader.Find( shader ) );
        //		Material newMaterial = new Material( Shader.Find( "WOTD/UnlitAlpha" ) );
        meshRenderer.sharedMaterial = newMaterial;

        meshRenderer.sharedMaterial.mainTexture = atlas.m_TexturePage;
        meshRenderer.sharedMaterial.color = new Color( 1.0f, 1.0f, 1.0f, 1.0f );

        meshRenderer.sharedMaterial.renderQueue = 3500;

        return gameObject;
    }
Exemplo n.º 48
0
	private GUIContent getPreview(TextureAtlas tileset, int index, SerializedProperty sequence){
		if (tileset == null)
			return new GUIContent("No valid Tileset found");
		if (tileset.texture == null)
			return new GUIContent("Tileset has no valid texture");
		if (index == -1)
			return new GUIContent(tileset.texture);
		index = (index+1)%sequence.arraySize;
		Texture2D tex = tileset.getSubtexture(null, sequence.GetArrayElementAtIndex(index).intValue % (tileset.width * tileset.height));
		if (style.normal.background != tex)
			style.normal.background = tex;
		return tex == null ? new GUIContent("Texture cannot be read") : null;
	}
Exemplo n.º 49
0
    /// <summary>
    /// Draw the atlas and sprite selection fields.
    /// </summary>
    protected bool OnDrawProperties()
    {
        mSprite = mWidget;
        //		Debug.Log(mSprite);
        ComponentSelector.Draw<UIAtlas>(mSprite.atlas, OnSelectAtlas);
        if (mSprite.atlas == null) return false;

        string spriteName = SpriteField(mSprite.atlas, mSprite.spriteName);

        if (mSprite.spriteName != spriteName)
        {
            NGUIEditorTools.RegisterUndo("Sprite Change", mSprite);
            mSprite.spriteName = spriteName;
        //			mSprite.MakePixelPerfect();
            EditorUtility.SetDirty(mSprite.gameObject);
        }
        return true;
    }
        private void CreateScene()
        {
            DisposeScene();

            _ellipsoid = new TessellatedGlobe();
            _ellipsoid.Shape = _globeShape;
            _ellipsoid.NumberOfSlicePartitions = 64;
            _ellipsoid.NumberOfStackPartitions = 32;

            ///////////////////////////////////////////////////////////////////

            Mesh mesh = GeographicGridEllipsoidTessellator.Compute(_globeShape,
                64, 32, GeographicGridEllipsoidVertexAttributes.Position);

            _wireframe = new Wireframe(_window.Context, mesh);
            _wireframe.Width = 2;

            ///////////////////////////////////////////////////////////////////

            _axes = new Axes();
            _axes.Length = 1.5;
            _axes.Width = 3;

            ///////////////////////////////////////////////////////////////////

            Vector3D p = _globeShape.ToVector3D(new Geodetic3D(0, Trig.ToRadians(45), 0));
            Vector3D deticNormal = _globeShape.GeodeticSurfaceNormal(p);
            Vector3D centricNormal = Ellipsoid.CentricSurfaceNormal(p);

            double normalLength = _globeShape.MaximumRadius;
            Vector3D pDetic = p + (normalLength * deticNormal);
            Vector3D pCentric = p + (normalLength * centricNormal);

            VertexAttributeFloatVector3 positionAttribute = new VertexAttributeFloatVector3("position", 4);
            positionAttribute.Values.Add(p.ToVector3F());
            positionAttribute.Values.Add(pDetic.ToVector3F());
            positionAttribute.Values.Add(p.ToVector3F());
            positionAttribute.Values.Add(pCentric.ToVector3F());

            VertexAttributeRGBA colorAttribute = new VertexAttributeRGBA("color", 4);
            colorAttribute.AddColor(Color.DarkGreen);
            colorAttribute.AddColor(Color.DarkGreen);
            colorAttribute.AddColor(Color.DarkCyan);
            colorAttribute.AddColor(Color.DarkCyan);

            Mesh polyline = new Mesh();
            polyline.PrimitiveType = PrimitiveType.Lines;
            polyline.Attributes.Add(positionAttribute);
            polyline.Attributes.Add(colorAttribute);

            _normals = new Polyline();
            _normals.Set(_window.Context, polyline);
            _normals.Width = 3;

            ///////////////////////////////////////////////////////////////////
            Font font = new Font("Arial", 24);
            IList<Bitmap> labelBitmaps = new List<Bitmap>(2);
            labelBitmaps.Add(Device.CreateBitmapFromText("Geodetic", font));
            labelBitmaps.Add(Device.CreateBitmapFromText("Geocentric", font));
            font.Dispose();

            TextureAtlas atlas = new TextureAtlas(labelBitmaps);

            _labels = new BillboardCollection(_window.Context, 2);
            _labels.Texture = Device.CreateTexture2D(atlas.Bitmap, TextureFormat.RedGreenBlueAlpha8, false);
            _labels.Add(new Billboard()
            {
                Position = pDetic,
                TextureCoordinates = atlas.TextureCoordinates[0],
                Color = Color.DarkGreen,
                HorizontalOrigin = HorizontalOrigin.Right,
                VerticalOrigin = VerticalOrigin.Bottom
            });
            _labels.Add(new Billboard()
            {
                Position = pCentric,
                TextureCoordinates = atlas.TextureCoordinates[1],
                Color = Color.DarkCyan,
                HorizontalOrigin = HorizontalOrigin.Right,
                VerticalOrigin = VerticalOrigin.Bottom
            });

            atlas.Dispose();

            ///////////////////////////////////////////////////////////////////
            Vector3D east = Vector3D.UnitZ.Cross(deticNormal);
            Vector3D north = deticNormal.Cross(east);

            _tangentPlane = new Plane(_window.Context);
            _tangentPlane.Origin = p;
            _tangentPlane.XAxis = east;
            _tangentPlane.YAxis = north;
            _tangentPlane.OutlineWidth = 3;
        }
Exemplo n.º 51
0
    //-----------------------------------------------------------------------------
    // Method:	InitialiseAtlases
    // Desc:	Sets all the atlas texture data
    public void InitialiseAtlases()
    {
        //	Create them all
        for( int a = 0; a<(int)TextureAtlas.AtlasID.NUM; a++ )
            m_Atlases[a] = new TextureAtlas();

        //	Load the textures
        m_Atlases[(int)TextureAtlas.AtlasID.PARTICLE_FX].m_TexturePage =
            Resources.Load( "FX_Atlas" ) as Texture;
        m_Atlases[(int)TextureAtlas.AtlasID.PARTICLE_FX_ALPHA].m_TexturePage =
            Resources.Load( "FX_Alpha_Atlas" ) as Texture;
        m_Atlases[(int)TextureAtlas.AtlasID.NUMBERS].m_TexturePage =
            Resources.Load( "Numbers_Atlas" ) as Texture;

        if( FrontEnd.instance != null )
        {
            m_Atlases[(int)TextureAtlas.AtlasID.FRONTEND].m_TexturePage =
                Resources.Load( FrontEnd.instance.m_AtlasFile ) as Texture;
            if (m_Atlases[(int)TextureAtlas.AtlasID.FRONTEND].m_TexturePage == null)
                Debug.Log ("Failed to load Atlas " + FrontEnd.instance.m_AtlasFile);
        }
        else
        {
            m_Atlases[(int)TextureAtlas.AtlasID.FRONTEND].m_TexturePage =
                Resources.Load( "Numbers_Atlas" ) as Texture;
        }

        m_Atlases[(int)TextureAtlas.AtlasID.PLAYER].m_TexturePage =
            Resources.Load( "Player_Atlas" ) as Texture;
        m_Atlases[(int)TextureAtlas.AtlasID.ELVIS].m_TexturePage =
            Resources.Load( "Elvis_Atlas" ) as Texture;
        m_Atlases[(int)TextureAtlas.AtlasID.OBSTACLES].m_TexturePage =
            Resources.Load( "Obstacles_Atlas" ) as Texture;
        m_Atlases[(int)TextureAtlas.AtlasID.COINS].m_TexturePage =
            Resources.Load( "Coins_Atlas" ) as Texture;
        m_Atlases[(int)TextureAtlas.AtlasID.PLATFORMS].m_TexturePage =
            Resources.Load( "Platforms_Atlas" ) as Texture;

        //	Set up the FX atlases
        TextureAtlas fxAtlas = m_Atlases[(int)TextureAtlas.AtlasID.PARTICLE_FX];
        fxAtlas.m_NumElements = (int)TextureAtlas.ParticleFX.NUM;
        fxAtlas.m_UVSet = new Vector4[fxAtlas.m_NumElements];

        fxAtlas.m_UVSet[(int)TextureAtlas.ParticleFX.SHINE] = new Vector4( 0.0f, 0.5f, 0.5f, 1.0f );
        fxAtlas.m_UVSet[(int)TextureAtlas.ParticleFX.BANG_PIECES] = new Vector4( 0.5f, 0.5f, 1.0f, 1.0f );
        fxAtlas.m_UVSet[(int)TextureAtlas.ParticleFX.GLOW_RING] = new Vector4( 0.0f, 0.0f, 0.5f, 0.5f );
        fxAtlas.m_UVSet[(int)TextureAtlas.ParticleFX.GLOW] = new Vector4( 0.5f, 0.0f, 1.0f, 0.5f );

        TextureAtlas fxAlphaAtlas = m_Atlases[(int)TextureAtlas.AtlasID.PARTICLE_FX_ALPHA];
        fxAlphaAtlas.m_NumElements = (int)TextureAtlas.ParticleFXAlpha.NUM;
        fxAlphaAtlas.m_UVSet = new Vector4[fxAtlas.m_NumElements];

        fxAlphaAtlas.m_UVSet[(int)TextureAtlas.ParticleFXAlpha.DUST] = new Vector4( 0.0f, 0.0f, 1.0f, 1.0f );

        //	And the numbers
        TextureAtlas numbersAtlas = m_Atlases[(int)TextureAtlas.AtlasID.NUMBERS];
        numbersAtlas.m_NumElements = (int)TextureAtlas.Numbers.NUM;
        numbersAtlas.m_UVSet = new Vector4[numbersAtlas.m_NumElements];

        for( int n = 0; n<10; n++ )
        {
            int column = n%4;
            int row = 3 - n/4;

            float uStart = (float)column*0.25f;
            float vStart = (float)row*0.25f;

            numbersAtlas.m_UVSet[n] = new Vector4( uStart, vStart, uStart + 0.25f, vStart + 0.25f );
        }

        numbersAtlas.m_UVSet[(int)TextureAtlas.Numbers.NUM_COLON] = new Vector4( 0.0f, 0.0f, 0.25f, 0.25f );
        numbersAtlas.m_UVSet[(int)TextureAtlas.Numbers.NUM_PERCENT] = new Vector4( 0.75f, 0.25f, 1.0f, 0.5f );
        numbersAtlas.m_UVSet[(int)TextureAtlas.Numbers.NUM_TIMES] = new Vector4( 0.5f, 0.25f, 0.75f, 0.5f );

        // And the front-end
        TextureAtlas frontendAtlas = m_Atlases[(int)TextureAtlas.AtlasID.FRONTEND];
        frontendAtlas.m_NumElements = TextureAtlas.maxFrontendElements;
        frontendAtlas.m_UVSet = new Vector4[frontendAtlas.m_NumElements]; // Setup dynamically by FastGUIElement

        //	The player atlas - just break it up in pieces for now to leave it open for animation
        TextureAtlas playerAtlas = m_Atlases[(int)TextureAtlas.AtlasID.PLAYER];
        playerAtlas.m_NumElements = 64;
        playerAtlas.m_UVSet = new Vector4[playerAtlas.m_NumElements];

        for( int p = 0; p<64; p++ )
        {
            float uTex = ((float)(p%8))*0.125f;
            float vTex = (1.0f - 0.125f) - ((float)(p/8))*0.125f;

            playerAtlas.m_UVSet[p] = new Vector4( uTex, vTex, uTex + 0.125f, vTex + 0.125f );
        }

        //	Same for Elvis
        TextureAtlas elvisAtlas = m_Atlases[(int)TextureAtlas.AtlasID.ELVIS];
        elvisAtlas.m_NumElements = 64;
        elvisAtlas.m_UVSet = new Vector4[elvisAtlas.m_NumElements];

        for( int e = 0; e<64; e++ )
        {
            float uTex = ((float)(e%8))*0.125f;
            float vTex = ((float)(e/8))*0.125f;

            elvisAtlas.m_UVSet[e] = new Vector4( uTex, vTex, uTex + 0.125f, vTex + 0.125f );
        }

        //	Obstacle atlas
        TextureAtlas obstacleAtlas = m_Atlases[(int)TextureAtlas.AtlasID.OBSTACLES];
        obstacleAtlas.m_NumElements = (int)TextureAtlas.Obstacles.NUM;
        obstacleAtlas.m_UVSet = new Vector4[obstacleAtlas.m_NumElements];

        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.BLOCK] = new Vector4( 0.25f, 0.0f, 0.5f, 0.125f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.BLOCK_LEFT] = new Vector4( 0.5f, 0.0f, 0.75f, 0.125f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.BLOCK_RIGHT] = new Vector4( 0.75f, 0.0f, 1.0f, 0.125f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.COLUMN_BOTTOM] = new Vector4( 0.25f, 0.125f, 0.5f, 0.25f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.COLUMN_MIDDLE] = new Vector4( 0.5f, 0.125f, 0.75f, 0.25f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.COLUMN_TOP] = new Vector4( 0.75f, 0.125f, 1.0f, 0.25f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.BLACK_LIMO_FRONT] = new Vector4( 0.0f, 0.25f, 0.5f, 0.375f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.BLACK_LIMO_MIDDLE] = new Vector4( 0.5f, 0.25f, 0.75f, 0.375f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.BLACK_LIMO_END] = new Vector4( 0.75f, 0.25f, 1.0f, 0.375f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.WHITE_LIMO_FRONT] = new Vector4( 0.0f, 0.375f, 0.5f, 0.5f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.WHITE_LIMO_MIDDLE] = new Vector4( 0.5f, 0.375f, 0.75f, 0.5f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.WHITE_LIMO_END] = new Vector4( 0.75f, 0.375f, 1.0f, 0.5f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.PINK_LIMO_FRONT] = new Vector4( 0.0f, 0.75f, 0.5f, 0.875f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.PINK_LIMO_MIDDLE] = new Vector4( 0.5f, 0.75f, 0.75f, 0.875f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.PINK_LIMO_END] = new Vector4( 0.75f, 0.75f, 1.0f, 0.875f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.BLUE_LIMO_FRONT] = new Vector4( 0.0f, 0.875f, 0.5f, 1.0f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.BLUE_LIMO_MIDDLE] = new Vector4( 0.5f, 0.875f, 0.75f, 1.0f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.BLUE_LIMO_END] = new Vector4( 0.75f, 0.875f, 1.0f, 1.0f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.NEON_SIGN] = new Vector4( 0.0f, 0.0f, 0.25f, 0.25f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.NEON_HOTEL] = new Vector4( 0.0f, 0.5f, 0.25f, 0.75f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.NEON_SHOE] = new Vector4( 0.25f, 0.625f, 0.5f, 0.75f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.NEON_COWBOY] = new Vector4( 0.25f, 0.5f, 0.5f, 0.625f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.NEON_CHAPEL] = new Vector4( 0.5f, 0.5f, 0.75f, 0.625f );
        obstacleAtlas.m_UVSet[(int)TextureAtlas.Obstacles.NEON_WIDE] = new Vector4( 0.5f, 0.625f, 1.0f, 0.75f );

        //	Coins atlas
        TextureAtlas coinsAtlas = m_Atlases[(int)TextureAtlas.AtlasID.COINS];
        coinsAtlas.m_NumElements = 64;
        coinsAtlas.m_UVSet = new Vector4[coinsAtlas.m_NumElements];

        for( int e = 0; e<32; e++ )
        {
            float uTex = ((float)(e%4))*0.25f;
            float vTex = ((float)(e/4))*0.125f;

            coinsAtlas.m_UVSet[e] = new Vector4( uTex, vTex, uTex + 0.25f, vTex + 0.125f );
        }

        //	Platform atlas
        TextureAtlas platformAtlas = m_Atlases[(int)TextureAtlas.AtlasID.PLATFORMS];
        platformAtlas.m_NumElements = (int)TextureAtlas.Platforms.NUM;
        platformAtlas.m_UVSet = new Vector4[platformAtlas.m_NumElements];

        platformAtlas.m_UVSet[(int)TextureAtlas.Platforms.SOLID] = new Vector4( 0.0f, 0.5f, 1.0f, 1.0f );
        platformAtlas.m_UVSet[(int)TextureAtlas.Platforms.PASS_THROUGH] = new Vector4( 0.0f, 0.426f, 1.0f, 0.5f );
    }