Jump to content

[SOLVED] Sprite - setLayerTexCoord


photo

Recommended Posts

Hey Unigine,

 

setLayerTexCoord isn't working with X and Y as 0 / 0

 

if you set now:

mysprite.setTexCoord(vec4(0.0f,0.0f,(engine.app.getWidth() / statusBarLayerSprite.getWidth()) +2,45.0f));

 

The sprites aren't rendered at all.

 

In attachment the example.

 

Greetings

Lars

roastatus.rar

Link to comment

Hello Frustum,

thanks for the help.
Now it make sense why the behavior was such strange.

I think the documentation needs an update:

"vec4 texcoord - Texture coordinates. The first pair of coordinates (x and y) is for the upper left corner, the second pair (z and w) is for the lower right corner."

Thanks

Link to comment

Sorry, the documentation was right.

The default texture coordinates are 0, 0, 1, 1.

The first pair is upper left. The second pair is lower right corner.

Link to comment

Hey Frustrum, 
but then its strange,test my example and put the first two textures to 0/0, and the textures aren't repeated, if you put them to 1/1 they are repeated.

I'm standing on a pipe?

Link to comment

Update: Found something realy strange going on:

 

If you have a look into spacing.png you'll the the red - arrow which displays on a "spacing" on the graphic -> post-248-0-05332600-1363205356_thumb.png

If you'll have a look on the pure added image -> post-248-0-97083500-1363205381_thumb.png theres no spacing at all.

 

I found out that:

        statusbarTopSprite.setWidth(engine.app.getWidth());
        statusbarTopSprite.arrange();
        WidgetSprite statusBarLayerSprite = new WidgetSprite(engine.getGui(),"roastatus/statusbar_repeating.png");


        statusBarLayerSprite.arrange();


        statusbarTopSprite.setTexCoord(vec4(1.0f,1.0f,(engine.app.getWidth() / statusBarLayerSprite.getWidth()) +2,45.0f));
        statusbarTopSprite.setWrapRepeat(1);
        statusbarTopSprite.arrange();

 

 

Textcord with setWrapRepeat includes this spacing:  statusbarTopSprite.setTexCoord(vec4(1.0f,1.0f,(engine.app.getWidth() / statusBarLayerSprite.getWidth()) +2,45.0f));  statusbarTopSprite.setWrapRepeat(1);

 

Update: if you remove the setTexCoord and setWrapRepeat it looks like post-248-0-51640700-1363205863_thumb.png (left top) - so theres no blackspacing between.

 

In attachment you're finding a little example where you can reproduce this error.

For a fast help I would be realy glad.

 

Thanks 

Lars

roastatus.rar

Link to comment

Be carefully with integer division because int/int = int.

 

statusbarTopSprite.setTexCoord(vec4(0.0f,0.0f,float(engine.app.getWidth()) / statusBarLayerSprite.getWidth(),1.0f));

with repeat:

00000.jpg

without:

00001.jpg

Link to comment

Hey frustum,

 

thanks for advice, float() casting didn't bring up the solution:

topLayerSprite.setTexCoord(vec4(1.0f,1.0f,float(float(engine.app.getWidth()) / float(statusBarLayerSprite.getWidth())) +float(2),45.0f));
            topLayerSprite.setWrapRepeat(1);
            topLayerSprite.arrange();

 

I just tried with float around engine app and then I put every where, same error.

I attached again the problem after casting to float aswell.

Edit: It makes no difference if I remove +float(2) or not. FYI.

Greetings

Lars

post-248-0-59955200-1363525032_thumb.png

Link to comment

Lars,

 

As you can see by yourself, in the example Frustum has provided there is no black spacing. And since it is rendered correctly, I suggest you look through your code again. It is possible that this pixel appears due to incorrect scaling (if we are talking about int division) or if wrong texture coordinates are set.

Link to comment

Hey Manguste,

I'll check it this evening again with the sample I provided Frustum aswell.

 

I changed all int divisions to float division so there shouldnt be a problem anymore.

But y I'll check it this evening and notify you.

Greets

Lars

Link to comment

Hello Manguste, Hello Frustum,

 

I tried it a new, I attached a label where you see this problem.

Here the screenshot where you see the label "test" which shows that setTexCoords does something strange:post-248-0-35285400-1363892698_thumb.png

If i remove the texcoord and the wrap I got this: post-248-0-20092300-1363892847_thumb.png

 

 

Where you see the Image isn't destroyed.

 

PS: I casted all to (float) etc. but problem still exists.

I hope you can reproduce this error now.

In attachment the project with the attached label so you can see it.

 

Thanks

Lars

roastatus_new.rar

Link to comment

Hey Anton,

 

but that means that the label is attached ABOVE the sprite.

I wanted to show that the label is shown below the sprite cause its wrapped wrong and so a spacing is created.

Have a look into the pic posted before.

Here you see that the label is shown if i attach this behind the sprite.

This comes up if I use "settexcoord" and "setWrap" functionality, without it doesn't happend.

 

But thanks for hint anyway.

So Issue still open.

 

Greets

Lars

Link to comment

Maybe I found a solution for this problem I'll inform you in some days anew with the solution or with more informations.

What I can say till now: Seems like a white space above the image which is rendered into the middle (realy strange whats going on there).

 

Greetings

Lars

Link to comment

Hello Unigine again,

 

I found the issue of the repeating bug now. It seems, like I posted above, that the "whitespace (its transparent)" in the image is killing the wrapFunctionality.

This whitespace is above the "statusbar" can be made visibile in photoshop or call this image with paint then you will see it. - It would be cool when you can check this aswell, a transparency shouldn't kill this functionality at all.

 

IMPORTANT ASWELL:

 

At all we got another issue with this functionality:

 

In Windows 7 the wrapping works after I removed the transparency above the statusbar.

In Linux (Ubuntu 12.10 to be exactly) it doesn't work.

This bug occures with and without the transparency in image..

 

Have a look into the attachment to see the bug in Linux:post-248-0-21323900-1364589966_thumb.png

Have a look into the attachment to see how it works looks on Windows:post-248-0-01327700-1364590035_thumb.png

 

 

In attachment the new version with the new image file without the transparency above the statusbar.

Iif you want the transparency as well to test, have a look into a post before with the attached roastatus.rar.

 

Greetings

Lars

roastatus.rar

Link to comment

Hi Manguste,

 

it isn't fixed.

We did a workarround with a sprite with 2600 pixel width.

Cause the widest resolution we support is 2550.

 

So we dismissed at first the .setWrap functionality etc.

So bug is still open.

Greetings

Lars

Link to comment

Please set the correct texture coordinates for sprites:

statusbarTopSprite.setTexCoord(vec4(0.0f,0.0f,float(engine.app.getWidth() / statusBarLayerSprite.getWidth()),1.0f));

mysprite.setTexCoord(vec4(0.0f,0.0f,float(engine.app.getWidth() / statusBarLayerSprite.getWidth()),1.0f));

Link to comment

The problem is in wrong texture coordinates.

statusbarTopSprite.setTexCoord(vec4(0.0f,0.0f,float(engine.app.getWidth()) / statusBarLayerSprite.getWidth(),1.0f));
mysprite.setTexCoord(vec4(0.0f,0.0f,float(engine.app.getWidth()) / statusBarLayerSprite.getWidth(),1.0f));
The first pair of numbers is upper-left corner.

The second pair is a lower-right corner.

The default value (0,0,1,1) means whole sprite coverage by texture without repeat.

Link to comment

Hey Frustum,

we tested it now on Windows and Linux, its working!

Thanks for your BIG afford!

 

Case can be closed.

Greetings

Lars

Link to comment
×
×
  • Create New...