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:
http://dl.dropbox.com/u/5342359/Balder/SampleBrowser/TestPage.html
(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!

Cheers,
Richie
http://kiwigis.blogspot.com

 

 

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

Thanks. 

 

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.

Coordinator
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() {
        InitializeComponent();

        this.HeightMap.Prepared += (s, e) => {
            IGeometryDetailLevel geometryDetailLevel = HeightMap.GeometryContext.GetDetailLevel(DetailLevel.Full);
            Vertex[] vertexs = geometryDetailLevel.GetVertices();
            geometryDetailLevel.AllocateTextureCoordinates(geometryDetailLevel.VertexCount);
            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;
            }
        };
    }

}