View Single Post
  #20  
Old 03-31-2014, 01:34 AM
SUJITH_KJ SUJITH_KJ is offline
Member
 
Join Date: Mar 2014
Posts: 7
hey... in my following code, collision is not detected wen the avatar walks to (0,0,5) wen i press the 'w' key. After that wen i press 'c' key the avatar walks to (0,0,15) and collision is detected this time. May i know why this is happening. Thanks a lot...


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 onCollideBegin(g):
if g.obj1 == rHandBox:
if g.obj2 == box:
box.color(viz.RED)
textScreen = viz.addText('Press a',parent=viz.ORTHO,pos=[400,500,0],fontSize=50)
viz.callback(viz.COLLIDE_BEGIN_EVENT,onCollideBegi n)



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



def onCollideBegin(e):
if e.obj1 == rHandBox:
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,onCollideBegi n)
Reply With Quote