eboo Posted February 28, 2016 Share Posted February 28, 2016 Have you a way to use "generic" animations? I ve a few elements (with same skeleton and skeleton names inside^^) I d like to use the same "way" to animate them. is it possible? my objective is to simplify my .bablylons and save few time in blender ^^. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 29, 2016 Share Posted February 29, 2016 Hello you can use the same skeleton with multiple meshes. But this will mostly depend on which tool you use to generate the .babylon Quote Link to comment Share on other sites More sharing options...
eboo Posted February 29, 2016 Author Share Posted February 29, 2016 i use blender. my dream: generate 2 differents meshes.babylon (with skeleton) but no animation inside load them in my scene Animate them. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted February 29, 2016 Share Posted February 29, 2016 How about 3 .babylons? The 4.2+ exporters are set up to do that with multiple actions & friendly with inverse kinematics skeletons. In .babylon / blend 1: first mesh wt skeleton, but no animation. In .babylon / blend 2: second mesh wt same skeleton, but no animation. In .babylon / blend 3: a skeleton (with optional bones ending in .ik that do not get exported). As many named actions as you wish. loading: var scene = new BABYLON.Scene(engine); var lights = ... var camera = ... var url = ... BABYLON.SceneLoader.Append(url, "mesh1.babylon", scene); BABYLON.SceneLoader.Append(url, "mesh2.babylon", scene); BABYLON.SceneLoader.Append(url, "skeleton_library.babylon", scene); scene.executeWhenReady(function () { // Attach camera to canvas inputs scene.activeCamera.attachControl(canvas); // Once the scene is loaded, register a render loop engine.runRenderLoop(function() { scene.render(); }); var skeleton1 = scene.getSkeletonByName("skeleton1"); var skeleton2 = scene.getSkeletonByName("skeleton2"); var library = scene.getSkeletonByName("library"); skeleton1.copyAnimationRange(library, "myaction1", true); skeleton1.beginAnimation("myaction1"); skeleton2.copyAnimationRange(library, "myaction2", true); skeleton2.beginAnimation("myaction2"); }); satguru, GameMonetize, eboo and 1 other 4 Quote Link to comment Share on other sites More sharing options...
eboo Posted February 29, 2016 Author Share Posted February 29, 2016 thanks Quote Link to comment Share on other sites More sharing options...
gryff Posted March 1, 2016 Share Posted March 1, 2016 Oooh, very very nice Jeff cheers, gryff Quote Link to comment Share on other sites More sharing options...
eboo Posted March 2, 2016 Author Share Posted March 2, 2016 i've tried with a mesh with sketon and one with animation only. console give me good news but skeleton1.copyAnimationRange(library, "myaction1", true); give me this error TypeError: this._keys is undefined babylon....max.js (ligne 21916) is there a way to copyanimation with frame numbers? exemple skeleton1.copyAnimatinRange(library,1,100,true) Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted March 2, 2016 Share Posted March 2, 2016 No. The point of an AnimationRange is to use names not magic numbers. This becomes really important once you have multiple actions. Did you give the name of your action "myaction1"? That is what I used in my sample. Even imported .bvh files have an action associated with them. Think you may need to up your Blender game. To find the name of an action, switch your layout to 'Animation'. Change your Dope sheet panel to 'Action Editor' mode. The name(s) of your actions are just to the right. Showing action, base08_11x94. Quote Link to comment Share on other sites More sharing options...
eboo Posted March 2, 2016 Author Share Posted March 2, 2016 yes i have. my animation name is "marcher". Quote Link to comment Share on other sites More sharing options...
eboo Posted March 2, 2016 Author Share Posted March 2, 2016 here are my two files. nain skeleton is "armature" animation walk name is "marcher" walk.babylon nain.babylon Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted March 2, 2016 Share Posted March 2, 2016 Line 21916 indicates there is not animation. Looked at your files. Is your load script lik: BABYLON.SceneLoader.Append(url, "nain.babylon", scene); BABYLON.SceneLoader.Append(url, "walk.babylon", scene); scene.executeWhenReady(function () { // Attach camera to canvas inputs scene.activeCamera.attachControl(canvas); // Once the scene is loaded, register a render loop engine.runRenderLoop(function() { scene.render(); }); var skeleton1 = scene.getSkeletonByName("Armature"); var library = scene.getSkeletonByName("marcher"); skeleton1.copyAnimationRange(library, "marcher", true); skeleton1.beginAnimation("marcher"); }); eboo 1 Quote Link to comment Share on other sites More sharing options...
eboo Posted March 2, 2016 Author Share Posted March 2, 2016 initiated with BABYLON.SceneLoader.ImportMesh("", "bb/nain/", "nain.babylon", scene, function (newMeshes, particleSystems, skeletons) { few thinks } skeleton1 = scene.getSkeletonByName("Armature"); and a listener on "x" touch BABYLON.SceneLoader.Append("bb/nain/", "walk.babylon", scene); library = scene.getSkeletonByName("marcher"); skeleton1.copyAnimationRange(library, "marcher", true); skeleton1.beginAnimation("marcher"); if il look library with firebug i found animations i will give a try with easier animation and skeleton Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted March 2, 2016 Share Posted March 2, 2016 I used my append way. I get a different error, and in copyAnimationRange() instead. There is a bug. When I did my testing, my destination bones already had some animation, because I wanted to test deleteRange() too. So I did not get an error. There needs to be a test added to check if there is no animation[0] to push an empty. Will not get to this today. My "Gulp"er needs some TLC too. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 2, 2016 Share Posted March 2, 2016 @eboo: can you reproduce on the playground? I'll fix it for you Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted March 3, 2016 Share Posted March 3, 2016 Here, is mine showing error. I do 2 appends, then copy in executeWhenReady. Thing he gets a different error cause not waiting to do copy. I have a fix, but cannot gulp. I was checking if there was no animations & adding in that case, but an Animation has no keys until setKeys(). Here is a changed Bone.copyAnimationRange with 1 line added to setKeys(). public copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired = false): boolean { // all animation may be coming from a library skeleton, so may need to create animation if (this.animations.length === 0) { this.animations.push(new Animation(this.name, "_matrix", source.animations[0].framePerSecond, Animation.ANIMATIONTYPE_MATRIX, 0)); this.animations[0].setKeys([{}]); } // get animation info / verify there is such a range from the source bone var sourceRange = source.animations[0].getRange(rangeName); if (!sourceRange) { return false; } var from = sourceRange.from; var to = sourceRange.to; var sourceKeys = source.animations[0].getKeys(); // rescaling prep var sourceBoneLength = source.length; var scalingReqd = rescaleAsRequired && sourceBoneLength && this.length && sourceBoneLength !== this.length; var ratio = scalingReqd ? this.length / sourceBoneLength : null; var destKeys = this.animations[0].getKeys(); // loop vars declaration / initialization var orig: { frame: number, value: Matrix }; var origScale = scalingReqd ? BABYLON.Vector3.Zero() : null; var origRotation = scalingReqd ? new BABYLON.Quaternion() : null; var origTranslation = scalingReqd ? BABYLON.Vector3.Zero() : null; var mat: Matrix; for (var key = 0, nKeys = sourceKeys.length; key < nKeys; key++) { orig = sourceKeys[key]; if (orig.frame >= from && orig.frame <= to) { if (scalingReqd) { orig.value.decompose(origScale, origRotation, origTranslation); origTranslation.scaleInPlace(ratio); mat = Matrix.Compose(origScale, origRotation, origTranslation); } else { mat = orig.value; } destKeys.push({ frame: orig.frame + frameOffset, value: mat }); } } this.animations[0].createRange(rangeName, from + frameOffset, to + frameOffset); return true; } Dad72 and eboo 2 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 3, 2016 Share Posted March 3, 2016 Ok..will merge it for next commit Quote Link to comment Share on other sites More sharing options...
eboo Posted March 3, 2016 Author Share Posted March 3, 2016 thanks, i will try this it's sound good and could be the same error for me :). Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted March 3, 2016 Share Posted March 3, 2016 I tested, and get past the problem with the change. Did not update that googledrive url. The scene is black, but I do not have the textures nor do I know whether the cameras and lights are in a good spot in the nain.babylon. Quote Link to comment Share on other sites More sharing options...
eboo Posted March 4, 2016 Author Share Posted March 4, 2016 same black screen Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted March 4, 2016 Share Posted March 4, 2016 eboo, Having a black screen is because the lights & camera in the nain.babylon file are wrong. I created my own light & arc rotate camera in the html of my example. It displays now. With 2.4 alpha, the animation range copies but errors on playing. I need to drop back and see that my own test scenes work with the newest of everything. If not, work back to final 2.3 & earlier Blender exporters. No offense eboo, gryff, & dad72 (sort of but I do not know 3dMax), but no point in even trying to debug or get your stuff to run. I know my tests ran, even if slightly flawed in that I already had some animation in the destination skeleton to test range deletion. Depending on my retesting, I will then proceed accordingly. eboo 1 Quote Link to comment Share on other sites More sharing options...
eboo Posted March 4, 2016 Author Share Posted March 4, 2016 Oh man!!!! no light no trouble!!!! i ve update my nain.babylons with cam and light... and i got it. Thanks a lot!!!!! 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.