4

I'm doing my first steps with Bevy aiming for "settlers" or "anno 18xx" kind of simulation. I have a tree model, that I exported from Blender as gltf. The tree has a brown trunk and green leaves. I could open the gltf file in a web based viewer and everything looks fine so far.

In Bevy I setup a simple camera, light, ... and can load the tree like this:

let tree = asset_server.load("tree.gltf#Scene0");
commands.spawn_scene(tree);

This works fine. I can see the tree with the correct colors. But it is a full "scene" with a "world". I would like to render many trees with different transformations, so I tried to render the "plain" mesh. I figured out that the model is composed out of two meshes, so I had to do something like:

let trunk = asset_server.load("tree.gltf#Mesh0/Primitive0");
let leaves = asset_server.load("tree.gltf#Mesh1/Primitive0");

commands.spawn_bundle(PbrBundle {
    mesh: leaves,
    material: materials.add(Color::rgb(0.0, 1.0, 0.0).into()),
    // ...

This works "somewhat": I loose the colors from the gltf file and have to set them manually. The relative position between trunk and leaves is broken, so I probably lost some transformations defined in the file.

According to https://bevyengine.org/news/bevy-0-5/#top-level-gltf-asset the Gltf handling has been improved in Bevy 0.5, but I don't get what's the intended way to use it in my case.

Could somebody give me a simplest example on how to define my game assets (tree, house, fence, ...) in Blender and just render the exported gltf multiple times in Bevy? Including assigned colors / materials? I assume there must be something "between" my two approaches I showed above, but I don't get it.

Achim
  • 15,415
  • 15
  • 80
  • 144

0 Answers0