melvinw / tracer

ISC License
0 stars 1 forks source link

[Feature Request] Tree Mesh Generator #3

Open melvinw opened 2 years ago

melvinw commented 2 years ago

Right now users of tracer have to generate its input by hand using blender or some other software, then export their work as GLTF that tracer can consume. It would be nice if we could offer a tool that could be composed with tracer that lets users proceduraly generate meshes for Trees by specifying some higher level parameters and positions on a grid. Then users could invoke both like this:

$ ./your_tool some_input_file.json | ./tracer -

One such procedural tree model is the Webber-Penn Model. It is described in this paper: https://courses.cs.duke.edu/cps124/spring08/assign/07_papers/p119-weber.pdf

Whoever picks up this feature could also look to the existing implementation linked below for inspiration. https://baileylab.ucdavis.edu/software/helios/_weber_penn_doc.html https://github.com/PlantSimulationLab/Helios/tree/master/plugins/weberpenntree

The input to this program would probably be a JSON object that looks something like the snippet below and would output the GLTF-formatted scene.

{
  "params": {
    "apple": { /* webber-penn params */ },
    "almond": { /* webber-penn params */ },
    ...
  },
  "instances": [
    {"name": "my_apple", "type": "apple", "position": [x, y]},
    {"name": "my_other_apple", "type": "apple", "position": [x, y]},
    {"name": "an_almond", "type": "almond", "position": [x, y]}
  ]
}

Implementing https://github.com/melvinw/tracer/issues/2 first may actually make implementing this feature easier, since translating from tracer's internal geometry types to a OBJ format may be less tedious than GLTF. The details of the latter would distract from the useful and interesting parts of this feature anyway.

If you do, however, end up using GLTF as the output format, the following resources might be helpful. https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/figures/gltfOverview-2.0.0b.png https://github.com/syoyo/tinygltf/blob/master/examples/build-gltf/create_triangle_gltf.cpp