gzlock Posted November 15, 2017 Share Posted November 15, 2017 code: http://www.babylonjs-playground.com/#Y5561T The green object was generated from CSG (BoxA.intersect(BoxB)) and the pivot point was inherited from BoxA. So I want to let the pivot point of the new object reset to the center. I tested NewMesh.setPivotMatrix(BABYLON.Matrix.Translation(0, 0, 0)); but the pivot point still stay in place. How to do it by easy way? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 15, 2017 Share Posted November 15, 2017 Hi gzlock, welcome aboard! Local super-hero Adam once helped me with a similar issue. http://www.html5gamedevs.com/topic/2571-the-wingnut-chronicles/?do=findComment&comment=194133 mesh.setPivotMatrix(BABYLON.Matrix.Identity()); Perhaps this will work for you. Quote Link to comment Share on other sites More sharing options...
gzlock Posted November 16, 2017 Author Share Posted November 16, 2017 @Wingnut No effect for the CSG program generated mesh object. mesh.setPivotMatrix(BABYLON.Matrix.Identity()); As same as with NewMesh.setPivotMatrix(BABYLON.Matrix.Translation(0, 0, 0)); Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 16, 2017 Share Posted November 16, 2017 Yeah, sorry. I tired some things last night... but failed. I tried assorted aimless commands. https://www.babylonjs-playground.com/#Y5561T#2 Wingnut fail. I have another project that needs pPoint center-up of some imported-from-3dsMax mesh. So far, I have failed for those, too. I don't have a solution, dag-nabbit. hmm. Hopefully, smarter people than I... will respond, soon. *scratch scratch* Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 16, 2017 Share Posted November 16, 2017 Yeah, sorry. I tried some stuff... failed. [#2] I have another project that needs pPoint center-up of some imported-from-3dsMax mesh. I failed for those, too. In that project, the mesh need to keep their pivotPoint/Origin offsets... because they are part of a bigger model. But I need to clone the mesh, and center up the pivots... for use in "View a single part of master model" -feature. In #3 version of your playground, lines 60-164 is demo code of the many things I have tried... in that other project. You can probably ignore lines 66-67. I was told that was a way to make non-updatable mesh... BE updatable. Having myClone be updatable and geometryUnigue()... is important for trying vertex position-kind shifting/moving (not yet tried). I'm not sure if simple pivotPoint/Origin adjusting... needs mesh to be set updatable or not. But, just in case, you can see twin "true" at the ends of lines 16/17... the lines that make your CSG source mesh. No joy. I don't have a solution, darnit. Hopefully, smarter people than I... will respond, soon. *scratch scratch* Quote Link to comment Share on other sites More sharing options...
JohnK Posted November 16, 2017 Share Posted November 16, 2017 Hi @gzlock and welcome to the forum from me. Have been quiet busy the last couple of days so even though I saw your problem had things to finish before I could have a go. First of all check out these pages from the documentation http://doc.babylonjs.com/how_to/pivots http://doc.babylonjs.com/how_to/pivot#how-to-use-a-pivot-as-a-center-of-rotation and the first PG that goes with it Secondly using CSG will set a local origin in an unknown place and certainly not at the center of the triangle. The actual center of the triangle would involve finding the intersection of its medians again difficult. You can use the center of the bounding box as an approximation to the center of the triangle. Here we seen the bounding box around the green mesh. Putting all this together gives https://www.babylonjs-playground.com/#Y5561T#4 which I hope sets you up for what you want. Arte 1 Quote Link to comment Share on other sites More sharing options...
gzlock Posted November 16, 2017 Author Share Posted November 16, 2017 (edited) @Wingnut @JohnK Thank you! Less code than JohnK. Box1.setPivotPoint(Box1.getBoundingInfo().boundingBox.centerWorld, BABYLON.Space.WORLD); http://www.babylonjs-playground.com/index.html#Q4KURW Edited November 16, 2017 by gzlock Arte 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 16, 2017 Share Posted November 16, 2017 You guys ROCK! Hey, it worked for my other project, too. YAY!!! Wanna hear a stupid story? I have about 6-8 hours into trying to solve that other project pivot re-centering. I had a little white box at scene.origin (0,0,0). I kept trying things, trying to get this damned pivot-offset mesh... to land perfectly upon that white box.... indicating success. Unfortunately, I didn't have a code line that set mesh.position to 0,0,0. I wasn't NOTICING the correction in pivot points... because I was judging success upon landing the mesh perfectly onto the white box. Well, if ya never put the mesh AT the white box... then you're an idiot. And that was the case... with me. Yikes, am I stupid sometimes! So, forum question-asker... RESCUES forum-helper. hehe. Cool! What the heck, I'm not complaining AT ALL! PARTY!!! Quote Link to comment Share on other sites More sharing options...
gzlock Posted November 17, 2017 Author Share Posted November 17, 2017 This code can be more shortened a little more Box1.setPivotPoint(Box1.getBoundingInfo().boundingBox.center); 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.