views:

1743

answers:

9

I know how to draw basic objects using JOGL or LWJGL to connect to OpenGL. What I would like is something that can generate some kind of geometry for trees, similar to what SpeedTree is famous for. Obviously I don't expect the same quality as SpeedTree.

I want the trees to not look repetitive. Speed is not a concern, I do not expect to need more than 100 trees on screen at one time.

Are there free tree-drawing libraries available in Java? Or sample code or demos? Is there anything in other languages which I could port or learn from?

+2  A: 

There are thousands of methods. A better question would define 'best' in a more confined way. Are we talking 'best' as in speed of drawing (suitable for thousands or millions of trees)? Best as in best-looking? etc.

workmad3
+2  A: 

2D or 3D?
In 2D, a common way is to use L-systems.
I also tried an OO approach, defining objects for trunk, branches, leaves, all extending an abstract class and implementing a Genotype interface (to vary the kind of trees).
Not sure if it is efficient (lot of objects created, particularly if I animate the tree) but interesting to do.

PhiLho
A: 

If you are using eclipse/SWT, try Draw 2D.

questzen
A: 

If you're serious about getting good-looking, fast trees, there's a commercial C++ library SpeedTree. Lots of big-time games use it (e.g., GTA, Elder Scrolls).

Jesse Beder
SpeedTree is amazing, but I am planning some software that will be free and open source (probably GPL licensed) and so I need to either find a free solution or make my own.
Liam
A: 

A combination of OpenSceneGraph and SpeedTree has worked for me.

Aidos
A: 

I know of two libraries that enable the usage of OpenGl with java.

LWJGL (Light Weight Java Gaming Library), which imo is the better one due to its simplicity and its similarity to using opengl with c/c++.

JOGL If you want to mix swing components with opengl this may be the better choice, I've never used it but several years ago it was known to be pretty buggy, I don't know if its matured since then.

As for drawing trees, there are many ways to do so like the other poster said, you might want to be more specific.

edit: I guess I misunderstood the question a bit, oh well : / You can load in a 3d model of a tree and display that.

argonide
A: 

http://www.codeplex.com/LTrees has some source code on that. it's c++ though.

mdm
+1  A: 

Here are a couple resources that may be helpful:

  • gamedev thread on the subject - contains some useful advice/suggestions
  • ngPlant - an open-source procedural plant generation tool. It is not written in Java, but you may be able to find ideas in its algorithms.
thekidder
+4  A: 

http://arbaro.sourceforge.net/

http://www.propro.ru/go/Wshop/povtree/povtree.html

Non java: http://www.aust-manufaktur.de/austt.html

Boune
Wow these look promising, thanks.
Liam
I don't see the javadoc for arbaro but you can always get the source and generate it yourself. Good luck.
Boune