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.

AppGameKit Studio Chat / Bone object and tweening

Author
Message
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 3rd Jul 2019 14:47
Hello forum,
One question regarding tweening and animated objects. When trying to change the scale of an animated object (loadobjectwithchildren), by tweening (settweenobjectscalex, y, z), the tween does not work. The object stays at the same size. Is it supposed to work like this? Maybe the animations will not work if it would be possible this feature?

Thank you!
www.alexmatei.com
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 3rd Jul 2019 21:48
I think animating scale is not supported with LoadObjectWithChildren()
Run your app with debug and you should get a message to that effect
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 4th Jul 2019 09:00
Has the bone name issue been fixed? In classic, if you loaded an animated object with bones, you could cycle through them by using getobjectnumbones, then message each bone name.....all worked well. But if you tried referencing a bone by a name, it always returned 0. Or at least, for .X models.
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 4th Jul 2019 13:44 Edited at: 4th Jul 2019 14:00
This is to do with the shaders that AppGameKit uses internally. When an object is animated using bones (GetObjectNumBones>0), AppGameKit uses a specific shader to animate the object (using quaternions)

In ALL the other shaders, the agk_World matrix translates position and applies the scale to an object too. In the bone animated shader, agk_World is not applied at all

Just try using SetObjectScale() and not even that works on a bone animated object - so its not just tweens (No scale of any sort works due to the lack of agk_World being applied)

So...if you write a custom shader which is basically the standard bone animated one but with an additional application of scale values.... then you CAN actually scale an animated model too. If you reintroduce the agk_World variable and multiply the position then the model animates and the scale is applied but the translation gets applied twice so you have to remove the bottom row of the matrix in the shader. I've also tried this with a tween and it works with the tween scale too and SetObjectScale() works again correctly.

There is then potentially an issue of normals needing normalising in the shader too due to this potentially, but I wont go into that here. The point is that its to do with the animated shader and it is fixable by changing the shader if it is absolutely needed.

It probably wants raising as a bug on github and it is fixable fairly easily.


...The OP's issue is nothing to do with bone names. Depending on the model file format bone names can be loaded. Its just a case of it being dependent on the exact software used to produce the model. I've a few MS3D models where the bone names are loaded correctly. Seems to be quite flaky as do the animation names which dont seem to work with every filetype either.
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 5th Jul 2019 08:27
Hi Bengismo.

With the bone names, you can load the model and read the names......AGK will tell you them (bone 1 called "left leg" etc), but if you then call that bone name it returns zero. Seems like a bug.

Can you calc normals in a shader with a geometry shader? I've been trying to do that for months!
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 5th Jul 2019 09:34 Edited at: 5th Jul 2019 09:41
Quote: "With the bone names, you can load the model and read the names......AGK will tell you them (bone 1 called "left leg" etc), but if you then call that bone name it returns zero. Seems like a bug."


The Bone Animation sample that ships with AppGameKit has an example of loading the soldier.x model that ships with AppGameKit and then finding a bone ID by its name

Ie: headBone = GetObjectBoneByName( 1, "Bip01_Head" )

And if you use ... GetObjectBoneName(1, headBone) = "Bip01_Head" it gives the correct name

This works fine and all his bones are well named. All of my models work ok like this too. If your having an issue with it, you could try and make an example file and then post a bug. Also check that you model loads as one animated object and not multiple child objects. If there a re multiple child objects you may have to find the bone in those I guess. It does work with .x files and with a few other formats too but I havent check ALL the supported formats.


Normals are typically calculated in vertex shaders (geometry shaders are a whole other topic) and typically just involve multiplying by the normal by agk_WorldNormal. Its is possible to calculate normals in shaders (say like on a tesselated mesh or on a terrain) but you should probably post a separate question about exactly what your trying to do and get the help of the pros (ie..Mr Janbo and others).
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 5th Jul 2019 15:14
It is a .x model. Very odd, I'll maybe pull out just that model and test to see if I can show the issue. It's not a major issue, I just scan till I find the number that's the name I want, then store it and reference that way.

Thanks.....but you are an expert. Lol. I'll post a separate thread, been told before it's not possible to calc normals in just a vertex shader.....I.e for a mesh that doesn't have correct normals, such as water waves that are moved in the vertex shader

Login to post a reply

Server time is: 2024-03-28 21:39:49
Your offset time is: 2024-03-28 21:39:49