![]() |
|
|
|
#1
|
|||
|
|||
|
Thanks for your help JimC, but this throws me all the intersections with the line but just in scene 1.
Something that i don't know how to use it because if i print this, is a list with this: [<viz.Intersect object at 0x02646390>, <viz.Intersect object at 0x026463D0>] I don't know why to elements if just intersect with one element(maybe cause it was cube,and intersect with to faces of the cube the line), but how i use this information in hexadecimal? But returning with my original question i found the solution, something that i didn't check before because i was searching the solution on viz.screentoworld but is with <scene>.intersect this check if something intersect on the scene that you specify
|
|
#2
|
|||
|
|||
|
this is a example of the solution if some want to know, i make it without the wiimote because i didn't have my wiimote at the moment
Code:
import viz
viz.go()
#Disable Mouse
viz.mouse.setOverride(viz.ON)
#Add Box at position 0,2,4
box = viz.add("box.wrl")
box.setPosition(0,2,4)
#Add Sphere at position 0.7,2,5
sphere = viz.add("ball.wrl",scene=2)
sphere.setPosition(0.7,2,5)
#2D crosshair
pointer = viz.addTexQuad(viz.SCREEN,texture=viz.addTexture("crosshair.png"))
pointer2 = viz.addTexQuad(viz.SCREEN,texture=viz.addTexture("crosshair.png"),scene=2)
#Move the pointer
def mueveCursor(e):
pointer.setPosition(e.x,e.y)
pointer2.setPosition(e.x,e.y)
viz.callback(viz.MOUSE_MOVE_EVENT,mueveCursor)
#Make a line and check intersections
def FireLine():
line = viz.screentoworld(pointer.getPosition())
dir = viz.Vector(line.dir)
dir.setLength(200)
begin = line.begin
end = line.begin + dir
if viz.MainView.getScene() == viz.Scene1:
info = viz.intersect(begin,end)
else:
info = viz.Scene2.intersect(begin,end)
if info.valid and info.object == box:
print "intersected with the box"
elif info.valid and info.object == sphere:
print "intersected with the sphere"
else:
print "not intersected"
vizact.onkeydown(" ",FireLine)
#Change between scenes
def switchScene(key):
if key is "1":
viz.scene(1)
elif key is "2":
viz.scene(2)
viz.callback(viz.KEYDOWN_EVENT,switchScene)
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Strange Wii Mote error... | shivanangel | Vizard | 8 | 02-18-2009 01:32 PM |
| vizinfo + wiimote ? | djdesmangles | Vizard | 6 | 10-22-2008 03:18 PM |
| Sending sound to Wiimote ? | djdesmangles | Vizard | 1 | 07-31-2008 12:26 PM |
| wiimote and sensor bar | masaki | Vizard | 1 | 03-06-2008 04:07 PM |