Unity3D Heightmap

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
absentmaverick
Posts: 3
Joined: Tue Sep 01, 2015 3:37 am

Unity3D Heightmap

Post by absentmaverick » Tue Sep 01, 2015 3:38 am

Are the Unity3D terrain and the BEPUPhysics terrain the same?

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

Re: Unity3D Heightmap

Post by Norbo » Tue Sep 01, 2015 4:04 pm

It depends on what details you're comparing, probably. On the other hand, I don't know anything about unity's terrain, so I'm guessing they're not the same :)

If you have a specific question about the nature of the BEPUphysics terrain, I could be of more help.

absentmaverick
Posts: 3
Joined: Tue Sep 01, 2015 3:37 am

Re: Unity3D Heightmap

Post by absentmaverick » Tue Sep 01, 2015 5:41 pm

If I want to create an authoritative server that simulates a Unity game world, can I use the BEPU terrain class to mirror Unity's terrain class?

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

Re: Unity3D Heightmap

Post by Norbo » Tue Sep 01, 2015 6:39 pm

Maybe or even probably, but I don't know for sure. If unity's representation is a grid-based heightfield with two triangles per quad with uniform layout, it should be possible to line things up with little effort. If it's a more complicated representation, it could be more difficult. In the worst case, a custom triangle organization could be created for the BEPUphysics Terrain (this would require source changes).

absentmaverick
Posts: 3
Joined: Tue Sep 01, 2015 3:37 am

Re: Unity3D Heightmap

Post by absentmaverick » Tue Sep 01, 2015 8:08 pm

How would I go about doing that?

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

Re: Unity3D Heightmap

Post by Norbo » Tue Sep 01, 2015 8:23 pm

First, you'd have to look into Unity's terrain representation to figure out what it's actually doing. Hopefully it's very similar and you won't have to do anything at all, and it would be as simple as the TerrainDemo in the BEPUphysicsDemos.

If you end up needing to make modifications, then main function that needs to be changed is TerrainShape.GetOverlaps. This selects a region of the grid using a bounding box and adds all triangles indices inhabiting the overlapped cells to a list. Depending on the changes made there, the TerrainShape.GetLocalIndices function will need to be updated as well to map between triangle index and vertex indices. Some secondary systems like CCD rely on TerrainShape.GetTriangle, too.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests