View Single Post
  #1  
Old 05-13-2008, 05:06 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
Collision of an avatar with a quad

Hi all,

I'm having some problems with a task I'm making. I want to do something when an avatar touches a texquad. Therefore I created the texquad, added a collidebox around it and tested the situation. If I let the avatar touch the texquad in the beginning, something happens, but if I move the texquad 50 cm in front of the avatar and I let the avatar touch the texquad later, nothing happens. My code:
Code:
import viz
#import vizmocap
import random

#viz.go( viz.HMD | viz.FULLSCREEN | viz.STEREO )
viz.go()

viz.phys.enable()

environment = viz.add('gallery.ive')

quad = viz.addTexQuad()
#quad.setPosition(0,1.5,.5) #doesn't work
quad.setPosition(0,1.5,.1) #does work (once)
quad.scale(.25, .25, .25)
quad.collideBox()
quad.color(255,255,255)
quad.enable(viz.COLLIDE_NOTIFY)#object 1 for collision
quad.disable( viz.DYNAMICS )

avatar = viz.add('vcc_female.cfg')
avatar.collideMesh() #object 2 for collision
avatar.disable( viz.DYNAMICS )
#vizmocap.LiveCharacter('192.168.2.103',8050,model=avatar)
viz.MainView.translate(0,1.80,-2)

def onCollide(e):#e.obj1 == quad & e.obj2 == avatar
	if e.obj1.getColor() == [255,255,255]:
		print "white"
		e.obj1.color(viz.GREEN)
	else:
		print "green"

viz.callback( viz.COLLIDE_BEGIN_EVENT, onCollide )
I use the LiveCharacter plugin to move the avatar, but that shouldn't be the problem (I think). What I want is that the callbackfunction is activated every time the avatar collides with the collidebox around the texquad. I.e. green should be printed the second time the texquad is touched. Can somebody help me?
Reply With Quote