I want to use the FPrismaticJoint in my python mode processing sketch, but when i use setAxis() of the Joint, it never works. I want the Joint to move horizontally。
add_library('fisica')
from my_func import *
def setup():
global world
size(800, 600)
Fisica.init(this)
world = FWorld()
world.setEdges()
add_bodys(world)
def draw():
background(255)
world.draw()
world.step()
def add_bodys(w):
hand_l = FCircle(20)
set_fbody(hand_l, pos=(200, 400))
hand_r = FCircle(20)
set_fbody(hand_r, pos=(600, 400))
board = FBox(100, 10)
set_fbody(board, pos=(400, 500))
ghost = FCircle(20)
set_fbody(ghost, pos=(30, 30))
ghost.setStatic(True)
joint_l = FDistanceJoint(hand_l, board)
joint_l.setFrequency(2)
joint_l.setAnchor2(-50, 0)
joint_r = FDistanceJoint(hand_r, board)
joint_r.setFrequency(2)
joint_r.setAnchor2(50, 0)
ding_l = FPrismaticJoint(hand_l, ghost)
ding_l.setAxis(0, 1)
ding_l.setAnchor(100, 400)
# ding_l.setDrawable(False)
ding_r = FPrismaticJoint(hand_r, ghost)
ding_r.setAxis(1, 0)
ding_r.setAnchor(500, 400)
ding_r.setDrawable(False)
[world.add(x) for x in (hand_l, hand_r, board,
ghost, joint_l, joint_r, ding_l, ding_r)]
and this is another file(my_func.py):
def set_fbody(fbody, pos=None, v=None, f=None, dens=None, damp=None,
rest=None, fric=None, stroke=None, fill=None, img=None):
if pos:
fbody.setPosition(*pos)
if v:
fbody.setVelocity(*v)
if f:
fbody.setForce(*f)
if dens:
fbody.setDensity(dens)
if damp:
fbody.setDamping(damp)
if rest:
fbody.setRestitution(rest)
if fric:
fbody.setFriction(fric)
if stroke:
fbody.setStroke(*stroke)
if fill:
fbody.setFill(*fill)
if img:
fbody.attachImage(img)