| Poster | : newgamecoder | | Posts | : 13 | | Country | : USA | | City | : Oak Island |
| | | | Posted by newgamecoder on 19/03/2007 at 21:43:32
| | I have been racking my brain trying to come up with a way to create a larger terrain effect using multiple buffers or something to that effect.
My idea is to go ahead and load the heightmap data from any size bitmap which has dimensions that are a multiple of 196 (or 64*3) this way I can draw the map in 64x64 blocks all around my camera (or player position).
I am running into a wall when it comes to the vertexes and indices.
I was wondering if anyone could explain the relationship between the vertices and indexes and the image that is drawn as far as the drawn terrain's position in 3d space...
My thoughts are that I want to load all of the information I need about the map at the start of the program and have it draw my map data based upon the position of the camera (or player).
So, if I want to show the map around a player position of (216, 158) then I would have to display the vertex information and heightdata for the area of (128 through 320, 64 through 256).
Am I thinking along the right lines? If so, how might i go about displaying only that part of the vertex information and would my indices change for this?
Thank you for any thoughts you might share. | |
|
|
| |
| |
| Poster | : newgamecoder | | Posts | : 13 | | Country | : USA | | City | : Oak Island |
| | | | Posted by newgamecoder on 19/03/2007 at 22:17:39
| | By draw part of the vertex information I mean load the vertex buffer with only the data that I need (the area around the player).
Of course, this would have to be recalculated every time the scene is drawn.
Also, I do not want to lose the ability to track my players actual position in space.
Instead, I would like to tell XNA to only draw a certain area of the heightmap data.
Understand?
Thanks | |
|
|
| |
| |
| Poster | : newgamecoder | | Posts | : 13 | | Country | : USA | | City | : Oak Island |
| | | | Posted by newgamecoder on 19/03/2007 at 22:31:04
| | Another way to do this (and probably less complex) would be to calculate the amount of terrain that you want to show at a time (say 256 x 256) around the camera and load the buffers with that data...
in other words, if my player is at the same position (256, 512) then I would want to draw only 128-384 for my x values and 384-640 for my y values.
This information should still be pulled from the heightmap array, but it should dynamically load the buffer(s) with the appropriate information.
This way we are drawing no more vertices to the screen than what our graphics cards (i'm on a laptop) can handle and we have a much smoother terrain...
One last thought for the night...
There needs to be some checking to make sure that we don't get an index out of bounds error. To accomplish this (in this case) we need to make sure the player can not move to a position within 128 of the total size of our map on each edge.
Okay, now I really need to hit the rack or I'm going to be useless tomorrow.
Thanks for any additional code / methodology you might add. I'm still stumped on how to draw only the area that I want to display and primarily, the best place to load the information for the new vertex buffer. But as always I will continue to hack away at it. | |
|
|
| |
| |
| Poster | : riemer | | Posts | : 1392 | | Country | : Belgium | | City | : Antwerp |
| | | | Posted by riemer on 20/03/2007 at 03:51:59
| | Well this is really something that requires a lot of explanation. But what you're explaining there is called view frustrum culling. Googling for this you'll find OpenGL or DirectX examples, but you're only interesed in the theory right ??
The XNA framework has built-in view frustrum functionality, with Viewport.Project you can check what parts of the terrain are in sight. | |
|
|
| |
| |
| Poster | : newgamecoder | | Posts | : 13 | | Country | : USA | | City | : Oak Island |
| | | | Posted by newgamecoder on 20/03/2007 at 14:51:21
| | Well, I'm not sure if that is what I am thinking about or not.
I think it would be better described as dynamically loading the vertex buffer so that the area of a map that isn't directly surrounding a point in space (the camera or player) isn't even drawn, but at the same time, when the terrain is drawn around the camera, it is drawn exactly where it would have been had we drawn the entire (and larger) heightmap file.
so if we have a file 512x512 and our camera is in the middle of it, the vertex buffer should only contain the data for the terrain surrounding our point (lets say a distance of degrees all around), but make the coordinate system still work as though we actually had a 1024x1024 map loaded.
Another picture...
Say I'm standing on a mountain and the area around me is drawn only far enough so that i can see the bottom of the mountain but no grass land... As I walk down the mountain the grass land is drawn in front of me and the mountain begins to disappear because it's vertices are no longer in the vertexbuffer.
What I'm trying to do is just load the vertex buffer (on the fly) based upon my player's position in my much larger world.
That's as simple as I can make what I'm thinking about.
Understand? | |
|
|
| |
| |
| Poster | : riemer | | Posts | : 1392 | | Country | : Belgium | | City | : Antwerp |
| | | | Posted by riemer on 21/03/2007 at 14:12:36
| | Well, I think you're giving the definition of view frustrum culling: draw only the vertices that are in sight of the camera.
For this, you'll want to divide your terrain into smaller rectangular patches. This can be done with a quadtree structure.
The combination of both is called an octree. | |
|
|
| |
| |
| Poster | : Anonymous | | Posts | : | | Country | : | | City | : |
| | | | Posted by Anonymous on 03/10/2011 at 18:34:19
| | | Fuarrelz? That's marvelously good to know. | |
|
|