Archived

This topic is now archived and is closed to further replies.

sakky

Direct3D 9 and Heightmaps

Recommended Posts

sakky    100
    I''m in the process of making a terrain engine with Direct3D9. I''ve been having problems getting the vertices to render correctly. I also think there might be and error in I''m initializing the vertex buffer. I don''t see any thing on my screen. I''ve also tried changing view transformations. But I''ve had no luck there either.     I''ve deleted the code because I couldn''t get it to work after 4 1/2 hours of editing it; A run of bad luck. I just wanted some snippets from one of you guys that have done this too. I need something that I can reference too that works. My RAW images are 128x128, and they are also grayscale: curtsey from Adobe Photoshop. I you would help, I would be truly grateful. I''ve been tiring to accomplish something like this for some time now.

Share this post


Link to post
Share on other sites
bpopp    122
I have my Brute Force Direct3D terrain engine in my CVS. It's not the best implementation and it's still very much in development, but it will get you started.



You can view it at:

http://cvs.bpopp.net/cgi-bin/cvsweb.cgi/terrain/

The most important source file is called cterrain.cpp. Some of the earlier revisions might be easier to understand. In the newer versions, I've implemented index buffers and I'm in the process of implementing a recursive quadtree (which complicates the source.)

If you are not familiar with CVS and you'de rather, message me on my site and I'll email you the full package.

[edited by - bpopp on March 18, 2003 6:03:14 PM]

Share this post


Link to post
Share on other sites
Magius    220
One thing I always used to do when I first started out was forget to set the vertex shader. With DX9 you can use the IDirect3DDevice9''s SetFVF function (and pass in your custom vertex format) to declare a default vertex shader.

Share this post


Link to post
Share on other sites
sakky    100
quote:

Original port by Magius
One thing I always used to do when I first started out was forget to set the vertex shader. With DX9 you can use the IDirect3DDevice9''s SetFVF function (and pass in your custom vertex format) to declare a default vertex shader.



Yes, I''ve done that when I first wrote the code. I think the area that I''m having problems with is loading the heightmap into the vertex buffer, then displaying it properly.

When I load the heightmap, how should I load the array? I used a double for loop to reference the BYTEs to floats. I also wondered if I should try to convert the heightmap to a mesh.

bpopp: I will take a look at your source code.

Share this post


Link to post
Share on other sites
Magius    220
Are you running the debug run-time? If so, it may print out some hints as to what your errors are in the Output window. From there you can further narrow down your problem. Other than that, without some source code it is difficult to give a more thorough response to your problem.

Share this post


Link to post
Share on other sites