nickak2003
06-06-2013 01:31:04
So I'm getting this strange error where a variable, mTransform, is not being stored in self, even though I go, self.mTranform = btTransform(). It errors when setTransform is called. It says variable, mTransform is not a member of self. Here's the code:
The mTransform =btTransform() code in __init__ executes fine, but when I look at the debugger while stepping through, it does not actually add mTransform to self!
class PhysicsObject:
def __init__(self):
self.mShape = None
self.mRigidBody = None
self.mTransform = bullet.btTransform()
self.mTransform.setIdentity()
print "transform " + repr( self.mTransform )
self.mInertia = bullet.btVector3(0, 0, 0)
self.mMotionState = None
self.mMass = 0.0
self.mTriMesh = None
def __del__(self):
pass
def destroy(self, world):
world.removeRigidBody(self.mRigidBody)
if self.mTriMesh:
del self.mTriMesh
if self.mShape:
del self.mShape
del self.mRigidBody
del self.mMotionState
def isDynamic(self):
if (self.mMass != 0.0):
return True
return False
def setInertia(self, inertia):
self.mInertia = inertia
if self.isDynamic():
self.mShape.calculateLocalInertia(self.mMass, self.mInertia)
def setShape(self, shape):
self.mShape = shape
def setMass(self, mass):
# A Bullet rigidbody is dynamic if and only if mass is non zero.
self.mMass = mass
def setTransform(self, origin, rot=None):
print "asd: " + repr( self.mTransform )
self.mTransform.setOrigin(origin)
if (rot):
self.mTransform.setRotation(rot)
def setMotion(self, mParentNode, dynamicsWorld):
if not self.isDynamic():
self.mMotionState = bullet.btDefaultMotionState(self.mTransform)
else:
self.mMotionState = OgreMotionState(self.mTransform, mParentNode)
rigidbody_info = bullet.btRigidBody.btRigidBodyConstructionInfo(
self.mMass,
self.mMotionState,
self.mShape,
self.mInertia)
self.mRigidBody = bullet.btRigidBody(rigidbody_info)
dynamicsWorld.addRigidBody(self.mRigidBody)
self.mRigidBody.setUserData(mParentNode)
The mTransform =btTransform() code in __init__ executes fine, but when I look at the debugger while stepping through, it does not actually add mTransform to self!