Modify terrain on the fly

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
nikolaiko
Posts: 43
Joined: Mon Aug 04, 2014 8:26 am

Modify terrain on the fly

Post by nikolaiko » Thu May 21, 2015 12:07 pm

Hi.
I start to working on next feature of my game. Now it is terraforming. We are using Unity Engine for client and for Unity there is a plugin in Asset Store (TerraVol: Voxel Terrain Engine ), I didn't buyed it yet, but I am planning to do it (and look how it works, that mechanics...), here is the demo of this package : http://terravol.com/demo_v2/. Can I implement same functionality on server side (in BEPUPhysics).

Thanks.

Norbo
Site Admin
Posts: 4570
Joined: Tue Jul 04, 2006 4:45 am

Re: Modify terrain on the fly

Post by Norbo » Thu May 21, 2015 6:33 pm

BEPUphysics just needs the mesh, and it looks like that will output a mesh. I don't know of any reason it wouldn't work. Just beware of the usual issues:
1) It can take a while to regenerate the acceleration structure of a mesh in the current version of BEPUphysics. 'Chunking' the mesh so it only has to rebuild small parts would be a good idea.
2) Ideally, the mesh would have proper connectivity in the form of an index buffer so that bumps between triangles could be smoothed out.

nikolaiko
Posts: 43
Joined: Mon Aug 04, 2014 8:26 am

Re: Modify terrain on the fly

Post by nikolaiko » Fri May 22, 2015 1:50 am

Thanks, Norbo!

Today I will dig this Unity plugin and look how it working, then I will try to implement same on serve side.

Thanks.

nikolaiko
Posts: 43
Joined: Mon Aug 04, 2014 8:26 am

Re: Modify terrain on the fly

Post by nikolaiko » Fri May 22, 2015 11:44 am

Okay, I worked with this plugin. So it is very similiar to minecraft. Terrain contains of Chunks. Chunks are composed of 8x8x8 blocks. A chunk is basically a portion of terrain. Each block (ie. voxel) contains some information in order to create the terrain geometry and texture it. I tried to export this terrain to BEPUPhysics and it works, but in some places robot went throught terrain. So, looks like in some places something goes wrong and it didn't exported well.

I tried to display terrain in modifed demo (wich I use to debug, render exported terrains). But faced problem. Here is how it looks in Unity.
Image
But then I export it to demo and try to look from upper angle or then camera on same level as terrain, it looks very wierd :
Image
Image
And I can check how it is exported, right or no, maybe something missing. But then I move camera under terrain and look up, I will see solid terrain :
Image
Image
Some camera options wrong?

Thanks.

Norbo
Site Admin
Posts: 4570
Joined: Tue Jul 04, 2006 4:45 am

Re: Modify terrain on the fly

Post by Norbo » Fri May 22, 2015 6:31 pm

The sidedness of the terrain appears to be reversed. That's probably why stuff was falling through, too- if the mesh's Sidedness set to one of the one-sided options, the other side is transparent to collision.

Try setting the mesh's sidedness to DoubleSided. If that fixes the collision issues, then you can go back and choose a one sided version (assuming that you don't want collision from both directions) that matches the mesh's triangle winding. (If a single mesh has inconsistent winding internally, it will need to be made consistent for one-sided collision modes to work properly.)

nikolaiko
Posts: 43
Joined: Mon Aug 04, 2014 8:26 am

Re: Modify terrain on the fly

Post by nikolaiko » Tue May 26, 2015 4:28 am

Hi,
Checked sideness - it set to DoubleSided by default. So, I guiess this is not the case, working to solve this issue.

Norbo
Site Admin
Posts: 4570
Joined: Tue Jul 04, 2006 4:45 am

Re: Modify terrain on the fly

Post by Norbo » Tue May 26, 2015 6:28 pm

If the sidedness is not the issue and stuff is still falling through without interacting with the surface at all, it may be a collision rule configuration issue or a piece of the terrain not being in the Space.

If stuff falls through and interacts somewhat (like hitting a slight bump on its way through) and objects are moving quite fast, it may be that they're tunneling through the ground before good contacts can be formed. Turning CCD on for the fast objects would help with this.

If it's not either of those, the best strategy might be for me to just check out the mesh in question in the BEPUphysicsDemos.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests