AttachElementsOffsets: Difference between revisions
mNo edit summary |
m (To be checked...) |
||
Line 1: | Line 1: | ||
'''This article concerns the note left in [[attachElements]].''' | '''This article concerns the note left in [[attachElements]].''' | ||
==Explanation== | ==Explanation== |
Revision as of 04:09, 21 March 2011
This article concerns the note left in attachElements.
Explanation
The offset coordinates reflect the object space, not the world space. This means that you cannot simply visualize the attachment in the map editor and calculate the offsets between the 2 sets of world coordinates between "theElement" and "theAttachToObject".
Example
Start freeroam resource and paste this into the console:
setpos 1904.7426757813 -2411.1262207031 13.53911781311
Now, use the following script and look at the rocket. See how it is off center? Despite the fact you found the positions in the map editor and calculated the offsets. If you commented out attachElements you will see that it is in the correct position in terms of world coordinates.
If you make "rocketRZ = 0" you will have the correct coordinates. Again, because the offsets are based off "theAttachToElement". If you kept any rotations in the object, it would change the XYZ coordinates "theElement" would need to be attached at.
--This example illustrates the problem with using the world coordinate math to calculate offsets. --Change rocketRZ to 0 to get the correct position. local rocketX = 1925.022705 local rocketY = -2450.944336 local rocketZ = 18.053474 local rocketRX = 0 local rocketRY = 0 local rocketRZ = 69.61437 local vehX = 1925.112793 --more is forward local vehY = -2446.260742 -- less is forward local vehZ = 26.692139 local vehRX = 89.38142 local vehRY = 0.030000 local vehRZ = 177.90356 shuttletable = {} shuttletable[1] = createObject ( 17050, rocketX, rocketY, rocketZ, rocketRX, rocketRY, rocketRZ ) shuttletable[2] = createVehicle ( 519, vehX, vehY, vehZ, vehRX, vehRY, vehRZ ) attachOffsetX = vehX-rocketX attachOffsetY = vehY-rocketY attachOffsetZ = vehZ-rocketZ attachOffsetRX = vehRX-rocketRX attachOffsetRY = vehRY-rocketRY attachOffsetRZ = vehRZ-rocketRZ attachElements( shuttletable[2], shuttletable[1], attachOffsetX, attachOffsetY, attachOffsetZ, attachOffsetRX, attachOffsetRY, attachOffsetRZ )