Zero Position of Bullet Hinge Constraint

Hi all,

I am struggling with the hinge angle in BulletHingeConstraint. In detail, I am wondering why a hinge constraint along the y-axis between two boxes, of which one is rotated by 180 degrees around the z-axis, has an initial hinge_angle of 180 degrees. To make this clear, here is an example:

from direct.showbase.ShowBase import ShowBase
from panda3d.core import Vec3, Point3
from panda3d.bullet import BulletWorld
from panda3d.bullet import BulletRigidBodyNode
from panda3d.bullet import BulletBoxShape
from panda3d.bullet import BulletHingeConstraint

from panda3d.bullet import BulletDebugNode

class MyApp(ShowBase):
	def __init__(self):
		ShowBase.__init__(self), -10, 0), 0, 0)

		# create a debug node to get debug view
		self.debugNode = BulletDebugNode('Debug')
		debugNP = self.render.attachNewNode(self.debugNode)

		# create the world = BulletWorld(), 0, -9.81))

		# create a box
		box = BulletRigidBodyNode('Box')
		box.addShape(BulletBoxShape(Vec3(0.5, 0.5, 0.5)))
		np = self.render.attachNewNode(box)
		model = self.loader.loadModel('box.egg')
		np.setPos(0, 0, 0)

		#create a second box
		box2 = BulletRigidBodyNode('Box2')
		box2.addShape(BulletBoxShape(Vec3(0.5, 0.5, 0.5)))
		np = self.render.attachNewNode(box2)
		model = self.loader.loadModel('box.egg')
		np.setPos(2.0, 0, 0.0)
		np.setHpr(180, 0, 0)

		# create a joint between the boxes
		self.joint = BulletHingeConstraint(
			Point3(1.0, 0, 0.0),
			Point3(1.0, 0, 0.0),
			Vec3(0, 1, 0),
			Vec3(0, -1, 0))

		self.taskMgr.add(self.update, 'update')

	# update function
	def update(self, task):
		dt = globalClock.getDt()
		print self.joint.get_hinge_angle()
		return task.cont

app = MyApp()

The given out hinge angles starts with 180 degree! In contrast, I would have expected it to start with zero degrees in the initial position. While it may seem stupid here to rotate the box around the z-axis, this may be perfectly justified when dealing with more complex objects. The problem when starting with 180 degrees is that the angle limits of the constraint cannot be used any longer as they have to be between -180 and 180 degrees.

To sum up, I wonder what I have to do with the HingeConstraint to obtain a zero degrees hinge angle in the initial condition even if one of the objects is rotated.

Thanks for your help!

try putting a static Cone Twist object between ,& maybe a static plane under the cone twist (to hold up the c.t , when parenting 2 rigid bodys ) might have to play around with this mixture , x/y angle of the c.t so it dont spin in ways u dont want, best of luck

thanks for your help! However, this approach seems quite complex and a little bit unnatural. I will try first whether the alternative constructors of BulletHingeConstraint (Panda Bullet) may help me.