Dynamic Trees

Dynamic Trees

25M Downloads

Exporting tree models for rendering

TheoBearDB opened this issue ยท 5 comments

commented

Hi! I've been playing with this mod for some time now, and love every bit of it! The aesthetic is wonderful, but I was wanting to put this out there for the possibility of using this mod for renders/animations

Is your feature request related to a problem? Please describe.
Somewhat. I'm attempting to use a popular Minecraft to OBJ model exporter called JMC2OBJ to export my modded minecraft world to a 3D program (Blender for what I use, but most any other one accepts OBJ) for rendering and possible animations, but I'm needing some information regarding how this mod operates and how it creates the model for trees.

For context, most OBJ exporters essentially build a toned down version of the minecraft world they are pointed to, and export it with the minecraft object's textures. I was attempting to do this with Dynamic Trees here hoping it would do it out of the box, but I've been unsuccessful so far in getting it right.

I'm not really asking for a quick solution as that's not your thing to handle with someone else's software, but a bit of knowledge in how the mod works to create the trees would be very helpful! From looking at the code here my first thought was that the mod uses the branch.json model to build out the Trunk and other smaller branches (Referred to as BranchS and BranchL) depending on how far they are from the ground/other branches. If that's the case, I think I can figure something out to get this to work, but I'm curious if there's some critical bit of info I'm missing. Or that I'm completely wrong, which is definitely a possibility!

I was also wondering if there's a way to set 'finished' trees to be one custom model after they are fully grown. If so, that would be a lot easier to work with as I could just tell the exporter to point at a specific tree model instead of having it try to build it by itself using the different json models, or just export some trees as objects themselves and place them in place of the regular trees in my rendering software! Once again I'm probably very wrong so if I am feel free to tell me so!! If there's any info that you think might help, that would be greatly appreciated!! Love this mod, and all the work everyone puts into it!

commented

The branch models are dynamic baked models, calculated based on their personal radius (a block state) and the surrounding branches' radii (calculated from their respective block states and sent to the baked model). The baked model gets the textures to use for the rings and log from the model Jsons (for example, here is the one for the oak branch).

I'm afraid I don't have any experience on blender or how OBJ models work, so I don't think I can really have any other useful input on this issue. Hopefully the above info was somewhat useful, although I'm not sure how much technical detail you wanted so it's rather shallow. If you need more then feel free to ask of course.

commented

Thank you both! I'm thinking that at the very least knowing how it builds out the trees could help us get to where we need to go.

As far as finished tree question goes, I was asking if the mod somehow, after the tree had finished building itself out from the worldgen with the method that @ferreusveritas stated, if the mod then stored the completed tree somewhere as a whole, instead of the individual branches. I was asking because if so, it might be possible for me to just grab the entire 'tree file' so to speak and export that instead of having the OBJ exporter build out the tree individually. If not though, that's ok! I think I can work with the JMC2OBJ devs and see if there's anything they can do further on it.

Thank you for your awesome work, I love using this mod and would love to really showcase it with some renders if I can! I'll let you know if I end up getting anywhere, or if it's alright, if I need any more info :D

commented

I can appreciate what you're trying to accomplish. Sounds really neat. The branch blocks in Dynamic Trees have a "radius" property that describes how large the core of the node is. If it's 1 then it's a cube of 2x2x2 standard texels(a texel being 1/16 of a block) centered in the block on all 3 axis. If the radius is 2 it's a 4x4x4 texel block, etc.
Radius -> Size
1 -> 2x2x2
2 -> 4x4x4
3 -> 6x6x6
4 -> 8x8x8
5 -> 10x10x10
6 -> 12x12x12
7 -> 14x14x14
8 -> 16x16x16(A full block)

These nodes are connected together to neighboring nodes using connecting boxes that are the size of the smaller node between any two connections. In other words, if a radius 2 branch is next to a radius 6 branch then they will be connected together with a radius 2 connection. There are also special cases for branches involving adjacent leaves and rooty soil blocks.
Rooty soil blocks are connected to always with the radius of the node. Leaves blocks are only connected when the branch block's radius is 1(under nearly all circumstances).

I'm unable to answer your question about setting a custom model from a 'finished' tree. I don't quite understand what you are asking.

commented

The branch structure of trees are used during world gen, yes. These are encoded into a set of base64 instructions, all is explained in this Wiki page. An example is the oak tree Jocodes. Note, however, that these don't include the leaves which are constructed from leaf clusters which are essentially grids of leaf cells with values based on the distance to the nearest branch (which are a block state when the leaves are placed in the world).

Again I'm being a little shallow in my explanation here as I'm not sure how much that information will help, especially since it's not at all related to the tree model (other than the data that is then collected to render it when it comes onto the player's screen of course).

commented

And that would be great, please do keep us up to date with any progress you make, and of course feel free to ask as much as you need. :)