WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 01-27-2009, 12:24 AM
AlyssaK AlyssaK is offline
Join Date: Dec 2006
Posts: 16

Hi all,

I'm looking at integrating the wiimote into an environment created in vizard.

I've looked at the documentation in help, still relatively new to python and vizard apologies

I have a few questions, I was previously using viz.pick to find out which object the mouse is pointing towards. I'm now using a pointer as demonstrated in the documentation:

pointer = viz.addTextQuad(viz.SCREEN, texture=viz.add('arrow.tif'))


I need to select an object how would i achieve this without using viz.pick?

I have thought about using the arrow keys to navigate similar to the below code using the arrow keys of the keyboard
vizact.whilekeydown(viz.KEY_LEFT, viz.rotate, viz.BODY_ORI, -ROTATION_INC, 0, 0)

I have got this far thinking of creating a seperate method for each button

vizact.onsensordown(wiimote,wii.BUTTON_LEFT,func,a rgs)

I'm not sure where to go from here.

I look forward to hearing your opinions on how to approach this.

Reply With Quote
Old 01-27-2009, 09:42 PM
Jeff Jeff is offline
WorldViz Team Member
Join Date: Aug 2008
Posts: 2,465
try using the viz.screentoworld function to get a line that you can use to call viz.intersect. This code should let you know if the pointer is in line with an object

def FireLine():
	line = viz.screentoworld(pointer.getPosition())
	dir = viz.Vector(line.dir)
	begin = line.begin
	end = line.begin + dir
	info = viz.intersect(begin,end)
	if info.valid:
		print "intersected"

Reply With Quote
Old 05-11-2010, 11:20 PM
Darkmax Darkmax is offline
Join Date: Feb 2010
Posts: 108
I found this code to implement my cursor with wii in my vr and it works great, but just with the first scene cause, i have 4 world each in a scene and i'm trying to implement this on the four scenes but just its working with the first.

i searched on the documentation and forums, and i cant find how to tell vizard to generate a line on the second world? for example to check if something colliding between the line but on the scene 2 not in the first one
Reply With Quote
Old 05-13-2010, 12:32 PM
JimC JimC is offline
Join Date: Jun 2009
Posts: 42
Have you tried passing all=True to viz.intersect()?
Reply With Quote
Old 05-13-2010, 08:23 PM
Darkmax Darkmax is offline
Join Date: Feb 2010
Posts: 108

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
Reply With Quote
Old 05-13-2010, 08:40 PM
Darkmax Darkmax is offline
Join Date: Feb 2010
Posts: 108
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

import viz


#Disable Mouse

#Add Box at position 0,2,4
box = viz.add("box.wrl")

#Add Sphere at position 0.7,2,5
sphere = viz.add("ball.wrl",scene=2)

#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):

#Make a line and check intersections
def FireLine():
	line = viz.screentoworld(pointer.getPosition())
	dir = viz.Vector(line.dir)
	begin = line.begin
	end = line.begin + dir
	if viz.MainView.getScene() == viz.Scene1:
		info = viz.intersect(begin,end)
		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"
		print "not intersected"

vizact.onkeydown(" ",FireLine)

#Change between scenes
def switchScene(key):
	if key is "1":
	elif key is "2":
Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange Wii Mote error... shivanangel Vizard 8 02-18-2009 12:32 PM
vizinfo + wiimote ? djdesmangles Vizard 6 10-22-2008 02:18 PM
Sending sound to Wiimote ? djdesmangles Vizard 1 07-31-2008 11:26 AM
wiimote and sensor bar masaki Vizard 1 03-06-2008 03:07 PM

All times are GMT -7. The time now is 08:05 PM.

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