altreality Posted December 24, 2014 Share Posted December 24, 2014 In the babylon.physicsEngine.js file I see that the z and the y have been interchanged. I guess thats because cannon has z axis up and not y axis like Babylon. But shouldnt z or y have their sign changed also to take care of the handedness. I ask because cannon has added heightmap support and I want to adapt the following code for supporting the heightmaps in babylon from cannon : CannonJSPlugin.prototype._createConvexPolyhedron = function (rawVerts, rawFaces, mesh, options) { var verts = [], faces = []; mesh.computeWorldMatrix(true); for (var i = 0; i < rawVerts.length; i += 3) { var transformed = BABYLON.Vector3.Zero(); BABYLON.Vector3.TransformNormalFromFloatsToRef(rawVerts[i], rawVerts[i + 1], rawVerts[i + 2], mesh.getWorldMatrix(), transformed); verts.push(new CANNON.Vec3(transformed.x, transformed.z, transformed.y)); } for (var j = 0; j < rawFaces.length; j += 3) { faces.push([rawFaces[j], rawFaces[j + 2], rawFaces[j + 1]]); } var shape = new CANNON.ConvexPolyhedron(verts, faces); if (!options) { return shape; } return this._createRigidBodyFromShape(shape, mesh, options.mass, options.friction, options.restitution); }; Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 27, 2014 Share Posted December 27, 2014 Hello from the test I did inverting y and z was enough Is it not working for you? (Happy to see heightmap support added:)) 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.