IsoSurface Demo - Dev blog experiment... (released)

@N-18 said: I can already imagine a character walking on top of that terrain. And with that come some ideas for a game.

I see the MeshGenerator interface has a method named buildMesh that returns a Mesh object. I didn’t found it yet but I think that mesh will in time go to a Geometry object. May be that you are building a RigidBodyControl using that mesh to create a CollisionShape? That is how I’m Physicallizing my terrain in my voxels experiment, using the Mesh object that results from decoding a chunk of the map, but your previous comment suggests you are doing something more complex than that.

Looks amazing with a NVidia GTX650 and Windows 7.

If you wanted to do conventional physics then that’s how you would do it. The IsoSurfaceZone is what uses the Mesh and makes Geometry. It builds the mesh on a background thread run by the PagedGrid. During that time you could also make a collision mesh.

I had a theory that the raw density field could be used for collision detection even if no geometry was generated. This experiment shows that for some use-cases it could work. For larger objects, they would have to be broken down into small spheres to use this particular approach. Different things could be done to improve its accuracy but in the end if you need truly accurate physics then you’d want a real collision mesh.

However, for a lot of use-cases (say finding the height of terrain to place an object or building, placing units for an RTS, plotting routes, etc.) then the density field and this technique are enough.

Essentially, at any point in 3D space, you can sample what the density is. Less than 0 is open space, greater than 0 is solid space. You can also sample the ‘field direction’ at any point which is sort of the average gradient change of the density field. (This is also used to calculate the normals at the surface.) With these things and a little math, you can approximate collisions with the solid surface.

For procedural generated content it doesn’t really make sense to use mesh shapes. It would be more efficient to query the data source and use that directly.

I used this approach in jmeplanet. I ended up creating a custom physics shape that directly queried the fractal noise generator I used to create the terrain. This worked out quite well versus trying to dynamically create and destroy collision meshes. I wasn’t using a density field, but I imagine the same idea could be applied here.

https://bitbucket.org/aaronperkins/jmeplanet/src/bd5fff780f24e6fba090ec0f6435e9894e57b12f/src/jmeplanet/PlanetShape.java?at=default

@pspeed said: Essentially, at any point in 3D space, you can sample what the density is. Less than 0 is open space, greater than 0 is solid space. You can also sample the ‘field direction’ at any point which is sort of the average gradient change of the density field. (This is also used to calculate the normals at the surface.) With these things and a little math, you can approximate collisions with the solid surface.

That should be a lot faster than constantly create and destroy mesh collision shapes. The creation of collision shapes can be postponed until more complex physics are needed, and for terrain, that may never happen, depending on the game of course.

@aaronperkins said: a custom physics shape that directly queried the fractal noise generator I used to create the terrain. This worked out quite well versus trying to dynamically create and destroy collision meshes. I wasn’t using a density field, but I imagine the same idea could be applied here.

Good idea. I will try it with my VoxelMap, there are 7 methods to override from ConcaveShape and the map can directly participate in the physics simulation. Also lets say that in the future there is no more Mesh object, and the geometry is generated in a geometry shader (not possible yet with JME3, true?)

@aaronperkins said: For procedural generated content it doesn't really make sense to use mesh shapes. It would be more efficient to query the data source and use that directly.

I used this approach in jmeplanet. I ended up creating a custom physics shape that directly queried the fractal noise generator I used to create the terrain. This worked out quite well versus trying to dynamically create and destroy collision meshes. I wasn’t using a density field, but I imagine the same idea could be applied here.

https://bitbucket.org/aaronperkins/jmeplanet/src/bd5fff780f24e6fba090ec0f6435e9894e57b12f/src/jmeplanet/PlanetShape.java?at=default

This is good stuff… especially for more traditional block-voxel games.

For the density field it is problematic. Ultimately you’d end up at least partially generating the mesh as simply querying the density field is not enough to accurately answer collision questions. At least not accurate enough for a physics engine which will require a certain amount of consistency to avoid blowing up.

For example, there are certain places in my world where if I shoot a ball then it rolls up hill really fast. Even though the 0-boundary surface makes a nice mesh, the field around it can be quite turbulent in unexpected ways. So to provide accurate collision information you have to do the same work that was done to generate the mesh so that you know where the actual surface was rendered.

…also because the surface itself is only a gridded approximation in this case.

In the mean time, there are many many applications that do not need real physics that can benefit from this quick-and-dirty approach. And as seen, even for my semi-physics example it’s not so bad.

So, I’ve posted another new release:

https://simsilica-tools.googlecode.com/svn/trunk/IsoSurfaceDemo/release/IsoSurfaceDemo-Windows.zip
https://simsilica-tools.googlecode.com/svn/trunk/IsoSurfaceDemo/release/IsoSurfaceDemo-Linux.zip
https://simsilica-tools.googlecode.com/svn/trunk/IsoSurfaceDemo/release/IsoSurfaceDemo-MacOSX.zip

Controls are still the same as in this post:
http://hub.jmonkeyengine.org/forum/topic/isosurface-demo-dev-blog-experiment/page/2/#post-289215

…except now you can also hit “p” to fire a projectile.

Oh, and I added video recording. F12 toggles video recording on/off.

The big change in this release is the basic physics support. Both in the shooting of projectiles mentioned above and in the ability to walk around on the ground.

There as some new options on the Camera panel. Turning “Walk Mode” on will cause you to fall to the ground at ‘eye offset’ above the surface. You can walk around and will fall/slide down steep hills and so on. Collision detection is just based on the feet so you can still end up walking through things and so on… but it’s still sometimes a nicer way to view the world and helps put things into better scale.

I put the eye offset in because it’s kind of fun to lower yourself to 20 cm above the ground and try to walk around that way. It’s almost like a mini game to try to navigate this way since in many areas you cannot see past the grass in front of you. Because of the slopes and variation of the terrain, it can be quite challenging to find a way to walk up to the higher ground.

Have fun “playing”.

@N-18 said: I failed to run the latest demo for Linux using onboard graphics, expected as this one has an obsolete GPU. Looking to try it in my gamer PC (when my little bro stop abusing it).

The demo actually runs, and shows the statistics, for example FPS is around 50, but I cannot see the terrain, only solid colors. Initially I thought I was inside the terrain and needed to move backward or upward, but I concluded It was due to my obsolete GPU. Intel GMA X4500.

Same here, but with Windows 7 x64 and sandy bridge GPU (HD2000 I think). :frowning:

@Pesegato said: Same here, but with Windows 7 x64 and sandy bridge GPU (HD2000 I think). :(

If you can see the UI, click into the “Filters” tab and turn off the water filter. =)

1 Like
@kwando said: If you can see the UI, click into the "Filters" tab and turn off the water filter. =)

Wow! It worked! How did you know??? :-?

@Pesegato said: Wow! It worked! How did you know??? :-?

I’ve been bugging pspeed about this for some time ^^ It is fixed in the nightly version of jME but this demo is using the stable version. =)

@pspeed, show ground disc disappears when I fiddle around with the sliders on the Ground tab.

  1. Change Ground Exposure => ground disc disappear
  2. Change Air Density => ground disc comes back
@kwando said: @pspeed, show ground disc disappears when I fiddle around with the sliders on the Ground tab.
  1. Change Ground Exposure => ground disc disappear
  2. Change Air Density => ground disc comes back

Which way did you change them?

It’s really easy to overload the ground disc math and cause strange behavior.

I cannot follow those indications on my Linux box because in my case, even if I can see the GUI with all the sliders, the mouse pointer is hidden and I cannot know where I’m clicking. I tried to change the sliders by chance but failed to hit any control. Only changing of GPU works. It seems any Intel GMA or HD may do the same, and X4500 is the only one GMA listed in JME3 minimum requirements. I will try to play with the sliders in the code.


Ups, cannot generate binaries due to a dependency on a project called Lemur (no open source?). Also the assets are missing (no part of what was open sourced?).

@N-18 said: I cannot follow those indications on my Linux box because in my case, even if I can see the GUI with all the sliders, the mouse pointer is hidden and I cannot know where I'm clicking. I tried to change the sliders by chance but failed to hit any control. Only changing of GPU works. It seems any Intel GMA or HD may do the same, and X4500 is the only one GMA listed in JME3 minimum requirements. I will try to play with the sliders in the code.

Ups, cannot generate binaries due to a dependency on a project called Lemur (no open source?). Also the assets are missing (no part of what was open sourced?).

Lemur is another project in contrib. If you search here then you will find a whole forum section for it.

Did you hit the space bar to get the mouse to appear?

Thanks. The space key showed the mouse pointer allowing me to go to Filters tab and disable water, that seems to be what this GPU does not like.

@pspeed said: Lemur is another project in contrib. If you search here then you will find a whole forum section for it.

Ok.

No new release just yet but I did finally get instancing working… and with instancing, I could finally turn wind on for the trees.

Instancing does lose me a few FPS but it gives back so much RAM… it’s glorious.

Here is a video for now:

5 Likes

It’s looking so good, nice work.

So, finally I’ve posted what will be the last release for a while. For my initial concept of this experiment, it is pretty much considered “done”. I could add and tweak things forever but it wouldn’t get me any closer to a game.

Also, some of the things I could add would make the code even more complicated to follow. For example, mutable terrain is no big deal except that suddenly I have to implement terrain caching, etc. which obfuscates things and causes more sharing between zone implementations than exists now. Right now it’s nice because the zone implementations are pretty independent and IsoTerrainZone is especially straight forward since it just grabs density data and generates a mesh. No worries of pulling mutated data from a cache or from storage, etc…

Anyway…

The big change in this update is the trees are now using instancing. This may be slightly slower on some platforms but the memory usage is much better. Furthermore, I can load all LODs at once for free and just switch between them. When I was batching, I rebuilt the batches every time the LOD changed. So now even crossing from one zone to the next should be much cheaper.

Here are the download links again:
https://simsilica-tools.googlecode.com/svn/trunk/IsoSurfaceDemo/release/IsoSurfaceDemo-Windows.zip
https://simsilica-tools.googlecode.com/svn/trunk/IsoSurfaceDemo/release/IsoSurfaceDemo-Linux.zip
https://simsilica-tools.googlecode.com/svn/trunk/IsoSurfaceDemo/release/IsoSurfaceDemo-MacOSX.zip

Note: since google code is dead now you’ll have to build from source here: GitHub - Simsilica/IsoSurfaceDemo: Technology demo of the IsoSurface terrain library.
…until I get around to pushing a new release up.

Controls are still the same as in this post:

http://hub.jmonkeyengine.org/forum/topic/isosurface-demo-dev-blog-experiment/page/2/#post-289215

…except now you can also hit “p” to fire a projectile.

Oh, and I added video recording. F12 toggles video recording on/off.

Bugs of note:
-really the only one I can think of is that the grass doesn’t always sort properly when it’s in the adjacent tile. As you move around it’s supposed to resort the grass based on your current location. For adjacent tiles it’s only supposed to do it when their relative grid position changes… except when you are close and then it will sort them always. So I think some interaction is causing them to not sort when they are supposed to. At any rate, the visual issue is that the grass looks like it did before I fixed sorting and then will suddenly pop in with correct sorting. A relatively minor issue.

Fun ways to play:
In addition to the bug’s eye view mentioned in a previous post, I’ve found that setting walk mode on but then running around with ctrl-shift pressed can be quite fun. Quickly finding the paths that can be traversed and/or seeking high-ground to jump across large valleys can be quite a challenge… but it’s a skill that improves with practice. Earlier tonight I even managed to on-the-fly jump from one tall hill, skip-bounce on a floating island, and continue on to the next hill… it was exciting enough to make me ‘whoop’ out loud.

This is encouraging because the original game idea was some kind of hover-bike racing game. I would do the terrain a little differently and have more and larger trees… but it’s nice to know that even in this primitive form the rough mechanic is still kind of fun.

Might as well load this post up with some screen shots, too:





4 Likes

The demo is simply amazing. Great work. I’m definitly going to use the IsoSurfaceLib.jar for my game - am I allowed to ?

@pspeed: I checked out the IsoSurface SVN project and there are two errors in the code. I’m using the trunk engine jme3-core.jar - the two places are:

Line 123 + 124 in InstanceTemplate.java

VertexBuffer vb = new VertexBuffer(Type.InstanceData); vb.setInstanceSpan(1);
Type.InstanceData doesn't exist + VertexBuffer.setInstanceSpan() doesn't exist.

Type.InstanceData is also referenced in InstancedTreeZone line 371.

I also checked out the IsoSurfaceDemo which gave me an error here:

TerrainState.java, line 64:
import com.simsilica.iso.plot.PlotFrequencyZone;

the PlotFrequencyZone doens’t exist.

Is there a better place to report bugs on SVN checkouts? I know it’s all work-in-progress and I’m only supposed to use the compiled jar-file - but I just wanted to see how it was done and to help.

@asser.fahrenholz said: The demo is simply amazing. Great work. I'm definitly going to use the IsoSurfaceLib.jar for my game - am I allowed to ?

Of course. That’s what it’s there for. :slight_smile:

@asser.fahrenholz said: @pspeed: I checked out the IsoSurface SVN project and there are two errors in the code. I'm using the trunk engine jme3-core.jar - the two places are:

Line 123 + 124 in InstanceTemplate.java

Type.InstanceData doesn’t exist + VertexBuffer.setInstanceSpan() doesn’t exist.

Type.InstanceData is also referenced in InstancedTreeZone line 371.

I mentioned earlier in the thread (thought forgot to mention it in the last release post) that I had to move to trunk (and abandon 3.0 stable compatibility) to get instancing working… because instancing is only in trunk.

@asser.fahrenholz said: I also checked out the IsoSurfaceDemo which gave me an error here:

TerrainState.java, line 64:
import com.simsilica.iso.plot.PlotFrequencyZone;

the PlotFrequencyZone doens’t exist.

Is there a better place to report bugs on SVN checkouts? I know it’s all work-in-progress and I’m only supposed to use the compiled jar-file - but I just wanted to see how it was done and to help.

This is a fine place. If the traffic gets to be too high then maybe I’ll have @erlend create a forum section for IsoSurface (and SimArboreal or whatever, too) or something.

Anyway, you can comment out that line and the if( freqPlot ) section way below it. It’s left over from some testing and I either need to check in the test class or remove that code. Sorry for the trouble.

@pspeed said: I mentioned earlier in the thread (thought forgot to mention it in the last release post) that I had to move to trunk (and abandon 3.0 stable compatibility) to get instancing working... because instancing is only in trunk.

If I understand what you are saying, I have to use the trunk engine jme3-core.jar. But that’s what I’m doing…I’ll double check to see if I have a double reference to the jar-file.

Thanks for replying so fast.