View Single Post
  #8  
Old 09-13-2006, 01:32 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
I have experimented with your script and model. There seems to be invisible physics shapes in your model.

Instead of calling collideMesh on the child objects I just called it on the root "mall" node. This seems to work well. Would this be a solution for you?

Code:
import viz
import random
viz.go()

# Set physicss
viz.phys.enable()
viz.phys.setGravity( 0, 0, 0 )

# Set start position
viz.MainView.setPosition([20,2.7,20])
viz.clip(0.1,10000)
viz.fov(70)
viz.eyeheight(1.6)
viz.stepsize(0.3)

# add sky
env = viz.add(viz.ENVIRONMENT_MAP,'temp0000.jpg')
sky = viz.add('skydome.dlc')
sky.texture(env)

# disable headlight
viz.disable(viz.LIGHT0)

# add our light
light=viz.addLight()
light.position(0,20,0)
light.intensity(1)
light.ambient(.5,.5,.5)
light.enable()

mall = viz.add( 'test.ive' )
mall.collideMesh()
mall.disable( viz.DYNAMICS )

# place avatars
avatars = []
#spawn = [[120,29,1],[60,67,1],[68,60,5],[109,70,5],[52,45,9],[105,21,9],[81,69,13],[92,13,13],[36,45,17],[91,38,17],[98,43,21],[71,85,21],[61,29,25],[61,74,25],[103,62,25],[112,91,25],[43,8,29],[76,63,29],[89,22,33],[74,85,33],[71,67,37],[117,36,37]]
spawn = [[20,30,2]] # TEST LOCATION
for i in range(0,10): #number of avatars
	mf = random.choice([0, 1]) # Random Male/Female
	location = random.choice(spawn)	# Random pick spawn position
	rotation = random.choice([0,45,90,135,180,225,270,315]) #Random starting rotation
	avatarspeed = 10 + random.random() # random speed
	if mf==1: 
		avatar = viz.add('male.cfg')
	else:
		avatar = viz.add('female.cfg')
	avatar.translate(location[0]+2*random.random()-1,location[2],location[1]+2*random.random()-1) #SPAWN
	avatar.rotate(0,1,0,rotation) #ROTATE
	avatar.speed(avatarspeed) # Set speed
	vector = avatar.get(viz.LOOK) # Get directional vector
	avatar.collideBox()	#Physics
	avatar.disable(viz.DYNAMICS) #Physics
	avatar.enable(viz.COLLIDE_NOTIFY) #Physics
	avatar.addAction( vizact.walkto(location[0] + vector[0]*60,location[2],location[1] +vector[2]*60) ) #START WALKING
	avatars.append(avatar) #append avatar to array

# Collision-routine
def onCollide(e):
	if e.obj2 in avatars:
		print "avatar-avatar collision"
	if e.obj2 == mall:
		print "avatar-object collision"
		e.obj1.endAction(pool=0)
		
viz.callback( viz.COLLIDE_BEGIN_EVENT, onCollide )
__________________
Paul Elliott
WorldViz LLC
Reply With Quote