PhaserJS 2.4 released with integrated Creature support!
Re: PhaserJS 2.4 released with integrated Creature support!
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?
is there any reason why when it scales, it scales from the right rather than the center of the mesh?
Re: PhaserJS 2.4 released with integrated Creature support!
Hello,
I will need to investigate but I think this might have something to do with Phaser or PixiJS's own scaling mechanism.
Cheers
I will need to investigate but I think this might have something to do with Phaser or PixiJS's own scaling mechanism.
Cheers
Re: PhaserJS 2.4 released with integrated Creature support!
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
Re: PhaserJS 2.4 released with integrated Creature support!
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
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
Re: PhaserJS 2.4 released with integrated Creature support!
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?
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?
Re: PhaserJS 2.4 released with integrated Creature support!
Hello,
If you look at the function:
in:
https://github.com/kestrelm/Creature_We ... eshBone.js
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:
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
If you look at the function:
Code: Select all
target_creature.ComputeBoundaryMinMax();
https://github.com/kestrelm/Creature_We ... eshBone.js
Code: Select all
// Compute min and max bounds of the animated mesh
Creature.prototype.ComputeBoundaryMinMax = function()
...
{
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);
};
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
Re: PhaserJS 2.4 released with integrated Creature support!
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.
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.
Re: PhaserJS 2.4 released with integrated Creature support!
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:
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
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;
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
Re: PhaserJS 2.4 released with integrated Creature support!
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
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
Re: PhaserJS 2.4 released with integrated Creature support!
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
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