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

Latest Forum posts

 Backup DVD Escape Plan
  Posted by: Applefly
  When: 17/04/2014 at 06:00:12

 Disney DVDs to MP4
  Posted by: Applefly
  When: 17/04/2014 at 05:56:07

 DVD movies through media streamer
  Posted by: VIKIVannessa
  When: 16/04/2014 at 02:25:09

 DVD movies to play on Galaxy Tab 3 10.1
  Posted by: VIKIVannessa
  When: 16/04/2014 at 02:20:51

 Blu-ray to Apple ProRes
  Posted by: Applefly
  When: 12/04/2014 at 00:47:46

 HD H.264 MP4 format
  Posted by: Applefly
  When: 12/04/2014 at 00:43:23

 DVD collection to computer
  Posted by: VIKIVannessa
  When: 04/04/2014 at 07:13:33

 DVD movies to play on Galaxy Tab 3 10.1
  Posted by: VIKIVannessa
  When: 04/04/2014 at 07:11:27

 DVD movies to play on Galaxy Tab 3 10.1
  Posted by: VIKIVannessa
  When: 04/04/2014 at 07:11:27

 DVD Ripper to populate
  Posted by: Applefly
  When: 04/04/2014 at 05:01:35

 kids and family watch DVD
  Posted by: Applefly
  When: 04/04/2014 at 04:59:21

 Blu-ray movie for your lovely kids
  Posted by: VIKIVannessa
  When: 02/04/2014 at 05:47:49

 DVD to DNxHD Converter for Mac
  Posted by: VIKIVannessa
  When: 02/04/2014 at 05:46:04

 play HD Videos on Galaxy
  Posted by: Applefly
  When: 01/04/2014 at 03:16:39

 video on iPhone 6
  Posted by: Applefly
  When: 01/04/2014 at 03:15:18

  Posted by: net777
  When: 31/03/2014 at 03:34:55

 Play MVI/MKV/AVI on Galaxy NotePro 12.2
  Posted by: VIKIVannessa
  When: 31/03/2014 at 01:30:21

 Create family videos with iMovie on Mac
  Posted by: VIKIVannessa
  When: 31/03/2014 at 01:29:25

 WMV format from DVD
  Posted by: Applefly
  When: 28/03/2014 at 02:55:09

  Posted by: Applefly
  When: 28/03/2014 at 02:53:35

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.


 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.

 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
 Country :

Posted by Anonymous on 03/10/2011 at 18:34:19
Fuarrelz? That's marvelously good to know.

Post a new reply

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

XNA 2.0 Recipes Book (8)
XNA 3.0 Recipes Book (8)
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
Rotation - Translation
Terrain creation
Terrain from file
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)