Jump to content

Is there a way to create a heightmap manually or to access its vertices ?


altreality
 Share

Recommended Posts

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).  :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 ? 

Link to comment
Share on other sites

  • 2 years later...

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...