Does Heightmap support Textures?

Jul 27, 2010 at 12:26 AM

Hi Einar,

Does Heightmap support textured material?

Starting with the "water" sample, I renamed the "ReflectionMap" property to "DiffuseMap".  I would expect to see the sky image (blue sky with clouds) on the rotating heightmap, instead it is just gray.

Water Sample:
(click Creative > Water)

It appears that Heightmap class never sets the texture coordinates of faces that comprise it.  If this is the case, is there a helper class to do this?

BTW, great job with Balder!




Jul 27, 2010 at 10:57 AM
Edited Jul 27, 2010 at 10:58 AM



It should, but I see in the source that it doesn't. I simply must have forgotten to implement that. :)

I'll copy this to a work item and fix it when I get a chance.

Jul 27, 2010 at 10:58 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Jul 28, 2010 at 1:38 AM

Here is a workaround for assigning texture coordinates to Heightmap faces.


public partial class MainPage : UserControl {
    public MainPage() {

        this.HeightMap.Prepared += (s, e) => {
            IGeometryDetailLevel geometryDetailLevel = HeightMap.GeometryContext.GetDetailLevel(DetailLevel.Full);
            Vertex[] vertexs = geometryDetailLevel.GetVertices();
            for (int i = 0; i < geometryDetailLevel.VertexCount; i++) {
                Vertex vertex = vertexs[i];
                float u = (vertex.X + 40f) / 80f;
                float v = 1f - (vertex.Z + 40f) / 80f;
                geometryDetailLevel.SetTextureCoordinate(i, new TextureCoordinate(u, v));
            Face[] faces = geometryDetailLevel.GetFaces();
            foreach (Face face in geometryDetailLevel.GetFaces()) {
                face.DiffuseA = face.A;
                face.DiffuseB = face.B;
                face.DiffuseC = face.C;