TexturePacker Extension for ShiVa 3D

2013-02-01 Christian Herzog

This ShiVa importer is not available anymore.
Please check out our new tutorial: Creating sprite sheets for ShiVa

This is a guest blogpost from Christian Herzog!

My first product got published on the ShiVa Asset Store: an extension to support the awesome program TexturePacker by Andreas Löw. If you don’t know of it yet, check it out at TexturePacker. Here is a screenshot of the supplied demo, showing off all the supported features:

Models and HUD

Features

Usage

Create your atlas with TexturePacker
  1. Create your atlas with TexturePacker:
    • Data Format is Generic XML. (Update TexturePacker 3.0.5: now there is a designated Shiva3D Exporter)
    • Texture Format is PNG.
    • Allow Rotation is only supported for texturing Models. HUDs are not supported!
    • Trim Mode is None.
    • Press the Publish button. This will create 2 files: an XML and a PNG.
  2. Import the PNG and the XML via the Data Explorer into Shiva and add them as Resources to your game:
    Import the PNG
    Import the XML
  3. If texturing a Model, create a Material with the same name as the texture, configure it such that it uses the texture and also add it to the Resources of your game.

You are now ready to use the atlas!

Here is some example code:

local hUser = application.getCurrentUser ( )

application.setCurrentUserScene ( "TexturePacker" )

--Load atlas data:
--Use sendEventImmediate!
user.sendEventImmediate ( hUser, "TexturePacker", "onLoadAtlas", "atlasTexturePacker" )
--user.sendEventImmediate ( hUser, "TexturePacker", "onLoadAtlas", "otherAtlas" )

--Texturize Model via code:
user.sendEventImmediate ( hUser, "TexturePacker", "onSetObjectTexture",
    application.getCurrentUserSceneTaggedObject ( "obj8" ), "tp05" )
user.sendEventImmediate ( hUser, "TexturePacker", "onSetObjectTexture",
    application.getCurrentUserSceneTaggedObject ( "obj1" ), "tp01" )
user.sendEventImmediate ( hUser, "TexturePacker", "onSetObjectTexture",
    application.getCurrentUserSceneTaggedObject ( "obj2" ), "tp02" )

--Or use Object AI "TexturePackerAI" (done for obj3 and obj4)

Best you take a look at the supplied TexturePackerDemo. Set your viewport to Android Landscape (800×480) for best results.

Here’s a snapshot of a little game I’m currently working on, utilizing the TexturePacker extension (every texture is coming out of an atlas):

Game in Progress

Feedback is welcome!

This ShiVa importer is not available anymore.
Please check out our new tutorial: Creating sprite sheets for ShiVa

Did you like the tutorial? Please share!