View Single Post
  #2  
Old 04-08-2014, 07:05 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
First of all, the next time you post your code, put code tags around your code so that indentation is preserved (which is essential for python code). You can do so by copy-pasting the code in the message field, selecting the code, and clicking the # symbol in the message tools. This way, other people can just take the code and run it, without having to figure out the indentation themselves. The chance that you get a timely response increases by doing so.

Second, I noticed that you posted the same question in a different (unrelated) thread. As bad as you would like to get help, there is no need to re-post the same question in a different thread, and especially not in an unrelated thread.

Third, your problem was that with every collision, a new textScreen variable was added, so they got layered instead of changed. I made a global variable for the collision function to solve the problem. Have a look at the manual of Vizard at http://s3.worldviz.com/pdf/Vizard%20...0Book%20R4.pdf. It describes very fundamental parts of Vizard, like the ones you're struggling with.

Code:
import viz
import vizact
viz.phys.enable()
viz.setMultiSample(4)
viz.fov(60)
viz.go()
male = viz.addAvatar('vcc_male.cfg')
male.scale(3,3,3)
ground = viz.add('tut_ground.wrl')
ground.collidePlane()
box = viz.add('box.wrl',scale=[2,2,2],pos=(0,0,5),color = viz.BLUE)
box.collideBox()
box.disable(viz.DYNAMICS)

env=viz.add(viz.ENVIRONMENT_MAP,'sky.jpg')
dome = viz.add('skydome.dlc')
dome.texture(env) 
box1 = viz.add('box.wrl',scale=[1.5,1.5,1.5],pos=(0,0,15),color = viz.RED)
box1.collideBox()
box1.disable(viz.DYNAMICS)

box2 = viz.add('box.wrl',scale=[1.5,1.5,1.5],pos=(-10,0,0),color = viz.RED)
box2.collideBox()
box2.disable(viz.DYNAMICS)

box3 = viz.add('box.wrl',scale=[1.5,1.5,1.5],pos=(-20,0,0),color = viz.RED)
box3.collideBox()
box3.disable(viz.DYNAMICS)

rHandBox = viz.add('box.wrl',scale=[1,1,1])
rHandBox.collideBox()
rHandBox.disable(viz.DYNAMICS)
rHandBox.enable(viz.COLLIDE_NOTIFY)
rHandLink = viz.link( male.getBone('Bip01 R Foot') , rHandBox )
#tweak the position of the box to cover the hand
rHandLink.preTrans([0.05,-0.5,0])

global textScreen
textScreen = viz.addText('Press a',parent=viz.ORTHO,pos=[400,500,0],fontSize=50) 
textScreen.visible(viz.OFF)

def onCollideBegin(g):
	global textScreen
	if g.obj1 == rHandBox:
		print 'collided'
	if g.obj2 == box:
		box.color(viz.RED)
		textScreen.message('santhosh')
		textScreen.visible(viz.ON)
	if g.obj2 == box1:
		box1.color(viz.BLUE)
		textScreen.message('sujith')
		textScreen.message
	if g.obj2 == box2:
		box2.color(viz.BLUE)
		textScreen = viz.addText('Press c',parent=viz.ORTHO,pos=[100,0,0],fontSize=50)
	if g.obj2 == box3:
		box3.color(viz.BLUE)
		textScreen = viz.addText('Press r',parent=viz.ORTHO,pos=[400,200,0],fontSize=50) 
viz.callback(viz.COLLIDE_BEGIN_EVENT,onCollideBegin)

def wukavatar(): 
	walk1 = vizact.walkTo([0,0,5])
	male.addAction(walk1)

vizact.onkeydown('w',wukavatar)

def walkAvatars():
	walk2 = vizact.walkTo([0,0,15])
	male.addAction(walk2)

vizact.onkeydown('c',walkAvatars)
Reply With Quote