WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #21  
Old 04-01-2014, 01:53 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
The code did what it was supposed to do. Collision was detected when walking to (0,0,5), but you did not tell Vizard to do anything. Now it prints 'collision detected!' whenever the rHandBox collides with something. In your original code you had two identical onCollideBegin functions, one of which was obsolete. See the code below.
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])

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)

def onCollideBegin(e):
	if e.obj1 == rHandBox:
		print 'collision detected!'
	if e.obj2 == box1:
		box1.color(viz.BLUE)
		textScreen = viz.addText('Press a',parent=viz.ORTHO,pos=[400,500,0],fontSize=50)

viz.callback(viz.COLLIDE_BEGIN_EVENT,onCollideBegin)
Reply With Quote
 


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


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


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