Hersir

Rotate sphere inside cylinder

Recommended Posts

Hi just started to use babylon js :) Would like to  have some sugestions on physics animaton. I have cylinder like mesh and inside in it is small sphere. I need to animate ball so that it push to border of cylinder and moves along it in cw direction, like centrifuge. Can i do it using physics? Till now i did it using posotion changes but as i need to slow down it would be nicer with some forces. One way I thought of  is to calculate angle from center and apply impulse away from center and slighty forward but maybe there is better way.

Share this post


Link to post
Share on other sites

@Hersir use @ to let me know about reply next time. first of all are you sure you need to apply force or can a body push each other? if not consider using applyImpulse

https://doc.babylonjs.com/overviews/using_the_physics_engine#impulses-and-forces

if you need to calculate the direction propertly ask me and I will show you how to do it using rotation matrix. Sorry if I didn't understand what you meant.

Share this post


Link to post
Share on other sites

@wo997 Sorry for poor explanation.  What I need is a mesh that is cylinder with hole in middle. So its looks like tube, and inside is one object , sphere. This sphere should accelerate in CW direction by applying force. Sphere is pushed to border of cylinder and hits it and rolls along it in CW direction.

 

Share this post


Link to post
Share on other sites

@Hersir Consider making many jointed cuboids, can you image this arrangement? It's the only way to do it propertly, you need physics and rendering as well. Making them as one body can be a little challenge for you, I would use joints and I would place virtual cube in middle so it holds cuboids together.

Share this post


Link to post
Share on other sites

I think picture will describe my idea better. I want to move sphere inside "bowl like object",  using physics, I have working version for initial impulse that shoots ball and than it slowly slows down but I need to maintain speed till its ready to slow down (as slowdown need to happen on user interaction) so I need to re-add impulse in correct direction (tangential acceleration I think http://formulas.tutorvista.com/physics/tangential-acceleration-formula.html ) . But is it even possible to maintain constant speed with applyImpulse or applyForce? 

screen.png

Share this post


Link to post
Share on other sites

Hi guys!  Yeah, somebody else was goofing around with that, too.

http://www.babylonjs-playground.com/#PBVEM#38

Version 42 is good, too... http://www.babylonjs-playground.com/#PBVEM#42

I bet that whole playground series is full of weird things.  No 3rd party physics engines used... in those two.

There IS a physics engine version somewhere around here.  I think I saw someone put @RaananW's little physics-active car... in the bowl, too.  And his cloth mesh got dropped into the bowl, as well.

http://www.babylonjs-playground.com/#PBVEM#80

Ahh, there it is.  That's the physics engine version... with the car, and the cloth, and the ball... all in the bowl.  But, it's not working right now.  hmm.

Good fun.  Hope this helps.  Maintain perpetual motion, you say?  Helluva challenge.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.