Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: PoN on October 08, 2012, 10:33:45 PM

Title: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: PoN on October 08, 2012, 10:33:45 PM
Pls ,Tell me how can i do that, create atlas by NGUI Atlas Maker and use "rotation" feature of Texture Packer ? thx
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: yuewah on October 08, 2012, 11:54:15 PM
I think it doesn't support it yet.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: jprice on October 09, 2012, 01:32:47 PM
Yeah, in NGUIJson.LoadSpriteData, there is a comment:

            // TODO: Account for rotated sprites

NGUI currently imports the rotated sprite's UVs correctly; it doesn't rotate the sprite correctly when it is created, though.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: nah0y on October 10, 2012, 06:25:41 AM
This is a request feature then :)

ArenMook is this something really hard to do ? Don't we just have to rotate the sprite ?
This will be something really great !
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: ArenMook on October 10, 2012, 09:44:45 AM
Hard? Nah. But this feature is requested once in a blue moon (the last time was in February I think?), so I didn't look into it.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: nah0y on October 10, 2012, 09:46:24 AM
Héhé, well I'm thinking about switching every atlas generation with TexturePacker so that would be great
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: ArenMook on October 10, 2012, 09:48:24 AM
Send me an atlas that has a rotated sprite in it then. Do that on the 12th though, as I don't return until then.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: nah0y on October 10, 2012, 09:59:43 AM
I've just sent you an email, that you'll find on the 12th ;)

Thanks !
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: nah0y on October 18, 2012, 05:41:30 AM
Hi,

Just a reminder, should I send you another email ?
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: ArenMook on October 18, 2012, 02:26:18 PM
No, I have it saved. Just haven't gotten around to it yet.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: _joe_ on October 25, 2012, 10:58:53 AM
I would also like to see this feature, Texture packer has the MaxRects Algorithm which place 20% more sprites on the same Atlas, and having NGUI to support to orientation (+90 or -90 degrees) would be a very nice addition.

Best
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: PixelEnvision on October 25, 2012, 05:33:45 PM
+1 for that feature...
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: yuewah on October 25, 2012, 08:53:51 PM
+1
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: Eskema on October 30, 2012, 09:37:38 AM
I have to cry like the rest :P +1 for this feature
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: Ferazel on October 30, 2012, 12:50:27 PM
+1 for this feature.
Especially, with NGUI rolling your own texture packer you could use that to rotate the sprites for the optimal placement on the sprite atlas, and/or import the rotated sprites from TexturePacker output. I understand if it doesn't get done as this would probably impact a significant number of widgets to maintain the offset and rotational value of the sprites and then do and undo that transform when performing calculations.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: RobD on December 20, 2012, 10:11:42 AM
I just had a quick go at this (going through my whole HUD to fix items that had changed rotation every time I re-packed the textures was really getting on my nerves). My solution seems to work fine, and is pretty easy. No guarantees though - it's likely I've missed something somewhere...

Anyway, a brief summary of my changes:

NGUIJson.cs:
Just under
bool rotated = (bool)table["rotated"];
add
newSprite.isRotated = rotated;

UIAtlas.cs
Under
public bool hasPadding { get { return paddingLeft != 0f || paddingRight != 0f || paddingTop != 0f || paddingBottom != 0f; } }
add
public bool isRotated;

UISprite.cs
Under
float pixelSize = atlas.pixelSize
add
if (mSprite.isRotated)
{
float tmp = rect.width;
rect.width = rect.height;
rect.height = tmp;
}


Replace
uvs.Add(uv1);
uvs.Add(new Vector2(uv1.x, uv0.y));
uvs.Add(uv0);
uvs.Add(new Vector2(uv0.x, uv1.y));

with
if (!mSprite.isRotated)
{
uvs.Add(uv1);
uvs.Add(new Vector2(uv1.x, uv0.y));
uvs.Add(uv0);
uvs.Add(new Vector2(uv0.x, uv1.y));
}
else
{
uvs.Add(new Vector2(uv1.x, uv0.y));
uvs.Add(uv0);
uvs.Add(new Vector2(uv0.x, uv1.y));
uvs.Add(uv1);
}


That should be it!

ArenMook - if this looks OK to you, any chance you could drop it into the next version? I'd hate to have to merge it in every time.

Cheers!
Rob.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: ArenMook on December 20, 2012, 11:19:04 AM
Absolutely. Just keep in mind this wont affect sliced sprites or filled sprites. Just regular sprites.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: Kiu on January 24, 2013, 04:48:09 AM
@RobD: Thank you! Great help to squeeze the last few sprites into a tight ram budget. Would love to see this in the full version.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: ranilian on May 14, 2013, 02:53:45 PM
Any updates on this? I still can't see it in the Pro version.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: PoN on May 14, 2013, 09:31:51 PM
Interesting to me too, Up
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: Zophiel on July 02, 2013, 07:26:25 AM
I'm curious as well on what the status is on this? More so if i can use Texture Packer to generate my atlases and if so how do i import them for use with NGUI?

I'd love to use the rotate feature, it makes my textures oh so small!
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: ArenMook on July 02, 2013, 10:12:49 AM
From what I remember the posted code drew rotated sprites in the wrong order (back-faced) resulting in the sprite being inside-out. That combined with the fact that it only handled regular sprites, and not sliced, filled, or tiled sprites created too many inconsistencies for me to add it as-is.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: Zophiel on July 03, 2013, 03:24:32 AM
Is there a specific reason why the custom packer doesnt rotate sprites?
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: ArenMook on July 03, 2013, 04:27:15 AM
Nothing does. Only TexturePacker rotates sprites, if enabled.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: nah0y on July 03, 2013, 04:28:01 AM
Yup, I'm using TexturePacker with NGUI and it's much more powerful (no offense) than the one in NGUI :)
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: splash on July 04, 2013, 05:07:21 AM
Hi, I just make some modify to UISprite and make it possible to use rotated sprite in Simple / Sliced / Tiled / Filled type. :D
I attached the patch file and if any problem please let me know :)

Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: ArenMook on July 04, 2013, 08:34:26 AM
Nice. You even #ifdef'd the whole thing -- that's useful, thanks.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: Zophiel on July 08, 2013, 03:47:53 AM
Sounds awesome. Can i apply the patch myself somehow or should i wait for an update?
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: ArenMook on July 08, 2013, 11:30:30 AM
Can't apply it as-is unfortunately as splash is either not a Pro user or didn't use the pro repository, so revision numbers don't match.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: Zophiel on July 08, 2013, 01:15:03 PM
Is the #if flag set through the atlas information from TexturePacker? the patch file looks pretty straight forward. Guess i should test in an empty project.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: splash on July 09, 2013, 01:08:57 AM
If you use NGUI 2.6.3, you can apply this patch to UISprite.cs. I think it should work well.
Use of #if ... #endif is a way to change code back to original behavior when I test rotated sprite.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: ArenMook on July 09, 2013, 08:27:13 AM
I tried it with 2.6.3 and no luck. You likely have a custom repository (perhaps containing your game code?) and it uses version numbers from there. You are not using the NGUI's Pro repository.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: splash on July 10, 2013, 01:32:52 AM
I don't know if I'm allowed to attach entire UISprite.cs on forum. :-\ ...
And I tried patch UISprite.cs from 2.6.3 NGUI package and works ok.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: Malzbier on July 10, 2013, 01:56:43 AM
Do not post NGUI code in the form.
Send a email to support at tasharen.com with UISprite.cs attached.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: ArenMook on July 10, 2013, 12:43:36 PM
Individual files are just fine, Malzbier.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: BGL on October 04, 2013, 03:38:30 AM
Any news about this feature? I think it is really important. When you are constrained to a POT Texture, it could reduce to a half the amount of memory required for an atlas.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: Willem Kokke on October 04, 2013, 03:57:27 AM
+1 Supporting rotated sprites in texture packer would have made my life a lot easier!
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: splash on October 06, 2013, 09:12:02 PM
Here is the UISprite.cs I modified for rotated sprite.
Base on 2.6.5b.
If any problem please let me know.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: glequeux on November 18, 2013, 07:05:17 AM
Anybody did this for NGUI 3? Looked a bit into it but there is a lot of changes  :(
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: PoN on May 13, 2014, 02:21:18 AM
+1, Up up up. So what's about a rotation feature in NGUI 3 ?
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: oddurmagg on June 24, 2014, 06:19:00 AM
Did this ever make it into the repository ?
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: ArenMook on June 25, 2014, 04:54:19 AM
I don't believe so.
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: oddurmagg on June 25, 2014, 06:43:15 AM
I´ll take a stab at merging that patch into the pro repo when I have time
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: DonPepe1705 on July 25, 2014, 04:25:02 AM
Have you had the time to give it a shot?
Title: Re: Create Atlas by Texture Packer with "rotation" sprite ?
Post by: echeg on November 20, 2015, 07:25:43 AM
+1 Supporting rotated sprites in texture packer.