Support for texturemap tile margins.

A place to post your custom classes and engine extensions to share with the community.

Support for texturemap tile margins.

Postby medium8 » Sun Mar 16, 2014 6:22 pm

Demotis has suggested IGE support for tiled textures with margins (http://www.isogenicengine.com/forum/viewtopic.php?f=6&t=63).
I wanted this support too, and decided to try to implement this feature as a class extension.
The solution is simplier, as expected, and here is it :)

The generated tile map keeps the tile width and height settings, but draws additional pixels left, right and above the tile.

How to use:

self.tileMap1 = new paddedTextureMap()
.id('tileMap1')
.isometricMounts(true)
.tileWidth(16)
.tileHeight(16)

.paddingX(4)
.paddingY(4)
.paddingZ(16)

.mount(self.objectScene);

Standard texture in this example should have the size 32x16 px.
But with paddings set, texture image (cell) should have 40px width (tileWidth 16px + paddingX 4px + tileHeight 16px + +paddingY 4px) and 32px height (tileHeight 16px + paddingZ 16px). Otherwise it will be "fitted" (deformed) to the original tile size.

Enjoy!
Attachments
paddedTextureMap.js.zip
(535 Bytes) Downloaded 661 times
medium8
 
Posts: 3
Joined: Sun Mar 16, 2014 4:30 pm

Re: Support for texturemap tile margins.

Postby Demotis » Sun Mar 16, 2014 9:53 pm

Oh !!! Great!!! Now I have to go back and change the hack I used to make this work. :) Thanks for the additional work.

Just kidding.

Thanks for taking the time to look into this. I was really missing this feature as I wanted to just use textures and not create ISO tiles for each tile that really should have just been a texture map with no real "3D" positioning needed. I'll add this into my project.

Thanks.
Demotis
 
Posts: 18
Joined: Mon Oct 28, 2013 6:20 pm

Re: Support for texturemap tile margins.

Postby medium8 » Sun Mar 16, 2014 10:28 pm

I'm glad I could help you :)

Demotis wrote:I was really missing this feature as I wanted to just use textures and not create ISO tiles for each tile that really should have just been a texture map with no real "3D" positioning needed.
Thanks.


I have tried this approach (as proposed by rob) too: to place flat (or 3d) objects on every grid to achieve this effect. But this slowed down the application very bad. On a 20x20 map I have got 20fps, on a 100x100 map 1fps, and nothing was clickable :) No wonder - 100x100 are 100000 objects to draw on every tick. A tile map is generated once and technically this is only one large image.
medium8
 
Posts: 3
Joined: Sun Mar 16, 2014 4:30 pm

Re: Support for texturemap tile margins.

Postby Demotis » Mon Mar 17, 2014 12:06 am

I had the same issue. Was able to get past it with IgeEntityManager, but it still wasn't as fast as using the texturemap. Details about the issue and my "fix" is here. http://www.isogenicengine.com/forum/viewtopic.php?t=128

I've started playing with this code you posted and it is really easy for me to switch over what I have. My game has no moving characters so the tiled images works great and since I don't have to load the TileMap any more it's really increased frame rate.
Demotis
 
Posts: 18
Joined: Mon Oct 28, 2013 6:20 pm


Return to Custom Code

Who is online

Users browsing this forum: No registered users and 1 guest
cron