WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-12-2006, 06:52 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I can't replicate your problem. I downloaded your model and made the thickness of the wall to 1.0. I then setup a timer that would perform a 180 degree sweep of intersection tests based on the current view position/orientation. I spent a minute navigating through the maze and never got a missed intersection. Here's the script I used to test it out:
Code:
import viz
import math
viz.go()

wall = viz.add('wall_thick.wrl')
wall.collideMesh()
wall.disable(viz.DYNAMICS)

viz.MainView.translate(10.5,1.3,-21.0)

def SweepIntersection():

	#Get begin point for intersection test
	begin = viz.MainView.getPosition()
	bx = begin[0]
	by = begin[1]
	bz = begin[2]
	
	#Get point 100 units ahead of viewpoint
	forward = viz.Vector(viz.MainView.getMatrix().getForward(),length=100)
	px = forward[0]
	pz = forward[2]
	
	for deg in range(-90,90):
		
		#Rotate ahead point by deg (Assume no pitch/roll)
		rad = viz.radians(deg)
		x = math.cos(rad)*px - math.sin(rad)*pz 
		z = math.sin(rad)*px + math.cos(rad)*pz
		
		#Calculate end point
		ex = bx + x
		ez = bz + z
		
		#Perform intersection
		info = viz.phys.intersectLine(begin,(ex,by,ez))
		
		#Check if intersection is not valid
		if not info.valid:
			print 'NO INTERSECTION'

vizact.ontimer(0,SweepIntersection)
Does this problem only occur under certain conditions or is it pretty much random?
Reply With Quote
  #2  
Old 09-12-2006, 08:34 PM
pbeeson pbeeson is offline
Member
 
Join Date: Aug 2006
Posts: 31
Here is code that works with the Test.wrl I posted earlier. The view is at an angle to the hallway, so a line straight ahead should intersect the wall which is 4.3 meters away. But, this particular line misses the intersection with the closest wall and intersects another wall in the environment (> 10 meters away).

This shows the different results sometimes returned by viz.phys.intersectLine() and viz.intersect().

Code:
import viz, math

viz.go()

env = viz.add('Test.wrl')
env.collidemesh()
env.disable(viz.DYNAMICS)

start_pos=[10.5, 1.3, -21.43391, 23.975]

view=viz.get(viz.MAIN_VIEWPOINT)
view.translate(start_pos[0], start_pos[1], start_pos[2])
view.rotate(0,1,0,start_pos[3], viz.BODY_ORI,viz.ABSOLUTE)

def dist(x1,y1,x2,y2):
    return math.sqrt(pow(x1-x2,2)+pow(y1-y2,2))

def timerCallback(num): 
    end_pos=[start_pos[0]+100*math.sin(start_pos[3]*math.pi/180),
             start_pos[1],
             start_pos[2]+100*math.cos(start_pos[3]*math.pi/180)]
    inters_obj = viz.phys.intersectLine(start_pos[0:3], end_pos)
    print inters_obj.intersectPoint
    print dist(inters_obj.intersectPoint[0],inters_obj.intersectPoint[2],
               start_pos[0],start_pos[2])
    inters_obj = viz.intersect(start_pos[0:3], end_pos)
    print ''
    print inters_obj.intersectPoint
    print dist(inters_obj.intersectPoint[0],inters_obj.intersectPoint[2],
               start_pos[0],start_pos[2])
    print '\n\n'

    

viz.callback(viz.TIMER_EVENT, timerCallback)
viz.starttimer(1, 1, -1)

Last edited by pbeeson; 09-13-2006 at 07:26 AM.
Reply With Quote
  #3  
Old 09-13-2006, 09:33 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I see now, at first I thought the problem was that no intersections were being reported, but the problem is that it doesn't return the closest intersection. Thanks for the test script, the problem should be fixed now.
Reply With Quote
  #4  
Old 09-13-2006, 09:51 AM
pbeeson pbeeson is offline
Member
 
Join Date: Aug 2006
Posts: 31
Quote:
Originally Posted by farshizzo
I see now, at first I thought the problem was that no intersections were being reported, but the problem is that it doesn't return the closest intersection. Thanks for the test script, the problem should be fixed now.
Any way I can get my hands on the fixed code. For "testing" purposes.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 04:18 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC