Clustering in the Foliage and Shape Replicators
by Jeff Loveless · 01/05/2007 (2:03 pm) · 11 comments
Download Code File
This resource adds a clustering effect to the foliage and shape replicators (originally written by Melv May and now part of the TGE code). This allows for plants and shapes to be arranged in clusters when they are placed randomly. For the foliage replicator, it allows for a more "patchy" look for foliage like for wild plant growth. I also threw the effect into the shape replicator just for kicks (could be used for tree clustering, e.g.)!
Each replicator has gained five new fields in the editor UI:
- UseClustering - flag for toggling the use of clusters
- CountPerCluster - count per cluster of each item
- ClusCountVariation - variation (plus or minus) in the count per cluster
- ClusterRadius - radius of a typical cluster
- ClusRadVariation - variation in the radius of a cluster
Also, to help the effect look more natural, each foliage replicator can now use multiple plant textures, and each shape replicator can now use multiple shape files. The number that each one can handle has been set to four, but this can be set to a different number by changing appropriate constants (NUM_TEXTURE_FILES for the foliage replicator and NUM_SHAPE_FILES for the shape replicator).
To install, just copy fxFoliageReplicator.h, fxFoliageReplicator.cc, fxShapeReplicator.h, and fxShapeReplicator.cc over the files in the engine\game\fx\ directory (or use a merging tool to move the changes in).
Enjoy!
Possible Improvements:
- The number of clusters placed could be specified directly instead of having it sort of divided out of the number of objects placed. It is possible to have the last cluster be really small because of leftovers.
- If you use the shape replicator to make trees with clustering, you may experience the trees stacking on each other. This is a result of how the shape replicator places its objects. Further work could be done to optionally shut this behavior off.
This resource adds a clustering effect to the foliage and shape replicators (originally written by Melv May and now part of the TGE code). This allows for plants and shapes to be arranged in clusters when they are placed randomly. For the foliage replicator, it allows for a more "patchy" look for foliage like for wild plant growth. I also threw the effect into the shape replicator just for kicks (could be used for tree clustering, e.g.)!
Each replicator has gained five new fields in the editor UI:
- UseClustering - flag for toggling the use of clusters
- CountPerCluster - count per cluster of each item
- ClusCountVariation - variation (plus or minus) in the count per cluster
- ClusterRadius - radius of a typical cluster
- ClusRadVariation - variation in the radius of a cluster
Also, to help the effect look more natural, each foliage replicator can now use multiple plant textures, and each shape replicator can now use multiple shape files. The number that each one can handle has been set to four, but this can be set to a different number by changing appropriate constants (NUM_TEXTURE_FILES for the foliage replicator and NUM_SHAPE_FILES for the shape replicator).
To install, just copy fxFoliageReplicator.h, fxFoliageReplicator.cc, fxShapeReplicator.h, and fxShapeReplicator.cc over the files in the engine\game\fx\ directory (or use a merging tool to move the changes in).
Enjoy!
Possible Improvements:
- The number of clusters placed could be specified directly instead of having it sort of divided out of the number of objects placed. It is possible to have the last cluster be really small because of leftovers.
- If you use the shape replicator to make trees with clustering, you may experience the trees stacking on each other. This is a result of how the shape replicator places its objects. Further work could be done to optionally shut this behavior off.
#2
01/05/2007 (3:48 pm)
that's really nice addition!
#3
01/05/2007 (4:24 pm)
Awesome resource
#4
01/05/2007 (10:16 pm)
Thanks guys, Happy to share with the community. :) I found myself thinking that TGE's (and TGEA's? ...untested) foliage replicator could look as nice as the foliage in say.. Oblivion, with a little sprucing up. Whether this achieves this goal largely depends on your opinion and your ability to make good foliage textures. However I can say that it lets you give your maps a more organic covering of foliage while only have to place one replicator rather than many. Works in TGE 1.42 and 1.5
#5
01/06/2007 (7:26 am)
this is vry gd thanks
#6
01/08/2007 (6:08 pm)
This looks very good!
#7
01/16/2007 (5:32 pm)
We tried to get this up an runing in TSE (TGEA) without much luck yet, we havent given up on it though :) If anyone beats me to it post the patch file.
#8
J.C.Smith has gotten this working in TGEA if you own a liscence to TGEA and want to include these changes visit that link above, it seems as well as getting it up and going in TGEA he's changed the method of having multiple textures and added some shader functionality to it.
BTW: If anyone wants more, or less than 4 possible types of foliage/shapes per replicator you can just change the constant that defines it in the code.
01/29/2007 (2:10 pm)
http://www.garagegames.com/mg/forums/result.thread.php?qt=56798 J.C.Smith has gotten this working in TGEA if you own a liscence to TGEA and want to include these changes visit that link above, it seems as well as getting it up and going in TGEA he's changed the method of having multiple textures and added some shader functionality to it.
BTW: If anyone wants more, or less than 4 possible types of foliage/shapes per replicator you can just change the constant that defines it in the code.
#9
02/15/2007 (2:59 pm)
Definitely a valuable resource. thank you very much for sharing.
#10
03/09/2007 (2:32 pm)
Great resource. Big thanks for sharing!
#11
03/27/2008 (4:23 am)
Really good idea - thanks! 
Torque 3D Owner Todd Pickens
I will have to give this a try.