WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1  
Old 06-11-2015, 06:26 AM
Madzar Madzar is offline
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 = 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.
Reply With Quote
  #2  
Old 06-15-2015, 04:36 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Please post the simplest Vizard code that reproduces the issue.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Jump

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


All times are GMT -7. The time now is 07:33 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC