Search the Community
Showing results for tags 'heightfield'.
-
I need some simple pointers on how to turn an imported model into a Cannon.js heightfield. I would prefer this over actual heightmaps, as I feel that I'm more in control of the design of the ground. I made a simple PG example so I can test it along the way. Just a very basic model made out of a 20x20 plane. How would you pull the positions(Especially Y) on the individual vertices, so they can be used to create the heightfield shape and added to a Cannon.js body? This is the relevant code from the heightfield demo: var matrix = []; var sizeX = 15, sizeY = 15; for (var i = 0; i < sizeX; i++) { matrix.push([]); for (var j = 0; j < sizeY; j++) { var height = Math.cos(i/sizeX * Math.PI * 2)*Math.cos(j/sizeY * Math.PI * 2) + 2; if(i===0 || i === sizeX-1 || j===0 || j === sizeY-1) height = 3; matrix[i].push(height); } } https://github.com/schteppe/cannon.js/blob/master/demos/heightfield.html
- 9 replies
-
- cannon.js
- heightfield
-
(and 1 more)
Tagged with:
-
How can I get my mesh moving around on a height field when using Oimo Plugin in Babylon js? This is "working": Render.prototype.createScene = function(){ this.ground = BABYLON.Mesh.CreateGroundFromHeightMap("ground", "textures/heightMap.png", 50, 50, 100, 0, 2, this.scene, false, onGroundCreated);}function onGroundCreated(ground){ ground.setPhysicsState(BABYLON.PhysicsEngine.BoxImpostor, {friction:0, mass: 0, move : false });}The problem is, as the Imposter is a Box, my Mesh moves just on top of the height field. In this tutorial: https://blogs.msdn.microsoft.com/davrous/2014/11/18/understanding-collisions-physics-by-building-a-cool-webgl-babylon-js-demo-with-oimo-js/ It states four different possibilitys for colliders. Box, Sphere, Capsule and Mesh. Is Capsule and Mesh also available in the Babylon OimoJSPlugin? Because I guess thats what I would need to move around the height field i guess. Or maybe there are other valid options for that problem.
- 5 replies
-
- Babylon.js
- Oimo.js
-
(and 3 more)
Tagged with: