ian Posted September 20, 2016 Share Posted September 20, 2016 How can we use cannon's native API with babylon?. Are/Is there any example(s)? How cen we set up sphere and plane/box? (any simple example?) Must we always set physics Impostor/Collider on mesh which has checkCollisions = true ? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted September 21, 2016 Share Posted September 21, 2016 Hi Ian. CheckCollisions property is not used with physics engines (afaik). That is for BJS built-in collision system, not 3rd party physics engines. Now, native api... Go here... http://www.babylonjs-playground.com/#1ND6TH#9 Look at lines 124-129... nativeParams: That is one way set native parameters during construction of physics things. Now for another way... for after-construction fun... See line 100... it logs wheelBody object to console. Open your browser f12 dev tools, and click on that object in the console. View it in object inspector. Notice that it is the same object as... http://schteppe.github.io/cannon.js/docs/classes/Body.html So, you may work-with a Cannon Body Class... by working with wheelBody. Makes sense, right? WheelBody == CannonBody. Many properties and methods on wheelBody... all native to Cannon. You can call/set them all... from within scene. Also, http://doc.babylonjs.com/classes/2.4/PhysicsEngine That is a way to interface with the physics engine, too. There is no scene.currentPhysicsEngineObject, becasue physics engines do not use that method of "integrating" with BJS. This should help. Experiment, experiment, experiment. ian 1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted September 21, 2016 Share Posted September 21, 2016 Thanks Wingnut! A perfect answer. Just wanted to add - each and every impostor has a public variable called physicsBody , which is the physics engine body. Every joint has physicsJoint (I will let you guess what this is), and the physics engine class itself has the world (of the physics engine) as a public variable as well. You have all tools to use the native functions of the physics engine, just don't forget that Babylon is always taking care of the basics for you - position and rotation update every frame. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
ian Posted September 21, 2016 Author Share Posted September 21, 2016 I'll try to play around. But still don'n know (have a time to explore). Can anybody just post any simple code snippet how to set ground and ball (physics with cannon.js native classes/objects/constructors/methods... greetings ian 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.