-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Terrain System #8
Comments
Awesome! I try to bake it in my terrain manager. I googled libgdx heighmap and there are a height map test that might be useful. However we need to get it working with bullet of course. |
I forgot to ask, how does this render? Isn't it easier to build a model class from the vertices and them just create a model instance? :) |
I forgot to add the GroundChunk class, you can see it is used inside HeightMapModel: The ground chunks are just added to a list, and then rendered like this: private void renderGroundChunks() {
Lists.visibleGroundChunks.clear();
for (GroundChunk ground : Lists.groundChunks) {
if (ground.isVisible(cam)) {
modelBatch.render(ground, environment);
Lists.visibleGroundChunks.add(ground);
}
}
} visibleGroundChunks was just for debugging to see how many were visible in that project, it's not necessary |
You might also want these files for testings: Here is the texture you can use for it: http://www.superior-tactics.com:12080/hm1_paint.png It should look something like this: https://www.youtube.com/watch?v=xNbi63i8aT4 |
This looks great! Im home from work in about 2/3h and have a lot of time to fix this. cant wait hehe. Have you used BtHeightFieldTerrainShape and know how it works? |
a while back when I was working on that terrain stuff I tried to create a btHeightFieldTerrainShape but the shape always came out corrupted/distorted, and I never got it working correctly. I ended up just writing a function that checks the height (y) of the ground at the 2d point (x,z) to do simple ground collisions. That worked fine, but it won't for GDX-proto, because we need the bullet shape to get the ground terrain working properly with ray casting. |
What I see there are two options:
Im going to go with #2 first but when we find a soloution it will be easy as a pie to change it. |
Yeah, model-based object should be easy to get working, it's already used for the static geometry |
Alright! So Im thinking That you have a Terrain manager that is responsible for all terrain related stuff. Terrain Manager can created TerrainChunks/GroundChunks (depending on the name) for you by example writing Terrain.createMeshTerrain(parameters) and there should be a a couple of methods to do that. At the moment I have:
And when you have the returned Chunk you can modify it by:
Then you want to add the chunk to the game and here is what I need some help. Because there are multiple ways of dealing with terrains. One way is to have one large chunk that is your world however in most cases that will not work. Lets say you want to create a Open World game. Well good luck on that. With some research I found that a common method is to scroll the terrain chunks with you. 000 By using 9 chunks where the 0 represent a distant chunk and the 1 is the chunk the player is on. When the player steps over to a 0 new terrain are created and some terrain are destroyed to keep the player at the middle chunk. Do you have any suggestions on how I should set up the terrain? |
Here's some code I used in a previous project for creating heightmapped terrain from reading a PNG file:
HeightMap reads the PNG file and creates a 2d array of vertices
HeightMapModel creates a 3d model based on the HeightMap
it doesn't have LOD or anything like that. At the time I tried to create a Bullet btHeightfieldTerrain body based on the data but could never get it to work.
HeightMap.java
HeightMapModel.java
The text was updated successfully, but these errors were encountered: