another tree generator

A forum to store posts deemed exceptionally wise and useful
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

another tree generator

Post by kornwaretm »

a new tree generator just get started on github. it's not generating one tree. it generates the whole jungle.
content :
  1. 1. KornJungle : the headers and cpps needed
  • 2. bin : precompiled binary and resources needed
screen shoot
Image

how to use
firstly create the jungle node. this node require a terrain scene node for height reference.

Code: Select all

 
     // create jungle.
    // terrain texture is 256 x 256 scaled by 40.0
    // lets create density of one tree every 8x8 pixel
    jungleScene::Jungle *jungle =
        new jungleScene::Jungle(
                10240, // world size
                8,// chunk size. "chunk size" * "chunk size" = "tree count per chunk"
                16,// max tree dimension diameter
                4,// tree circular detail
                terrain,
                smgr,
                -1);
    smgr->getRootSceneNode()->addChild(jungle);
    jungle->getMaterial(0).setFlag(EMF_LIGHTING, false);
    //jungle->getMaterial(0).setFlag(EMF_BACK_FACE_CULLING, false);
    jungle->getMaterial(0).setTexture(0, driver->getTexture("./media/bark.png"));
    jungle->getMaterial(0).MaterialType = EMT_SOLID;
 
    jungle->getMaterial(1).setFlag(EMF_LIGHTING, false);
    jungle->getMaterial(1).setFlag(EMF_BACK_FACE_CULLING, false);
    jungle->getMaterial(1).setTexture(0,driver->getTexture("./media/leaf.png"));
    jungle->getMaterial(1).MaterialType = EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
 

create a tree. for easier usage, a tree struct can be create to store all configuration. maybe a json file next time. pay attention on the last parameter. you can create a tree with "instant grow" means it suddenly mature and tall, or "growing slowly".

Code: Select all

 
jungle->addTreeAt(core::vector3df(cx, terrain->getHeight(cx,cy), cy),
                    16,// segment count per branch, the more the better curve
                    5,// min rotation allowed
                    30,// max rotation allowed
                    800.0f, // length
                    2, // branching count, how many branch may appear from single trunk
                    7.5f, // max radius, the widest radius
                    3, // ground root, max number of ground root.
                    200.0f, // leaf width. maximum leaf dimension
                    200.0f, // leaf height. maximum leaf dimension
                    2, // leaf segments, number of leaf segment (for now not working yet, just use 2, reserved for palm trees)
                    1.0, // leaf stiffness (not working for now, reserved to generate palm trees)
                    0, //leaf type, this is leaf texture selector, for now 0-7, next release user defined
                    0, // bark type, this is bark texture selector, for now 0-7, next release user defined
                    seed, // seed, random seed, integer value to make every tree unique
                    true // instant grow or use animated growing, bad if the chunk are too large since an update at a chunk means an update to whole tree collection in it.
                    );
 
for growing animation, check here https://www.youtube.com/watch?v=xPIAh0bb9wU
check it here https://github.com/kornwaretm/korn-irrl ... -generator
Last edited by kornwaretm on Tue Jul 19, 2016 3:50 pm, edited 1 time in total.
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: another tree generator

Post by CuteAlien »

Nice, add more pictures! (yeah, could compile ... will maybe do later on, that kind of stuff interests me also a a lot).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Re: another tree generator

Post by kornwaretm »

tree has roots :D. infinite amount of tree types, possible to define as many as possible tree settings, infinite amount of texture variation, for now 8, i'm planning to make this user defined, each texture split to 8 horizontally. and the generator pick one using uv coordinate. this way each chunk drawn using only 2 materials.
Image

current project has 8 types of bark, and leaf texture. massive tree count good FPS.
Image

sorry for the lack of lighting.
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: another tree generator

Post by Cube_ »

that's pretty good looking, what algorithm (or family of algorithms) is it using?
"this is not the bottleneck you are looking for"
netpipe
Posts: 669
Joined: Fri Jun 06, 2008 12:50 pm
Location: Edmonton, Alberta, Canada
Contact:

Re: another tree generator

Post by netpipe »

looks great might use this in conjunction with klasgers trees for Luna engine. thanks
Live long and phosphor!
-- https://github.com/netpipe/Luna Game Engine Status 95%
netpipe
Posts: 669
Joined: Fri Jun 06, 2008 12:50 pm
Location: Edmonton, Alberta, Canada
Contact:

Re: another tree generator

Post by netpipe »

was wondering if you would make it able to generate a single tree for a iscenenode or a mesh to place with odd rotations and unique placement / also would make it more compatable with other terrains.
Live long and phosphor!
-- https://github.com/netpipe/Luna Game Engine Status 95%
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Re: another tree generator

Post by kornwaretm »

aaammmsterdddam wrote:that's pretty good looking, what algorithm (or family of algorithms) is it using?
thank you very much. probably.. people call it n system or so. actually i don't have sufficient math or coding skill to call it n-system. all i know it is recursive and take advantages over the pseudo random that irrlicht or c++ has. it is fascinating that we can have "constant" rand() result, so saving a tree growth state is as simple as storing 2 numbers, one for its age and one for its seed. the algorithm first developed for my 2d flash game called "the serum aftermath" , the 2d system has abillity to generate fast tree types. just in case of curiosity the game is here http://www.maxgames.com/play/the-serum-aftermath.html.
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Re: another tree generator

Post by kornwaretm »

tecan wrote:was wondering if you would make it able to generate a single tree for a iscenenode .....
yes in the future i will make it happen. my bad math skill are hitting huge wall right now :lol: . trying to generate tangent for the trees, for lighting. i can not promise any release soon, just tying to be productive in both producing and learning, perhaps next month.
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: another tree generator

Post by Cube_ »

oh, ok. well - no matter, it's neat and I'm probably going to use it for some rapid prototyping tests.
"this is not the bottleneck you are looking for"
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Re: another tree generator

Post by kornwaretm »

thank you guys. i have a big plan on these trees. volumetric ivy, cracks, leaves, etc are coming hopefully next release if i could, i'm working on my ray marching for richer geometry detail. probabbly not even close to a good article, but here's my progress https://kornwaretm.wordpress.com/2016/0 ... -geometry/.i got anti polygon syndrome :lol: .
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: another tree generator

Post by REDDemon »

Pretty cool. If I had time it is something I would like to try or even do myself.
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
trivtn
Posts: 132
Joined: Tue Jan 17, 2006 12:30 pm
Location: Viet Nam
Contact:

Re: another tree generator

Post by trivtn »

My simple tree generator !
Image
There's something is fantastic, there's nothing is absolute.
denzelbro
Posts: 50
Joined: Wed Jun 27, 2018 11:53 pm

Re: another tree generator

Post by denzelbro »

This is really nice and already tested it! Some thoughts and suggestions though if you are interested and willing to get some feedback. A simple LOD system would be nice as it really hits performance even when you got below 50 trees. The normal maps are also not working (dark branches) since the setting is some sort of directional lighting or outside environment which it seems the engine does not currently support.

still awesome work, so keep it up! :)
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: another tree generator

Post by Mel »

50 trees all together in the same mesh buffer, or 50 tree objects? if you pack them together, the load should alleviate a bit (also, store them on the video card...)
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
denzelbro
Posts: 50
Joined: Wed Jun 27, 2018 11:53 pm

Re: another tree generator

Post by denzelbro »

Mel wrote:50 trees all together in the same mesh buffer, or 50 tree objects?
Hey Mel, I just ran the demo that was included and actually it is setup with 100 (objects) and so I reduce it to 50.
Post Reply