fxShapereplicator Polysoup for TGEA 1.7.x
by James Laker (BurNinG) · 06/18/2008 (8:10 am) · 7 comments
I'm a little bored and waiting for time to pass, so I thought I would quickly submit my code to get polysoup working for fxShapereplicators. This was a key feature needed for me in Solar Battles to have ships fly through asteroid fields with proper collision.
Lets get right to it and open up fxShapereplicator.h. Search for where all the variables are being declared under:
and add:
Down a little is where we give it a default value so just add the following:
That's it for the Header file; Open up fxShapereplicator.cpp and add the following at the bottom of void fxShapeReplicator::initPersistFields():
The above code will make sure you can change it in the Mission Editor to use Polysoup or not - It's that simple ;)
In the next method (void fxShapeReplicator::CreateShapes(void)) we find where we create each individual shape and change it to look like this:
Just make sure we send the variable over to wire by changing the following int U32 fxShapeReplicator::packUpdate to:
And of course also update the unpack (void fxShapeReplicator::unpackUpdate) make the following changes:
Recompile and Pow - It's that simple :)
Lets get right to it and open up fxShapereplicator.h. Search for where all the variables are being declared under:
class tagFieldData
{
public:and add:
//JLAKER - Polysoup
bool mUsePolysoup;
//JLAKER - PolysoupDown a little is where we give it a default value so just add the following:
mAllowedTerrainSlope= 90;
mAlignToTerrain = false;
mInteractions = true;
//JLAKER - Polysoup
mUsePolysoup = false;
//JLAKER - PolysoupThat's it for the Header file; Open up fxShapereplicator.cpp and add the following at the bottom of void fxShapeReplicator::initPersistFields():
//JLAKER - Polysoup addGroup( "Collision" ); addField( "usePolysoup", TypeBool, Offset( mFieldData.mUsePolysoup, fxShapeReplicator ) ); endGroup( "Collision" ); // MM: Added Group Footer. //JLAKER - Polysoup
The above code will make sure you can change it in the Mission Editor to use Polysoup or not - It's that simple ;)
In the next method (void fxShapeReplicator::CreateShapes(void)) we find where we create each individual shape and change it to look like this:
.
...
.....
// Create our static shape.
fxStatic = new fxShapeReplicatedStatic();
// Set the 'shapeName' field.
fxStatic->setField("shapeName", mFieldData.mShapeFile);
//JLAKER - Polysoup
if (mFieldData.mUsePolysoup)
fxStatic->setField("usePolysoup", "true");
else
fxStatic->setField("usePolysoup", "false");
//JLAKER - Polysoup
// Is this Replicator on the Server?
if (isServerObject())
.....
...
.Just make sure we send the variable over to wire by changing the following int U32 fxShapeReplicator::packUpdate to:
stream->write(mFieldData.mPlaceAreaColour); //JLAKER - Polysoup stream->writeFlag(mFieldData.mUsePolysoup); // Polysoup. //JLAKER - Polysoup } //JLaker -> Dont miss this!
And of course also update the unpack (void fxShapeReplicator::unpackUpdate) make the following changes:
stream->read(&mFieldData.mPlaceAreaColour); //JLAKER - Polysoup mFieldData.mUsePolysoup = stream->readFlag(); //Polysoup... Tastes like chicken //JLAKER - Polysoup // Set Transform. setTransform(ReplicatorObjectMatrix);
Recompile and Pow - It's that simple :)
About the author
#2
But i have some problem.
i add your code and compiled.
add fxshapereplicator in my test mission.
but not add shapes.
this is my console message.
and i remove this code
Then possible add fxshapereplicator in mission.
but not apply polysoup.
i need some help.
06/18/2008 (5:06 pm)
Thanks for posting this resource.But i have some problem.
i add your code and compiled.
add fxshapereplicator in my test mission.
but not add shapes.
this is my console message.
TSStatic::onAdd: unable to load shape: true [asdferdf] - Could not load shape file 'scriptsAndAssets/data/shapes/trees/oak1.dts'! TSStatic::onAdd: unable to load shape: true [(null)] - Could not load shape file 'scriptsAndAssets/data/shapes/trees/oak1.dts'!
and i remove this code
if (mFieldData.mUsePolysoup)
fxStatic->setField("shapeName", "true");
else
fxStatic->setField("shapeName", "false");Then possible add fxshapereplicator in mission.
but not apply polysoup.
i need some help.
#3
fxStatic->setField("usePolysoup", "false/true");
instead of
fxStatic->setField("shapeName", "false/true");
06/18/2008 (11:47 pm)
Just a thought, but shouldn't it be:fxStatic->setField("usePolysoup", "false/true");
instead of
fxStatic->setField("shapeName", "false/true");
#4
@Mquaker: Updated the resource, just make the small change Taylor gave.
06/19/2008 (1:19 am)
Thanx Taylor... Stupid Typo from my side.@Mquaker: Updated the resource, just make the small change Taylor gave.
#5
06/19/2008 (2:21 am)
No problem James.
#6
06/19/2008 (7:06 pm)
Thanks Taylor & James. :)
#7
08/07/2008 (5:12 am)
Nice... thats how it should be. 
Torque Owner Taylor Petrick