View Single Post
  #2  
Old 05-08-2012, 11:26 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
It looks for two lists:

lineBegin
[x,y,z] position of begin point of intersection line.

lineEnd
[x,y,z] position of end point of intersection line.

In the following example code a ball is placed at the intersection point on the quad in the direction the user is looking:
Code:
import viz
import vizact
import vizmat
viz.go()

dojo = viz.addChild('dojo.osgb')

import vizshape
quad = vizshape.addQuad(pos=[0,1.5,2],color=viz.SKYBLUE)
ball = vizshape.addSphere(radius=0.02,color=viz.ORANGE)

def showIntersection():
	lineBegin = viz.MainView.getPosition()
	vector = viz.MainView.getMatrix().getForward()
	lineEnd = vizmat.MoveAlongVector(lineBegin,vector,10)
	i = quad.intersect(lineBegin,lineEnd)
	point = i.point
	ball.setPosition(point)
	
vizact.onkeydown(' ',showIntersection)
Reply With Quote