View Single Post
  #36  
Old 03-30-2006, 01:07 PM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
Earilier in this forum, when we discussed the crosshair, you mentioned that we shouldn't be using objects that are attached to the screen when using stereo. I spoke to Mattias this weekend at the VR conference in Alexandria, VA and he mentioned that if we use a 3d object, we would probably be able to fix the problem of the bullets (mentioned in above posts) without having to change the IPD. Is this the case. Is there some way of making a "3d crosshair" that will accurately point to where the bullet would go? If so, do you have any ideas on how this can be implemented? I was thinking of making a vector that would match the vector of the bullet and place an icon (crosshair) at some point on the vector, in 3d, to show an aiming point. How does this idea sound? Can it be done? Please help.

Below is the code I have for the bullet so far.
Code:
def shootBullet():
	global nextBullet
	#find the next available ball to shoot
	bullet = bullets[nextBullet]
	nextBullet = (nextBullet + 1) % NUM_BULLETS
	#Calculate the vector of the ball based on the mouse position
	pos = viz.mousepos()
	bulletvector = viz.screentoworld(pos[0]+0.25,pos[1]) #Need to account for stereo
	bullet.vector = viz.Vector(bulletvector[3]-bulletvector[0],bulletvector[4]-bulletvector[1],bulletvector[5]-bulletvector[2])
	bullet.vector.normalize()
	bullet.vector *= BULLET_SPEED
	
	#translate the bullet to the head position
	bullet.translate(viz.get(viz.HEAD_POS))
	
	#make the bullet visible
	bullet.visible(viz.ON)
	
	#mark the bullet as active
	bullet.active = 1

def MoveBullet(bullet,elapsed):
	global avatarsHit
	#get the bullet's current position
	pos = bullet.get(viz.POSITION)
	
	#calculate the balls future position based on it's velocity
	futurePos = pos + (bullet.vector * elapsed)
	
	#Check if bullet intersected with anything
	info = viz.intersect(pos,futurePos)
	if info.intersected:
		avatarsHit = avatarsHit + 1
		print 'Avatars hit: ', avatarsHit
		print 'intersect point is',info.intersectPoint
		if info.object in avatars:
			WaitThenFreeze = vizact.sequence( vizact.waittime(info.object.getduration(7)-0.005), vizact.speed_node(0) )
			info.object.execute(7)
			info.object.clear(viz.ALL)
			info.object.clear(viz.CURRENT_ACTION)
			info.object.add(WaitThenFreeze) #Add the action to the avatar
			RemoveAvatarAction = vizact.call(RemoveAvatar,info.object)
			info.object.add(RemoveAvatarAction) #Add action to remove avatar

		bullet.visible(0)
		bullet.active = 0
	
	#Update balls positions
	bullet.translate(futurePos.get())
Reply With Quote