Game Development Community

MultiAngled Foliage

by Dylan Sale · 09/20/2002 (9:45 am) · 9 comments

Download Code File

Basically what I did was made the billboards have multiple textures that are displayed at different viewing angles. This allows you to have say... a tree and see it differently from multiple angles, instead of it always looking the same, no matter from what angle you viewed it.

I haven't yet found out how to change the number of textures dynamically, so at the moment it is a constant in the .h file called MAX_NUM_SIDES. I know its a bit cryptic but I really only did this as an experiment.

Eg. If you wanted to have 6 views of the Billboard then you would put 6 into the MAX_NUM_SIDES constant, then recompile, then go back into the map editor and change add the extra textures. - I really have to fix this.

OH BTW the MAX_NUM_SIDES constant needs to be an even number.

THANKS TO MELV MAY, His code is truly a pleasure to work with.

HOW TO USE THIS

Read Melv's Drinkme.txt to find out how to set it up.

All thats changed in the editor is there is now fields for each of the textures.

BTW This will not work on maps that used the Foliage Replicator - you will have to reenter the textures. All the textures dimensions need to be powers of 2. ie 2, 4, 8, 16 pixels etc. However they dont need to be squares.

EDIT:
Oh and sorry if i have butchered your code Melv :)

Also I think that this combined with the fxShapeReplicator would be awesome. The 2D billboards could become 3d objects as they came closer. If anyone is not doing this I would like to give it a go.

#1
09/25/2002 (9:07 pm)
You know I was looking around on the web and saw a site with a demo for something close to what you were doing, only using it to represent volumetric clouds.

There would be textures of "slices" of the cloud either stored or rendered to texture on the fly, and then as the player got close, the billboard would continue to face the player and the textures would switch to give the illusion of the cloud's different sides. Also, this allows the player to "fly through" the cloud by the billboard being close to the camera and displaying the "slices" of the cloud as the player progressed.

Just a thought if you wanted to kick it up a notch =)
#2
09/26/2002 (9:34 pm)
Thanks. Do you know what the site was?
#3
09/27/2002 (8:27 am)
No, it was late night and I found it through following a billion links. But... I might be able to track it down possibly, I'll let you know if I come across it. That kind of functionality would be really awesome to have!
#4
09/27/2002 (7:29 pm)
If you do, just email it to me. I'll look for it as well. Thanks.
#5
09/30/2002 (3:23 am)
Maybe you mean SkyWorks?

http://www.cs.unc.edu/~harrism/SkyWorks/
#6
10/01/2002 (5:22 am)
Yeah Ted sent me an email with that one in it. Thanks for the help though.
#7
01/26/2005 (7:09 pm)
So has anything ever come of this resource? The real-time cloud rendering done at the Skyworks looks great. It'd be cool if someone did something like that in Torque. I would if I could.
#8
05/25/2006 (10:45 pm)
Well this was my first code snipet I compiled into my engine (head 1.4) and its amazing. The best use for this is to do a 3d render of grass in max ahead of time and create a rotation around that object. After that you can make your simple 2d grass appear 3d as if it were modeled for real.

This is a huge help in my project to creat realism. Note that head 1.4 already has the replicator implemented so all you need to do is follow the instructions but ignore the declare strings when they are already declared (I never programed before so this was my first lesson in redundancy). Now Im off to figure out how to restrict foliadge to a specific texture painted on the turrain, I know there is code to restrict the player to a single texture on the map so it seems that foliadge grass could be restricted to my grass texture on the turrain block.
#9
07/26/2006 (12:26 am)
Does anyone know where I can find of a good texture file for "grassy" Foliage?