Constrain Rotations

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Constrain Rotations

Postby Julio Jerez » Mon Oct 12, 2020 11:32 am

ok I was looking at this and I am confused.

teh player does set the player matrix to the direction in which he or her is heading.
I am surprised because I am on the camp that prefer the player capsules not to rotate, but there it is the player capsule does rotate. I guess is was fixed at some point and I forget.
look at file ..\sdk\dVehicle\dPlayerController\dPlayerController.cpp
function void dPlayerController::PreUpdate(dFloat timestep)

about line 509 or so you will see this code
Code: Select all
   // set player orientation
   dMatrix matrix(dYawMatrix(GetHeadingAngle()));
   NewtonBodyGetPosition(m_newtonBody, &matrix.m_posit[0]);
   NewtonBodySetMatrix(m_newtonBody, &matrix[0][0]);

set the matrix of the player capsule is set to the heading direction.

if you add this line
dTrace(("%f (%f %f) ", GetHeadingAngle() * dRadToDegree, matrix[0][0], matrix[0][2]));

you can see thet the matrix is set to the player heading every tick, so unless I misunderstood the problem, this should be working.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Constrain Rotations

Postby Julio Jerez » Mon Oct 12, 2020 11:39 am

I commited the test set to the player capsule and added the a trace to print the player front vector .

you can see that is working in fact you can see the capsule aligning to teh header visually, so I do no really knwo what is that problem you mention.
do you meant the player to have a matrix rotation that is different to the heading direction?
I never saw any one doing that?

My guess is that some how in your code, you are calling SetHeadingAngle(angle)
with a value of zero when the player is not moving.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Previous

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 50 guests