When a point is rotated more than 90 degrees on two axes in local space, one of the axes is lost. This issue is difficult to understand without examples, so here are some.
With SetOrientation()
// offset is vector in angles armorPiece.SetOrientation(offset + "0 90 90");
This should logically rotate the object with an offset of +90 degrees on both the Y and Z axes.
Tests with different offsets:
offset = "0 0 0"
offset = "90 0 0"
offset = "0 90 0"
offset = "0 0 90"
As you can see, the X axis is completely lost.
Manual rotation of a point in space
Sorry for the complex example:
float radAngle = Math.DEG2RAD * ConeAngle; float theta = Math.RandomFloatInclusive(0, radAngle); float phi = Math.RandomFloatInclusive(0, Math.PI2); float x = Math.Sin(theta) * Math.Cos(phi); float y = Math.Sin(theta) * Math.Sin(phi); float z = Math.Cos(theta); vector localDir = Vector(x, y, z);
This creates a direction vector in local space, randomly positioned within a cone of angle ConeAngle.
Now, I want to rotate this vector twice using directional vectors.
// ConeVector is directional vector I want to align my vector with vector transform[3]; Math3D.DirectionAndUpMatrix(ConeVector, vector.Up, transform); localDir = localDir.Multiply3(transform);
If I apply this transformation once, it works as expected:
ConeVector:
"0 1 0"
"0 -1 0"
"1 0 0"
"-1 0 0"
However, when I apply the same rotation again, an axis is lost:
"0 1 0"
"0 -1 0"
"1 0 0"
"-1 0 0"
Both X and Y rotate on one axis but in different directions.
InventorySlotsOffsets Issue
This issue is easiest to replicate using InventorySlotsOffsets.
Here, I add the InventorySlotsOffsets for the Belt_Right slot to the holster:
"0 90 90"
"90 90 90"
"0 180 90"
"0 90 180"