Menu

Map image to HeightField - 2

Help
DaveW
2023-06-19
2023-06-20
  • DaveW

    DaveW - 2023-06-19

    After a lot of experimenting I think that the initial problem was that the HeightField does not have a TextureOffset & TextureScale property, these are only available via a MaterialLibrary.Material. So I changed the example Fxy demo app by adding a MaterialLibrary and then:

    procedure TFormFxy.FormCreate(Sender: TObject);
    begin
      GLMaterialLibrary1.Materials.Clear;
      with GLMaterialLibrary1.AddTextureMaterial('Image1','HTFViewer.jpg') do
        begin
        textureoffset.x := -0.5;
        textureoffset.y := -0.5;
        Material.Texture.Disabled := false;
        Material.Texture.TextureMode := tmDecal;
        end;
    
      HeightField1.Material.MaterialLibrary := GLMaterialLibrary1;
      HeightField1.Material.LibMaterialName := 'Image1';
    
    // OR
    //  HeightField1.Material.Texture.Image.LoadFromFile('HTFViewer.jpg');
    end;
    

    However this just produces a solid color which seems to be taken from a single pixel in the image, at least changing the textureoffset can result in other colors that are seen in the image. Also the heightfield now shows as 'flat' with no shading of the shape.

    Can someone please tell me what I need to do to get the image onto the heightfield via the MaterialLibrary with positioning and shading as seen when just loading an image directly into the HeightField's Material.texture.Image?

     
  • DaveW

    DaveW - 2023-06-20

    Hi Pavel,
    Thank you for the links to those examples, I think I should be able to figure it out from them.
    I had searched all the demos installed with the main code but had not found the Examples folder on SourceForge, I have downloaded all of them now though!
    David.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.