3D models of packages and boards

From @ubruhin on Thu Oct 25 2018 19:55:49 GMT+0000 (UTC)

LibrePCB packages should have support for 3D models, so that we can implement a 3D board viewer & export.

In KiCad, footprints can have two different types of 3D models:

  • VRML for 3D board viewer and raytracing
  • STEP for export to mechanical CAD

Although it’s cumbersome to have two different file formats for 3D models, I guess this is the most reasonable solution. So I think it would make sense if we do it the same way…

Or are there other opinions?

Copied from original issue: https://github.com/LibrePCB/librepcb-rfcs/issues/32

From @dbrgn on Thu Oct 25 2018 20:33:15 GMT+0000 (UTC)

VRML is horrible unfortunately… But I don’t really know a good alternative.

On the other hand, using the same format as KiCAD would allow us to use their 3D models and vice versa. With the growing popularity of KiCAD, maybe better editing tools will pop up. KiCAD libraries are licensed CC-BY-SA, so we could use them. This is probably a case where converging on a common format would give the open source community a lot of benefits.

Also, it seems that nowadays FreeCAD can generate valid VRML files for KiCAD. That wasn’t the case a few years ago :slight_smile:

From @ubruhin on Fri Oct 26 2018 20:55:13 GMT+0000 (UTC)

> On the other hand, using the same format as KiCAD would allow us to use their 3D models and vice versa.

Yes, that would be really helpful!

KiCAD libraries are licensed CC-BY-SA, so we could use them.

Hmm I’m not sure if we really could/should use them. Actually I want to have all official LibrePCB libraries to be published under CC0, so that users can do absolutely everything with the libraries, without even worrying about their license. CC-BY-SA breaks this, as it has restrictions :frowning:

A cursory glance at other CAD apps shows STEP is everywhere, and STL/AMF are fairly common.

The new version of STEP can contain colors it seems, so if STEP alone is good enough for a basic fallback, you could have STEP required, and allow arbitrarily many other files as well.

It seems like VRML is the one of the only things that really has an accepted way to put materials with specular reflection and the like into a file, aside from going with an app-specific format.

One could define a standard set of STEP material names, and an exporter that knows what material to apply to a GoldPlatedPin or some Solder or some BlackChipEpoxy. That kind of abstraction gives flexibility and prevents being forever tied to one model of how rendering should work.

OBJ seems to explicitly be designed for that kind of workflow, with named materials and a separate MTL thing, and it’s pretty bog standard. The MTL files have transparency and specular reflection and such.

You could just have a basic flat color+openGL viewer integrated, and leave HQ rendering to a Blender exporter with a library of shaders for each material.

This would also save parts authors from having to worry about presentation too much. They just type a material name, and LibrePCB handles making it look good.

Another pretty big advantage is that different people’s models will have the same color chips and pins and such in the render, preventing an annoying cacophony unless a part really does have a specific color.

I like that. Having a standard set of materials allows for consistent look & feel in 3D renderings.

We are dealing here with 2 kinds of requirements:

  • Generate a nice 3D rendering of the board (promote your work)
  • Create an accurate 3D model for mechanical purpose (make the box around the electronics)

3D rendering is best done with tools like Blender and Maya (list is not exhaustive). These uses format as *.obj files, collada (more or less standard)…
They provides materials, photo realistic rendering… But they are not accurate for dimensions.

STEP (and other format like IGES, solidworks…) are for 3D mechanical manipulation and are accurate.

According to me, information about 3D rendering (texture,bump map…) must be present in the component library but its format can be proprietary as long as we can export it to a standard 3D rendering format.
3D mechanical information must also be present in the 3D library to allow exportation with software like SolidWorks, or SolidEdge.

By the way, third party plugins in Blender (or Maya) already allow asset generation for other applications. An example is OpenTTD (Open Source Transport Tycoon Deluxe) whose has Blender templates to generate new buildings and transport models for the game.

I took a look at the STEP format. STEP (aka ISO10303) is hugely complex: https://www.datakit.com/en/step_organization.php There’s the file exchange format (ISO10303-21), but that only describes how to parse the files. It does not say anything about the meaning of the parsed data.

The meaning depends on some other substandards, and it depends on the schema that is being used for a file. A schema can be something like automotive_design, but it can be other things too.

Does someone know whether other schemas than automotive_design are being used to model electronics parts?

Regarding the OBJ format as an alternative, the main downside is that it doesn’t contain any absolute scale information. However, we should be able to store the scaling information in a separate file, or in the library, right?

If I understand the format correctly, then OBJ will contain geometric information and it allows to reference materials specified in a separate file to change the look of a polygon. This means we could create a set of standard materials in a librepcb.mtl file and reference those materials from the library OBJ files, right?