nmwsharp / geometry-central

Applied 3D geometry in C++, with a focus on surface meshes.
https://geometry-central.net
MIT License
1.08k stars 151 forks source link

Feature request: Load texture baked in .obj files #179

Open HarryRos opened 3 months ago

HarryRos commented 3 months ago

It is possible to save a texture within .obj files by defining an RGB colour on each vertex.

For instance, a .obj file with a vertex line as follows:

v 136 99 52 0.46 0.4 0.3

means a vertex at position (136 99 52) with RGB colour (0.46 0.4 0.3)

It would be great if the simple_polygon_mesh.cpp could be extended to load these colours, possibly into a VertexData structure?

...

if (token == "v") {
  Vector3 position;
  ss >> position;
  if (ss.tellg() >= 0)
  {
    Vector3 colour;
    ss >> colour;
    vertexColours.push_back(colour);
  }

...

nmwsharp commented 2 weeks ago

This makes sense, I'd be happy to merge a PR for this if anyone has time!