Can‘t export :( - Sprite Swapping Issues

Discuss issues pertaining to the Creature Animation Editor here.
zampano
Posts: 70
Joined: Wed Jun 07, 2017 3:37 pm

Can‘t export :( - Sprite Swapping Issues

Post by zampano » Tue Aug 21, 2018 6:58 am

Hey,
I‘m having serious trouble, I‘m stuck at the „optimizing texture size“ screen when trying to export for game engines. I tried to send you a PM with my project files but I‘m not sure whether you got it since for some reason it ended up in my outbox and not in my sent messages folder.

Thanks
Last edited by zampano on Thu Aug 23, 2018 1:59 pm, edited 1 time in total.

chong
Posts: 1178
Joined: Thu Feb 19, 2015 2:21 am

Re: Can‘t export :(

Post by chong » Tue Aug 21, 2018 3:37 pm

Hello,

I tried your sample. It actually does export fine, it's just that it takes a long time :) I will see if any optimizations can be done for an update with this level of Sprite Swapping.

Thanks

zampano
Posts: 70
Joined: Wed Jun 07, 2017 3:37 pm

Re: Can‘t export :(

Post by zampano » Tue Aug 21, 2018 4:10 pm

Oh, you're right. Did lose faith after maybe 6-8 minutes, but after around 10 minutes it was finally ready :mrgreen:

chong
Posts: 1178
Joined: Thu Feb 19, 2015 2:21 am

Re: Can‘t export :(

Post by chong » Tue Aug 21, 2018 4:20 pm

Hello,

Yes indeed. For certain sizes of Sprite Swapping, the system will take a much longer time to figure out the correct texture size. This needs to be optimized of course, will look into it when I get the cycles.

( Another update is coming up with some decent userbility features, stay tuned )

Thanks

zampano
Posts: 70
Joined: Wed Jun 07, 2017 3:37 pm

Re: Can‘t export :(

Post by zampano » Tue Aug 21, 2018 5:21 pm

Very nice, thanks a lot!

zampano
Posts: 70
Joined: Wed Jun 07, 2017 3:37 pm

Re: Can‘t export :(

Post by zampano » Tue Aug 21, 2018 9:26 pm

Can you tell me how I use SetActiveItemSwap in Phaser when using Image Swap from Character Meshes? I assumed I need to use the numbers shown in the "Image Swapping from Character Meshes" window, but it won't work even though I'm using the same code that worked with sprite manager image swapping before. Also after loading the project, all the sprites in that window turn black which can only be resolved by pressing "regen". When saving and loading the project however, most but not all of the numbers go back to how there were before which makes it even more confusing to find the (supposedly) correct tag values.

chong
Posts: 1178
Joined: Thu Feb 19, 2015 2:21 am

Re: Can‘t export :(

Post by chong » Tue Aug 21, 2018 10:13 pm

Hello,

The swapping code for active item swapping is listed as: ( https://github.com/kestrelm/Creature_We ... eshBone.js )

Code: Select all

for(var cur_action_key in active_swap_actions)
	{
		if (cur_action_key in regions_map)
		{
			var swap_tag = active_swap_actions[cur_action_key];
			var swap_list = swap_packets[cur_action_key];
			for(var j = 0; j < swap_list.length; j++)
			{
				var cur_item = swap_list[j];
				
				if (cur_item.tag == swap_tag)
				{
					// Perfrom UV Item Swap
					var cur_region = regions_map[cur_action_key];
					cur_region.setUvWarpLocalOffset(cur_item.local_offset);
					cur_region.setUvWarpGlobalOffset(cur_item.global_offset);
					cur_region.setUvWarpScale(cur_item.scale);
					cur_region.runUvWarp();

					break;
				}
			}
		}
	}
It will only perform the swapping if the swap_tag is found. Is the swap_tag found in your case when you debug it?

More info: You see in the code above the region you want to perform the swap needs to be enabled for Sprite Swapping first ( I assume you already did this in the Creature editor ). Then it will loop through all the mesh regions, for each mesh region it first retrieves a list of all possible swappable items ( swap_list). Each item has its own swap tag. Then it grabs the swap_tag you defined for that region you set from SetActiveItemSwap() . It tries to find the matching tag in swap_list. If found, it will then perform the swap. So does the code in your case find your tag and perform the swap?

zampano
Posts: 70
Joined: Wed Jun 07, 2017 3:37 pm

Re: Can‘t export :(

Post by zampano » Wed Aug 22, 2018 8:06 am

I found that this.target_creature.uv_swap_packets is empty for some reason so it will abort the item swap.

In the json file, uv_swap_items is also just an empty object. I double checked and I definitely activated UV Swap when exporting as well as on all the areas.

chong
Posts: 1178
Joined: Thu Feb 19, 2015 2:21 am

Re: Can‘t export :(

Post by chong » Wed Aug 22, 2018 3:47 pm

Hello,

So in the sample you sent me there does not seem to be any swap items when I open the Sprite Frame Manager.
In order for that field to be populated, you will need at swap in at least 1 sprite item into that mesh so that the correct offsets/uv info can be computed and written out. Since you are going to be swapping them live, I suggest you set a single sprite swap at the first frame for the mesh regions you want to actively swap out at runtime. Export that out and verify the JSON has the uv_swap_items populated.

As for active_uv_swap_actions, you will see in the code there is no place where it actively clears it, it is created as an empty map but it is up to you to populate it via SetActiveItemSwap(). I am not sure why in your case it is still empty. You might want to trace through your code to see if there is any clearing operation involved.

Thanks

zampano
Posts: 70
Joined: Wed Jun 07, 2017 3:37 pm

Re: Can‘t export :(

Post by zampano » Wed Aug 22, 2018 4:21 pm

So in the sample you sent me there does not seem to be any swap items when I open the Sprite Frame Manager.
Yes, that is because I am only using "Image Swapping from Character Meshes". Do I still need to put something in the Sprite Frame Manager?
Last edited by zampano on Wed Aug 22, 2018 4:45 pm, edited 2 times in total.

Post Reply