Raggar Posted August 6, 2016 Share Posted August 6, 2016 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. Quote Link to comment Share on other sites More sharing options...
Milton Posted August 6, 2016 Share Posted August 6, 2016 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. Quote Link to comment Share on other sites More sharing options...
Raggar Posted August 6, 2016 Author Share Posted August 6, 2016 Yeah, but I thought the bullet port had some performance issues? Quote Link to comment Share on other sites More sharing options...
Milton Posted August 6, 2016 Share Posted August 6, 2016 I have no idea. Haven't used it with Babylon. But when using Three.js, Bullet (ammo.js) seems just as fast as Cannon/Oimo/Anything else I've tried... Quote Link to comment Share on other sites More sharing options...
Milton Posted August 6, 2016 Share Posted August 6, 2016 Found the demo, just for reference. http://babylonhx.com/demos/bulletvehicle/ Quote Link to comment Share on other sites More sharing options...
RaananW Posted August 7, 2016 Share Posted August 7, 2016 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. Raggar and webGLmmk 2 Quote Link to comment Share on other sites More sharing options...
Raggar Posted August 8, 2016 Author Share Posted August 8, 2016 Thanks! Looks like 'bakeCurrentTransformIntoVertices()' was what I was looking for. Obviously it wouldn't be a problem as soon as you start importing models, but I thought I'd ask. 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.