Hi guys,
I think I've made it work with some voodoo. Maybe one of you understands what I did and knows a better way. I really need to learn more about this topic to make sense of it
@JoeJ thanks for your detailed post, I really appreciate your help. To be honest I need to read it over again to understand all of it
JoeJ wrote:This has to happen to anybody at least once in life

Can't wait for the next time lol
@Julio your hint partially helped, let me explain what I did.
In my last attempt, I've made the scene objects face in the correct direction, but the collision was off. All this was done with disabled transformation updates to verify the base setup.
Now I've built on that and think I was able to fix the collision rotation with this setup code:
- Code: Select all
S3DX::AIVariable hObject = S3DX::object.fromStaticHandle(staticHandle);
S3DX::AIVariables<3> pos = S3DX::object.getTranslation(hObject, S3DX::object.kGlobalSpace);
dVector position(pos[0], pos[1], pos[2]);
S3DX::AIVariables<4> rot = S3DX::object.getRotationQuaternion(hObject, S3DX::object.kGlobalSpace);
dQuaternion rotation(rot[1], rot[2], rot[3], rot[0]);
rotation.m_q0 = -rotation.m_q0;
rotation.m_q1 = -rotation.m_q1;
dMatrix matrix(rotation, position);
NewtonBody* const body = NewtonCreateDynamicBody(world, collision, &matrix[0][0]);
This is how it looks like, still no collision updates...

Since I'm still working with just box collisions, I need to check the rotation somehow, maybe with debug drawing a vector or a convex hull...
Next I've enabled the ForceAndTorque and Transform Callback and used this code for the updates:
- Code: Select all
void SetTransformCallback(const NewtonBody* body, const dFloat* matrix, int threadIndex)
{
dVector position;
BodyUserData* bud = (BodyUserData*)NewtonBodyGetUserData(body);
S3DX::AIVariable hObject = S3DX::object.fromStaticHandle(bud->staticHandle);
dMatrix transform (matrix);
dQuaternion rotation (transform);
S3DX::object.setRotationQuaternion(hObject, rotation.m_q1, rotation.m_q2, rotation.m_q3, rotation.m_q0, S3DX::object.kGlobalSpace);
NewtonBodyGetPosition(body, &position.m_x);
S3DX::object.setTranslation(hObject, position.m_x, position.m_y, position.m_z, S3DX::object.kGlobalSpace);
}
Here's the result:

The collision looks ok, but the gizmo scene objects are rotated... like 180 degree on the local Y axis.
So right after setting the rotation quaternion, I now rotate the objects around Y axis in local space.
- Code: Select all
S3DX::object.setRotationQuaternion(hObject, rotation.m_q1, rotation.m_q2, rotation.m_q3, rotation.m_q0, S3DX::object.kGlobalSpace);
S3DX::object.rotateAxisAngle(hObject, 0.f, 1.f, 0.f, 180.f, S3DX::object.kLocalSpace); // rotate 180 degree around Y in local space
This way it looks at least like a solution. As stated above, I still need to check the rotation.
Isn't that voodoo? The way I did it looks weird. Do you guys have an explanation why it works this way and probably a better solution?
Thanks
Shaderman