Hi, I’m using PyODE to do some physics simulation in my application. From PyODE I can do body.getPosition , body.getRotation.
Setting position is simple -> I just call node.setPos(position) and it works.
The problem is that body.getRotation returns a row major rotation matrix for the object.
dunno if this helps you. but might be worth looking at since its a ODE sample in cobination with panda. tried it myself month ago and worked quite well. https://discourse.panda3d.org/viewtopic.php?t=1485&highlight=ode
if not. just try to search the forum for “ode”
There is a setCell / getCell function on Mat4 & Mat3 matrix in panda3D.
I use following code to convert from Newton to P3D and from P33D to Newton.
Newton follow a row major convention (it’s the same convention than DirectX in fact).
I hope this may help you a little.
def toNewtonMatrix(self,P3Dmatrix):
nMat=nMatrix()
offset=0
for i in range(4):
for j in range(4):
nMat[offset+j]=c_float(P3Dmatrix.getCell(i,j))
offset=offset+j+1
return nMat
def toP3DMatrix(self,NEWTONmatrix):
pMat=Mat4(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0)
offset=0
for i in range(4):
for j in range(4):
pMat.setCell(i,j,NEWTONmatrix[offset+j])
offset=offset+j+1
return pMat