View Full Version : How to draw trees on a 3d landscape?
03-11-2001, 05:26 AM
What kind of trees should i use? some models are 4mb big. How can i use an obj file? can i just draw the obj file at x y z? if i use display lists will i still be able to use these 4mb trees and still have good prformance? are there any tricks that i can use to give the impression of a really life like tree without 2 million polygons???
Any suggestions to any of these questions will be most welcome.
03-11-2001, 11:16 AM
You can use a tecnique that is called billboarding (I suppose...). It consists on using two (or more, why not?) perpendicular quads texture mapped with the image of a 2d tree... If you want to add realism you can draw something like a cylinder for the wood...
In this way you can get very good results and draw a lot of trees without loosing in performance.
However the nearest the tree you go, the more visible will be the trick!
03-12-2001, 07:32 AM
Your solutions seems fine but i am having a problem making the background on the bitmap of the tree transparent so that you only see a tree and whatever is behind it well not directly behind but on the left and right of it. Also in my drawing i can see the left and right and top, bottom of the quad, is this because they are transparent.
03-12-2001, 08:14 AM
You will need to do an alpha test nad convert the tree texture to a rgba format. You then cycle through the texture and allocate a 1.0 for the alpha except where you want it to be transparent ( i.e by looking at the pixel colour, if it is your background colour say black or pink then set the alpha to 0.0.) This way you have a texture which is opaque where you want it to be and transparent at the background ( you could load a .tga file or such like which contains an alpha channel). Then you use the alpha test and draw only what is greater than 0.05(or so) and there you have it.
billboarded trees look horrible.
ive made a couple of lowpolygon trees (100-150 tris) that im willing to post on my site.
03-12-2001, 12:20 PM
Sure, billboarded trees will never be like poly trees but the choice depends on how many trees you have to draw...
To do the transparency you can use a standard bmp with one color dedicated to transparency. After loading you can cycle through the pixels and change the color to (0.0,0.0,0.0,0.0).
I never did this, but I'm sure that can be done!
03-13-2001, 06:59 AM
Thank you all very much for your help i have my quad tree drawn perfectly, i think i will stick to the quad and not polygons as my intention is to draw a tree every where the user clicks with the mouse. which brings me to my question. How do i draw a tree every place i click. i am using gluUnproject to capture and convert mouse points but my tree seems to drawn in the same place every time and disappears every second click of the mouse. My drawing code is below. does anyone see my problem?
gluLookAt (0.0, 0.0, -5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glTranslatef(mousex, mousey, mousez);
03-13-2001, 07:09 AM
let me make a correction-- the tree gets drawn at its possition then when mouse button is clicked it comes right up to the camera/viewpoint then back to its original position when mouse clicked again.
PS: I am using nehes tutorials
03-14-2001, 01:47 AM
some models are 4mb big.
Well, this seems big for a single tree. I Think we still don't have 3d cards for that ;)
Why don't to try smaller meshes ? A 1500 tris tree can be cool i think... Level Of Detail meshes can help you to display more trees too.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.