WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Help with applying force (https://forum.worldviz.com/showthread.php?t=5376)

 Madzar 06-11-2015 06:26 AM

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)```
I put the support like this:

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 try to scale nogica1 or nogica2 it just goes crazy. Since i dont know how scaling works. I tried looking in help section, but its like alien to me. :(

When i tried aplying the force with
Code:

`teg.applyForce(dir=[-10*tegForce.get(),0,0],duration=0.1)`
it does nothing. If someone could help me with this, i would be soooooo grateful. :D

 Jeff 06-15-2015 04:36 PM

Please post the simplest Vizard code that reproduces the issue.

 All times are GMT -7. The time now is 10:05 AM.