def addAbsoluteOffset(self, name, offset=[0, 0, 0, 0, 0, 0, 1], index=0): ## adding a offset given in absolute coordinates to the offset return RigidBody.Offset(self.node, name, (Rigid.Frame(offset) * self.frame.inv()).offset(), index)
def __init__(self, node, name, offset, index): self.node = node.createChild(name) self.frame = Rigid.Frame(offset) self.dofs = self.frame.insert(self.node, name='dofs') self.mapping = self.node.createObject('AssembledRigidRigidMapping', name="mapping", source='0 ' + str(self.frame))
def addVisualModel(self, filepath, scale3d=[1, 1, 1], offset=[0, 0, 0, 0, 0, 0, 1]): ## adding a visual model to the rigid body with a relative offset # @warning the translation due to the center of mass offset is automatically removed. If necessary a function without this mecanism could be added return RigidBody.VisualModel(self.node, filepath, scale3d, (self.framecom.inv() * Rigid.Frame(offset)).offset())
def addCollisionMesh(self, filepath, scale3d=[1, 1, 1], offset=[0, 0, 0, 0, 0, 0, 1]): ## adding a collision mesh to the rigid body with a relative offset # (only a Triangle collision model is created, more models can be added manually) # @warning the translation due to the center of mass offset is automatically removed. If necessary a function without this mecanism could be added return RigidBody.CollisionMesh(self.node, filepath, scale3d, (self.framecom.inv() * Rigid.Frame(offset)).offset())
def setManually(self, offset=[0, 0, 0, 0, 0, 0, 1], mass=1, inertia=[1, 1, 1], inertia_forces=False): ## create the rigid body by manually giving its inertia self.frame = Rigid.Frame(offset) self.dofs = self.frame.insert(self.node, name='dofs') self.mass = self.node.createObject('RigidMass', template='Rigid', name='mass', mass=mass, inertia=concat(inertia), inertia_forces=inertia_forces)
def setFromMesh(self, filepath, density=1000.0, offset=[0, 0, 0, 0, 0, 0, 1], scale3d=[1, 1, 1], inertia_forces=False): ## create the rigid body from a mesh (inertia and com are automatically computed) info = Rigid.generate_rigid(filepath, density, scale3d) self.framecom = Rigid.Frame() self.framecom.rotation = info.inertia_rotation self.framecom.translation = info.com self.frame = Rigid.Frame(offset) * self.framecom self.dofs = self.frame.insert(self.node, name='dofs') self.mass = self.node.createObject('RigidMass', template='Rigid', name='mass', mass=info.mass, inertia=concat( info.diagonal_inertia.tolist()), inertia_forces=inertia_forces)
def setFromMesh(self, filepath, density = 1000.0, offset = [0,0,0,0,0,0,1], scale3d=[1,1,1], inertia_forces = False ): ## create the rigid body from a mesh (inertia and com are automatically computed) info = Rigid.generate_rigid(filepath, density, scale3d) self.framecom = Rigid.Frame() self.framecom.rotation = info.inertia_rotation self.framecom.translation = info.com self.frame = Rigid.Frame(offset) * self.framecom self.dofs = self.frame.insert( self.node, name = 'dofs' ) self.mass = self.node.createObject('RigidMass', template = 'Rigid', name = 'mass', mass = info.mass, inertia = concat(info.diagonal_inertia.tolist()), inertia_forces = inertia_forces )
def addOffset(self, name, offset=[0, 0, 0, 0, 0, 0, 1], index=0): ## adding a relative offset to the rigid body (e.g. used as a joint location) # @warning the translation due to the center of mass offset is automatically removed. If necessary a function without this mecanism could be added return RigidBody.Offset(self.node, name, (self.framecom.inv() * Rigid.Frame(offset)).offset(), index)
def __init__(self, node, name): self.node = node.createChild(name) # node self.dofs = 0 # dofs self.mass = 0 # mass self.frame = Rigid.Frame() self.framecom = Rigid.Frame()