View Single Post
  #3  
Old 04-23-2015, 09:58 PM
adhocdown adhocdown is offline
Member
 
Join Date: Mar 2015
Posts: 10
I simplified the code as much as I could. It replicates the same problem of glitchy collisions and the problem of 'Collided' calls en masse.

Code:
import viz
import time
import string
import vizact
import vizcam
import random
import oculus
import vizinfo
import vizshape
import vizinput

import viztracker
import vizproximity

viz.go()																				# Run Vizard.


#Flags
isIn = False
inWhat = -1
inWhere = None

# Counters.
revisitCtr = 0


# Arrays.
o_house = []
t_ball  = []
houses  = []

NUM_HOUSES = 24; 

# Detect and add the oculus rift ---------------------------------------------------------- #
hmd = oculus.Rift();
vrpn = viz.add('vrpn7.dle')								#Other code should use tracker number 5
posTracker = vrpn.addTracker('PPT0@WORLDVIZ-PC', 5)

isense = viz.add('intersense.dle')
oriTracker = hmd.getSensor()
oriTracker.reset(viz.RESET_OPERATORS)

if not hmd.getSensor():
	sys.exit('Oculus Rift not detected')
# Check if HMD supports position tracking ----------------------------------------------- #
headTracker = viz.mergeLinkable(posTracker, oriTracker)
supportPositionTracking = hmd.getSensor().getSrcMask() & viz.LINK_POS
if supportPositionTracking:
	# Add camera bounds model
	camera_bounds = hmd.addCameraBounds()
	camera_bounds.visible(False)

	def CheckPositionTracked():
		if hmd.getSensor().getStatus() & oculus.STATUS_POSITION_TRACKED:
			camera_bounds.color(viz.GREEN)
		else:
			camera_bounds.color(viz.RED)
	vizact.onupdate(0, CheckPositionTracked)

# Setup navigation node and link to main view
navigationNode = viz.addGroup()
viewLink = viz.link(navigationNode, viz.MainView)
viewLink.preMultLinkable(hmd.getSensor())

# Apply user profile eye height to view --------------------------------------------------- #
profile = hmd.getProfile()
if profile:
	viewLink.setOffset([0,profile.eyeHeight,0])
else:
	viewLink.setOffset([0,1.8,0])

headlink = viz.link(headTracker, viz.MainView)
headlink.reset(viz.RESET_ORI_RAW)
headlink.postScale([2,1,2])
hmd.window = headlink

vizact.onkeydown('r', oriTracker.reset)

MOVE_SPEED = 2.0
yaw,pitch,roll = headlink.getEuler()
m = viz.Matrix.euler(yaw,0,0)

# Add sensor to self.
manager = vizproximity.Manager()
target = vizproximity.Target(headlink)
manager.addTarget(target)
height = 1.3


# Enable Collision Detection --------------------------------------------------------------#
#viz.MainView.collision( viz.ON )
viz.collision(viz.ON)
viz.MainView.stepsize(3) #this seems to make the rejection twitching less violent


def mycollision(info):
	print 'Collided'
viz.callback(viz.COLLISION_EVENT, mycollision)



# Environment Setup ----------------------------------------------------------------------- #
day = viz.add('sky_day.osgb')
ground = viz.add('tut_ground.wrl')





LOCATIONS = [
	 [1, 0, -5]
	,[-5, 0, 1]
	,[5, 0, 1]
	,[3, 0, 2]
	,[2, 0, 2]
]
	
columns = []

	
# Birdhouse Setup ------------------------------------------------------------------------- #	
def make_a_home():
	col_num = 0
	for pos in LOCATIONS:
		print 'Add a house'
		newCol = viz.addChild('plant.osgb')
		
		#Create collision boxes and link to birdhouses
		colBox = viz.add('box.wrl', scale=[0.5, 8, 0.5])
		colBox.collideBox()

		colBox.disable(viz.DYNAMICS)
		colLink = viz.link( newCol, colBox )
		colBox.disable(viz.RENDERING)
	
		columns.append(newCol)
		
		x_val = pos[0]
		z_val = pos[2]
		print col_num
		print pos[0]
		print pos[2]
		columns[col_num].setPosition([x_val, 0, z_val]) 
		col_num +=1


make_a_home();

Additionally, we tried to turn on collisions with vizconnect, as well. However, the moment we useviz.collision(viz.ON), it disconnects our avatar from MainView. Do you know why this occurs?
Reply With Quote