adwilson Posted September 7, 2014 Share Posted September 7, 2014 Hi Babylon.js forum, I've been particularly setback by a problem I haven't been able to solve for the last day. I have created a stage in Blender, exported it to Babylon. I had two objects I wanted to create a compound imposter and I found createCompoundImpostor() at this site: http://blogs.msdn.com/b/eternalcoding/archive/2013/12/19/create-wonderful-interactive-games-for-the-web-using-webgl-and-a-physics-engine-babylon-js-amp-cannon-js.aspx. It says you have to create a hierarchy so I did, using .parent... except it squashed one of the meshes. I wondered if this was something in my export so I started a new test project in Blender and yet it still squashes a mesh, in particular it squashes the child mesh! Here is a section of my test codevar pushers = { pusher: null, rod: null};var loaded = false;BABYLON.SceneLoader.ImportMesh("", "", "Stage-Test-4-TEST001.babylon", scene, function (meshes) { meshes.forEach(function (mesh) { if (mesh.id === "Slider_Pusher") { pushers.pusher = mesh; } else if (mesh.id === "Slider_Test") { pushers.rod = mesh; } }); pushers.rod.parent = pushers.pusher; var parts = [ { mesh: pushers.pusher, impostor: BABYLON.PhysicsEngine.BoxImpostor }, { mesh: pushers.rod, impostor: BABYLON.PhysicsEngine.BoxImpostor } ] scene.createCompoundImpostor(parts, { mass: 1, friction: 0.1, restitution: 0.1 }); loaded = true;});And here are two screenshots, first from Blender and then from my browser (Ignore the missing faces in pushers.pusher, that's just a stupid problem I encountered making this setup even though all the normals are consistent in Blender) I just cannot figure out what's going on, the only documentation on the entire Internet on this feature is the 2 lines, 1 quoted line and few lines of code from that page! I'm using Oimo.js but in cannon.js it did the same thing. Is this a library bug or am I just doing it completely wrong? Does anyone have any working examples they could share? I'm in despair and losing faith!! Haha! Cheers guys. Quote Link to comment Share on other sites More sharing options...
Temechon Posted September 7, 2014 Share Posted September 7, 2014 Hello, The position of the children is set relative to the parent.If the parent position is (1,1,1), and one of its child position is (1,1,1), then the child will appear at position (2,2,2) (child.position + parent.position). When creating a parenting relation, you have to keep this in mind. In your case, you just have to substract the parent position to the child position. Cheers, Edit : Same goes with rotation and scaling ! Generally, all transformations done to the parent will be done on the child. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
adwilson Posted September 10, 2014 Author Share Posted September 10, 2014 Thanks Temechon, I'll give this a whirl when I get the time! Thanks for your help 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.