Sign in to follow this  
Raggar

Cylinder-based Physics Wheels

Recommended Posts

Okay, so I'm playing around with some vehicle-rigs, and the ones I found on the forum/the playground use spheres as wheels, where as I'm trying ti use the more traditional cylinders instead.

Here I have created cylinders instead of spheres: http://www.babylonjs-playground.com/#IIIVB#1

I have commented out the cylinder imposter, and went with the sphere one, as it doesn't make much of a difference at this point.

What I'm trying to achieve, is making the rotation of the cylinder more in the likes of a wheel, but no matter how and where I try to rotate the wheels, they just don't seem to do as I command them to.

Based on the cylinder imposter, the shapes are all right, but it's a very weird ride, since, as you can see, the wheels behave in a noticably different way than they are supposed to.

The playground code is based on this: http://www.babylonjs-playground.com/#IIIVB

In which there are quite some versions of on the playground. All with spheres, though.

 

Another example is this, using Oimo.js, and again some code I found on the forum/playground:

http://www.babylonjs-playground.com/#1MSQGK#19 (Based on the 18 versions before it).

I, again, switched the spheres with cylinders, and changed the imposters accordingly.

Same problem. How do I rotate the wheels/axis in the right position?

 

And on a side note, has anyone played with the Energy.js engine?

In this thread:

RaananW mentions that:

On 1/8/2016 at 6:59 PM, RaananW said:

Energy solves a lot more :)

But sadly it is very time consuming. The beta version is already working (integrated into babylon's physics system), but there are still a few features missing. I hope to find time soon to fix everything.

 

But it isn't present in plugin form?

 

Maybe I should get to know at least the basics of One first, but, this one just seemed perfect for vehicular physics. :P

 

Share this post


Link to post
Share on other sites

I saw a very cool car demo with Babylon using Bullet (Ammo) not too long ago.

Bullet comes with a simple vehicle controller, which can be used for arcade style vehicle simulations. Instead of simulation of each wheel and chassis as separate rigid bodies connected by joints, it simply uses a single rigid body for the chassis. Collision detection for the wheels is approximated by ray casts, and the tire friction is a basic anisotropic friction model. This approach to vehicle modelling is called "raycast vehicle", and it is used widely in commercial and non-commercial driving games.

 

Share this post


Link to post
Share on other sites

Hiya!

Your main problem is the way the engines are dealing with initial rotation and the fact that a cylinder is facing up per default.

There are, as always two ways to solve this. The easy way, or the hard way. (Or better yet the easy way or the right way :)

Th easy way would be to say - actually, you are right. wheels are not spheres. But it seems like using a sphere impostor works well. Why won't I "simulate" the wheels using cylinders, but continue using the sphere impostor? Easy. Has down sides of course. But here is how you can achieve that - http://www.babylonjs-playground.com/#IIIVB#3

The hard way is.... well... harder :)

if you want to use cannon's Rigid vehicle - http://www.babylonjs-playground.com/#IIIVB#2 , this is a start. you will notice that everything is kind'a flipped. the front wheels are the side wheels, etc' etc'. You will need to adjust that and actually make a few changes to the cannon class for it to work.

I am terribly sorry, but I don't have time to start fixing your oimo demo (which is a modified version of an old car demo I did.). When I'll have the time I'll try finding the best way to solve this with oimo.

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.