luknei Posted October 28, 2016 Share Posted October 28, 2016 Hello guys, Just started using babylon JS more than a week ago at work. Everything was going quite smooth so far. However I am struggling to export .babylon file from blender. Most probably it's because I have pretty much no experience with blender and 3D models in general. The mesh gets exported correctly but the main problem is with animations/animations actions, when I import .babylon file to the babylon engine and start any of the animations the mesh goes all over the place... I add .fbx file and .babylon file I get when I export it form blender. I hope someone can help me. I really need a help on this one. ArmyPilot_babylon.rar ArmyPilot_fbx.rar Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 28, 2016 Share Posted October 28, 2016 Ping our Blender divinity @gryff Quote Link to comment Share on other sites More sharing options...
gryff Posted October 29, 2016 Share Posted October 29, 2016 @luknei : Hi luknei welcome to the forum Can you post your .blend file? cheers, gryff Quote Link to comment Share on other sites More sharing options...
luknei Posted October 29, 2016 Author Share Posted October 29, 2016 @gryff Thanks guys, I feel that this community cares Of course I can. It is just over 5mb so cannot add directly here, but here is the link to the zipped blend file: https://www.dropbox.com/s/0gpxja9yi056x75/ArmyPilot_blend.rar?dl=0 Quote Link to comment Share on other sites More sharing options...
gryff Posted October 29, 2016 Share Posted October 29, 2016 @luknei : TY for the .blend file. On 2016-10-28 at 11:33 AM, luknei said: when I import .babylon file to the babylon engine and start any of the animations the mesh goes all over the place... What version of the Blender Babylon Exporter (BBE) are you using? I am using v5.0.6 - and it won't even let me export to .babylon. The reason : you have un-applied transforms which is why you will get the "spaghetti monster" with older versions of the BBE So: 1. Select the Mesh in "Object Mode" and Object->Apply ->"Rotation and Scale" 2. Select the Armature "Object Mode" and again Object->Apply ->"Rotation and Scale" That allows me to export the file. However, when I try to run it I get this error message: BJS - [12:44:45]: Unable to compile effect: babylon.2.5.js:3:22965 BJS - [12:44:45]: Vertex shader:defaultbabylon.2.5.js:3:22965 BJS - [12:44:45]: Fragment shader:defaultbabylon.2.5.js:3:22965 BJS - [12:44:45]: Defines: #define NUM_BONE_INFLUENCERS 4 #define BonesPerMesh 65 babylon.2.5.js:3:22965 BJS - [12:44:45]: Error: ERROR: too many uniformsbabylon.2.5.js:3:22965 You notice the number of bones 65. It looks like my PC is choking on those bones. Recommended number 40 or less. So, if you can get an export and can see the soldier, try applying Scale and Rotation as above and re-export Then try viewing you new export. cheers, gryff drodsou 1 Quote Link to comment Share on other sites More sharing options...
dbawel Posted October 29, 2016 Share Posted October 29, 2016 Always reset your transforms before exporting any file from one application to another - regardless of the format. The issue is that the application you import into will look at the transforms, and adjust the animation to the scale, rotation, and if you want to translate your object in WebGL, then I highly advise to set the center axis of the parent of your sleleton at 0,0,0 in XYZ, and then animate.If your' past this point, then you should parent to a new object in your script. However, as @gryff made clear, if you don't take the steps he stated, then there is no way to maintain your animation as you might expect - especially on meshes bound to a skeleton in WebGL. Even if a mesh is not bound to a skeleton or bone(s), always reset your transforms before exporting from any package. DB Quote Link to comment Share on other sites More sharing options...
luknei Posted November 2, 2016 Author Share Posted November 2, 2016 Hey guys,@gryff, I was using 4.6.* before. Now I tried exporting with 5.0.7. It did not allow me to export the model at first (as you said), after applying transformations it finally allowed. However the animations are still all over the place. About the bones count, I'm not going to decrease number of bones, because I'm a noob at the blender and 3D modeling in general. And this model is for our MVP version, so we are going to buy more detailed and more complex model later on. So I'm not completely clear if I'm still doing something wrong or it is impossible to export that kind of model from blender (because of the bones count)? I tried playing with 3ds max. It exported model and animation correctly, but problem with it is that I can only import one animation from .fbx file. I also tried fbx to babylon coverter, but it seems it has the same problem - you can select only one animation :| I'm now confused for which tool should I spend more time investigating how to export this model. Maybe someone of you could set the necessary options and upload the .blend file here? Thanks, Lukas Quote Link to comment Share on other sites More sharing options...
gryff Posted November 3, 2016 Share Posted November 3, 2016 @luknei How does this look ? Soldier Just one animation. And the soldier boy has no uniform as you did not embed the textures in the .blend file cheers, gryff Quote Link to comment Share on other sites More sharing options...
luknei Posted November 3, 2016 Author Share Posted November 3, 2016 Hey! Looks good Do not care about the textures right now So can you guide me how you did export the model? Because currently I wrote monstrous script that uses .fbx > .babylon converter and then concats bones animations from different files to single skeleton ( Terrible ) Quote Link to comment Share on other sites More sharing options...
gryff Posted November 4, 2016 Share Posted November 4, 2016 Well Is it what I did @luknei I noticed that once I had applied the scale/rotation to the rig and the mesh, that if I played the animation the soldier was moving all over the place in the 3D window of Blender (in the X and Y directions) . I looked at your fbx file in AutoDesk FBX Converter and the animations were basically in the same spot. So I thought to myself the scaling has not been applied to the animation. So here are the steps I took to try and correct that. I have posted below a couple of images that may help you including the general layout I used in Blender (Image 1) : A.) The Outliner with the pelvis bone selected (red box) B.) 3DWindow again showing the pelvis bone selected (red box) C.) The Dopesheet D.) The Timeline Step 1: In Object Mode I applied the scale/rot to the mesh and rig. Step 2: Selected Rig/Armature -> then chose an animation to fix Step 3: Pose Mode-> Selected the Pelvis Bone Step 4: With mouse cursor over the Dopesheet window and the Dopesheet in Action Editor mode go Shift+Spacebar. This is a toggle that allows you to just display just the window the mouse is over. (Image 2) Step 5 Deselect all the key frames (the A key) they should all now be white. Step 6: Using the right scroll bar for the Dopesheet, scroll down until you find the Pelvis bone - it will be highlighted in white. Step 7: Using Box Select (B key) select the key frames for "Location", then X key to delete keyframes. Now toggle back to the general layout Shift + SpaceBar again, chose another animation and repeat Steps1-7 I should add some statements about what I managed to achieve 1. I could only get sucess with just a single animation (I deleted all the rest) and even in that case it defaulted back to the CPU from the GPU for calculations 2. Attempts at more than one animation and I get that "too many uniforms message" and nothing shows up. 3. As the position of the pelvis is being deleted, any animation that specifically needs it (a jump/crouch for example) will need new key frames to be added back after the the old position key frames have been deleted 4. Perhaps before you try to deal with all the animations, you maybe try just two or three (delete the rest) cheers, gryff Quote Link to comment Share on other sites More sharing options...
MrVR Posted November 4, 2016 Share Posted November 4, 2016 14 hours ago, luknei said: Hey! Looks good Do not care about the textures right now So can you guide me how you did export the model? Because currently I wrote monstrous script that uses .fbx > .babylon converter and then concats bones animations from different files to single skeleton ( Terrible ) HI @gryff nice post, but is it possible to do it with an vertex animation cache , meaning with out bones like an alembic file, I import the file into blender the animation plays well but I try the animated and its no working I created a .babylon file and added the animation attributes, e.g.' autoAnimate ... ' see below, then I drop the file in the sandbox I tried before CTRL + A and add location, rotation, scale, and it worked http://brandsocialguru.com/files/cube.blend http://brandsocialguru.com/files/cube.babylon I repeat the same with my files and it does not work "autoAnimate": true, "autoAnimateFrom": 0, "autoAnimateTo": 50, "autoAnimateLoop": true the files are big so please download it from this links the first one is the alembic the other ones are FBX and a BVH to capture the animation and also below I put pictures of my export options and the cube babylon code animated ready http://brandsocialguru.com/files/RobDancer.abc ,http://brandsocialguru.com/files/motionBUilder.fbx ,http://brandsocialguru.com/files/RobForum.fbx, http://brandsocialguru.com/files/RRobForum_motion0.bvh The cube code {"producer":{"name":"Blender","version":"2.78 (sub 0)","exporter_version":"4.6.1","file":"cube.babylon"}, "autoClear":true,"clearColor":[0.0509,0.0509,0.0509],"ambientColor":[0,0,0],"gravity":[0,-9.81,0], "materials":[{"name":"cube.Material","id":"cube.Material","ambient":[0.8,0.8,0.8],"diffuse":[0.64,0.64,0.64],"specular":[0.5,0.5,0.5],"emissive":[0,0,0],"specularPower":50,"alpha":1,"backFaceCulling":true,"checkReadyOnlyOnce":false}], "multiMaterials":[], "skeletons":[], "meshes":[{"name":"Cube","id":"Cube","materialId":"cube.Material","billboardMode":0,"position":[0,0,0],"rotation":[0,-1.4905,0],"scaling":[1,1,1],"isVisible":true,"freezeWorldMatrix":false,"isEnabled":true,"checkCollisions":false,"receiveShadows":false ,"positions":[1.1265,-1,-0.855,-1.1265,-1,0.855,0.855,-1,1.1265,-1.1265,1,0.855,1.1265,1,-0.855,0.855,1,1.1265,-0.855,-1,-1.1265,-0.855,1,-1.1265] ,"normals":[0.6503,-0.5773,-0.4936,-0.6503,-0.5773,0.4936,0.4936,-0.5773,0.6503,-0.6503,0.5773,0.4936,0.6503,0.5773,-0.4936,0.4936,0.5773,0.6503,-0.4936,-0.5773,-0.6503,-0.4936,0.5773,-0.6503] ,"indices":[0,1,2,3,4,5,5,0,2,4,6,0,6,3,1,2,3,5,0,6,1,3,7,4,5,4,0,4,7,6,6,7,3,2,1,3] ,"subMeshes":[{"materialIndex":0,"verticesStart":0,"verticesCount":8,"indexStart":0,"indexCount":36}], "autoAnimate": true, "autoAnimateFrom": 0, "autoAnimateTo": 50, "autoAnimateLoop": true ,"animations":[{"dataType":1,"framePerSecond":24,"keys":[ {"frame":7,"values":[0,-0.1361,0]}, {"frame":83,"values":[0,4.7927,0]}],"loopBehavior":1,"name":"rotation animation","property":"rotation"},{"dataType":1,"framePerSecond":24,"keys":[ {"frame":7,"values":[0,0,0]}, {"frame":83,"values":[0,0,0]}],"loopBehavior":1,"name":"position animation","property":"position"},{"dataType":1,"framePerSecond":24,"keys":[ {"frame":7,"values":[1,1,1]}, {"frame":83,"values":[1,1,1]}],"loopBehavior":1,"name":"scaling animation","property":"scaling"}],"ranges":[{"name":"CubeAction","from":0,"to":83}] ,"instances":[]} ], "cameras":[{"name":"Camera","id":"Camera","position":[7.4811,5.3437,-6.5076],"rotation":[0.4615,-0.8149,0],"fov":0.8576,"minZ":0.1,"maxZ":100,"speed":1,"inertia":0.9,"checkCollisions":false,"applyGravity":false,"ellipsoid":[0.2,0.9,0.2],"cameraRigMode":0,"interaxial_distance":0.0637,"type":"FreeCamera"}],"activeCamera":"Camera", "lights":[{"name":"Lamp","id":"Lamp","type":0,"position":[4.0762,5.9039,1.0055],"intensity":1,"diffuse":[1,1,1],"specular":[1,1,1]}], "shadowGenerators":[] } Quote Link to comment Share on other sites More sharing options...
MrVR Posted November 4, 2016 Share Posted November 4, 2016 I leave you with a preview of my PROJECT in play-canvas (P.S. adult content) , I drooped it because it was too difficult and slow to load files. Then I tried Bend4web PROJECT , please be patience this one open some times slow, so leave it open and check it out later . I'm planning to use the files from these other SDK's because they are JSON format and similar , Blend4web uses json/bin two files, and play canvas fbx and json animation, also here is a plugin where you can create a one mesh animation and a .PC2 file . Thanks for all your help !!! attached below the json file and here is the link for the binary if someone is interested JSON files compare FROM B4W and BABY gingerBreadMan.json Quote Link to comment Share on other sites More sharing options...
gryff Posted November 4, 2016 Share Posted November 4, 2016 @MrVR Hi and Welcome to the forum I'm sorry to say that my knowledge of alembic files and their use is very limited. Basically that they were introduced with Blender 2.78 (the latest version of Blender). As for animations without "bones", the author ( @JCPalmer)of the Blender Babylon Exporter (BBE) has been working on the Blender "Tower Of Babel" (TOB) exporter which involves Queued Interpolation which might be where you should be looking. I tried the B4W example - took a while to load. Over two years ago I looked at three.js, BJS and B4W - and the reason I passed on B4W was its slowness. Now it is capable of exporting more Blender features than the BBE but I am happy with the speed and file sizes from the BBE. The Play Canvas demo never loaded. Here is a "dancing" lady demo (rigged) I created within a month of deciding to use BJS - over 2 years ago. File size 2.77 Mb + 1Mb of textures. You might want to start a new thread on this subject - to get more of the coders attention. cheers, gryff Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted November 4, 2016 Share Posted November 4, 2016 @gryff, to specifically answer this VR man's question (not sure why all these pictures are required), NO. Animations which involve a bone chain length > 1 cannot always satisfactorily be performed using vertex deformation. Usually you need to do it really fast (200 milli), like I did in my shape key finger test scene. User fooled into thinking it was right. In that case, ditching 30 bones was far better, even when gestures could no longer be performed in slow motion. Not sure what is his real problem. You cannot do auto animate with skeletal animation, period. He needs to break down and build a page. Providing all these picture, especially FBX stuff, justs sends me running. Quote Link to comment Share on other sites More sharing options...
MrVR Posted November 4, 2016 Share Posted November 4, 2016 5 minutes ago, gryff said: @MrVR Hi and Welcome to the forum I'm sorry to say that my knowledge of alembic files and their use is very limited. Basically that they were introduced with Blender 2.78 (the latest version of Blender). As for animations without "bones", the author ( @JCPalmer)of the Blender Babylon Exporter (BBE) has been working on the Blender "Tower Of Babel" (TOB) exporter which involves Queued Interpolation which might be where you should be looking. I tried the B4W example - took a while to load. Over two years ago I looked at three.js, BJS and B4W - and the reason I passed on B4W was its slowness. Now it is capable of exporting more Blender features than the BBE but I am happy with the speed and file sizes from the BBE. The Play Canvas demo never loaded. Here is a "dancing" lady demo (rigged) I created within a month of deciding to use BJS - over 2 years ago. File size 2.77 Mb + 1Mb of textures. You might want to start a new thread on this subject - to get more of the coders attention. cheers, gryff Thanks @gryff I just purchase the babylonjs book along with the sample codes, But I still have to go through it to see if I find a solution, anyways thanks for the link I will definitely check this today or tomorrow but this weekend I will put all my effort to solve it, let me tell you alembic is very nice type of file you can pack lots of stuff (cameras, mesh, lights etc...) in one file , I jsut import it in blender and the animations are very nice since I use motion capture. Quote Link to comment Share on other sites More sharing options...
MrVR Posted November 4, 2016 Share Posted November 4, 2016 8 minutes ago, JCPalmer said: @gryff, to specifically answer this VR man's question (not sure why all these pictures are required), NO. Animations which involve a bone chain length > 1 cannot always satisfactorily be performed using vertex deformation. Usually you need to do it really fast (200 milli), like I did in my shape key finger test scene. User fooled into thinking it was right. In that case, ditching 30 bones was far better, even when gestures could no longer be performed in slow motion. Not sure what is his real problem. You cannot do auto animate with skeletal animation, period. He needs to break down and build a page. Providing all these picture, especially FBX stuff, justs sends me running. Hi , thanks for the reply Mr Palmer, if you see the pictures there are many ways to do it and many ways to export the FBX , (alembic) files; I was just looking for the right options setup (3ds Max export or unity export type..), I provided links and pictures to show that the vertex cache animation works in other sdk's and platforms (Play-canvas and Blend4Web) but not in BJS; I will keep trying and see how it goes and can you please provide a link for this ,Key Finger Test Scene , so I can understand better your answer. thank you Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted November 4, 2016 Share Posted November 4, 2016 Well, do not know what alembic files are, but they need to import into Blender as shapekeys on meshes. When there are a number of joins, converting rotation into morphing between 2 states can look weird. Slow down making of a fist. Also, shapekeys take more file space than skeleton animation. Quote Link to comment Share on other sites More sharing options...
MrVR Posted November 4, 2016 Share Posted November 4, 2016 9 hours ago, JCPalmer said: Well, do not know what alembic files are, but they need to import into Blender as shapekeys on meshes. When there are a number of joins, converting rotation into morphing between 2 states can look weird. Slow down making of a fist. Also, shapekeys take more file space than skeleton animation. Thanks Mr. Palmer, I see what you mean, I have a pluging ,animationJointer, that merge animated objects into only one mesh, then I want to animated by a mesh cache modifier and a .pc2 file (I have not figure this part yet), this has the option to create keyframes. or just the pc2 file, I have no experiment further yet but this another option to consider review, it worked in beld4web after baking it with their SDK and it produces the b4w json/bin files,I deployed it and it worked , the plugin creates a one single mesh with keyframes, then , baking the mesh but no going over 200 frames more or less before the blender crashes , too many frames . what do you think? may be with the keyframes created by this tool is it possible to reproduce the animation in BSJ? below the keyframes created and the close up of the plugin. Quote Link to comment Share on other sites More sharing options...
gryff Posted November 6, 2016 Share Posted November 6, 2016 @luknei : I don't know If you are still interested, but it is possible to fix the issue of the location of pelvis bone using the F-Curve Editor. This avoids problems with jumping/crouching animations. If you are interested I can post the methods used. cheers, gryff Quote Link to comment Share on other sites More sharing options...
luknei Posted November 8, 2016 Author Share Posted November 8, 2016 Hello, Thanks for your help! It seemed to much work to export this model (at least for the rookie) so we decided to buy premium model and work with it. However if you have easier solution on how to fix this kind of issues it might be useful for someone else though. Thanks! 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.