FxShapeReplicator ignoring rotation - bug?!
by Thomas \"Man of Ice\" Lund · in Torque Game Engine · 06/01/2004 (6:56 am) · 7 replies
Sorry if this is already known. I've done a quick search and cant find anything on it.
I'm running head from approx middle of March, and I'm trying to use the fxShapeReplicator to put in a bunch of trees.
My problem is that the replicator ignores the rotation of my area circles. As pictures speak a 1000 words, look here:

The replication area is 200 long and 30 wide + rotated around the z axis a bit to run along the fairway and green area in this golf game
But all shapes are put into the game disregarding the rotation and going straight "north/south"
Looking through the source code for the fxShareReplicator it seems that the code never uses that rotation, but simply does this in CreateShapes():
I would imagine that the fix would be to add the rotation angle of the fxShapeReplicator node to the above mentioned Angle.
Or am I missing something?
I'm running head from approx middle of March, and I'm trying to use the fxShapeReplicator to put in a bunch of trees.
My problem is that the replicator ignores the rotation of my area circles. As pictures speak a 1000 words, look here:

The replication area is 200 long and 30 wide + rotated around the z axis a bit to run along the fairway and green area in this golf game
But all shapes are put into the game disregarding the rotation and going straight "north/south"
Looking through the source code for the fxShareReplicator it seems that the code never uses that rotation, but simply does this in CreateShapes():
// Get the Replicator Position. ShapePosition = getPosition(); // Calculate a random offset HypX = RandomGen.randF(mFieldData.mInnerRadiusX, mFieldData.mOuterRadiusX); HypY = RandomGen.randF(mFieldData.mInnerRadiusY, mFieldData.mOuterRadiusY); Angle = RandomGen.randF(0, M_2PI); // Calcualte the new position. ShapePosition.x += HypX * mCos(Angle); ShapePosition.y += HypY * mSin(Angle);
I would imagine that the fix would be to add the rotation angle of the fxShapeReplicator node to the above mentioned Angle.
Or am I missing something?
#2
In CreateShapes() find the code
and replace with
Recompile and thats it
06/01/2004 (11:33 am)
Thanks Melv - I fixed it. I'm unsure what to do with the fix though, so I'll post it here and write a quick resource. Maybe someone puts it into head - then feel free to delete the resource.In CreateShapes() find the code
// Find it a home ...
do
{
// Get the Replicator Position.
ShapePosition = getPosition();
// Calculate a random offset
HypX = RandomGen.randF(mFieldData.mInnerRadiusX, mFieldData.mOuterRadiusX);
HypY = RandomGen.randF(mFieldData.mInnerRadiusY, mFieldData.mOuterRadiusY);
Angle = RandomGen.randF(0, M_2PI);
// Calcualte the new position.
ShapePosition.x += HypX * mCos(Angle);
ShapePosition.y += HypY * mSin(Angle);and replace with
// Find it a home ...
do
{
// Calculate a random offset
HypX = RandomGen.randF(mFieldData.mInnerRadiusX, mFieldData.mOuterRadiusX);
HypY = RandomGen.randF(mFieldData.mInnerRadiusY, mFieldData.mOuterRadiusY);
Angle = RandomGen.randF(0, M_2PI);
// Calcualte the new random position (in local space).
Point3F RandomShapePosLocal;
RandomShapePosLocal.x = HypX * mCos(Angle);
RandomShapePosLocal.y = HypY * mSin(Angle);
// Transform into world space coordinates
Point3F shapePosWorld;
MatrixF objToWorld = getRenderTransform();
objToWorld.mulP(RandomShapePosLocal, &shapePosWorld);
ShapePosition = shapePosWorld;Recompile and thats it
#3
06/02/2004 (3:56 am)
Cool.
#4
11/19/2007 (10:21 pm)
@Thomas: Thanks for sharing that work. I know it's probably not much to you, but I'm smiling because my mushrooms are now rotating :-)
#5
11/20/2007 (12:42 am)
Anytime :-)
#6
I don't know how that escaped my notice last night...may have been the late hours...the beers...who knows...the less said the better.
So anyway I followed the function a little further, and the engine does honor the min/max rotation values in there, but only if you're not aligning to terrain--or rather, the option to align to terrain is not selected. I unchecked align-to-terrain in the editor, and voila, each mushroom was rotating by a random amount specified by mix/max rotation, creating the chaotic effect I was looking for.
Honestly it looks like it would be easy to force it to do this on terrain as well, but I didn't try it, it might blow up your monitor or something, I dunno. I'm using polysoup collision, so it's not an issue :-)
11/20/2007 (8:38 pm)
Hmm an interesting note that I think might be useful. I had kinda assumed that Thomas' fix provided random rotation of each member shape of the replicator. However, this is not the case. What he's doing is still having them all facing the same direction, but just at the angle he chooses, as opposed to just zero rotation.I don't know how that escaped my notice last night...may have been the late hours...the beers...who knows...the less said the better.
So anyway I followed the function a little further, and the engine does honor the min/max rotation values in there, but only if you're not aligning to terrain--or rather, the option to align to terrain is not selected. I unchecked align-to-terrain in the editor, and voila, each mushroom was rotating by a random amount specified by mix/max rotation, creating the chaotic effect I was looking for.
Honestly it looks like it would be easy to force it to do this on terrain as well, but I didn't try it, it might blow up your monitor or something, I dunno. I'm using polysoup collision, so it's not an issue :-)
#7

Sorry for the hi res, but it really lost a lot of interest when I shrunk it down.
11/20/2007 (10:09 pm)
Almost on topic, but just for the hell of it thought I'd post this screenie that shows what happens when you have several shape replicators copied/pasted with the same coordinates and seed. BUT, you can also see the fungi on top are all rotated randomly :-)
Sorry for the hi res, but it really lost a lot of interest when I shrunk it down.
Associate Melv May
It's not a bug, it simply wasn't put in. It wouldn't be a hardship to add that kind of rotation although only in the X/Y axis.
In the same fashion, it ignores the scale factors as well.
- Melv.