MackeyK24 Posted January 24, 2018 Share Posted January 24, 2018 How does one split a large ground mesh into sections. l have a large mesh that need to split in 3 x 3 or 4 x 4 grid of sections ... how do I do that in Babylon ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 24, 2018 Share Posted January 24, 2018 Hello, by default when creating a ground you can define subdivisions: http://doc.babylonjs.com/babylon101/discover_basic_elements#ground Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted January 24, 2018 Author Share Posted January 24, 2018 Yo @Deltakosh ... I am using CreateGroundFromHeightmap to create a ground terrain... But for my HIGH POLY terrains I would like to break them up into sections like a 3 x 3 grid of smaller meshes or be able to modify the CreateGroundFromHeightMap VertexData and SOMEHOW split that up into sections... How about splitting the Heightmap up into section BEFORE I call create ground from height map... I dunno, what are your thoughts to splitting up a LARGE terrain mesh ??? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 25, 2018 Share Posted January 25, 2018 The subdivisions parameter in the constructor is here for this purpose: http://doc.babylonjs.com/classes/3.1/mesh#static-creategroundfromheightmap-name-url-width-height-subdivisions-minheight-maxheight-scene-updatable-onready-rarr-groundmesh-classes-3-1-groundmesh- with a value of 3 you will split your ground into 3x3 submeshes (which will be used for frustum clipping) Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted January 25, 2018 Author Share Posted January 25, 2018 But wait... subdivisions is controlling the density of the mesh. the resolution is the from the height map image dimensions (this example 33) Currently I am calling CreateGroundFromHeightmap("ground", url, 300, 300, resolution, 0, 100, scene ) this generates ONE SINGLE ground mesh object made from the vertex data generated in the onready function in CreateGroundFromHeightMap. The mesh is a PERFECT representation of the Terrain from Unity. That mesh = 1089 verts... I really just wanted to SPLIT that resulting mesh into CHUNKS so that each mesh peice is smaller... I dont see how passing value of 3 instead of 33 will make 9 separate meshes... it just makes the DENSITY much smaller but still ONE SINGLE mesh. I dont understand Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted January 26, 2018 Author Share Posted January 26, 2018 1 hour ago, Deltakosh said: The subdivisions parameter in the constructor is here for this purpose: http://doc.babylonjs.com/classes/3.1/mesh#static-creategroundfromheightmap-name-url-width-height-subdivisions-minheight-maxheight-scene-updatable-onready-rarr-groundmesh-classes-3-1-groundmesh- with a value of 3 you will split your ground into 3x3 submeshes (which will be used for frustum clipping) Yo @Deltakosh Since I am calling CreateGroundFromHeightmap with a value of 33 now are saying the somehow internally the GroundMesh contains 33 sub meshes ??? If so how do I use those sub meshes ... I want to treat each mesh CHUNK as a separate mesh so I can put checkCollisions or physics state. If I put check collision or physics state on the main ground mesh of 65535 verts it really kills the frame rate... My hope was to be able to SPLIT the 65535 vert ground mesh in sections ... still maintaining all the detail but just create SMALLER sections that I could put checkCollisions or physics state on... Not to mention then I can create LOD version simply calling CreateGroundFromHeightmap again But with a Percentage of the original resolution value to create a less detailed version of the same exact terrain height map data. Quote Link to comment Share on other sites More sharing options...
satguru Posted January 26, 2018 Share Posted January 26, 2018 @MackeyK24 Maybe you can use BABYLON.DynamicTerrain.CreateMapFromHeightMap function to get a data map from the ht map and then create sub meshes from the data map? https://doc.babylonjs.com/extensions/dynamic_terrain#map-creation-from-a-height-map @jerome might have some idea on how to do that. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 26, 2018 Share Posted January 26, 2018 Yep the subdivisions will generate subMeshes not meshes You will have to manually go through the list of submeshes and generates meshes. For collision, you can call mesh.createOrUpdateSelectionOctree() to organize the submeshes into an octree that will boost the collision engine For physics no simple way other than manually creating meshes Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted January 26, 2018 Author Share Posted January 26, 2018 Can you please show me somr code how to get to the submeshes and create meshes from those submeshes Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted January 26, 2018 Author Share Posted January 26, 2018 59 minutes ago, Deltakosh said: Yep the subdivisions will generate subMeshes not meshes You will have to manually go through the list of submeshes and generates meshes. For collision, you can call mesh.createOrUpdateSelectionOctree() to organize the submeshes into an octree that will boost the collision engine For physics no simple way other than manually creating meshes Yo @Deltakosh I am using 32 subdivisions but still only has 1 sub mesh: this is a snippet from the GroundMesh created with Create Ground From Heightmap Am I supposed to somehow create these sub meshes my self from the vertex data... I just dont see how to get to what is supposed to be 32 submeshes Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 26, 2018 Share Posted January 26, 2018 Can you try to call ground.subdivide(100) when the ground is ready? Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted January 26, 2018 Author Share Posted January 26, 2018 Now that made 100 submeshes... do how do i extract each one of those submeshes... is there some kind of get mesh from submesh function that i just dont see Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted January 26, 2018 Author Share Posted January 26, 2018 Acutually made 98 ... probobly adjusts to all the submesh vertex stuff matches up Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 26, 2018 Share Posted January 26, 2018 Nope, there is no. Submesh is essentially a pointer into the mesh index buffer. So basically I will recommend to clone the root mesh and then only keep one submesh in the clone.subMeshes array Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted January 26, 2018 Author Share Posted January 26, 2018 What about some way to grab the vertex data for that submesh and create a new grounf mesh and apply vertex data to new mesh Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted January 26, 2018 Author Share Posted January 26, 2018 Yo @Deltakosh i also noticed the submeshes are long strips of the mesh... the larger the vale to the subdivide function the skinnier the strip is... is there anyway to subdivide in grid of rows and cols instead of long skinny strips for the submesh Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 29, 2018 Share Posted January 29, 2018 Not directly but the code for subdivide is rather straightforward: https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.mesh.ts#L865 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.