MackeyK24 Posted July 20, 2018 Author Share Posted July 20, 2018 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 Quote Link to comment Share on other sites More sharing options...
bghgary Posted July 20, 2018 Share Posted July 20, 2018 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. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted August 19, 2018 Author Share Posted August 19, 2018 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 Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted August 22, 2018 Author Share Posted August 22, 2018 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 ??? Quote Link to comment Share on other sites More sharing options...
Sebavan Posted August 22, 2018 Share Posted August 22, 2018 @bghgary is currently in vacation I bet he ll answer as soon as he ll be back ? Quote Link to comment Share on other sites More sharing options...
bghgary Posted September 6, 2018 Share Posted September 6, 2018 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. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 6, 2018 Author Share Posted September 6, 2018 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 Quote Link to comment Share on other sites More sharing options...
bghgary Posted September 6, 2018 Share Posted September 6, 2018 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. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 17, 2018 Author Share Posted September 17, 2018 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) 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 bghgary 1 Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 17, 2018 Author Share Posted September 17, 2018 And CESIUM Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 17, 2018 Author Share Posted September 17, 2018 And THREE.JS Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 17, 2018 Author Share Posted September 17, 2018 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) MarianG 1 Quote Link to comment Share on other sites More sharing options...
MarianG Posted September 17, 2018 Share Posted September 17, 2018 Well done!!! ? I'm waiting to play with it ? By the way... Is this working with GLB file too? And with draco compress? Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 17, 2018 Author Share Posted September 17, 2018 GLB ... yes From what I can tell I can only see decoder for Unity ... No encoders... so Draco compression will not be supported til they make an Encoder that cab used from Unity MarianG 1 Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 17, 2018 Author Share Posted September 17, 2018 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.