basisbyte Posted July 29, 2016 Share Posted July 29, 2016 Hi guys, First and most of all - thanks for creating this awesome piece of software. Really got me hooked and when I'm not working I mostly play around with babylonjs. Like a week ago I knew more or less null about 3D stuff and now I have cars happily driving around on my screen :). As you might have guessed, a question appeared. Some months ago a guy around here wanted to make a monster truck for his son, and so there was a playground demo. Actually the car in there behaved like I wanted it because of the springs it gave a moving "chassis" and wheels feeling, depending on how hard its being accelerated or cornered, which is awesome. But its based on oimo.js and oimo can't do heightmaps as far as I know - and purely flat streets are no fun :). So I tried to get the same car working with cannon.js but I simply can'get my wheels not to "wobble" like mad and even go sideways, as it seems like I can't find the setting to tell them to get more stiff as its done with the spring in the oimojs example (using the hinge2joint - which when I understood currectly from the tuts is the same as WheelJoint). Tried to find how its done in the raycast-vehicle-demo at cannonjs to find the nativeOptions to add them but now luck so far. A little bit of a wobble would be actually great as it adds to the realism. Playing around with the oimo example and different values I could get very close to a car behaving like I'd love it to behave - so old-american-muscle-car like. Would be great if you could help me out - would be so happy if someday i have an old Malibu or the like cruising along a nice heightmap into the sunset (Interstate 76 style - yay ) So here is the origonal babylonjs http://www.babylonjs-playground.com/#1MSQGK#6 Here is the version with oimo.js where I got close to the behaviour I'm looking for (so much friction - so car flips to much, but not an issue) http://www.babylonjs-playground.com/#1MSQGK#9 Here is the cannon js with wobbly wheels http://www.babylonjs-playground.com/#1MSQGK#15 Here is an example where I tried to somehow add cannon.js native stuff (messes up a lot, because of trying and fooling around) http://www.babylonjs-playground.com/#1MSQGK#18 Thanks a lot for your time guys, appreciate it Wingnut 1 Quote Link to comment Share on other sites More sharing options...
adam Posted July 29, 2016 Share Posted July 29, 2016 I'm not seeing a Hinge2 joint for Cannon in the docs. http://doc.babylonjs.com/overviews/Using_The_Physics_Engine Quote Link to comment Share on other sites More sharing options...
adam Posted July 29, 2016 Share Posted July 29, 2016 Here is a car demo in Cannon: https://github.com/schteppe/cannon.js/blob/master/demos/hinge.html Quote Link to comment Share on other sites More sharing options...
basisbyte Posted July 29, 2016 Author Share Posted July 29, 2016 Thanks for the answer, its far down on the page, like here BABYLON.PhysicsJoint.Hinge2Joint = BABYLON.PhysicsJoint.WheelJoint; and seems to work either - so the wheels are connected to the hinge and thats connected to the body - what I try to achieve is control of the wheels in terms of stabliity, which I think cannon.js is capable. So I try to find out how to make such a setting from cannon js working in babylon js - I think babylon can make use of such native settings where no streamlined command exists through nativeOptions: { } and nativeParams { } but I haven't found out yet how exactly Quote Link to comment Share on other sites More sharing options...
RaananW Posted July 29, 2016 Share Posted July 29, 2016 So! Cannon's down side is its hinges and constraints. Cannon has no hinge2 or wheel joint. you will have to "make" it by yourself (connecting 3 bodies with 2 hinge constraints, i guess), or use a single hinge. But then you don't get suspensions. Here is a demo using Cannon's native RigidCar and Babylon together: http://www.babylonjs-playground.com/#UGMIH#8 Here is a nice oimo.js demo - http://www.babylonjs-playground.com/#SFELK#3 with (kind of) suspensions and obstacles. Cannon's fallback to the hinge2 is the single hinge, hence the problems you had with the wobbly wheels. Quote Link to comment Share on other sites More sharing options...
basisbyte Posted July 31, 2016 Author Share Posted July 31, 2016 Hi RaananW, thanks a lot for your answer - okay, I understand. So I will try to get around the limitation in cannon.js or check if I can somehow avoid heightmaps in order to use oimo.js. Is there any news regarding energy.js? - I couldn't find much information with googeling around. But speaking from the videos that are available, I think energy.js solves both issues, so I'd wait for energy.js if it isn't all too far away. Have a nice remaining Sunday Quote Link to comment Share on other sites More sharing options...
RaananW Posted August 1, 2016 Share Posted August 1, 2016 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. 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.