Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / How to get export objects as children?

Author
Message
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 20th Apr 2018 22:32 Edited at: 21st Apr 2018 02:14
I have an animated object. My plan is to equip different outfits, and be able to move and what not. So, I made an outfit for my character. I load up the character. I have 5 separate meshes. Hair, shirt, pants, boots, and the body. I have set images to all 5.

These are not counted as children. I have 0 children loaded with the object. I am at a loss as to how to load these as children, as well as, meshes. Or even children and not meshes, since them being different meshes does not seem to help me.

I have come up empty on all my searches.



edit: Looks like we are not able to create animated objects using memblocks? Or am I doing it incorrectly? None of the objects I create from memblock have bones.

Left is animated. The right is the memblock mesh of the body, but it has no bones.

Attachments

Login to view attachments
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 21st Apr 2018 02:41 Edited at: 22nd Apr 2018 00:42
So far, the only way I have been able to do this is to load every piece with its on armature/animation. I then have to align all the pieces with FixObjecttoObject, and animate each separate piece. A note is to make sure all your pieces in your 3d modeling program are offset correctly.

As you can imagine this takes up a quite a bit of memory. I only have 52 frames and it takes over 1.5MB of space for having 5 different meshes. I am gonna need to add, at least another 400 frames, plus plenty more objects. I am thinking over 20MB of space with just this character...

I know I am not optimizing this. There is no way other mobile games are using that type of space for the player character. Appreciate any guidance!




So, after more testing, it seems like AddObjectMeshFromMemblock is not reliable on animated models. I get terrible distortions on the model. Bummer.
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 22nd Apr 2018 00:53 Edited at: 22nd Apr 2018 00:53
Setting the model to alphamask and assigning the meshes an image of just alpha background is a solution until I can figure out how to get actual children.


Is this hard on the GPU?

The good thing is a got a ton of practice with memblocks, and they are pretty cool.
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 8th May 2018 00:12
So, I have found out how to get children objects. Simply do not add an armature to them. I am not sure how that would work on more complex meshes that need more than 1 bone to control it. But for weapons etc.. seems perfect.
Rick Nasher
6
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 8th May 2018 00:39
Example code?(always interesting..)
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 8th May 2018 01:38
Well, its more about how its done in the 3d modeling program.

Any object loaded with LoadObjectWithChildren() without an armature will be a child object. I have not ventured that much into that aspect, since I need something more complex.

I am sticking with my method of assigning alpha image to any mesh that needs to be hidden.

To create a mesh in blender just assign a material to it. Each material assigned to an object is 1 mesh. So, 1 object can have lots of meshes. Here is just a quick code. You can get the object mesh name through getobjectmeshname() to make assigning the images more efficient. I am not sure if these can all be part of one image or not. I am still working on a few things, before I delve into that. I don't "think" that would be a problem as long as your UVs are lined up correct.



Once I have it all figured out I will try to post a cleaned up example with an example blend file.
Rick Nasher
6
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 13th May 2018 17:05
Don't meshes that are alpha-ed still get rendered in AppGameKit and perhaps even slower due to the alpha calcs?
If so, that would be a costly solution performance wise and perhaps swapping out pieces of the body mesh, or actually even better: the whole mesh altogether, would be less costly(less poly's)?

Guess it's a matter of trying out which one is the most optimized approach.


Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 14th May 2018 18:50
I am not sure, but I thought I have read that before.


The other solution was to create every piece of outfit/weapon as its on animated object, then fixobjecttoobect(). That works, but takes my 4 MB file, and turns it into about 30MB. I guess, isn't the end of the world, so if the alpha solution is too costly I can do that.



I have not been able to figure out how to swap animated meshes correctly. As the mesh seems to get its bone weight data all mixed up. So, if I attached the shirt via memblocks there is terrible stretching.
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 14th May 2018 22:18
Hi

You should use : fixobjecttobone ().

What i do if i want a character +a gun :
- rst model3d character + armature + animations
- 2hd model 3d : the gun, no bones, no anim

Loadobjectwithchildren () for the character, with bones animation.
Loadobject() for the the gun, then use fixobjecttobone.

On my character armature, i have a bone named "gun".

Only one mesh animated
And it work pretty good.
AGK2 tier1 - http://www.dracaena-studio.com
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 16th May 2018 03:29 Edited at: 16th May 2018 03:31
Hey Blendman,

That works great for a gun/weapon/etc that only needs one bone. But for a shirt/pants fixobjecttobone won't suffice, since I need it to be attached to a bunch of bones with differing weights.

I am curious as to why the boneweights are incorrect when trying to use memblocks. When I open the file created by createfilefrommemblock() its just gibberish!
Rick Nasher
6
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 17th May 2018 00:53 Edited at: 17th May 2018 01:01
Perhaps a silly question, for haven't really used this much yet, but looking at the syntax:
FixObjectToBone( objID, toObjID, toBoneIndex )

Isn't it possible to fix the object, e.g. shirt, to multiple bones using above command?

If doesn't then we know what to ask Santa for x-mas.. new commands!
(I also didn't see a 'Remove/Delete ObjectFromBone' command, which could be useful)
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 1st Jun 2018 03:09
Rick,

That strategy does not work. However, I can add a correctly animated mesh via memblock to the object. Unfortunately, I do not know how to get rid of the original mesh. Once, I am able to figure out how to do that, I will no longer need to set an alphaimage. Sadly, I am still stuck on that being my only option. I am a little surprised there are no commands to delete or hide a mesh. That is killing me.

I have tried to write a shader to get rid of any alpha colored vertices, but for so far no luck. I will continue to try this path.
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 1st Jun 2018 03:32 Edited at: 1st Jun 2018 03:51
Well, its amazing what a little booze and determination will do. I fixed the shader, and I now am able to delete the mesh, and create a new mesh with correct animation. It was actually pretty simple, and am a little disappointed I got stuck this long.

I will post an example soon.

Login to post a reply

Server time is: 2024-04-18 23:29:56
Your offset time is: 2024-04-18 23:29:56