Archived

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

aker_jus

Getting heightvalues from bitmap

Recommended Posts

I am making a geomipmapping terrain renderer, but I am having some trouble getting the height values. This is C# btw. This is my loading code:
//Create the heightmap data.

D3D.Surface		HeightSurf;
D3D.ImageInformation HeightInfo = D3D.TextureLoader.ImageInformationFromFile (Heightmap);

D3D.Device	D3DDev = RTKernel.CreatedDevice.Device;
HeightSurf = D3DDev.CreateOffscreenPlainSurface (HeightInfo.Width, HeightInfo.Height,
			D3D.Format.R8G8B8, D3D.Pool.Scratch);
D3D.SurfaceLoader.FromFile (HeightSurf, Heightmap, D3D.Filter.None, 0);


m_Heights = new byte [HeightInfo.Width * HeightInfo.Height * 3];

Array arr = HeightSurf.LockRectangle (typeof(byte), D3D.LockFlags.None, 1);
arr.CopyTo (m_Heights, 0);
HeightSurf.UnlockRectangle();
All the elements in the height array are 0, except the first one which is 65. This is not corresponding to the heightmap I load at all. In c++, I would have a LOCKED_RECT structure passed out from the lockRectangle, and use the pBits to copy the memory to the array. I don''t seem to find such a parameter in MDX though, so I think that the array it returns (or the graphicsstream class), contains the image data, but it doesn''t work that way it seems. GraphicsWare|RenderTech http://www.graphicsware.com 3D Graphics & Solutions

Share this post


Link to post
Share on other sites
Ahhh that''s ok, I found it. I used a GraphicsStream and ReadByte() function to fill the height array.


GraphicsWare|RenderTech
http://www.graphicsware.com

3D Graphics & Solutions

Share this post


Link to post
Share on other sites