View Single Post
  #1  
Old 05-12-2017, 09:43 AM
engelskri3ger engelskri3ger is offline
Member
 
Join Date: May 2017
Posts: 1
Using 2 slider joints to move on a plane

Hey there,

I'm working on a project where I need to use a portalcrane where the mounted object is moved by grabbing it with the vizconnect grabber and the parts of the crane should move too. I want to use the built-in physics engine, so i tried to use multiple joints to connect the crane parts, but I didn't figure out yet, how I could use 2 slider joints to get the crane moving in the room.
Is there a way to do this? This is an example code I use for testing purposes:
Code:
# -----------------------------------------------------------------------
# Options

CYCLES_PER_SEC = 0.05  # Frames
viz.setMultiSample(4)  # Multisampling
viz.setOption('viz.max_frame_rate', 60)  # Avoid flickering
viz.vsync(viz.OFF)  # V-Sync
viz.collision(viz.ON)  # Viewport Collision
viz.phys.enable()  # Physics Simulation
viz.setOption('viz.model.cache', viz.CACHE_CLONE)
vizconnect.go(r'../vizconnect_files/keyboard.py') # Standard Vizconnect Keyboard Setting

# -----------------------------------------------------------------------
# Loading of Objects
grabber = vizconnect.getRawTool('grabber')
position = [5.0, 0, 0]
room = viz.add('lab.osgb')  # Room is loaded
room.collideMesh()  # Room gets Collision

box = vizshape.addBox(size=[12.8, 0.2, 0.2], pos=[0, 5.5, position[2]])
box.collideBox()
box_joint = viz.phys.addSliderJoint(box, None, pos=[0, 5.5, position[2]], axis0=(0, 0, 1))
box_joint.setAxisLimit(0, -6, 6)  # Limit sliding distance
box_joint.setAxisBounce(0, 0)  # Change end bounce properties

rope = vizshape.addBox(size=[0.075, 3, 0.075], pos=[position[0], 3.9, position[2]])
rope.collideBox()
rope_joint = viz.phys.addSliderJoint(rope, None, pos=[position[0], 3.9, position[2]], axis0=(1, 0, 0))
rope_joint.setAxisLimit(0, -12.8 / 2 - position[0],12.8 / 2 - position[0]) # Limit sliding distance
rope_joint.setAxisBounce(0, 0)  # Change end bounce properties

# rope_box_joint = viz.phys.addFixedJoint(box, rope)

grabber.addItems([rope])
Reply With Quote