Skip to content

GLS.FileOBJ unit has some trouble #56

Description

@funnyhong

3d model .OBJ File loading error

in mtl file

newmtl ShinyMaterial
Ka 1.0 1.0 1.0
Kd 0.8 0.8 0.8
Ks 1.0 1.0 1.0
Ns 500.0 # Shininess (Specular Exponent: 0 ~ 1000)

but in unit GLS.Material
TGLShininess = 0..128;

so value mapping error
TGLShininess = 0..128
mtl (obj) = 0..1000

so
i tried temporary MapValue function

function MapValue(Value, Min1, Max1, Min2, Max2: Double): Double;
begin
if Max1 = Min1 then
begin
Result := Min2;
Exit;
end;
Result := Min2 + (Value - Min1) * (Max2 - Min2) / (Max1 - Min1);
end;

and

function GetOrAllocateMaterial(const libName, matName: string): string;
...
//Shininess := StrToIntDef(objMtl.MaterialStringProperty(matName, 'Ns'), 1); // previous code

    // Fix by funnyhong
    var iTemp : Integer;
    iTemp := StrToIntDef(objMtl.MaterialStringProperty(matName, 'Ns'), 1);
    Shininess := Round(MapValue(iTemp, 0, 1000, 0, 128));

...
end;

I would like to express my sincere gratitude to the GLXEngine production team.
good luck

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions