![]() |
|
|
|
#1
|
|||
|
|||
|
Is there a collision shape defined for the wall, probably with collideMesh()? viz.phys.intersectLine() only intersects with VizPhysicsShapes, not model geometry.
__________________
Paul Elliott WorldViz LLC |
|
#2
|
|||
|
|||
|
Quote:
|
|
#3
|
|||
|
|||
|
Do these missed intersections occur near a triangle boundary?
|
|
#4
|
|||
|
|||
|
Quote:
Last edited by pbeeson; 09-12-2006 at 04:08 PM. |
|
#5
|
|||
|
|||
|
Quote:
Attached is the .wrl file of the environment I am using (I changed it to .txt to get it to upload). If you search and replace 0.01, you can change the thickness of walls. I start at (10.5,1.3,-21.0) with an orientation of 0.0. The rays you see in the left image that go through the wall are at about 12.25, 1.3, -17.5 (the thing in the middle in the picture is an avatar). Hope this helps. Last edited by pbeeson; 09-12-2006 at 04:56 PM. |
|
#6
|
|||
|
|||
|
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)
|
|
#7
|
|||
|
|||
|
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. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|