Libgdx runtime questions

Discuss issues pertaining to the various game/web runtimes of Creature here.
crackajack
Posts: 11
Joined: Mon Jan 04, 2016 11:47 pm

Re: Libgdx runtime questions

Post by crackajack » Tue Jan 05, 2016 1:05 am

wow, Chong, thanks for super-fast reply :)

as for FBX as I understand it doesn't support mesh deformation (this feature is the main reason why I consider Creature). also, I like to have full control on my project code, and Unity is not easy for that. from that point libgdx is best java engine I've seen.

just wanted to clarify how do you plan to choose these key frames... will they match key frames in editor, or be like every 3rd frame? I actually thought about key frames related to motor/bone property change key frames in editor. maybe another solution is to store bone property change delta value between these key frames (those frames set in editor, or matching frames where motor property changes) - like "from frame 10 to frame 100 change bone1 angle for -30.0", so that only changing data is stored in output file. but that will require additional interpolation info (like non-linear stuff at start and end of property change) - and I thought motors operate that data.

anyway, thank you for considering my request!
will patiently wait for any kind of optimization!

cheers!

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

Re: Libgdx runtime questions

Post by chong » Tue Jan 05, 2016 1:34 am

Hello,

Mesh deformation is a pretty loaded term to be honest :) FBX does mesh skinning which is mesh deformation. You are deforming meshes via bone weights on the skin of the character, allowing you to do some pretty sophisticated effects like cloth and hair. In fact, all the cloth hair samples on the Creature website can be exported out to FBX since they are driven purely via bone motor animation.

The key compression feature will require some thought but I believe it should be possible. There are a couple more features I am currently working on right now for the editor before I can think about key compression. Having said that, thank you for the very useful feedback, I will put that request down on the list.

Cheers

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

Re: Libgdx runtime questions

Post by chong » Tue Jan 05, 2016 4:33 pm

Hello,

Actually one more thing occurred me. Is it the loading of the creature asset that is taking time or the point caching process that is the issue for you?

The loading should actually be pretty fast since it's already in binary format; my suspect is that it is the point caching that is the source of your issue.

Point caching in the runtime essentially precomputes out all the points of the character and saves it out into a buffer in memory for super fast playback.

The sample provided does just that with this call:

Code: Select all

 new_creature_manager.MakePointCache("default", 2);
You can disable point caching which will speed up load times but playback might be a bit slower depending on your device. You can also play around with the point caching options ( the second parameter adjusts the quality of the cache. 1 is the highest, as you increase it the generation is faster but the quality goes down)

In terms of the file size, the distributed raptor animation has not had its mesh resolution reduced/optimized yet. The typical step people do before exporting is to optimize the mesh, reducing the size by quite a bit. This is a feature in the "Advanced Export" available in the Pro version.

Cheers

crackajack
Posts: 11
Joined: Mon Jan 04, 2016 11:47 pm

Re: Libgdx runtime questions

Post by crackajack » Tue Jan 05, 2016 7:35 pm

Hello, Chong.
thanks again for your reply
I measured times for 1000 frames of raptor animation and indeed point cache takes most of the time

200ms - CreatureModuleUtils.LoadCreatureFlatData(flatFilename);
150ms - new Creature(flat_data);
900ms - new CreatureAnimation(flat_data.dataAnimation(), "default");
3600ms - new_creature_manager.MakePointCache("default", 2);
150ms - rest of initialization

however if I disable point cache it starts to lag very much (on Samsung S4).
as for quality:
1 - 7100ms
2 - 3600ms
3 - 2400ms
4 - 1800ms
5 - 1500ms (animation is not so smooth anymore)
6 - 1250ms (noticeable lags appear)

so far setting quality = 4 doesn't affect rendering performance much, but I need to try on other devices as well.

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

Re: Libgdx runtime questions

Post by chong » Tue Jan 05, 2016 7:45 pm

Hello,

Thanks for the profiling info. So the playback speed really depends on the device you are playing back the animation on. It also depends on the complexity of your animation of course. As I mentioned before, an optimized raptor mesh (through the Advanced Export option) does speed up playback speed as well.

Since point caching generation is the bottleneck, I think the better feature for me to look at is to allow a pre-computed point cache export binary file format. This way the point caches are already generated at load time, saving you the hassle of generating it at runtime.

Cheers

crackajack
Posts: 11
Joined: Mon Jan 04, 2016 11:47 pm

Re: Libgdx runtime questions

Post by crackajack » Tue Jan 12, 2016 8:10 am

Hello!

I've got another couple of questions about libgdx runtimes.

1. What is the best way to obtain world position of bone/region at run time during animation? I thought about attaching particle system to some bone :)

2. Is it possible to check for mesh region hit test? Would be nice to have such function in runtime code. For example, if I want to trigger animation if user touches or drags some part of creature.

3. As I understand libgdx recommends drawing everything using sprite batch for performance. I also have some other entities in my app (such as few background images and few foreground images, particle systems, etc.), and they use the same sprite batch during rendering process. it would be good to render creature using the same sprite batch, otherwise (because its in middleground) I would have to split existing sprite batch in 2 (background, foreground), and also render creature separately. probably this would not be very efficient. and if I add second creature and put some objects between both creatures it would be even less efficient... I tried to pass SpriteBatch to Flush() method, but creature uses its own shader (not default one used by sprite batch), so it didn't work out (probably because of position shader argument). But maybe its possible to do something with that?

Thanks in advance :)

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

Re: Libgdx runtime questions

Post by chong » Tue Jan 12, 2016 4:49 pm

Hello,

1) Have a look at the following methods in CreatureManager.java:

Code: Select all

 public String IsContactBone(Vector2 pt_in,
                                float radius)
and

Code: Select all

 public String ProcessContactBone(Vector2 pt_in,
                                     float radius,
                                     MeshBone bone_in)
That should give you a clue on how to grab bone start and end positions. Remember though that the "world" positions of the bones are still relative to your animation space. Do remember to transform them globally via your character world transform.

You can quickly grab a bone via the bones_map data structure in: MeshRenderBoneComposition.java .
It is indexed by the name of the bone.

2) Not yet but you do have access to the mesh structures so you can probably do something simple ( like a bounding box ). Also, ProcessContactBone accepts a radius so that might help too.

3) This isn't a sprite, it's a mesh so I am not sure if it fits into their framework.

Cheers

Post Reply