[SOLVED] Creating animated pictures class for 2d Hud

Those are very good info @skidrunner !
I will take a look on that, and seems I will learn a lot about it as well :slight_smile:

Where do you see animation in there?

…just normal texture atlasing to me.

your right :frowning: but wouldnt you be able to move the sprites yourself in code using a control for the animation on the sprite isnt that the point of using sprites for animation?

position = position > maxPosition ? 1 : position + speed * tpf;
mat.setFloat("Position", (int) position);

or somethign like that?

I made some modifications, its working, but I am wonder, do I need to create one vert file for each animation ? What if I want to determine the direction from the animation by run-time ?

Obs: I tried the animation from down to up :

float t = m_Position;

float tPointerYOffset = (floor(t / m_SizeX)) / m_SizeY;

float tPointerY = (t - (tPointerYOffset * m_SizeX * m_SizeY)) / m_SizeX;
float tPointerX = 1.0 - ((floor(m_Position / m_SizeX)) / m_SizeY) - 1.0 / m_SizeY;


texCoord.x = inTexCoord.x / m_SizeX + tPointerX;
texCoord.y = inTexCoord.y / m_SizeY + tPointerY;
gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1.0);

In other words, its possible to generate this material at run time ?

Yes, if you want cell animation that works but if you just want to slide texture coordinates then that won’t work on its own. You have to modify the texture coordinates somehow… but now I get dangerously close to repeating myself. :wink:

You don’t really want to generate a material at runtime. You want to make a better material.

Like instead of just moving it based on time move it based on a vector * time.

ie: write a shader that incorporates all of your desired features. Or instead do my original option (2) and ignore the shader and just modify texture coordinates in code instead and do whatever you want with them.

Well, I am just learning.
For now, I am going to use two materials, one txtMoveLeftRight.j3md and other txtMoveUpDown.j3md, it do what I need.
I will take a look on shader language, it seems to be fascinating functions.
Do you guys have any link to look at it ?
http://www.eng.utah.edu/~cs5610/lectures/GLSL-ATI-Intro.pdf maybe ?
Obs: I tried to open it but the link is off, maybe temporary ?

5 seconds of clicking on the tutorials page found this:

Yes, this one at the end have this external link, but its not working.

This is EXACTLY the reason for which I made the spritesheet: I want to manage the animation from the Java side, and tell the shader:

for (int i=0;i<10;i++){
draw frame #i

This gives me more power and flexibility in that I can choose what frame to draw and when.

Just FYI, the link works now. Seems it was a temporary issue.