View Full Version : SetupAnimEntity for texture mapping

07-20-2011, 09:05 PM
Entity* TmpE1 = CreateOverlayEntity(GetParent(), "testE1", TmpC, 64.0f, 64.0f);
SetupAnimEntity(TmpE1, 4, 4, 0, 0);

Entity* TmpE2 = CreateOverlayEntity(GetParent(), "testE2", TmpC, 0.0f, 0.0f);
SetupAnimEntity(TmpE2, 2, 2, 0, 0);

When I use this code first entity is mapped like second. I do not know whether the function is designed for such use. Maybe I need to share images on the parts?

07-20-2011, 10:01 PM
Hmm, TmpE2 should show a larger chunk of the image (1 of four squares instead of 1 of eight squared).

This isn't happening? Can you show a screenshot of the bug, and also the original source image?

07-21-2011, 07:47 AM
Ok, this is my sample graphic:

Entity* TmpE1 = CreateOverlayEntity(GetParent(), "testE1", "interface/numbers.rttex", 0,0);
SetupAnimEntity(TmpE1 , 4, 4, 0, 0);
Entity* TmpE2 = CreateOverlayEntity(GetParent(), "testE2", "interface/numbers.rttex", 256,256);
SetupAnimEntity(TmpE2 , 2, 2, 0, 0);

When i use this code mapped entities look like this:

When i change image in second entitiy first is mapped properly.

07-24-2011, 12:32 AM
Thanks for the detailed bug report, very helpful.

The problem is that Proton handles surfaces like this:

All surfaces with the same file name are shared internally with the same SurfaceAnim
Grid settings for how a surface is cut-up for an anim is saved in the SurfaceAnim, and not send it for the blit, like frameXY is.
Changing the grid settings breaks any previous grid settings set by other people sharing the Surface/SurfaceAnim

I'll have to give this some thought on the best way to fix it. Possibly I'll just change it so OverlayComponents set the grid size every frame.

For now, here is a work around - create a new surface for the second piece. This does waste extra texture memory for no reason though.

Entity* TmpE1 = CreateOverlayEntity(pGUIEnt, "testE1", "interface/numbers.rttex", 0,0);
SetupAnimEntity(TmpE1 , 4, 4, 0, 0);

//let's force the second instance to keep its own copy, so we won't overwrite its grid setup
Entity* TmpE2 = CreateOverlayEntity(pGUIEnt, "testE2", "", 256,256);

//get access to the overlay component inside the entity we just created above
OverlayRenderComponent *pOverlay = (OverlayRenderComponent*)TmpE2->GetComponentByName("OverlayRender");

//create a new surface manually
SurfaceAnim *pCustomSurface = new SurfaceAnim;

//feed it into the SurfaceOverlay to use, and tell it to delete it when done with it
pOverlay->SetSurface(pCustomSurface, true);
SetupAnimEntity(TmpE2 , 2, 2, 0, 0); //now this will work on our custom surface without affecting the first one

07-24-2011, 12:36 AM
An alternate fix would be to rename numbers.png to numbers2.png for the second instance.