okan Posted October 24, 2016 Share Posted October 24, 2016 Hello, I'm trying to learn babylonjs and build a simple tower defense game. However, there is a problem i could not solve. I have imported a tower model with some weapons on it (more than 20 meshes). When I print positions of these meshes, it says they are all at 0,0,0. However, when I try to rotate or change position it behaves like its pivot position is at 0,0,0 and their object position is at another point. So, I'm having trouble when i try to move and rotate the weapon meshes around the tower model. I have tried to set bounding box's center point as pivot point of the object, but it did not work. Still when i try to rotate weapons, it rotates around another axis. How can I solve this problem? If it's not clear I can send a playground demo to explain it better. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 24, 2016 Share Posted October 24, 2016 Hey Okan and welcome, even if the position is at 0,0,0 the vertices can still be stored with a value that takes in account a pivot. Which tool do you use to generate the .babylon file? The idea is to use this tool to reset the pivot to center Quote Link to comment Share on other sites More sharing options...
okan Posted October 25, 2016 Author Share Posted October 25, 2016 Hello Deltakosh and thank you for reply. Is it possible to change pivot in babylon without using a tool? If it is not, I think i can reset pivot to center with Blender. So, should I create different models for each weapon and set pivot to center for each of them? Is it the common way to do that instead of trying to change pivot of meshes in babylon or any other 3d engine? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 25, 2016 Share Posted October 25, 2016 Yes it is possible You can call mesh.bakeTransformIntoVertices(matrix): this method will apply a transformation to all vertices. The idea is to apply the right translation to move the pivot 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.