GLScene icon indicating copy to clipboard operation
GLScene copied to clipboard

Assigning a material library to a TGLFreeForm

Open GrooverMD opened this issue 4 years ago • 1 comments

Hi,

I have loaded a TGLFreeForm component with a 3ds file, used a TGMaterialLibrary to store the 3ds materials. I have also created another Material Library with grey scale versions of the 3ds materials, but I can't assign this material library to the FreeForm.

This works with the Material Library assigned to the FreeForm (GLS_Icon) when the 3ds file is loaded :

procedure TForm1.Button2Click(Sender: TObject);
  begin
    GLScene1.BeginUpdate();
     
    GLS_Icon.MaterialLibrary := NormalMaterials; //Materials created when loading the 3ds file.
   
    GLCone1.Material.MaterialLibrary := NormalMaterials;

    GLScene1.EndUpdate();
  end;  

image

This doesn't work with the designtime created material library:

procedure TForm1.Button1Click(Sender: TObject);
  begin
    GLScene1.BeginUpdate();

    GLS_Icon.MaterialLibrary := DisabledMaterials; //The designtime library with grey scale versions of the NormalMaterials

    GLCone1.Material.MaterialLibrary := DisabledMaterials;

    GLScene1.EndUpdate();
 end;

image

Any hints would be helpful.

Cheers.

GrooverMD avatar Aug 29 '21 05:08 GrooverMD

I have worked it out! The created Material Library needs the same material names as the 3ds material library.

GrooverMD avatar Aug 29 '21 05:08 GrooverMD

That's right, there are already names of materials there

glscene avatar Apr 17 '24 18:04 glscene