How to orient BulletGenericConstraint?

By default, the BulletGenericConstraint in Panda3D is oriented along positive X axis. The setAngularLimit method can be used to set only along X, Y or Z axis. How do I join two bodies which do not lie orthogonal to any of the axis by a BulletGenericConstraint and have a DOF (or angular limit) that is defined along the vector between them?

That is, how do I orient a BulletGenericConstraint in a direction along an arbitrary vector, which is not along X, Y or Z axis?

This example illustrates what I want:

A and B can be bodies anywhere in space, they have nodepaths, Bullet rigid bodies and their initial positions are known. A is a static body, while B is dynamic (has mass). There is no gravity, but forces will be applied on B during the simulation.

Imagine B to be tied by a metal rod to A. Now, I want the movement of B to be restricted by the region highlighted in red.

The constructor of the generic constraint allows you to provide two local “frames”, one for each of the two bodies. These frames are the local transforms of the constraints origin as seen from the connected bodies.

Thanks enn0x. I understand that these act as pivot points for the joint (constraint).

I set the angular limit for the constraint using setAngularLimit method. The X, Y and Z axis values accepted by this method, set the DOF along positive X axis. How do I orient this DOF to any arbitrary vector that I want?

The local frames are not only pivot points. They can have an orientation too. You have to provide such an TransformState, that the X-axis (or Y-axis or Z-axis…) of the joint is pointing in whatever direction you need.