PDA

View Full Version : flipping/rotating overlayrendercomponent



karelc
09-19-2011, 04:44 PM
I want to use one image and have it face all four directions. I use the pos2d, size2d and visible vars without a problem but setting flipX to 1 or rotation to 90 does nothing. I assume these are functional as you put them on the feature list?

Thanks

Seth
09-19-2011, 10:42 PM
Hrm, yes rotation should be working fine, I use it a lot.

Can you try stepping through void OverlayRenderComponent::OnRender(VariantList *pVList) and checking the value of m_pRotation? It shouldn't be 0 if you've set it.

In case it's a bug with using it with flipX/flipY, maybe try rotating without those first and see if it works.

karelc
09-20-2011, 09:14 AM
Just to be sure this is what I'm doing
pEnt->GetVar("flipX")->Set((uint32)1);
same with rotation where I put 90 and 270.

Actually setting rotation seems to crash on windows. Line 138 in Variant.h, assertion failed on ( m_type == TYPE_UNUSED || m_type == TYPE_UINT32 )
flipX doesn't crash, but in onRender it is set to 0. I'm confused here though, it only steps through once for that image even though I have several entities using it. But even when I set all those to flipX 1 it is still 0.

Seth
09-20-2011, 01:03 PM
Ok, I think I know what's wrong on both issues.

First, flipX is not at the entity level, it's a parm of the OverlayRender component as that's the only thing it works with. (actually, not true, it also works with the ProgressBarComponent)

So to fix, set like this:


EntityComponent *overlayComp = pEnt->GetComponentByName("OverlayRender");
overlayComp->GetVar("flipX")->Set(uint32(1));

Next, rotation is done at the entity level, but it is a float, not an int. The assert is saying "you are setting it as the wrong type, it's been previously initted with something else".

So, to fix that, send it a float.

If you're not sure about a parm, do a project-wide search for "rotation" or whatever and where it's initted should pop up and give you a better idea, for instance, rotate is initted like this:


m_pRotation = &GetParent()->GetVar("rotation")->GetFloat(); //in degrees

And "flipX" would get this:


m_pFlipX = &GetVar("flipX")->GetUINT32();

Notice the flipX one doesn't have GetParent()-> so you know it's at the component level of the file its in, not the entity like with "rotate". Yeah, it's confusing. I think I should have put flipX/flipY at the entity level really.

karelc
09-20-2011, 01:13 PM
Ok thanks. It's confusing to learn without intellisense and such helping out.