Game Development Community

Problem with FXShapeReplicator in low terrain

by Mahmud Hasan · in Torque Game Engine Advanced · 02/14/2007 (3:52 am) · 10 replies

Hi I got a problem with the FxRepliCator in TSE. When I added a new FXRepliCator the Foliage don't show in the area it supposed to show. When I switch on the debug info for Foliage Replicator I found that the Clustering info is not showing all the area of the Replicator and it seemed that the height has something to do with the problem. The debug cluster is showing in the heigher terrain area rather then terrain area relatively low. I have added a screen shot of the problem here.


img204.imageshack.us/img204/6246/fxfoliagewn8.jpg
If I place the replicator in the lower portion of terrain, the cluster is not calculated and the grass don't show up.

Can anyone help me to fix this problem? Thanks in advance!

#1
02/24/2007 (12:30 am)
Are you using fxFoliageReplicator ? If not use it instead of fxReplicator. I work perfectly with TGEA.

If you don't have it, send me an e-mail : cafournier@hotmail.com
#2
02/25/2007 (9:09 pm)
Hi Claude,

Thanks for the reply. I am using fxFoliageReplicator. But I've identified the problem. The proble I faced was a simple bug or may be its not a bug, but the TGEA was meant to design only one water block in a mission.

I used two water block in different height. I have a water dam in my level and I used lower water block out side the water dam and heigher water block inside the dam. and that was the root of the problem.

By studying the fxFoliageReplicator code I understood that while populating the billboards, the code checks only the intersection level of terrain with the water block. then it identified the upper half as land and lower half as under water. In our case the code was taking the intersection of our heigher waterblock and treating the land under it as a underwater land. In our case which is wrong.

We have lots of land area under the water level of teh waterblock inside the dam. We observed that the foliage was restricted under the waterblock and if we enable the flag allowon water surface it was replicated correctly.

To resolve the problem we added and extra line of checking. We also checked the water bounds. I'll post the changes soon after I got some time to review it and see it is working perfect.

Thank you.
#3
02/26/2007 (12:08 am)
We came across a similar issue when rotating a water block, it would prevent the foliage replicator from working. I would be interested to see your fix for your problem.

addikt
#4
02/27/2007 (12:30 am)
The change is as follows:

at terrain\waterBlock.cpp

bool WaterBlock::castRay(const Point3F& start, const Point3F& end, RayInfo* info )
{
   // Simply look for the hit on the water plane
   // and ignore any future issues with waves, etc.
   const Point3F norm(0,0,1);
   PlaneF plane( Point3F(0,0,0), norm );

   F32 hit = plane.intersect( start, end );
   if ( hit < 0.0f || hit > 1.0f )
      return false;
   
   info->t = hit;
   info->object = this;
   info->point = start + ( ( end - start ) * hit );

   //Our changes: Checking for the waterblock bound

   if( (info->point.x > mWidth) || (info->point.y > mWidth) ||
	   (info->point.x < 0) || (info->point.y < 0)) 
	   return false;
   //End of changes	   
   ///////////////////////////////////////////////////////////

   info->normal = norm;

   return true;
}
#5
03/01/2007 (11:20 pm)
Good one, I will add this to my code as well, I currently have only water block but sure somebody will add another few ;)
#6
03/01/2007 (11:23 pm)
By the way, I did not realise this but your change is in water block and surely to me it's a Bug. So you should post this in the bug section.
#7
03/02/2007 (12:20 am)
This fix will actually break the foliage replicator if you insert it.
It will make the replicator to spawn below waterblocks even if it isn't allowed to spawn on or in water at all.
Tested it with a single 32k x 32k waterblock.
#8
03/02/2007 (12:57 am)
Hi Marc,

You are correct. after this fix the foliage replicator is avoiding the AllowinWater flag in some case. In my scenario the foliageReplicator is avoiding the top water level of my mission. But in case of lower water level it is doing fine.

I'll try to check all the scenario when I get time.

Thank you.
#9
03/02/2007 (1:58 am)
No problem.
Thank you for trying to track down the problem :-)
#10
03/04/2007 (8:52 pm)
We arent having much luck with waterblocks in general. We have a corner that sticks out and without the fixes the surface isnt drawn, but the player goes underwater, with the fixes the water surface is drawn, and the player goes underwater... We cant rotate waterblocks to suit, as the bounding box goes massive and hence the player goes underwater anywhere near it....

Obviously the easiest way to fix it is by modifying the terrain, but still, the waterblocks dont seem to want to be tamed ;)

addikt

img402.imageshack.us/img402/9875/swamp1mw9.th.jpg