   Triangles, Heightmaps and FPS, C# DirectX
  I''ve been writin a simple terrain engine that loads a greyscale bitmap as a heightmap, and as I''ve never done any 3D programming before I wanna know if i''m doing things the right way, as it seems every other day I find out a different way something is done.So I''ve written the code so that I can load up any size bitmap, take the width and height of the bitmap as the x and z-axis and the brightness of each pixel as the y-axis component. Each pixel is represented by 2 triangles (Is this called a quad?).I''d like to know how I should store this data, at the moment i read the bitmap into an array of Vector3 and create an array of short[] to store index data to connect the vectors. I then create a new DirectX Mesh object and dump the vector and index data into it, then perform Mesh.WeldVerticies on the data and ComputeNormals etc (and other pretty DX Mesh optimizations). Is this how we are meant to do this sort of thing? Or should I just be storing the data in index buffers and vertx buffers and not using DX Mesh objects. I''m also curious because I seem to be getting really crap FPS with a 300x300 bitmap, erm that equates to something like 180,000 triangles, having never done 3D before I have no idea if thats /a lot/ of triangles or not, how much can I expect a decent (GeforceFX 5600) card to be able to display at 30+ fps?One other thing, a 300x300 bitmap seems REALLY small in 3D, I get the feeling i''d need more like 10,000x10,000 bitmap just to make it so u can''t see off the edge of the world, is this correct? Thanks for reading, really I''m just looking for practical advice as someone who is new to terrain rendering.Chris 
  Hi, I am in the same boat as you. I have just written a terrain class for my engine, and what I am doing is reading in the bitmap information in a char array[]. I take the width and height of the bitmap, for me its a greyscale, create the array and then read the data in from my bitmap. It should range from 0 to 255, if its 24 bit.Then from that information I created and index/vertex buffers and you have to use a scaling function in order to generate the terrain. I was using 32x32 images as you can imagine are quite small so I wanted to "magnify" it for my terrain. Then you loop through the image information you have and basically use it to create the "height" for you terrain. Assuming "Y" is up X and Z are easily calculatable from within 2 loops then you must calculate the "Y" height.Hope it works out well for you!   In the making Tread Wars - Tank Battle gamePowered by SKEnginehttp://www.highendgaming.com ;  What's your scale ? Most people use an index of 1 unit=1 meter, and if your camera is 2 meters above the ground (first person size) or 5 meters (behind the players) 300x300 is a pretty big area. You can always use multiple 64x64 or 128x128 meshes and only draw the ones that are near.Most games use a technique where the faraway terrain is drawn with less precision. If you use 128x128 maps, you can make subsets in each mesh, a 128x128 for up close, and 64x64, 32x32 and 16x16 ones which you use depending on the distance. Say 128x128 for the one you are standing in, 64x64 for the 8 surrounding it, and 16x16 for the 16 surrounding that. The rest is not drawn at all.The technique you describe is good, I do the same, generate vertices, indexes, call optimizeinplace and generatenormals. The pixels are the cornerpoints of the quads however, not the quads themselves, so 2 triangles don't represent a pixel but the area between 4 pixels.   [edited by - Fidelio66 on February 3, 2004 7:41:25 AM];  what do you mean by scale? when I import the heightmap each pixel on the image takes up a 1x1 square e.g this is 1 pixel:  (0,0) __(1,0) |\ | |_\| (0,1)   (1,1)by scale do you mean I should make each pixel 10x10 or some other size? or is scale relative, to everything else, and if so how do I make 1 unit in DirectX space = 1 meter in "real" space?Thanks for your help. ;  No, that''s just up to you. Coordinates are relative, if you multiply everything by 10 and the player is also 10x as big, it will look the same.