fxShapeReplicator Update
by James Laker (BurNinG) · 07/03/2006 (11:33 am) · 9 comments
Download Code File
Working on my little 2D space game I required some asteroids being placed on a plane (not an aeroplane :-P) beneath my fighters and then again between the camera and the fighter to give it a nice 3D effect.
However, the fxShapeReplicator didn't support the extra axis... The fxShapeReplicator as is, places a shape in a random area on something. By that I mean the shape will be on the terrain, another shape, diff, water, etc.
This update allows you to place objects in space with the added field (AllowInSpace). This could probably be called air, but I don't see any other use for it than in a Space Sim with asteroids.
To install this update do the following:
1) Backup your old fxShapeReplicator (engine\game\fx\fxShapeReplicator.h/.cc)
2) Copy the fxShapeReplicator.h and the fxShapeReplicator.cc in the ZIP file into the directory.
3) Recompile
To use:
1) Place the Shape like you normally would've (In World Editor/Creator).
2) Select the AllowInSpace to allow it to be in the air/space.
3) Add the UpperZ and LowerZ values (UpperZ is the highest value something can be in air, LowerZ the Lowerst)
4) Click Apply
Note: When the AllowOnTerrain is used with the AllowInSpace it will place the object on or above the terrain. Without the AllowOnTerrain it can be under the terrain and even sticking half way through
So if you have a terrain, I recommend using the AllowonTerrain setting too.
This was updated and tested on TGE1.4
Credit go to Melv off course for creating the original.
Screeny:

Working on my little 2D space game I required some asteroids being placed on a plane (not an aeroplane :-P) beneath my fighters and then again between the camera and the fighter to give it a nice 3D effect.
However, the fxShapeReplicator didn't support the extra axis... The fxShapeReplicator as is, places a shape in a random area on something. By that I mean the shape will be on the terrain, another shape, diff, water, etc.
This update allows you to place objects in space with the added field (AllowInSpace). This could probably be called air, but I don't see any other use for it than in a Space Sim with asteroids.
To install this update do the following:
1) Backup your old fxShapeReplicator (engine\game\fx\fxShapeReplicator.h/.cc)
2) Copy the fxShapeReplicator.h and the fxShapeReplicator.cc in the ZIP file into the directory.
3) Recompile
To use:
1) Place the Shape like you normally would've (In World Editor/Creator).
2) Select the AllowInSpace to allow it to be in the air/space.
3) Add the UpperZ and LowerZ values (UpperZ is the highest value something can be in air, LowerZ the Lowerst)
4) Click Apply
Note: When the AllowOnTerrain is used with the AllowInSpace it will place the object on or above the terrain. Without the AllowOnTerrain it can be under the terrain and even sticking half way through
So if you have a terrain, I recommend using the AllowonTerrain setting too.
This was updated and tested on TGE1.4
Credit go to Melv off course for creating the original.
Screeny:

About the author
#2
04/25/2006 (1:14 am)
If you manage to get clouds looking good, post us a screenshot.
#3
new fxShapeReplicator(test) {
canSaveDynamicFields = "1";
position = "395.85 690.953 5470.38";
rotation = "1 0 0 0";
scale = "1 1 1";
HideReplications = "0";
ShowPlacementArea = "1";
PlacementAreaHeight = "100";
PlacementColour = "0.4 0 0.8 1";
shapeFile = "~/data/shapes/asteroid/asteroid2.dts";
Seed = "136798728";
ShapeCount = "50";
ShapeRetries = "100";
InnerRadiusX = "0";
InnerRadiusY = "0";
OuterRadiusX = "1000";
OuterRadiusY = "1000";
UpperRadiusZ = "5500";
LowerRadiusZ = "5400";
AllowOnTerrain = "1";
AllowOnInteriors = "0";
AllowOnStatics = "0";
AllowOnWater = "0";
AllowInSpace = "1";
AllowWaterSurface = "0";
AlignToTerrain = "0";
Interactions = "1";
AllowedTerrainSlope = "90";
TerrainAlignment = "1 1 1";
FixShapeAspect = "1";
ShapeScaleMin = "5 5 5";
ShapeScaleMax = "5 5 5";
ShapeRotateMin = "0 0 0";
ShapeRotateMax = "0 0 0";
OffsetZ = "0";
receiveSunLight = "1";
receiveLMLighting = "1";
useAdaptiveSelfIllumination = "0";
useCustomAmbientLighting = "0";
customAmbientSelfIllumination = "0";
customAmbientLighting = "0 0 0 1";
};
I do use a terrain block, which is why the AllowOnTerrain flag is set. If I uncheck "AllowInSpace" then my asteriods appear on the terrain. Any thoughts?
08/03/2007 (9:53 pm)
Anyone get this working with 1.5? I added the code to fxshapereplicator.c and .h (the commented lines) and it doesn't work. My datablock looks like this:new fxShapeReplicator(test) {
canSaveDynamicFields = "1";
position = "395.85 690.953 5470.38";
rotation = "1 0 0 0";
scale = "1 1 1";
HideReplications = "0";
ShowPlacementArea = "1";
PlacementAreaHeight = "100";
PlacementColour = "0.4 0 0.8 1";
shapeFile = "~/data/shapes/asteroid/asteroid2.dts";
Seed = "136798728";
ShapeCount = "50";
ShapeRetries = "100";
InnerRadiusX = "0";
InnerRadiusY = "0";
OuterRadiusX = "1000";
OuterRadiusY = "1000";
UpperRadiusZ = "5500";
LowerRadiusZ = "5400";
AllowOnTerrain = "1";
AllowOnInteriors = "0";
AllowOnStatics = "0";
AllowOnWater = "0";
AllowInSpace = "1";
AllowWaterSurface = "0";
AlignToTerrain = "0";
Interactions = "1";
AllowedTerrainSlope = "90";
TerrainAlignment = "1 1 1";
FixShapeAspect = "1";
ShapeScaleMin = "5 5 5";
ShapeScaleMax = "5 5 5";
ShapeRotateMin = "0 0 0";
ShapeRotateMax = "0 0 0";
OffsetZ = "0";
receiveSunLight = "1";
receiveLMLighting = "1";
useAdaptiveSelfIllumination = "0";
useCustomAmbientLighting = "0";
customAmbientSelfIllumination = "0";
customAmbientLighting = "0 0 0 1";
};
I do use a terrain block, which is why the AllowOnTerrain flag is set. If I uncheck "AllowInSpace" then my asteriods appear on the terrain. Any thoughts?
#4
08/06/2007 (2:51 am)
Thats what it is suppose to do... With the AllowInSpace setting CHECKED the Shapes will show up in the air... Not only on the terrain? I dont understand your problem :-/
#5
10/21/2007 (6:52 am)
I used this resource for my B5 Game. I stripped out all non-space stuff to try to improve net and fps speed.
#6
10/21/2007 (9:00 am)
Make a resource of it, or send me the file and i'll add it to the resource.
#7
10/23/2007 (9:52 am)
I'll send you the my changes to the resource. It might be too stripped out - as I also ripped out the editor code. Have to figure out how to give the asteroids a slight autorotation.
#8
12/28/2007 (8:43 pm)
When running in debug mode it becomes apparent that there is a problem with the call to randF() on line 269 of fxShapeReplicator.cc where the mLowerRadiusZ and mUpperRadiusZ are inverted. randF() requires the first argument to be lower numerically, but the code is sending them in the opposite order. Furthermore, the Z coordinate need not even be calculated if mAllowInSpace is not turned on. Here is my proposed fix:// Calculate a random offset
HypX = RandomGen.randF(mFieldData.mInnerRadiusX, mFieldData.mOuterRadiusX);
HypY = RandomGen.randF(mFieldData.mInnerRadiusY, mFieldData.mOuterRadiusY);
if (mFieldData.mAllowInSpace)
HypZ = RandomGen.randF(mFieldData.mLowerRadiusZ, mFieldData.mUpperRadiusZ); //BRN
else
HypZ = 0;
Angle = RandomGen.randF(0, M_2PI);
#9
03/24/2009 (2:31 pm)
Anyone gotten this resource to work with a cloud type? 
Torque Owner Johnny Hill