Page 1 of 1

[Solved] Incorrect local coordinate translation when using multiple components

Posted: Tue Jan 28, 2020 11:15 pm
by kimbr
I ran into this issue while working on a lua specialization script for a mod. Here's the (much simplified) outline of the issue:

1. the lua script reads two node paths from a vehicle XML config key.
2. Next, it uses retrieves the nodes:

Code: Select all

node1 = I3DUtil.indexToObject(self.components, getXMLString(self.xmlFile,"path.to.my.key#node"));
node2 = I3DUtil.indexToObject(self.components, getXMLString(self.xmlFile,"path.to.my.key#baseNode"));
3. The world coordinates are retrieved:

Code: Select all

local xWorld, yWorld, zWorld = getWorldTranslation(node1)
4. The local coordinates relative to node2 are retrieved by using

Code: Select all

local xLocal, yLocal, zLocal = worldToLocal(node2, xWorld, yWorld, zWorld)
When node1 and node2 are part of the same component, this works beautifully.
But if they are part of two different components in the XML, the worldToLocal() call produces the wrong coordinates.

To make sure, I also tried this with node1 being a completely different object in-game. In that case, the expected results are returned.

Re: Incorrect local coordinate translation when using multiple components

Posted: Wed Apr 22, 2020 10:23 am
by Uruora
Thanks for that, forwarded it to the devs