VenomOG Posted September 22, 2018 Share Posted September 22, 2018 invert = {} matrix = {} mat = {} function getOffsetFromXYZ( mat, vec ) -- make sure our matrix is setup correctly 'cos MTA used to set all of these to 1. mat[1][4] = 0 mat[2][4] = 0 mat[3][4] = 0 mat[4][4] = 1 mat = matrix.invert( mat ) local offX = vec[1] * mat[1][1] + vec[2] * mat[2][1] + vec[3] * mat[3][1] + mat[4][1] local offY = vec[1] * mat[1][2] + vec[2] * mat[2][2] + vec[3] * mat[3][2] + mat[4][2] local offZ = vec[1] * mat[1][3] + vec[2] * mat[2][3] + vec[3] * mat[3][3] + mat[4][3] return {offX, offY, offZ} end veh = createVehicle(431,0,0,3) obj = createObject(14399,0,0,0) attachElements(obj,veh,0,0,3) addCommandHandler("offset", function () mat = getElementMatrix(veh) x,y,z = getElementPosition(obj) vec = Vector3(x,y,z) offsetTable = getOffsetFromXYZ(mat,vec) outputChatBox(offsetTable[1]..", "..offsetTable[2]..", "..offsetTable[3]) end ) Link to comment
URBAN Posted September 22, 2018 Share Posted September 22, 2018 https://github.com/davidm/lua-matrix/blob/master/lua/matrix.lua add matrix functions from there Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now