Jump to content

Rotate sphere inside cylinder


Hersir
 Share

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.

Link to comment
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.

Link to comment
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.

 

Link to comment
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.

Link to comment
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

Link to comment
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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...