View Single Post
  #5  
Old 09-13-2006, 02:35 AM
JvdBosch JvdBosch is offline
Member
 
Join Date: Sep 2006
Posts: 36
I'm going mad....

I added a collidemesh to the scene objects, but I'm not sure that that went correctly, because I have a lot of objects with the same name and Vizard does not have a wildcard option to search all the children within a scene, based upon their name...
But with one object I'm sure about that there's only one (the edge of the scene, named 'Layer:Bak'), the &^%& avatars just walk through, without generating a collision event....
And sometimes they generate a collision event, where there are no objects...
I'm at a loss...

Any bright ideas about what I am doing wrong?
I'm using Vizard R3 Beta 2 (maybe that helps)

LINK TO IVE FILE
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()

# Set collision parameters for scene objects
MallNames = ['Layer:Obstacle','Layer:Bak','Layer:VolBlokGevel','Layer:lm1','Layer:lm2','Layer:lm3','Layer:lm4','Layer:lm5','Layer:lm6','Layer:lm7','Layer:lm8','Layer:lm9','Layer:lm10']
MallObjects= []
for i in range(0,len(MallNames)):
	Bigobj = mall.getchild(MallNames[i])
	Bigobj.collideMesh()
	Bigobj.disable(viz.DYNAMICS)
	MallObjects.append(Bigobj) #APPEND AND COLLIDEMESH OBJECTS FROM SCENE

# 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,1]] # 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 = 0.5 + 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 in MallObjects:
		print "avatar-object collision"
		e.obj1.endAction(pool=0)
		
viz.callback( viz.COLLIDE_BEGIN_EVENT, onCollide )

Last edited by JvdBosch; 09-13-2006 at 07:31 AM.
Reply With Quote