WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-27-2009, 01:24 AM
AlyssaK AlyssaK is offline
Member
 
Join Date: Dec 2006
Posts: 16
wiimote

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'))

etc..

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.

Thanks
Reply With Quote
  #2  
Old 01-27-2009, 10:42 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,459
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

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

vizact.onsensordown(wiimote,wii.BUTTON_B,FireLine)
Reply With Quote
  #3  
Old 05-12-2010, 12:20 AM
Darkmax Darkmax is offline
Member
 
Join Date: Feb 2010
Posts: 108
Hi,
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
  #4  
Old 05-13-2010, 01:32 PM
JimC JimC is offline
Member
 
Join Date: Jun 2009
Posts: 42
Have you tried passing all=True to viz.intersect()?
Reply With Quote
  #5  
Old 05-13-2010, 09:23 PM
Darkmax Darkmax is offline
Member
 
Join Date: Feb 2010
Posts: 108
Cool

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
  #6  
Old 05-13-2010, 09:40 PM
Darkmax Darkmax is offline
Member
 
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

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)
Reply With Quote
Reply

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 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


All times are GMT -7. The time now is 10:50 PM.


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