![]() |
|
#1
|
|||
|
|||
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) |
#2
|
|||
|
|||
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. |
#3
|
|||
|
|||
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.
|
#4
|
|||
|
|||
Quote:
|
![]() |
|
|