Transformation matrix / translation problem

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Transformation matrix / translation problem

Postby JoeJ » Sun Mar 13, 2016 4:50 pm

Julio Jerez wrote:if I take the shiva quat and I do this

newton[0] = -Shiva [1]
newton[1] = -Shiva [2]
newton[2] = Shiva [3]
newton[3] = Shiva [0]

then the two quat match, the reverse should be

Shiva [0] = newton[3]
Shiva [1] = -newton[0]
Shiva [2] = -newton[1]
Shiva [3] = newton[2]


That's exactly what he's doing already.
He get's back to original numbers - only that all signs reverse somewhere which should have no effect.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Transformation matrix / translation problem

Postby Shaderman » Sun Mar 13, 2016 5:11 pm

Julio Jerez wrote:try that see if is does it.

That didn't help Julio :(

Julio Jerez wrote:Is this a quake base engine?

AFAIK no and I highly doubt it.

JoeJ wrote:Did you try to negate all numbers at setup, so that all signs match? No difference i guess

Yes, this also makes no difference :(

JoeJ wrote:S3DX::AIVariables<4> rot =
Is this modern C++ or templates? Does that return an array of 4 floats and preservis it the order of values?

Templates. Yes, it returns an array of 4 floats and keeps the order.

I've found a thread in the ShiVa forums which might be interesting. One guy made a bullet integration but used different ShiVa rotation functions like I do. I think I should try this approach.

I have to leave for a business trip in a few hours and won't be able to continue with this until Saturday.

Guys, I really appreciate your help!

Shaderman
Shaderman
 
Posts: 66
Joined: Tue Mar 08, 2016 2:51 am

Re: Transformation matrix / translation problem

Postby JoeJ » Sun Mar 13, 2016 5:30 pm

Shaderman wrote:I've found a thread in the ShiVa forums which might be interesting.


Worth a try, although it converts matrix to euler, and Shiva converts euler back to quat :)
There is also a utility function in Newton to convert matrix to euler, with the option to specify the order (Shiva does not state their order in docs, so assuming XYZ).
Make sure you did not forget to remove any 180 degree rotation in your code,
and report the issue in their forum - may be a serious bug.

One last thing:
Instead of updating Shiva quat in transform feedback, ignore Newton,
read the quat again from shiva, log it, and give it back to shiva.
Do the objects keep their position from the editor?
If this works it must be possible to transform Newtons output properly...

Edit: Maybe Shiva works only properly with negative w in quat,
so try to negate all numbers in update instead setup.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Transformation matrix / translation problem

Postby Shaderman » Sun Mar 13, 2016 6:01 pm

JoeJ wrote:There is also a utility function in Newton to convert matrix to euler, with the option to specify the order (Shiva does not state their order in docs, so assuming XYZ).

I think you mean dMatrix::GetEulerAngles which allows two orders:

Code: Select all
enum dEulerAngleOrder
{
   m_pitchYawRoll = (0 << 8) + (1 << 4) + (2 << 0),
   m_rollYawpitch = (2 << 8) + (1 << 4) + (0 << 0),
};


Unfortunately, Shiva seems to support YPR only.

JoeJ wrote:Instead of updating Shiva quat in transform feedback, ignore Newton,
read the quat again from shiva, log it, and give it back to shiva.
Do the objects keep their position from the editor?

Yes, there's no change. I don't know how several calls in a row are handled by the engine. Probably in one frame, maybe it takes more. I think this isn't reliable.

JoeJ wrote:Edit: Maybe Shiva works only properly with negative w in quat,
so try to negate all numbers in update instead setup.

I did, without success though :(

Well, let me try these other rotation functions when i'm back.
Shaderman
 
Posts: 66
Joined: Tue Mar 08, 2016 2:51 am

Re: Transformation matrix / translation problem

Postby JoeJ » Wed Mar 16, 2016 2:33 am

Shaderman wrote:I think you mean dMatrix::GetEulerAngles which allows two orders:

Code: Select all
enum dEulerAngleOrder
{
m_pitchYawRoll = (0 << 8) + (1 << 4) + (2 << 0),
m_rollYawpitch = (2 << 8) + (1 << 4) + (0 << 0),
};




Ah yes, this is because bad Julio made the order a named enum so the user can't change it :(
You would need to add your order there, or change th order function parameter to int.
The order is 3 4-bit numbers easily expressed in hex:
XYZ 0x012
ZYX 0x210
XZY 0x021
...
six posible orders.

Shaderman wrote: JoeJ wrote:
Instead of updating Shiva quat in transform feedback, ignore Newton,
read the quat again from shiva, log it, and give it back to shiva.
Do the objects keep their position from the editor?


Yes, there's no change. I don't know how several calls in a row are handled by the engine. Probably in one frame, maybe it takes more. I think this isn't reliable.


Does no change mean, the objects get flipped or they keep editor orientation like they should?
My idea is not using Newtons Transform feedback at all.
Maybe this causes the rotation update at a time where Shiva does not like it.
Instead, after Newton update is done and before Shivas drawing,
loop over all bodies manually and update Shiva.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Transformation matrix / translation problem

Postby Shaderman » Sat Mar 19, 2016 3:34 am

Hi JoeJ,

I also thought about modifying/adding ShiVa's euler angle order already.

JoeJ wrote:Does no change mean, the objects get flipped or they keep editor orientation like they should?

With my latest attempts, I didn't have any problems with editor/runtime rotation of objects.

JoeJ wrote:My idea is not using Newtons Transform feedback at all.
Maybe this causes the rotation update at a time where Shiva does not like it.
Instead, after Newton update is done and before Shivas drawing,
loop over all bodies manually and update Shiva.

I think Julio was ist who suggested to try that. So I did try it, but it didn't change the situation.

While I've been on tour this week, I had an idea. There was neither a difference with object rotation on creation nor at runtime anymore. It matched what I've seen in the editor.
The only thing which was apparently not matching was the collision. The collision appeared to be rotated which I was able to see when I started using convex hulls :oops:

So I've swapped the x and z axes (I pass -x, +y, -z to Newton) on collision hull creation to make it match. Here's a video and it looks to me like everything works as it should (debug drawing makes it slow).
To be honest, I don't completely understand why this swap should be required. If there was something wrong with convex hull creation in Newton, I bet others should have noticed it. What do you guys think?

I'll try to add a cone mesh and collision now. Let's see how that works :)

EDIT: I probably need to work with swapped offset matrix for Newtons collsion creation functions. Hmmm, things seem to make sense now again...

Thanks

Shaderman
Shaderman
 
Posts: 66
Joined: Tue Mar 08, 2016 2:51 am

Re: Transformation matrix / translation problem

Postby JoeJ » Sat Mar 19, 2016 4:51 am

Shaderman wrote:The only thing which was apparently not matching was the collision. The collision appeared to be rotated which I was able to see when I started using convex hulls :oops:


Ha ha, how stupid no one of us thought on that :P

Shaderman wrote:So I've swapped the x and z axes (I pass -x, +y, -z to Newton)


That's a 180 degree rotatation around y axis.
There may be a way to get rid of this in combination with some of the other hacks,
but it works so who cares :)

At least for now, it may get a bit annoying to tackle this everytime not only for bodies but also joints,
but it won't be a real problem.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Transformation matrix / translation problem

Postby Shaderman » Fri Mar 25, 2016 3:41 am

Hi JoeJ,

I started working on joints and had to learn about using the custom joints package first :D The CustomSlider is exposed to the LUA side of the engine already and I don't see any translation or rotation problems yet. I hope this won't change :mrgreen:

Thanks

Shaderman
Shaderman
 
Posts: 66
Joined: Tue Mar 08, 2016 2:51 am

Previous

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron