jerome Posted October 17, 2018 Author Share Posted October 17, 2018 this seems to be more complex than expected ... arg Quote Link to comment Share on other sites More sharing options...
jerome Posted October 26, 2018 Author Share Posted October 26, 2018 Well, here's the first working prototype of this new feature : http://jerome.bousquie.fr/BJS/test/terrainSP.html Demo description : - the wireframe is the visualization of the map, the logical pool of data describing the relief. Normally, it's not rendered and can be far bigger. - the textured square is the terrain. It's dynamically morphed to the map data when moving according to the camera position. I didn't activate any LOD or camera elevation correction. Just move the cam and zoom in/out. - the red sphere is the World origin and the red box shows the north, those are just tags in the space. => Another logical pool is added beside the map : a Solid Particle Map (SPMap). It's simply a bunch of data describing where some solid particles are in the World. The solid particles in this map have a type (a shape model), a set of coordinates, a set of rotation values and a set of scaling values. So 9 successive float values per particle of a given type. So the SPMap is simply an array of arrays. SPMap[particleType1] = [posx1, posy1, posz1, rotx1, rotx1, rotz1, sclx1, scly1, sclz1, posx2, posy2, posz2, etc ...] <= list of successive values of particle of type1 SPMap[particleType2] = [posx1, posy1, posz1, rotx1, rotx1, rotz1, sclx1, scly1, sclz1, posx2, posy2, posz2, etc ...] <= list of successive values of particle of type2 SPMap[ etc ] In this example type1 is a box, type2 a sphere and type3 a tetrahadron. I randomy populate the SPMap with particle values. There could be dozen thousands or millions objects in the map. There are just set at a fixed location, rotation and scaling. The SPMap feature of the DynamicTerrain allows to render dynamically only the SPMap objects visible on the terrain with a SPS. This SPS can then be quite little (according to the object density in the map actually). In this example, I just declared a SPS with 100 boxes, 100 spheres and 100 tetrahedrons what is quite few (less than 300 visible objects is easy to manage for the SPS engine; maybe I could have done it even tinier, didn't test) and I passed this SPS with the SPMap to the DynamicTerrain. And that's all. The DynamicTerrain will update the SPS for you by recycling automatically the particles per type in order to use and show only the needed ones in the terrain according to the current position and obviously to the SPMap data. Still a little buggy on the edges : from the terrain perspective the map is infinitely repeated and tiled, but not the SPMap for now. [EDITED] fixed ! Doc coming soon with better examples... What is this for ? This allows for instance to declare where some objects are located on a map (houses, trees, bridge, buildings... or clouds) and then to render these objects on the terrain with the best possible performance : a small SPS, recycling quickly a light pool of particles. . JohnK 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted October 26, 2018 Author Share Posted October 26, 2018 Please have a look at this better demo : http://jerome.bousquie.fr/BJS/test/terrainSP2.html - map : 1000 x 1000 points map - 66511 random particles fixed in the SPMap (well more than 66K) - terrain : 100 x 100 - sps : 2000 boxes, 2000 spheres, 2000 tetra (it can works with 500 of each if we don't get in altitude to see in the distance), so 6K real particles maximum So we can manage 66K objects from the map with only 6K (or less, if no LOD) real objects automatically recycled. not sure the LOD is really accurate with the particles ... (edit : I'm sure it's wrong actually) Wingnut, GameMonetize, Dad72 and 1 other 4 Quote Link to comment Share on other sites More sharing options...
jerome Posted October 27, 2018 Author Share Posted October 27, 2018 just having some ideas about infinite mazes ... remember that the solid particle can manage mesh intersections Quote Link to comment Share on other sites More sharing options...
Dad72 Posted October 27, 2018 Share Posted October 27, 2018 It's really unbelievable. jerome 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted November 7, 2018 Author Share Posted November 7, 2018 at last the documentation : https://github.com/BabylonJS/Extensions/blob/master/DynamicTerrain/documentation/dynamicTerrainDocumentation.md#more-advanced-terrain PG example to come Wingnut 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted November 11, 2018 Author Share Posted November 11, 2018 PG : https://www.babylonjs-playground.com/#FJNR5#264 3000 particles to render dozens thousands from the map. another one : an alien cilization erected 75K concentric stones in this landscape https://www.babylonjs-playground.com/#FJNR5#266 Quote Link to comment Share on other sites More sharing options...
Guest Posted November 12, 2018 Share Posted November 12, 2018 This is so cool! Quote Link to comment Share on other sites More sharing options...
jerome Posted November 12, 2018 Author Share Posted November 12, 2018 I know, I know ? but wait for the next feature : the per object UVs and colors from the object map. Here a blue house, there a red one, etc. Quote Link to comment Share on other sites More sharing options...
Guest Posted November 12, 2018 Share Posted November 12, 2018 Can't wait Quote Link to comment Share on other sites More sharing options...
jerome Posted November 16, 2018 Author Share Posted November 16, 2018 New feature for the DynamicTerrain : per object color and texture. The previous feature added the ability to set objects in an object map, as many as wanted, by setting their positions, rotations and scalings in the map. A SPS was used to render these objects in the terrain with a reduced pool of recycled solid particles. This new feature allows now to pass also to the terrain data about object colors and textures (uvs actually) in the same way than object settings. Example of randomly population of objects in the map with random colors and uvs : if (Math.random() > 0.8) { let xp = x; let yp = y; let zp = z; let ry = Math.random() * 3.6; let sx = 0.5 + Math.random(); let sy = 0.5 + Math.random(); let sz = 0.5 + Math.random(); let r = Math.abs(xp) / mapSubX + 0.5; let g = Math.abs(zp) / mapSubZ + 0.5; let b = Math.abs(yp) / elevationScale + 0.1; let u = 0.9 * Math.random(); let v = 0.9 * Math.random(); let type = index % 3; SPmapData[type].push(xp, yp, zp, 0, ry, 0, sx, sy, sz); SPcolorData[type].push(r, g, b, 1.0); SPuvData[type].push(u, v, u + 0.1, v + 0.1); } then the terrain creation with the new parameters SPcolorData and SPuvData : var terrainSub = 100; // terrain subdivisions var terrainOptions = { terrainSub: terrainSub, mapData: mapData, mapSubX: mapSubX, mapSubZ: mapSubZ, mapColors: mapColors, SPmapData: SPmapData, sps: sps, SPcolorData: SPcolorData, SPuvData: SPuvData }; var terrain = new BABYLON.DynamicTerrain("dt", terrainOptions, scene); terrain.mesh.material = terrainMaterial; That's all ... now each recycled solid particle will be ever given the right settings, colors and uvs when rendering the related object in the terrain. Documentation to come. Live example : http://jerome.bousquie.fr/BJS/test/terrainSP.html Sebavan, JohnK and GameMonetize 3 Quote Link to comment Share on other sites More sharing options...
jerome Posted November 19, 2018 Author Share Posted November 19, 2018 Documented and online : https://github.com/BabylonJS/Extensions/blob/master/DynamicTerrain/documentation/dynamicTerrainDocumentation.md#object-colors-and-textures PG : https://www.babylonjs-playground.com/#FJNR5#268 Quote Link to comment Share on other sites More sharing options...
JXD Posted September 16, 2021 Share Posted September 16, 2021 Could this be used for an RPG from a third person view? I seem to be struggling with the basic physics collision options of flat terrains. More specifically - I loaded a map using heighmaps, but characters meshes seem to go right through the terrain like it doesnt exist. 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.