Game Development Community

FxFoliageReplicator position calculation - how to override?

by Tim Holt · in Torque Game Engine Advanced · 05/01/2006 (2:29 pm) · 7 replies

For starters, I'm new to the realm of TSE and want to make sure I'm on the right track with something. I want to rewrite the position calculation methods for the fxFoliageReplicator to a new calculation method. What I wanted to ask/get clear on is this: is the code in fxFoliageReplicator::CreateFoliage only run on the SERVER and then all foliage positions communicated to the clients? Or are the positions calculated on both client and server.

The reason I'm asking is because I'd like to specify precise positions based on a database query at start of a level rather than randomly. I would be replacing this code loop...

// Find it a home ...
do
{
    // Get the fxFoliageReplicator Position.
    FoliagePosition = getPosition();

    // Calculate a random offset
    HypX	= RandomGen.randF((F32) mFieldData.mInnerRadiusX, (F32) mFieldData.mOuterRadiusX);
    HypY	= RandomGen.randF((F32) mFieldData.mInnerRadiusY, (F32) mFieldData.mOuterRadiusY);
    Angle	= RandomGen.randF(0, (F32) M_2PI);

    // Calcualte the new position.
    FoliagePosition.x += HypX * mCos(Angle);
    FoliagePosition.y += HypY * mSin(Angle);

with my own lookup calculation method.

I'd like to have the database access occur only on the server side of things (database hosted on same machine as game server) rather than have the clients all query the database.

So have I got the right idea here? Calculation is only server side?

#1
05/01/2006 (2:44 pm)
No...the big advantage of any replicator is the fact that it does not use the networking to transmit information about each individual object.

For what you want to accomplish, you'll need to have the database information on the client side as well (possibly feasible unless it's a dynamic database), or come up with an alternate solution.
#2
05/01/2006 (2:49 pm)
Gotcha ok, that makes sense.

What I had contemplated was a tightly formatted binary or ascii data file for each replicator that would contain the X/Y coordinates. The hybrid replicator would be pointed at that file for processing. It could even be accessed via http protocol I suppose, which would enable server-side updates of the data.

The application is a "serious games" project creating a large scale visualization of real forest data so it's got to be realistic in terms of placement. I've got data giving vegetation composition on a 30 meter grid over most of Washington, Oregon and Northern California. I don't need to override the coordinates of each tree, but I do need to specify "in this 30 meter bin, randomize just these types of plants". It would be the equivalent of having probably 100's of thousands of replicators in the mission file.
#3
05/01/2006 (2:55 pm)
There are a couple of different options, but the first two should work fine--you'd just want that data on both the client and the server, and have a determinsitic way of replicating the state on both sides.
#4
05/03/2006 (12:30 pm)
You probably want to do something like this : 1 fxShapeReplicator for very Huge Terrain With eventually animated shapes. And with every shape placed at a fixed position.

I have a solution for this (here is a screenshot)
www.solu-si.com/dragonhead/htc/dave.jpgIf you want more info, contact me by mail.
#5
05/03/2006 (1:19 pm)
First pass at a "clustering" system...

It uses a new item similar to the fxFoliageReplicator, which reads an external file that contains X, Y, offset and tree count data. I'm calling it a fxGNNFoliageReplicator for this project (which is named "GNN").

So for example the following input file...
-100.0 100.0 10
100.0 100.0 20
100.0 -100.0 30
-100.0 -100.0 100

...creates the following results from a single fxGNNFoliageReplicator. Note the 4 clumps with 10, 20, 30 and 100 plants respectively...

www.fsl.orst.edu/lemma/gnnviz/images/cluster_test_1.png
PS

Ignore that ground terrain :^)
#6
05/03/2006 (1:48 pm)
So, If I understand, you don't store each Tree/plant position. You store only position for groups of plants. This way may give you a different state on each running.
If my understanding of your technic is good. You may have difficulties with ShapeReplication (Positionning on already created shapes and so on). And also with Foliage/Shape transition. This last point is the main difficultie (In my opinion).
*Edit : For animated shapes you can check here : www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=10390
(Sorry for my poor english I'm a frenchy guy)
#7
05/03/2006 (9:56 pm)
> So, If I understand, you don't store each Tree/plant position. You store only position for
> groups of plants. This way may give you a different state on each running.

Correct. I am working from a database that maps estimated vegetation across a large area of the western US on a 30 meter grid. For each grid point, I have a list of estimated plant species present (specifically trees) and their sizes (height in meters, estimated age, amount of tree that is foliage and the amount that is just tree trunk). Statistically, I know there are an esimated 100 Douglas Fir trees in a given cell for example, but I have no data on each tree's specific coordinates.

So essentially what I have is the data to create an individual fxFoliageReplicator, one every 30 meters on my map. But obviously this would be a large number of replicators - perhaps 200 to 300 thousand separate replicators over a 10 by 10 kilometer area, and each replicator wanting to place anywhere from a handful of trees to 500 trees. The bottom line is, this is a LOT of trees!

So for right now I am working on a new type of replicator that reads actual tree distribution from a text file, rather than randomly generate their locations.

> If my understanding of your technic is good. You may have difficulties with ShapeReplication
> (Positionning on already created shapes and so on). And also with Foliage/Shape transition. \
> This last point is the main difficultie (In my opinion).
> *Edit : For animated shapes you can check here :
> www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=1039...

For right now, I am pretty happy to just use the billboard style trees available via the foliage replicator. But ultimately yes I would like to use something like you have created.

It may be that with the release of the Forest Pack, many of the issues I am wondering about will not be a problem.

> (Sorry for my poor english I'm a frenchy guy)
Hey well your english is far better than my French, so don't be sorry! :^)