View Issue Details

IDProjectCategoryView StatusLast Update
0005645Multi Theft Auto : San AndreasServerpublic2016-07-31 04:41
ReporterRemi-XAssigned Toqaisjp 
PrioritynormalSeverityfeatureReproducibilityN/A
Status resolvedResolutionfixed 
Product Version 
Target Version1.4Fixed in Version1.4 
Summary0005645: [Request] Add getElementMatrix serverside
Description

Would be useful, and I don't think this is too hard to do. Like this you could get the matrix, and also create something on that point to have that synced without triggering client and server-events. So this would save bandwidth too.

TagsNo tags attached.

Relationships

child of 0003344 closed New Feature Requests Requested features tracker 

Activities

qaisjp

2014-11-16 16:13

administrator   ~~0022450

Last edited: 2014-11-17 18:12

View 2 revisions

The server isn't aware of the engine.

Jusonex

2014-11-17 17:40

administrator   ~~0022503

You do not need any engine features to build an element matrix. All you need is the position and rotation (see https://wiki.multitheftauto.com/wiki/GetElementMatrix for details).

The object-oriented version Element.getMatrix is also already defined on the server.

Wojak

2015-08-20 14:08

viewer   ~~0023980

I think this was implemented with OOP:
https://wiki.multitheftauto.com/wiki/Matrix
the examples are “shared”.

if someone wants an oldschool function, I've made this back in 2012:
finction getMatrixOfElement(x,y,z,rx,ry,rz)
local sinx = math.sin(math.rad(rx))
local cosx = math.cos(math.rad(rx))
local siny = math.sin(math.rad(ry))
local cosy = math.cos(math.rad(ry))
local sinz = math.sin(math.rad(rz))
local cosz = math.cos(math.rad(rz))
local rotxmatrix = {{1,0,0},{0,cosx,sinx},{0,-sinx,cosx}}
local rotymatrix = {{cosy,0,-siny},{0,1,0},{siny,0,cosy}}
local rotzmatrix = {{cosz,sinz,0},{-sinz,cosz,0},{0,0,1}}
local returnmatrix = {}
local transform = function(A,B)
local C = {{0,0,0},{0,0,0},{0,0,0}}
for i=1,3 do
for j=1,3 do
for k=1,3 do
C[i][j] = C[i][j] + (A[i][k] * B[k][j])
end
end
end
return C
end
returnmatrix = transform(rotxmatrix,rotymatrix)
returnmatrix = transform(returnmatrix,rotzmatrix)
table.insert(returnmatrix[1],0)
table.insert(returnmatrix[2],0)
table.insert(returnmatrix[3],0)
returnmatrix[4] = {x,y,z,1}
return returnmatrix
end

the table this function creates is compatible with clientside getElementMatrix examples:
https://wiki.multitheftauto.com/wiki/GetElementMatrix

qaisjp

2015-08-20 21:53

administrator   ~~0023983

This sounds easy enough to make server side.

IIYAMA12

2015-08-21 17:27

viewer   ~~0023997

There is also a getElementMatrix example on the wiki site you can use too.
https://wiki.multitheftauto.com/wiki/GetElementMatrix
It works just fine serverside.

function getElementMatrix(element)
local rx, ry, rz = getElementRotation(element, "ZXY")
rx, ry, rz = math.rad(rx), math.rad(ry), math.rad(rz)
local matrix = {}
matrix[1] = {}
matrix[1][1] = math.cos(rz)math.cos(ry) - math.sin(rz)math.sin(rx)math.sin(ry)
matrix[1][2] = math.cos(ry)
math.sin(rz) + math.cos(rz)math.sin(rx)math.sin(ry)
matrix[1][3] = -math.cos(rx)*math.sin(ry)
matrix[1][4] = 1

matrix[2] = {}
matrix[2][1] = -math.cos(rx)*math.sin(rz)
matrix[2][2] = math.cos(rz)*math.cos(rx)
matrix[2][3] = math.sin(rx)
matrix[2][4] = 1

matrix[3] = {}
matrix[3][1] = math.cos(rz)*math.sin(ry) + math.cos(ry)*math.sin(rz)*math.sin(rx)
matrix[3][2] = math.sin(rz)*math.sin(ry) - math.cos(rz)*math.cos(ry)*math.sin(rx)
matrix[3][3] = math.cos(rx)*math.cos(ry)
matrix[3][4] = 1

matrix[4] = {}
matrix[4][1], matrix[4][2], matrix[4][3] = getElementPosition(element)
matrix[4][4] = 1

return matrix

end

qaisjp

2015-08-24 12:48

administrator   ~~0024008

Using these matrix functions are quite pointless.

You want to use the new Matrix class now.

nokizorque

2015-12-14 10:05

viewer   ~~0024234

Noki executed command: getElementMatrix(Player("Noki"))
Command results: table: 3D574F48 [table]

Looks to me like it's there.

qaisjp

2016-07-31 04:40

administrator   ~~0024998

Has existed for a while: https://github.com/multitheftauto/mtasa-blue/commit/f663b290c44f9e1b643a6fe01aeb735234267d33

Issue History

Date Modified Username Field Change