PhaserJS 2.4 released with integrated Creature support!

Discuss issues pertaining to the various game/web runtimes of Creature here.
abutkus
Posts: 18
Joined: Mon Apr 17, 2017 7:22 pm

Re: PhaserJS 2.4 released with integrated Creature support!

Post by abutkus » Wed Apr 19, 2017 9:07 pm

thank you, thank you, chong, seems to be working :)),

is there any reason why when it scales, it scales from the right rather than the center of the mesh?

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

Re: PhaserJS 2.4 released with integrated Creature support!

Post by chong » Wed Apr 19, 2017 11:20 pm

Hello,

I will need to investigate but I think this might have something to do with Phaser or PixiJS's own scaling mechanism.

Cheers

abutkus
Posts: 18
Joined: Mon Apr 17, 2017 7:22 pm

Re: PhaserJS 2.4 released with integrated Creature support!

Post by abutkus » Thu Apr 20, 2017 10:20 am

Ok thanks, of its any help it looked like the container around the mesh is maybe 3 times the width of the creature mesh and the scale point is perhaps halfway between making it look like it's scaling from the right side, it may be that the container needs to be resized to fit the mesh width or setting the mesh to be centre of the container. I'm also investigating some more my side to try and figure out what's going on, but I've not really delved deep into the Low levels of how this works but will try

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

Re: PhaserJS 2.4 released with integrated Creature support!

Post by chong » Thu Apr 20, 2017 3:50 pm

Hello,

Sounds great. The scaling function that was added is rather simple, you can take a look at it yourself. So feel free to change it to fit your requirements if needed, conceptually it's doing exactly what it is supposed to do but there might be some additional Phaser transform issues that were not accounted for.

One thing you could try is to divide the resultant computed scale by 2 and see what happens.

Cheers

abutkus
Posts: 18
Joined: Mon Apr 17, 2017 7:22 pm

Re: PhaserJS 2.4 released with integrated Creature support!

Post by abutkus » Fri Apr 21, 2017 12:30 pm

I had a look and tried your suggestion with halving the scale and that just makes the size of the sprite smaller - I don't think it's your code which isn't working, it looks like the container around the mesh is too wide - for the width/height of the creature size.

Is it possible that the exported mesh from creature is exporting dimensions of the mesh size wrong?

I can only see a list of vertices in the Json file, is there anyway i can open the json file and debug boundaries etc? Any tooling?

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

Re: PhaserJS 2.4 released with integrated Creature support!

Post by chong » Fri Apr 21, 2017 4:17 pm

Hello,

If you look at the function:

Code: Select all

target_creature.ComputeBoundaryMinMax();
in:
https://github.com/kestrelm/Creature_We ... eshBone.js

Code: Select all

// Compute min and max bounds of the animated mesh
Creature.prototype.ComputeBoundaryMinMax = function()
...
{
All it does is compute the min/max boundaries of the mesh based off the actual render points. This is a computation should be correct, otherwise there will not be any render culling. Also, there was a debug display that draw the boundary box that showed the correct bounds.

There is no notion of "correct" mesh scaling in Creature based off the sprite dimensions, again because as I mentioned before, Creature characters are authored as meshes ( like in Maya for example ) in character space, not image dimensions. You can scale it up/down however you want since they are a set of vertices in space.

Correct pixel scaling just means getting the correct scaling transforms to map the computed min/max boundaries into image space. If you want to debug, take a look at the ComputeBoundaryMinMax function for more info. You can try rendering a simple bounding box around that boundary to see how it looks like, if it's incorrect then something else is going on. ComputeBoundaryMinMax() computes the min/max in local character space; you still need to apply the world transform onto it to get it into the renderer space. And this is what UpdateCreatureBounds() does:

Code: Select all

CreatureRenderer.prototype.UpdateCreatureBounds = function()
{
	// update bounds based off world transform matrix
	var target_creature = this.creature_manager.target_creature;
		
	target_creature.ComputeBoundaryMinMax();
	this.creatureBoundsMin.set(target_creature.boundary_min[0],
								-target_creature.boundary_min[1]);
	this.creatureBoundsMax.set(target_creature.boundary_max[0],
								-target_creature.boundary_max[1]);
								
	
	this.worldTransform.apply(this.creatureBoundsMin, this.creatureBoundsMin);	
	this.worldTransform.apply(this.creatureBoundsMax, this.creatureBoundsMax);				
};

You can follow the same pattern to draw your boundary rectangle for testing.

I did test out the pixel scaling functions with a simple test of scaling the character up to fill the actual pixel dimensions of the screen and it worked. Take note that the pixel scaling getter function returns pixel scaling assuming there are no other additional transforms applied to it.

Cheers

abutkus
Posts: 18
Joined: Mon Apr 17, 2017 7:22 pm

Re: PhaserJS 2.4 released with integrated Creature support!

Post by abutkus » Sun Apr 23, 2017 8:18 pm

hi chong,

it looks like it wasnt a code problem, i loaded the iceDemonExport_character_img json and png into my code, and the scaling was working as expected.


i think the model im exporting from creature is setting the anchor point to the right of the character, i have found under the animate tool menu, an option called "Set Anchor point" and i drag it to the center of my character, but it appears to be doing nothing, i will keep looking but i think for now everything is ok in terms of the scaling.

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

Re: PhaserJS 2.4 released with integrated Creature support!

Post by chong » Mon Apr 24, 2017 1:18 am

Hello,

There is an experimental feature for Anchor points in the Creature JS runtimes:
https://github.com/kestrelm/Creature_We ... eshBone.js

In the constructor of your Creature object. line 2785:

Code: Select all

this.anchor_points_active = false;
You can try setting that to true and see what happens. It should invoke the function AlterBonesByAnchor(), line 3595.
This function itself is called in the default PoseCreature() function, line 3695.

Anchor points are enabled when the anchor_points_active flag is set to true, again this is an experimental feature ( it is officially published on UE4 and Unity platforms )

Cheers

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

Re: PhaserJS 2.4 released with integrated Creature support!

Post by chong » Mon Apr 24, 2017 2:02 am

Ok another update, please sync up with the latest from the GitHub Creature WebGL page:
https://github.com/kestrelm/Creature_WebGL

The anchor points feature should be working for the JS runtimes now.
Remember to set anchor_points_active = true on your instantiated Creature object:

https://github.com/kestrelm/Creature_We ... eshBone.js ( Line 2785 )

for the Creature objects that you want anchor points to be active on. I set anchor points on the Ice Demon character, flipped the Boolean and it transformed it relative to the anchor point.

Cheers

abutkus
Posts: 18
Joined: Mon Apr 17, 2017 7:22 pm

Re: PhaserJS 2.4 released with integrated Creature support!

Post by abutkus » Mon Apr 24, 2017 4:35 pm

hi chong,

works as described, thanks very much. I think i can now do everything i need to for setting up my sprites with creature meshes, - im not sure if you work for kestrel, but i have upgraded to pro to show support.

Thanks very much for your help

Andy

Post Reply