glscene / GLScene

GLScene is a graphics engine based on OpenGL with VCL components for Delphi & C++ Builder.
http://www.glscene.org
Mozilla Public License 2.0
216 stars 32 forks source link

Assigning a material library to a TGLFreeForm #10

Closed GrooverMD closed 6 months ago

GrooverMD commented 3 years ago

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 commented 3 years ago

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

glscene commented 6 months ago

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