In [1]:
import sys
sys.path.append('../build')
import numpy as np
import libry as ry
from time import sleep
In [2]:
C = ry.Config()
D = C.view()
In [3]:
C.addFrame('world')
block = C.addObject(name='block', shape=ry.ST.ssBox, size=[.2,.3,.5,.02], pos=[.0,.0,.5], color=[1,0,0])
block.setMass(1.);
C.addObject('finger', shape=ry.ST.ssBox, size=[.3, .1, .1, .02], color=[1.,1.,1.,.3], parent='world', pos=[1., 0., .45])
Out[3]:
In [4]:
# this fails, if the lib was not compiled with bullet (comment #BULLET=0 in config.mk)
P=C.physx()
#P=C.bullet()
In [5]:
x = C.getFrameState('finger')
for i in range(1,100):
x[0] -= .01
C.setFrameState(x, ['finger'])
P.step(C)
sleep(0.01)
In [6]:
V = P.getState(C)
X = C.getFrameState()
In [10]:
#run this cell multiple times! It resets bullet always to the same state
C.setFrameState(X)
x = C.getFrameState('finger')
P.setState(C,V)
for i in range(1,100):
x[0] -= .01
C.setFrameState(x, ['finger'])
P.step(C)
sleep(0.01)
In [8]:
P=0
D=0
C=0
In [ ]: