HomeHome  CalendarCalendar  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log inLog in  

Share | 
 

 using sprites from a tile set

View previous topic View next topic Go down 
AuthorMessage
Skreamz



Messages : 9
Date d'inscription : 2011-01-27

PostSubject: using sprites from a tile set   Mon Apr 09, 2012 11:58 am

Hi im using a IRRQuadRenderer and have just merged all my textures into one larget tileset. is there a way in spark to tell it the position of a sprite in the texture to use to render?

Thanks.
Back to top Go down
View user profile
Darktib
Committer


Messages : 389
Date d'inscription : 2009-07-20
Localisation : A coté de Paris

PostSubject: Re: using sprites from a tile set   Mon Apr 09, 2012 12:46 pm

You can use the atlas coordinates. If you have 4 * 5 textures grouped in a big one, you can use the texture and set the atlas coordinate to a fixed number (for just one texture). Use Interpolator for this (Graph interpolator works well if you want to change the texture while the effect is playing, else SimpleInitializer - or smth named like that - will suffice).
Be aware that the texture resolution might be lowered when you pack texture (see texture size limit)

_________________
Back to top Go down
View user profile
Skreamz



Messages : 9
Date d'inscription : 2011-01-27

PostSubject: Re: using sprites from a tile set   Mon Apr 09, 2012 1:27 pm

setAtlasDimensions? doesnt that just set how many images in your texture by rows and columns?

sorry but dont know the engine very well, only done basic stuff on it.

is this correct?

Model->setAtlasDimensions(2, 2); //the part of the texture is 2 x 2 (four 64x64's)
interpolator = Model->getInterpolator(PARAM_TEXTURE_INDEX);
interpolator->addEntry(128, 128); //top left of the texture i want to use
interpolator->addEntry(256, 256); //bottom right of the texture i want to use.

thanks for your help so far.
Back to top Go down
View user profile
Darktib
Committer


Messages : 389
Date d'inscription : 2009-07-20
Localisation : A coté de Paris

PostSubject: Re: using sprites from a tile set   Tue Apr 10, 2012 1:07 pm

It would be:
Code:

renderer->setAtlasDimensions(irr::core::dimensions2du(2,2)); // NOT model->setAtlasDimensions (because this function does not exists)
// Atlas indexes here:
// ---------
// | 0 | 1 |
// ---------
// | 2 | 3 |
// ---------
interpolator = ...;
interpolator->setType(SPK::INTERPOLATOR_LIFETIME, SPK::PARAM_TEXTURE_INDEX);
interpolator->addEntry(0, 0); // top left subtexture
interpolator->addEntry(1,3); // bottom right subtexture
Note: the first parameter of addEntry is the abscissa. The meaning of the abscissa depends on the interpolation type. Here, it is the lifetime, ie 0 is the birth of the particle and 1 the death of the particle.
PS: please use the [code] tag.

_________________
Back to top Go down
View user profile
Juff
Developer


Messages : 539
Date d'inscription : 2009-07-14
Age : 34

PostSubject: Re: using sprites from a tile set   Tue Apr 10, 2012 2:19 pm

Hi,

There s no support for real texture atlas in spark.
The only thing you can have is atlas of textures being grids.
This allows both texture animations and using different "cells" to render particles of the same group

As stated in the doc, you need to use PARAM_TEXTURE_INDEX to define the cell used for a given particle. The index of the cell will be the integer part of the param. An interpolator can be used to dynamically change this param, allowing texture animation.

Upgrading the system so that it can use user define atlases should be quite straight forward. The only thing the user will need to do is to register the atlas data to tell spark what index goes with which area in the texture. I put that on my todo list.



Back to top Go down
View user profile http://spark.developpez.com
Skreamz



Messages : 9
Date d'inscription : 2011-01-27

PostSubject: Re: using sprites from a tile set   Tue Apr 10, 2012 2:29 pm

thanks very much.
Back to top Go down
View user profile
Sponsored content




PostSubject: Re: using sprites from a tile set   Today at 3:42 am

Back to top Go down
 
using sprites from a tile set
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Tiling image behind banner on PhpBB?
» Lazy Sprites
» Felix's Mugs, Sprites and Maps.
» CSS Sprites forumotion

Permissions in this forum:You cannot reply to topics in this forum
 :: English Forum :: Questions (en)-
Jump to: