Forum
Contact





DirectX using C#
DirectX using C++
DirectX using Visual Basic



Latest Forum posts

 Tutorial 3 for Windows Phone 7
  Posted by: Anonymous
  When: 20/05/2013 at 02:30:13

 No download link for 2d series: shooter
  Posted by: zaboleq
  When: 07/05/2013 at 15:46:28

 Collision Class?
  Posted by: Anonymous
  When: 05/05/2013 at 19:03:59

 stack overflow
  Posted by: cityguy
  When: 07/04/2013 at 01:58:38

 Meshes looks strange.
  Posted by: ab_saratov
  When: 01/04/2013 at 04:31:08

 Lamppost Not loaded
  Posted by: Anonymous
  When: 22/03/2013 at 06:43:52

 Collision Class?
  Posted by: Da_Boom
  When: 21/03/2013 at 01:23:09

 Math boggles me
  Posted by: cityguy
  When: 17/03/2013 at 03:44:48

 Collision Class?
  Posted by: Da_Boom
  When: 16/03/2013 at 03:44:42

 Tree update
  Posted by: Anonymous
  When: 15/03/2013 at 21:11:22

 XNA 4.0
  Posted by: Anonymous
  When: 15/03/2013 at 19:43:57

 Error when I try to run.
  Posted by: Anonymous
  When: 15/03/2013 at 19:21:06

 Error With the Effect File
  Posted by: Anonymous
  When: 15/03/2013 at 18:21:01

 Can only get shadowmap
  Posted by: Anonymous
  When: 15/03/2013 at 15:48:52

 Vertex and Pixel Shader Versions?
  Posted by: Anonymous
  When: 15/03/2013 at 15:07:16

 Unsupported properties
  Posted by: Anonymous
  When: 15/03/2013 at 14:23:00

 Problem Loading Skybox
  Posted by: Rana
  When: 15/03/2013 at 10:34:45

 Black Screen Of Death - Help!
  Posted by: Anonymous
  When: 15/03/2013 at 03:43:43

 2.0 anyone?
  Posted by: Anonymous
  When: 15/03/2013 at 02:19:48

 Defitinition of tha rotation axis
  Posted by: Anonymous
  When: 15/03/2013 at 00:55:14




Topic: Multiple Buffers



  
Goto parent category
  
Create a new user account


   Multiple Buffers
 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.

  
Post a new reply
 





Google
 
Web www.riemers.net
If you appreciate the amount of time I spend creating and updating
these pages, feel free to donate -- any amount is welcome !
- Website design & DirectX code : Riemer Grootjans -
©2006 Riemer Grootjans


News
Home
Forum
XNA 2.0 Recipes Book (8)
XNA 3.0 Recipes Book (8)
Downloads
Extra Reading (3)
Matrices: geometrical
Matrix Mathematics
Homogenous matrices
Community Projects (1)
Tutorials (160)
XNA 4.0 using C# (89)
DirectX using C# (54)
Series 1:Terrain (14)
Opening a window
Linking to the Device
Drawing a triangle
Camera
Rotation - Translation
Indices
Terrain creation
Terrain from file
DirectInput
Importing bmp files
Colored vertices
DirectX Light basics
Mesh creation
Mesh lighting
Series 2: Flightsim (19)
Series 3: HLSL (19)
Short Tuts (2)
Resizing problem
Checking Device caps
DirectX using C++ (15)
DirectX using VB (2)