we are having a problem with a user importing 3ds files in our software (developed with Delphi). The software mimics the import procedure in the 3D demo which also fails to import this kind of 3ds files. I can see the import produces an exception when the 3ds file is read in Tsg3DNavigator.LoadFromFile
I was trying to narrow the problem and found a couple of things:
1) TMaterial3DS.shininess which is defined as a single in Type3DS. Then in GetOrAllocateMaterial, internal function of TGL3DSVectorFile.LoadFromStream in GLFile3DS.pas, shininess of a given material is stored in the property Shininess of the class TGLShader which has the type TShininess = 0..128. This is done in line 1749 of GLFile3DS.pas
Code: Select all
Shininess := MaxInteger(0, integer(round((material.Shininess) * 128)));
Code: Select all
Shininess := MinInteger(MaxInteger(0, integer(round((material.Shininess) * 128))), 128);
Code: Select all
camera_mesh.LoadAnimation(KeyFramer.CameraMotion[I]);
Code: Select all
if Assigned(KeyFramer.CameraMotion[I]) then
camera_mesh.LoadAnimation(KeyFramer.CameraMotion[I]);
this is probably not a good solution because then I have an exception when freeing the navigator. Tsg3DNavigator.Free
When we built the importer in our software we tested a number of 3ds files having no problems with the import, however the user claims that all the 3ds files they create fail to be open, we suspect the problem might be related with the way the files are constructed. The 3ds files that cause the problem are created in Rhino (Version 6 SR11) following these instructions:
Select complete model, type command _mesh
Recommendation for the exact settings of the polygon mesh:
Density: 0.5
Maximum angle: 1.0
Maximum aspect ratio: 0.0
Minimum edge length: 1.0
Maximum edge length: 0.0
Maximum edge to face distance: 0.01
Minimum squares of initial mesh: 0
Refine polygon mesh: Check
Serrated seams: Check
Simple planes: Check
Compress textures: Uncheck
Obviously, each model has its own history, and the same settings cannot always be used.
Delete "old" surfaces so that only polygon meshes remain.
Save model as 3ds
an example 3ds file producing the exception is also attached as a zip file.
It would be really helpful if you could take a look to these problems and share a solution with us. Also Do you think a change on the workflow for the creation of the model might help to avoid the problems? Thank you
Regards, Carlos