Game Development Community

Foliage Replicator...

by Melv May · 08/09/2002 (3:45 pm) · 74 comments

Download Code File

Using this object you can provide total coverage of your maps or target areas that need foliage embedding.

It provides you with the ability to create hundreds of thousands of foliage items over a controlled area. You can also control whether items are placed on terrain, interiors, statics or water. You can also control the terrain slope limit so that you don't get foliage stuck on steep angles of terrain which can look weird.

You can setup random sizes of foliage plus have the ability to fix the aspect ratio where you don't want your textures distorted but still have different sizes within the scene.

A neat feature is the ability to setup random swaying to simulate wind effects. There is also a lighting feature that changes the luminance of the foliage over time to simulate lighting changes in the scene.

On the performance side of things you can set the distance at which foliage appears. If you don't want the foliage just appearing/disappearing then there is the ability to control that too so items gradually fade in/out of view.

I have also added a very efficient culling algorithm that literally removes the processing of objects that are not within the view.

As always, I have hosted the code on my FTP site plus some images that are too large to host on the GG site. You will find instructions within the zip file but you should have no problem if you have previous used my fxShapeReplicator object as the installation is almost identical.

I would recommend that you download the Foliage Sample Images kindly provided by Doyoon Kim.

Here is my plan which contains some interesting links around the site on this subject.

Also, a new improvement is built into the code.

Foliage Source Code

------------------------------------------

Next up is experimentation with meshes rather than billboards (after I've done some more work on the water engine). Ryan Armstrong is kindly donating some of his teams valuable time to produce me various foliage meshes to experiment with. Thanks to you and your team Ryan. 8)

Expect a mesh variation plus updates to this object as I add more features and finally do some more optimisation on it.

I hope you find this useful, I enjoyed making it. 8)


[EDIT] 10/08/2002
Fixed a minor problem. When you allowed the placement of objects onto water they were previously *always* placed onto the surface which was poor. I have now added a field which allows you to control whether they are placed on the surface or the underlying terrain called 'AllowWaterSurface'.

[EDIT] 10/08/2002
Added a field 'GroundAlpha' which allows you to control the ground-level alpha. This gives you the ability to reduce the harsh edge you get where the billboard intersects the terrain.

[EDIT] 19/08/2002
Billboards now only rotate around the Z-Axis e.g. they *don't* lie-down when viewing from above.

[EDIT] 19/08/2002
Fixed problem with foliage disappearing at certain places when inside the object-box looking out.

[EDIT] 19/08/2002
Added a new field 'RandomFlip' which randomly flips the billboards horizontally to decrease the similarity between billboards. The is obviously only effective on a non-horizontally symetric texture.

[EDIT] 19/08/2002
Changed type for field 'OffsetZ'. Now floating point to allow for more control when offseting vertically.

[EDIT] 21/08/2002
Completely rewrote major chunks of the code and installed a sophisticated culling algorithm to allow you to control *massive* quantities of foliage.

[EDIT] 22/08/2002
The debug boxes were not positioned correctly. They now appear exactly on the quad-tree boundaries. This wouldn't of affected the billboards at all.

[EDIT] 23/08/2002
Fixed minor problem with visualisation of DebugInfo quad-tree boxes. The Z bounds are now clipped to the lowest/highest place foliage item.

[EDIT] 25/08/2002
Added a new field 'DebugBoxHeight' that allows you to control the height of the displayed quad-tree box for debugging purposes. Enter a value between 0-1 which equates to the min/max heights of the quad-tree boxes.

[EDIT] 12/09/2002
Modified the billboards to be world-aligned. Billboards now lean over when viewing from above.

[EDIT] 13/09/2002
Commented-out the addGroup/endGroup as default for people who are not running the [HEAD]. Thanks Eric.

[EDIT] 26/08/2002
Added requested function by Daniel Neilsen. Can now add "$pref::Foliage::replicationRatio = 1.0;" variable in "fps\client\prefs.cs" or your own client prefs mod file. This is a multiplier that controls the quantity of foliage. e.g. Using 0.5 means that you get half the number of originally specified foliage items. Use this to scale the foliage rendering at runtime against system power.

[EDIT] 1/2/2003
Moved hosting Web-site.

- Melv.
Page «Previous 1 2 3 4 Last »
#1
08/09/2002 (4:19 pm)
Niiiccee ... melv strikes again :D
#2
08/09/2002 (4:27 pm)
Ya, very nice done! This is really awesome! But i found one mistake (not really one) :) Every link has the source, no sample images.
#3
08/10/2002 (2:31 am)
Christian,

Sorry about that. I seperated the images from the code as I keep making updates and I didn't want to force people to download them again and again.

Fixed Now. ;)

- Melv.
#4
08/10/2002 (2:33 am)
There is also a minor problem. If you specify that the objects can be placed on water then they actually get placed on the surface of the water rather than the 'seabed'.

I will fix that shortly. This minor problem also applies to the fxShapeReplicator as well.

I'm on it. 8)

- Melv.
#5
08/10/2002 (5:17 am)
where exatly do you put the .cc and .h files provided?
your tut just says:
Add both source files to the Torque engine VC project. 'fxFoliageReplicator.cc' and 'fxFoliageReplicator.h'.

I put them in engine/console and get this error which leads to a ton of errors even on a clean build.

F:\torque\engine\console\simBase.cc(33) : error C2086: 'gfxFoliageSet' : redefinition
#6
08/10/2002 (6:37 am)
Ace,

It really doesn't matter where you place the files although I always place them in my own directory off the engine directory, something like "\torque\engine\melv" and then add them from there.

The error you are getting is nothing to do with the placement of the code files. Also, my instructions do not specify you use "gfxFoliageSet", it should be "fxFoliageSet".

- Put this in "/engine/console/simBase.h" (around line 509) somewhere in the 'nameSpace Sim' block (put it as the last xxxxSet entry)

DeclareNamedSet(fxFoliageSet)

- Put this in /engine/console/simBase.cc (around line 19) somewhere in the 'nameSpace Sim' block (put it as the last xxxxSet entry)

ImplementNamedSet(fxFoliageSet)

- Put this in /engine/console/simManager.cc [function void init()] (around line 269) (put it as the last xxxSet entry)

InstantiateNamedSet(fxFoliageSet);


Note that the first two do *not* have semi-colons after them and the last one *does*.

--------------------------------------------

If you still have problems then send me the following files and I will gladly amend them for you.

/engine/console/SimBase.cc
/engine/console/SimBase.h
/engine/console/SimManager.cc
/example/common/editor/EditorGui.cs
/example/common/editor/ObjectBuilderGui.gui

--------------------------------------------

Let me know how you get on, I would like to help. 8)

- Melv.
#7
08/10/2002 (6:55 am)
Okay,

I fixed a minor problem. When you allowed the placement of objects onto water they were previously *always* placed onto the surface which was poor. I have now added a field which allows you to control whether they are placed on the surface or the underlying terrain called 'AllowWaterSurface'.

This change has also been made to the fxShapeReplicator and all files both on GG and my FTP have been updated.

I've also added a field 'GroundAlpha' which allows you to control the ground-level alpha. This gives you the ability to reduce the harsh edge you get where the billboard intersects the terrain.


- Melv.
#8
08/10/2002 (8:59 am)
hmmm, weird, you are right, and i just did a search of the entire torque for gfxFoliageSet and it says it can findliteral string gfxFoliageSet

im using 112 with unedited engine , ill try another clean
#9
08/10/2002 (9:04 am)
Ace,

I wasn't thinking straight. The 'g' is prefixed by the 'set' macros and is not a typo by you, sorry.

If you send me the files I mentioned about I will at least have a look for you.

I can assure you I do have a SDK license. ;)

- Melv.
#10
08/10/2002 (9:17 am)
Looks great, Melv!

Since Paintball Net is going to be primarily an outdoor game, I'm always interested in ways to make outdoor environments look better. You've come through several times now...fxReplicator, fxFoliageReplicator. And I'm looking forward to the final version of the fluid rendering too.

Good stuff!

-David
Samu Games
#11
08/10/2002 (9:22 am)
ok i sent them, after another clean build it went down to only the one error,hey now i have to find out why textpad couldnt find gfxFoliageSet , Thanks
#12
08/10/2002 (9:35 am)
@Dave: No problem David. It's on it's way I assure you. ;)

@Ace: I have sent you the amended files. Below are the amendments I have made.

EditorGui.cs - The amendment to this file should really be put alongside the other similar entries on line 1145.

Simbase.h - You had entered 'ImplementNamedSet'. The instructions say 'DeclareNamedSet'.

I've sent you the amended files back. Would you give them a try and let me know how you get on.

- Hope this helps. 8)

- Melv.
#13
08/10/2002 (10:01 am)
Thats what i get for getting up at 4am (i was siked with all your awesome screenshots) and it dont suprise me the error is mine, seems i always have trouble adding new stuff, i just dont understand the language well enough yet.

thank you very much for the speedy help it compiled now, Now to go test it out :)
Thanks a gain
#14
08/10/2002 (10:03 am)
No problem Ace,

I should of done a CVS Patch for Release_1_1_2 really so that people don't have to mess with the engine.

- Melv.
#15
08/10/2002 (10:50 am)
oh duh , i can be so dumb at times i think i got it


I did get it :)Awesome!
#16
08/10/2002 (11:13 am)
Nice one Ace. 8)

- Melv.
#17
08/10/2002 (9:20 pm)
Wow i been playing with this alot today
www.planetquake.com/noescape/dev2/fire.jpg

do you think it will be hard to make the foliage (in this case fire) do damage when you get to close, just curious. I will be playing with this alot

Brilliant! :)
#18
08/11/2002 (3:09 am)
Ace,

That's an interesting way of using it!

It wouldn't be difficult to do but I won't be putting it in the fxFoliageReplicator becuase it doesn't really fit into it's design.

I guess what you could really do with is animated/procedural textures for your fire here?

Nice work. ;)

- Melv.
#19
08/11/2002 (7:11 am)
heh, thanks, your ligting stuff gives the fire a nice lil flicker as it is , and the sway added gives it a cool effect also, I think i will look into triggers with a radius damage. (just another thought). I have always been a decent modifier, im just slow when it comes to new stuff.

[edit] this should be cool for poison marshes also [/edit]
#20
08/11/2002 (7:16 am)
Ace,

You might want to download the latest one as it's got a few new features you might be interested in.

The 'GroundAlpha' field allows you to blend the billboards into a surface better so you can remove that harsh edge when it intersects the lava/terrain etc.

Just a thought. ;)

- Melv.
Page «Previous 1 2 3 4 Last »