Game Development Community

dev|Pro Game Development Curriculum

sgTree L-system Tree generator object

by Adam "OnO" Strzelecki · 04/07/2003 (1:21 pm) · 20 comments

Download Code File

Generating trees and plants is one of the hardest game developer problems.. as plants are quite complex objects. L-systems have been used for plant generation for many years and now you can use their power (and simplicity) to build beautiful trees and forests in your Torque realtime game.

This sources add sgTree object to you Torque distribution. Refer readme.txt and oak.tls, pine.tls for guide and examples.

You should read some L-system introduction before you play with that files.

Online L-system introduction:
http://life.csu.edu.au/complex/tutorials/tutorial2.html
http://www-sfb288.math.tu-berlin.de/vgp/javaview/vgp/tutor/lsystem/PaLSystem.html

Literature:
"The Algorithmic Beauty of Plants" by Przemyslaw Prusinkiewicz & Aristid Lindenmayer, Springer & Verlag, New York, 1990.

Note: This files are part of my thesis.. this files are provided "as is" without a mature documentation. Probably there won't be any updates are copyrights of rest code will be gained by university.

About the author

Recent Blogs


#1
04/04/2003 (10:56 am)
Screenshots and sample builds of sgTree available on:
http://www.signs.ig3.net/
#2
04/07/2003 (2:08 pm)
very sweet.

viva la poland!
#3
04/07/2003 (3:16 pm)
What kind of framerates are you getting? Have you compared say 1000 of your trees against 1000 modeled trees?
Your todo list in the readme states LOD will be forthcoming, which is probably needed, yet you state here you will most likely not be updating this. Is LOD still in your plans?
Otherwise, great resource! Code snippits like these are what make Torque the greatest engine available.
#4
04/07/2003 (4:28 pm)
> Is LOD still in your plans?
Yep, it's still in my plans.. but I can't tell you when I do that and if I release it here. There are several different aproaches to LOD with L-systems. I can use less triangles when building branches from triangle strips, and of course use different productions for every LOD in L-system gramma.
So I want to make a LOD plus distant clipping (or NULL LOD model for far distances).

> What kind of framerates are you getting?
I was mesuring frame rates for non L-system stuff I've writen previously.. but the method of rendering was the same.. and i got 20-35 fps with about 150 trees on screen. So with 1000 on screen it could be horrible. You have to make some feaker-wicked code to fool gamer eye that he sees 1000 trees..
I'm still very impressed with tree display optimization which were built in Operation Flashpoint game.. actualy its engine never rendered 1000, it was always like showing nearest trees.. and all the rest was rendered to look like deep forest/to look good.. you could this method failures when flying helicopter - seeing tree squares with nothing inside when above forest.

> Have you compared say 1000 of your trees against 1000 modeled trees?
No i didn't. But I want to point that it should be comparable because during rendering it actualy acts as static tree model, only difference is that it's not loaded from model file... but pre-built from L-system gramma and parameters.. which makes every tree looks different (using different seed of coz).
Well except flustrum clipping there is no actual optimizations about rendering.. no layering, octree stuff or anything. I'm trying to render it as fast as possible with vertex arrays... but the problem is I'm switching textures for every tree. What my aim is to make global one pass rendering function for all trees which should be much more quick and consume less memory than rendering every tree separately, but it would be quite not easy to build it in Torque.

> Otherwise, great resource! Code snippits like these are what make Torque the greatest engine available.
Actually it doesn't seem to be hard for me. But everything seems to be easy when you know that already. Anyway I'm happy you find it useful, Thanks.
#5
04/07/2003 (5:33 pm)
This should be put into HEAD cvs ASAP!! Great work dude, I doubt anyone else here could have done it.
#6
04/07/2003 (5:34 pm)
I remember trying this alpha version a long time ago and im curious if collision has been implemented since then ?

Great work though. Never knew such great looking trees could be generated on the fly :)

Keep it up
#7
04/07/2003 (6:07 pm)
I'm not familiar with OpFlash, but I think it's similiar to GhostRecon. Yes, they had an awesome lod system.
For your trees, I think 2 levels of less foilage, and 1 level of billboard should suffice. Melv mentioned switching out his fxitems with billboards, but I don't think he's gotten to it yet.
#8
04/08/2003 (11:14 am)
Yeah i agree with hobbiticus this works great with melv's resources, and should probably be committed to HEAD. But i think it should have LOD first. despite the slight impact on framerate this is an excellent resource which i cant see hurting any game in anyway by its inclusion into the tge source! Thanks for the resource!
#9
04/11/2003 (3:27 am)
Great stuff! :D
One question though... could you possibly provide some textures so that everyone can test this? I searched for usable textures on google, but couldnt find anything useful... and I'm not really an artist... :P would be great!! :D
#10
04/16/2003 (2:52 pm)
Thanks for releasing this, trees look awesome.
#11
04/19/2003 (4:36 pm)
Hi!
I am having some strange results... Could you give any details on how to create textures usable with this? (ie: size/format/colors etc)
I am no artist either, and I obtain a set of branches on cut trunk while trying the pine =/

Cheers,

Isi
#12
04/29/2003 (4:17 pm)
Sorry I don't get anything...please tell me more about brach texture..can you give an example ?
#13
04/30/2003 (3:53 am)
Is it possible to use this in commercial projects ?
#14
06/21/2003 (10:17 am)
What about collision on threes ?
It's important.
#15
07/14/2003 (7:12 am)
mmm i was wondering about the gpl thing in the readme file... doesn't it make the whole resource (which would be very cool otherwise) useless? shouldn't it be lgpl?
#16
07/30/2003 (5:55 pm)
"ARPG/environment/atgeDayNight.h"

Where does this header come from? Some day/night thing I assume, but I've looked through all the resources adn cant find where this comes from...


Thanks,

-s
#17
07/31/2003 (1:25 am)
I think it comes from Joshua Ritter's day night resource, but it doesn't seem to be available in the resources section anymore.

On the other hand, maybe you can find it here:
www.actionrpg.com/twiki/bin/view.cgi/Main/TorqueDayNight

there is an improved version of this, though
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4050

* edited, wrong urls
#18
09/03/2003 (4:07 pm)
Has anybody tried it in dedicated server mode? I don't know why, but it runs fine when i join a server or load a mission from the normal startmission gui... but when i try and run a dedicated server it stops when it should load sgTree objects.
This doesn't make much sense to me... any hints?

EDIT: ok, it looks like it works now. If you need it, change the line which reads:
rebuild();
in function sgTree::onAdd , to:
if (isClientObject()) rebuild();

Can anybody answer my gpl / lgpl question please? is this resource usable?
#19
12/12/2004 (11:47 am)
To remove the need for TGEDayNight. copmment out the included file in SgTree.cpp, and then an error will appear something like "Undefined (bla bla bla) tgneDayNight", find anything that says tgnedaynight and comment it out. This is just a quick hack to get ti to compile, and work kinda.
#20
06/19/2007 (6:44 am)
Does anyone respond to this anymore?? I got a copy of the book in .pdf format and I am enjoying the hell out of it. This is the kind of math that is used in the 64k contest. Yea it's still around.
www.maa.org/editorial/mathgames/mathgames_08_16_04.html
Download a complete 5 level fps that runs in 64K or less. This is the first time I have been able to find anyone using the math.
Hey Adam "OnO" Strzelecki where are you. We need to update this for the new LightManager which is the only obstacle to making this happen in TGE 1.5.2