#1
|
|||
|
|||
Help with applying force
Hi. I am new to programing in vizard, or programing as a whole. I have an asignment to add support to a ball, and to apply force on the ball, to make her move from from her support. Original program is:
Code:
""" Student: Ognjan Luzanin Simulacija klackalice. Pritisni razmaknicu za resetovanje scene. """ import viz import vizact viz.setMultiSample(4) viz.fov(60) viz.go() viz.phys.setGravity(0,-9.81,0) import vizinfo vizinfo.InfoPanel(align=viz.ALIGN_RIGHT_BOTTOM) #Bojimo pozadinu u svetlo plavu boju viz.clearcolor( 0,.5,1 ) #Onesposobljavamo delovanje sila viz.phys.enable() #Dodajemo podlogu podloga = viz.addChild('tut_ground.wrl') podloga.collidePlane() #Kontrola kolizije (omogucava da se telo ponasa kao cvrsto telo) #Dodajemo dasku za klackalicu daska = viz.addChild('box.wrl') daska.setScale([10,0.3,1]) daska.collideBox() #Kontrola kolizije (omogucava da se telo ponasa kao cvrsto telo) #Dodajemo oslonac za klackalicu oslonac = viz.addChild('tut_cone.wrl') oslonac.setScale([0.5,0.5,0.5]) oslonac.setPosition([0,0.01,1]) oslonac.collideMesh() #Kontrola kolizije (omogucava da se telo ponasa kao cvrsto telo) oslonac.disable( viz.DYNAMICS ) #Iskljucujemo dinamicke sile za oslonac (nece reagovati na dejstvo sila prilikom udara tega i kontratega) #Dodajemo teg teg = viz.addChild('white_ball.wrl') teg.setScale(3,3,3) teg.collideBox(density=10) teg.disable(viz.DYNAMICS) #Dodajemo kontrateg kontrateg = viz.addChild('box.wrl') kontrateg.color(viz.YELLOW) kontrateg.collideBox(density=5) #The high density parameter makes the object heavier #Podesavamo pogled na scenu, tako da sve bude obuhvaceno vidnim poljem viz.MainView.setPosition([0,2,-10]) #Sve elemente scene postavljamo u pocetni polozaj def reset(): daska.reset() #Ponistava prethodno dejstvo svih sila daska.setPosition([0,3,5]) daska.setEuler([0,0,0]) teg.reset() teg.setPosition([4,5,5]) teg.setEuler([0,0,0]) teg.disable(viz.DYNAMICS) kontrateg.reset() kontrateg.setPosition([-4, 9, 5]) kontrateg.setEuler([90,0,0]) kontrateg.disable(viz.DYNAMICS) def start(): teg.enable(viz.DYNAMICS) kontrateg.enable(viz.DYNAMICS) #Resetujemo simulaciju i spremni smo za pocetak rada reset() #Osposobljavamo simulaciju da reaguje na oznacene tastere vizact.onkeydown(' ', reset) vizact.onkeydown('s', start) Code:
#Dodajemo oslonac za teg oslonac1 = viz.addChild('box.wrl') oslonac1.setEuler([90,180,0]) oslonac1.setScale(4,0.5,4) oslonac1.collideBox(density=5) oslonac1.setPosition([5.8,4.45,5]) oslonac1.disable(viz.DYNAMICS) nogica1 = viz.addChild('pole.wrl',parent=oslonac1) nogica1.setPosition([0.5,0.5,0]) nogica1.collideBox(density=10) nogica1.disable(viz.DYNAMICS) nogica2 = viz.addChild('pole.wrl',parent=oslonac1) nogica2.setPosition([-0.5,0.5,0,]) nogica2.collideBox(density=10) nogica2.disable(viz.DYNAMICS) When i tried aplying the force with Code:
teg.applyForce(dir=[-10*tegForce.get(),0,0],duration=0.1) |
#2
|
|||
|
|||
Please post the simplest Vizard code that reproduces the issue.
|
Thread Tools | |
Display Modes | Rate This Thread |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
force screen refresh/update? | johnallen | Vizard | 3 | 08-19-2014 07:02 AM |
How to create AMTI AccuGait force plate plug-in using serial port connection? | manueleh | Plug-in development | 0 | 09-20-2012 01:22 PM |
strange force when applying colliders | dwaik | Vizard | 1 | 03-04-2010 08:47 AM |
Rendering a haptic Force | jalvarez | Vizard | 1 | 07-08-2008 11:59 AM |
Force Feedback Libraries | vDavid | Vizard | 1 | 01-14-2005 08:34 PM |