altreality Posted December 25, 2014 Share Posted December 25, 2014 I want to create the heightmap vertices through code and then pass it to cannon for creating a cannon heightmap as its impostor. Does the heightmap object in Babylon expose the vertices for filling up procedurally ? Quote Link to comment Share on other sites More sharing options...
altreality Posted December 25, 2014 Author Share Posted December 25, 2014 ok, a heightmap is just a Mesh, so its vertices can be got by mesh.getVerticesData(() Quote Link to comment Share on other sites More sharing options...
Wingnut Posted December 26, 2014 Share Posted December 26, 2014 Hi again AR! Also, you might want to check out.... https://github.com/BabylonJS/Babylon.js/blob/master/Babylon/Mesh/babylon.mesh.js line 809 - mesh.applyDisplacementMap() and line 834 - mesh.applyDisplacementMapFromBuffer() I used a slightly modified copy of applyDisplacementMapFromBuffer() in this demo... http://playground.babylonjs.com/#P9UZG I needed to rotate the image around, so I had to hack on the canvas that was being used for the displace. That's why I used a rogue copy of the function in the playground code... instead of using the default framework version. But maybe the rogue version was not needed. I'm not a very good programmer. Rogue? Maybe "vagabond" is a better word. *shrug* Grab a zip or a copy... have some fun, show us the cool stuff you make. Fun with heightMapping (from buffers/arrays). Carlos R 1 Quote Link to comment Share on other sites More sharing options...
altreality Posted December 28, 2014 Author Share Posted December 28, 2014 Thanks Wingnut. So now I am trying to apply a displacement map to get the heights on a ground mesh using mesh.applyDisplacementMapFromBuffer() http://playground.babylonjs.com/#1AVEYO#2 Any idea why the vertices do not displace ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 28, 2014 Share Posted December 28, 2014 You should use a ground with more subdivisions (like var ground = BABYLON.Mesh.CreateGround("ground", 2, 2, 100, scene, true); ) And by the way, the buffer should contain a picture with grayscale values. If you want to update a mesh you can use mesh.getVerticesData and mesh.updateVerticesData:http://pixelcodr.com/tutos/trees/trees.html Quote Link to comment Share on other sites More sharing options...
altreality Posted December 29, 2014 Author Share Posted December 29, 2014 ok, here is an updated sample : http://playground.babylonjs.com/#1AVEYO#10 I am using 100 subdivisions now. Still trying to figure this one out. Used mesh.getVerticesData() to get the vertex data and for setting the data I tried mesh.updateVerticesData and mesh.setVerticesData By the way, can the debug layer be modified to show the world axes too ? Quote Link to comment Share on other sites More sharing options...
altreality Posted December 29, 2014 Author Share Posted December 29, 2014 ok got it http://playground.babylonjs.com/#1AVEYO#13 Wingnut 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 29, 2014 Share Posted December 29, 2014 Good job:) Quote Link to comment Share on other sites More sharing options...
bentwonk Posted March 13, 2017 Share Posted March 13, 2017 var positions = ground.getVerticesData(BABYLON.VertexBuffer.PositionKind); var normals = ground.getVerticesData(BABYLON.VertexBuffer.NormalKind); var colors = ground.getVerticesData(BABYLON.VertexBuffer.ColorKind); var uvs = ground.getVerticesData(BABYLON.VertexBuffer.UVKind); var indices = ground.getIndices(); all return null for me when applied to a height map generated ground. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 13, 2017 Share Posted March 13, 2017 Hello, you have to wait for the height map to be loaded. There is a callback in the HeightMapGround constructor (http://doc.babylonjs.com/tutorials/height_map): var ground = BABYLON.Mesh.CreateGroundFromHeightMap("ground", "worldHeightMap.jpg", 200, 200, 250, 0, 10, scene, false, successCallback); 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.