Lesson 34 - adding character movement
Hi, I'd want to add movement to a character in a landscape generated like that in lesson 34. I think height map have to be regenerated when moving, to never 'exit' from landscape. Is it right? Thanks
There's no need to regenerate the heightmap. Just test if the character passed the terrain boundaries, and if it has, stop the movement. Unless I misunderstood you?
OOP Articles | C++: A Dialog (free book) | Thinking in C++ (free book) | Google Books - Free preview for many books
I guess you want to have a continuous terrain. There are a lot of ways to handle this:
either you generate all your terrain with mathematical functions (FFT, Perlin Noise, etc), or you create a tileable heightmap texture.
Probably the latter is the best option for you. So here's more detail:
You need to make sure that your heightmap texture fits in if you place it left or above itself without rotating or changing anything. Thats "tileable". Gimp and Photoshop have tools which help you with that.
If you have this kind of heightmap, you need to check where your camera looks at, and respectively render your terrain several times so it fits at the edges -> tiled.
Hope that helps
either you generate all your terrain with mathematical functions (FFT, Perlin Noise, etc), or you create a tileable heightmap texture.
Probably the latter is the best option for you. So here's more detail:
You need to make sure that your heightmap texture fits in if you place it left or above itself without rotating or changing anything. Thats "tileable". Gimp and Photoshop have tools which help you with that.
If you have this kind of heightmap, you need to check where your camera looks at, and respectively render your terrain several times so it fits at the edges -> tiled.
Hope that helps
Member of the NeHe team | PhD Student at Heidelberg Collaboratory for Image Processing | ProCamera Developer
Quote: Original post by Caste
You need to make sure that your heightmap texture fits in if you place it left or above itself without rotating or changing anything. Thats "tileable". Gimp and Photoshop have tools which help you with that.
If you have this kind of heightmap, you need to check where your camera looks at, and respectively render your terrain several times so it fits at the edges -> tiled.
Hope that helps
Thanks, that was what I was searching for. I'll try to figure out how to implement it.
Regards
Heh, just noticed you're from Padova.. have been there about 6 weeks ago and got caught because I used the bus without ticket from the bus station to the centre ^^ But its a nice city!
Back 2 topic: ask if you have any questions there..
Some ideas on how you might check which terrains to render:
at first you should make sure your position stays within one instance of the terrain from the view of the value, because as the landscape looks the same if your at 10,10 on no matter which instance of it.
So you might check that if posX > mapX → posX -= mapX and same for Y, additionally check for posX < 0 → posX += mapX so it doesnt get negative.
Next thing is to figure out which terrains apart from the one you're standing on needs to be rendered.
This can be done by getting the angle of your view direction. Lets say you look at your terrain from above, the heightmap placed on positive x and y axis. then you're standing somewhere in there and looking to a special direction. If you now get the angle (arctan(viewDirY/viewDirX)) you might checke whether the angle is between -30° and 30° (so your view frustum spans over an angle of 60°) then you render the terrain right of the one you're standing on.
For all others you just need to add the according check for the angle.
Cheers
Carsten
Back 2 topic: ask if you have any questions there..
Some ideas on how you might check which terrains to render:
at first you should make sure your position stays within one instance of the terrain from the view of the value, because as the landscape looks the same if your at 10,10 on no matter which instance of it.
So you might check that if posX > mapX → posX -= mapX and same for Y, additionally check for posX < 0 → posX += mapX so it doesnt get negative.
Next thing is to figure out which terrains apart from the one you're standing on needs to be rendered.
This can be done by getting the angle of your view direction. Lets say you look at your terrain from above, the heightmap placed on positive x and y axis. then you're standing somewhere in there and looking to a special direction. If you now get the angle (arctan(viewDirY/viewDirX)) you might checke whether the angle is between -30° and 30° (so your view frustum spans over an angle of 60°) then you render the terrain right of the one you're standing on.
For all others you just need to add the according check for the angle.
Cheers
Carsten
Member of the NeHe team | PhD Student at Heidelberg Collaboratory for Image Processing | ProCamera Developer
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement