WorldViz User Forum Help with applying force
 Register FAQ Search Today's Posts Mark Forums Read

#1
06-11-2015, 06:26 AM
 Madzar Member Join Date: Jun 2015 Posts: 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.collidePlane() #Kontrola kolizije (omogucava da se telo ponasa kao cvrsto telo)

daska.collideBox() #Kontrola kolizije (omogucava da se telo ponasa kao cvrsto telo)

#Dodajemo oslonac za klackalicu
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.setScale(3,3,3)
teg.collideBox(density=10)
teg.disable(viz.DYNAMICS)

#Dodajemo kontrateg
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

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.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.setPosition([0.5,0.5,0])
nogica1.collideBox(density=10)
nogica1.disable(viz.DYNAMICS)
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.

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements Vizard Precision Position Tracker (PPT) Plug-in development

 Similar Threads Thread Thread Starter Forum Replies Last Post johnallen Vizard 3 08-19-2014 07:02 AM manueleh Plug-in development 0 09-20-2012 01:22 PM dwaik Vizard 1 03-04-2010 08:47 AM jalvarez Vizard 1 07-08-2008 11:59 AM vDavid Vizard 1 01-14-2005 08:34 PM

All times are GMT -7. The time now is 12:25 AM.