jasonmcleod Posted October 2, 2016 Share Posted October 2, 2016 Hey guys, I found this playground which draws a cylinder between 2 points: http://www.babylonjs-playground.com/#1RWE59#12 I'm hoping someone can shed light on how to do this same trick with a rectangle. This is the closest I've been able to come http://www.babylonjs-playground.com/#1RWE59#57 Thanks in advance! Quote Link to comment Share on other sites More sharing options...
adam Posted October 2, 2016 Share Posted October 2, 2016 http://www.babylonjs-playground.com/#1RWE59#58 jerome and jasonmcleod 2 Quote Link to comment Share on other sites More sharing options...
jasonmcleod Posted October 2, 2016 Author Share Posted October 2, 2016 Oh right! The object takes width,height, depth! Thanks adam! Quote Link to comment Share on other sites More sharing options...
jasonmcleod Posted October 2, 2016 Author Share Posted October 2, 2016 So close! Just need to "twist" them to be "flat". - not sure how to describe flat, but hopefully this picture will help Quote Link to comment Share on other sites More sharing options...
jasonmcleod Posted October 3, 2016 Author Share Posted October 3, 2016 Created a playground with the issue I'm working through now: http://www.babylonjs-playground.com/#1RWE59#60 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted October 3, 2016 Share Posted October 3, 2016 I would do some reading on vectors... Quote Link to comment Share on other sites More sharing options...
adam Posted October 3, 2016 Share Posted October 3, 2016 http://www.babylonjs-playground.com/#1RWE59#61 Quote Link to comment Share on other sites More sharing options...
jasonmcleod Posted October 3, 2016 Author Share Posted October 3, 2016 Dang, @adam coming through again! http://www.babylonjs-playground.com/#1RWE59#61 has exactly what I'm after. Seeing some twisting in my implementation, depending on where I place them, probably related to the world position. I was heading down the path of adjusting rotation.y, but missed the swap of width and depth. I was hard coding the rotation.y and trying multiple values to see how it would affect it.. Your levelBox function is obviously much more appropriate Good news is that this still works well with physics. @Pryme8 I've learned so much from this forum, and I'm focusing on Vectors now. Thanks for everything guys Quote Link to comment Share on other sites More sharing options...
jasonmcleod Posted October 3, 2016 Author Share Posted October 3, 2016 Actually http://www.babylonjs-playground.com/#1RWE59#61 does show the same twisting, its just much less noticeable. Added a 3rd sphere, and an OFFSET variable to make it more obvious when they are further apart: http://www.babylonjs-playground.com/#1RWE59#62 Still working through it obviously, but wanted to post the update that while the levelBox function certainly helps - there is still a slight twist. Quote Link to comment Share on other sites More sharing options...
adam Posted October 3, 2016 Share Posted October 3, 2016 It has to twist like that because they are not on the same plane. Take a look at this one where I place the red sphere on y = 0: http://www.babylonjs-playground.com/#1RWE59#63 edit: I think you're right. http://www.babylonjs-playground.com/#1RWE59#64 Quote Link to comment Share on other sites More sharing options...
adam Posted October 3, 2016 Share Posted October 3, 2016 I forgot to normalize the vector. http://www.babylonjs-playground.com/#1RWE59#65 jasonmcleod, NasimiAsl and jerome 3 Quote Link to comment Share on other sites More sharing options...
jasonmcleod Posted October 3, 2016 Author Share Posted October 3, 2016 Thats it! Where is the "buy this man a beer" button? Can't thank you enough @adam adam and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
adam Posted October 4, 2016 Share Posted October 4, 2016 I had to change the function because in some cases you have to add the angDiff and other cases you have subtract (acos dot wasn't good for this). http://www.babylonjs-playground.com/#1RWE59#68 Quote Link to comment Share on other sites More sharing options...
jasonmcleod Posted October 4, 2016 Author Share Posted October 4, 2016 I noticed this also, forgot to come back and mention. But I solved for it by checking txaxis.x being negative. Thanks for the update, I'll try with both versions to see what difference it makes. 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.