2
$\begingroup$

I am looking for a file format to output some 3D geometry. In my case, it only needs to handle very simple shapes - uniformly spaced and sized cubes at points in space. So far I've ended up just representing them as triangles or quads depending on what I can use.

I've tried Binary STL format which is decently compact, but has no support for colors.

Wavefront Object format (OBJ) and the material library (MTL) work well for color support, but there is no binary version as far as I know - making it very bulky.

Is there a file format that:

  • Is compact in size
  • Has some way to support colors
  • Can be opened by software like 3D Viewer, Paint 3D, or other common tools?
$\endgroup$

3 Answers 3

3
$\begingroup$

GLTF is a standardized 3D file format from the Khronos group, the same people behind OpenGL and Vulkan. It has both text and binary formats (the latter called GLB) and is a full-featured format, including support for vertex colors.

tinygltf is an example of a C++ library for loading and saving GLTF/GLB files, but there are many others, I'm sure.

$\endgroup$
1
$\begingroup$

The PLY file format is a simple format similar to OBJ that allows arbitrary attributes (like colours) and has a binary mode.

$\endgroup$
3
  • $\begingroup$ The fact that it has an ASCII header for the binary format is a little frustrating, but I think I can work around that. Do you know how properties are handled for software that reads in PLY files? The header specifies where the properties are, what they apply to, and their size, but the names and types are arbitrary. How does any software deal with the fact that the colors could be called "red" "blue" and "green", or "rd" "bl" "gr" (or anything else), and they could be anything from uchar to float? How is that possible? $\endgroup$ Commented Feb 27, 2020 at 18:56
  • $\begingroup$ As a sidenote, can colors even be applied to faces? Or is the only option to define them per-vertex, or do some kind of user-defined elements? This is all a little confusing. $\endgroup$ Commented Feb 27, 2020 at 19:02
  • $\begingroup$ @TylerShellberg Unfortunately, you might have to rely on common practice for that, in the case of colours likely uchar red... That's the disadvantage of an entirely felxible file format like that. $\endgroup$ Commented Feb 27, 2020 at 19:03
1
$\begingroup$

FBX: while FBX is proprietary, it has both binary and text versions of the format, provides color support, and it provides an SDK which can make integration easier. Here is a link.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.