Jump to content

Test GLTF Animations


MackeyK24
 Share

Recommended Posts

Thats what i dont get... I have the code working to skin and joints and weights... what i dont understand is at WHAT POINT and WHERE would i encode the bones and what node... Do i get the Skeleton first then iterate all the bones... and if so, what am i attaching to...

or do i just check each node and see if it is a bone of skeleton, also what am i attaching to in gltf...

And most import... HOW DO ACTUALLY code all the tangent in out stuff... like i think it input/time and output/value or something like that.

Could you please just thru some code (or even pseudo code) on actually encoding a skeleton... Dude it just me... Not fully getting the GLTF spec for encoding a skeleton...

but if i just saw some code doing it... i can say OH...thats what going on... and take it from there :)

 

Link to comment
Share on other sites

9 minutes ago, MackeyK24 said:

Do i get the Skeleton first then iterate all the bones...

There is no need to iterate all the bones (at least not going from Unity to glTF). You would need to do something like that going from Unity to Babylon because Babylon has a separated skeleton structure. The Babylon glTF loader will handle creating the Babylon skeleton and iterate the bones, etc. etc. Both Unity and glTF don't do this as the skeleton hierarchy is together with the mesh hierarchy.

11 minutes ago, MackeyK24 said:

HOW DO ACTUALLY code all the tangent in out stuff... like i think it input/time and output/value or something like that.

Assuming you are talking about cubic splines animations, my code is here, but it doesn't handle every case as you've already seen. To get things working, I would suggest baking the animations into linear form (which I think you already do) and tackle cubic splines later after sorting out the skeleton issue.

Link to comment
Share on other sites

  • 5 weeks later...

Yo @bghgary ... Do you do side work for money. 

I have a MAJOR problem with the Animation Port of UnityGLTF you suggested before. The problem is Local Rotations. The code you (or your buddy) is using is looking for and ONLY support m_localRotation. This is OLD UNITY behavior. Unity use LOCAL EULERS. I have been trying for WEEKS but i cant figure out what you are doing here and how i can tweak this out to support Euler angle... Get the Quaternion form the Euler angle is EASY... Quaternion.Euler(x,y,z) ... But for the life of me I CANT FREAKING FIGURE out what the heck this is doing to encode GLTF Animations:

private AnimationSampler ExportAnimationSamplerRotation(AnimationCurve curveX, AnimationCurve curveY, AnimationCurve curveZ, AnimationCurve curveW)
{
	return ExportAnimationSampler(
		new AnimationCurve[] { curveX, curveY, curveZ, curveW },
		keyIndex => GetRightHandedQuaternion(new Quaternion(curveX.keys[keyIndex].inTangent, curveY.keys[keyIndex].inTangent, curveZ.keys[keyIndex].inTangent, curveW.keys[keyIndex].inTangent)),
		keyIndex => GetRightHandedQuaternion(CreateNormalizedQuaternion(curveX.keys[keyIndex].value, curveY.keys[keyIndex].value, curveZ.keys[keyIndex].value, curveW.keys[keyIndex].value)),
		keyIndex => GetRightHandedQuaternion(new Quaternion(curveX.keys[keyIndex].outTangent, curveY.keys[keyIndex].outTangent, curveZ.keys[keyIndex].outTangent, curveW.keys[keyIndex].outTangent)),
		time => GetRightHandedQuaternion(CreateNormalizedQuaternion(curveX.Evaluate(time), curveY.Evaluate(time), curveZ.Evaluate(time), curveW.Evaluate(time))),
		values => GLTF.DataExporter.ExportData(values.Select(value => value.ToGltfQuaternionConvert()), _bufferId, _root, _bufferWriter));
}

I will PAY you via PayPal (ASAP) if you please FIXUP the UnityGLTF animation port to support local euler rotations.

Just name your price (Remember i am just one guy, NOT a large corporation or anything... so please be reasonable on price)

.... THIS ONE ISSUE IS HOLDING UP ALL MY PROJECTS (Both BabylonJS and NON-BabylonJS). Everything in industry is SHIFTING to GLTF 2.0

but i can get the FREAKING animations exported. Please Help :)

 

Here is the project source i am using: https://www.babylontoolkit.com/files/UnityGLTF-ANIM-MASTER.zip

 

 

 

Link to comment
Share on other sites

On 8/18/2018 at 6:03 PM, MackeyK24 said:

Yo @bghgary ... Do you do side work for money. 

I have a MAJOR problem with the Animation Port of UnityGLTF you suggested before. The problem is Local Rotations. The code you (or your buddy) is using is looking for and ONLY support m_localRotation. This is OLD UNITY behavior. Unity use LOCAL EULERS. I have been trying for WEEKS but i cant figure out what you are doing here and how i can tweak this out to support Euler angle... Get the Quaternion form the Euler angle is EASY... Quaternion.Euler(x,y,z) ... But for the life of me I CANT FREAKING FIGURE out what the heck this is doing to encode GLTF Animations:


private AnimationSampler ExportAnimationSamplerRotation(AnimationCurve curveX, AnimationCurve curveY, AnimationCurve curveZ, AnimationCurve curveW)
{
	return ExportAnimationSampler(
		new AnimationCurve[] { curveX, curveY, curveZ, curveW },
		keyIndex => GetRightHandedQuaternion(new Quaternion(curveX.keys[keyIndex].inTangent, curveY.keys[keyIndex].inTangent, curveZ.keys[keyIndex].inTangent, curveW.keys[keyIndex].inTangent)),
		keyIndex => GetRightHandedQuaternion(CreateNormalizedQuaternion(curveX.keys[keyIndex].value, curveY.keys[keyIndex].value, curveZ.keys[keyIndex].value, curveW.keys[keyIndex].value)),
		keyIndex => GetRightHandedQuaternion(new Quaternion(curveX.keys[keyIndex].outTangent, curveY.keys[keyIndex].outTangent, curveZ.keys[keyIndex].outTangent, curveW.keys[keyIndex].outTangent)),
		time => GetRightHandedQuaternion(CreateNormalizedQuaternion(curveX.Evaluate(time), curveY.Evaluate(time), curveZ.Evaluate(time), curveW.Evaluate(time))),
		values => GLTF.DataExporter.ExportData(values.Select(value => value.ToGltfQuaternionConvert()), _bufferId, _root, _bufferWriter));
}

I will PAY you via PayPal (ASAP) if you please FIXUP the UnityGLTF animation port to support local euler rotations.

Just name your price (Remember i am just one guy, NOT a large corporation or anything... so please be reasonable on price)

.... THIS ONE ISSUE IS HOLDING UP ALL MY PROJECTS (Both BabylonJS and NON-BabylonJS). Everything in industry is SHIFTING to GLTF 2.0

but i can get the FREAKING animations exported. Please Help :)

 

Here is the project source i am using: https://www.babylontoolkit.com/files/UnityGLTF-ANIM-MASTER.zip

 

 

 

Anyone ???

Link to comment
Share on other sites

  • 2 weeks later...
On ‎8‎/‎22‎/‎2018 at 1:19 PM, MackeyK24 said:

This is OLD UNITY behavior. Unity use LOCAL EULERS.

Hmm, I'm not sure why you think this is old Unity behavior. Using quaternions has its benefits vs using Euler angles and vice versa.

On ‎8‎/‎22‎/‎2018 at 1:19 PM, MackeyK24 said:

please FIXUP the UnityGLTF animation port to support local euler rotations

Converting each value from Euler rotation to quaternion rotations is not enough since the interpolation would be different. The simplest thing to do is to bake the animation by evaluating the curve in small time increments, convert each Euler angle result to a quaternion, but this would result in larger data. The ideal way is to fit a quaternion curve against what the Euler angles would be, but this is quite a bit more complicated and will be slower to export.

Please file an issue on the UnityGLTF repo. I will talk to folks about adding support for it.

Link to comment
Share on other sites

21 hours ago, bghgary said:
 

This is OLD UNITY behavior. Unity use LOCAL EULERS.

Now Unity defaults to Euler Angles... you would have reset all Animations to Quats in Unity instead of encoding localEularxxxxx.

Also the skins don’t work, the inverse bind poses are all messed up. Even in the forks you told me about... none of them do skins right... for example the fork you told me about tried to do skins but it never makes the Joints_0 and the weights_0... so that will never work right for GLTF.

 

if I can get you work with me for a little bit... go over the code I have forked from the original khronos UnityGLTF and properly add skins and both transform and skeleton animations. I will pay you for your time. 

Can we we do a gotomeeting so I can show you everything I got so far and exactly where we need to skins and complete animation support.

Again, all my new toolkit stuff relies on a complete GLTF export. I am totally stuck because I can’t create a complete GLTF like the GLTF Blender exporter... that one seems to be kept up to date with all working implementations of GLTF... the UnityGLTF version seems to be the Red Headed Step Child and out of date compared to the work being done on Blender version of Exporter.

 

anyways... can I pay you to work with me for a little bit ???

 

FYI... The OTHER forked versions i am referring to: https://github.com/ziedbha/UnityGLTF

Link to comment
Share on other sites

2 hours ago, MackeyK24 said:

Now Unity defaults to Euler Angles

Unity has always defaulted to Euler angles as far as I'm aware.

2 hours ago, MackeyK24 said:

the fork you told me about tried to do skins but it never makes the Joints_0 and the weights_0

Which fork do you mean? The exporter that I wrote writes out joints and weights. https://github.com/bghgary/glTF-Tools-for-Unity/blob/master/UnityProject/Assets/Gltf/Editor/Exporter.cs#L648

2 hours ago, MackeyK24 said:

can I pay you to work with me for a little bit ???

Unfortunately, I can't accept any payment like this as a Microsoft employee.

Link to comment
Share on other sites

  • 2 weeks later...

Holy Shit... After taking apart, STRIPPING and RE-WRITING the SketchFab 1.0.0 UnityGLTF the export process workflow for things like:

1... Material fallbacks - Supports PBR Specular... and coming soon... CommonPhong, CommonBlinn and CommonLambert materials

2.. PBR Gloss Mapping - Supports the PROPER glossing levels across GLTF PNG Rendering Implementations

3... Multiple Transform Animations - Support both UnityEngine.Animation and UnityAnimator Control Support)

4... Multiple Skeletal Animations - Supports both Unity Mechanim Generic and Humanoid animation rigging (My OWN Design... Nothing else to go off of)

5... Full Unity Meta Data - Export Unity component data as GLTF Extra Metadata  (CVToos-unity-metadata)

6... GLTF or GLB - Supports full internal binary asset container packages for all images, skyboxes, dds, sounds, json, txt, etc...

I had to basically create my own animation baking system (using Sketchfab style of Unity GLTF Export but with all my BabylonToolkit style export code)

But finally working beautifully...

My new Canvas Tools are gonna be 10 Times better than my first generation toolkit is...

Will post BLOG video of my progress.. Just in case ANYONE is actually interested in my new CanvasTools :)

Example Shot os VSCode preview the export scene content SampleScene.gltf with a few test objects and two Skeleton animations ... Working beautiful... and that GLTF scene file can be used ANYWHERE that supports GLTF and GLB 2.0 Scene Files (and for extended usage....CVTOOLS_unity_metadata)

327259144_ScreenShot2018-09-16at11_33_20PM.thumb.png.d7e57a85ed1a236b902fd035b60087e8.png

 

Freakin Sweet... That is the CORE framework to my new CanvasTools... I had to figure out GLTF Encoding then re-write all the code myself again :)

 

Link to comment
Share on other sites

My Goal is to create all the Functionality of the Babylon Toolkit but for native GLTF Encoding... NOT .babylon File Format.

Of course Babylon.Js has the best GLTF render of the WebGL world and my exported scene look beautiful in Babylon.JS

But now you can use that exported content with any GLTF 2.0 implementations ... Including Native game engines Like Unreal and Godot (Via its GLTF Importers)

My GLTF Vision... Called Canvas Tools (Named for its general purpose WebGL HTML5 Canvas game dev tools... Not anything to do with PlayCanvas specifically) :)

 

Link to comment
Share on other sites

Yo @bghgary and @Deltakosh FYI... I check ALL of the GLTF C# Unity implementations... Even the one you made, your buddies fork of your code, The khronos original and even the sketchfab version... NONE of them handle Skeleton animations... And they never will unless you loop thru all the bones of the skeleton and BAKE out the TRANSLATION, ROTATION AND SCALE for EACH BONE at the given animation clip SAMPLE TIME.

Here is the code i re-wrote to work with both transform and skeleton animations... Just incase you ever wanna consider adding skeleton animation to UnityGLTF:

As you know from the SaveGLTF function AFTER you call ExportScene... You call exportAnimationNodes...

All here is my code how i handle multiple animations (including skeleton animations)... Check the bottom of file for the:

exportAnimationNodes and bakeAnimationsFromAvatar functions...

GLTFMetaDataExporter.cs

Works great :)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...