WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1  
Old 02-09-2006, 11:34 AM
Geoffrey Geoffrey is offline
Member
 
Join Date: Feb 2006
Posts: 8
First of all,
thank you for replying that quickly,

what I try to do :

A user will navigate (with a joystick) in a virtual room.
I need to know what he is looking at, an when he is looking at it.

I will get (real-time) data from a pc with an eye tracker.
this data consists of 2D coordinates.

I want to check which object is under those 2D coordinates.
And I want to write this to a file.

I also want to know when, which items are visible for the user.

I dont know yet how the data will need to be saved, but one thing is sure :
I need to be able to know which objects are on the screen and
Which object is under the 2D coordinate at particular time.

this should be written in a file to do datamanipulation with later on.

thank you,
geoffrey.
Reply With Quote
  #2  
Old 02-09-2006, 12:22 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

In this case you will need to create a Vizard node for each object that you want to be viewable by the user. If you have one model file with individually viewable objects, then you need to call getchild on each sub-object to ensure that a Vizard node is created for it.

You might want to create your own class that handles which objects are viewable and detects them for you. I've made a simple version here:
Code:
import viz
viz.go()

class NodeDetector:
	def __init__(self):
		self.__nodes = []
		
	def addNode(self,node,name):
		node.name = name
		self.__nodes.append(node)
		
	def detectNode(self,pos):
		line = viz.screentoworld(pos)
		info = viz.intersect(line[:3],line[3:])
		if info.intersected:
			if info.object in self.__nodes:
				return info.object
		return None

Cube1 = viz.add('theCube.ac')
Cube2 = viz.add('theCube.ac')
Cube3 = viz.add('theCube.ac')

Cube1.translate(-3,0,15)
Cube2.translate(0,0,15)
Cube3.translate(3,0,15)

nd = NodeDetector()
nd.addNode(Cube1,'Cube1')
nd.addNode(Cube2,'Cube2')
nd.addNode(Cube3,'Cube3')

def mijntimer(num):
	node = nd.detectNode(viz.mousepos())
	if node:
		print 'you are over object : ', node.name
		
viz.callback(viz.TIMER_EVENT,mijntimer)
viz.starttimer(0,0.5,viz.FOREVER)
Reply With Quote
  #3  
Old 02-09-2006, 12:53 PM
Geoffrey Geoffrey is offline
Member
 
Join Date: Feb 2006
Posts: 8
Owkay thank you,

and is there any way to automatically know which objects are available in a model file ?

I added another file with 3 cubes in it (Cube1_obj, Cube2_obj an Cube3_obj)
say I load this 'scene-file' in vizard, can I get a list with all the objects in this scene?

geoffrey
Reply With Quote
  #4  
Old 02-09-2006, 12:56 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

As I already mentioned, this feature is not built-in to Vizard, but can be made available with a plugin. Would you like the plug-in to simply return a list of all the unique names of the sub-objects?
Reply With Quote
  #5  
Old 02-09-2006, 01:00 PM
Geoffrey Geoffrey is offline
Member
 
Join Date: Feb 2006
Posts: 8
hello,
well for the moment, this is al that I would need to solve the problem here I guess.

I do not know how to write a plugin..
geoffrey.
Reply With Quote
  #6  
Old 02-09-2006, 01:23 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

I've attached the plugin you need with small sample script showing how to use it. Keep in mind that this will return ALL named nodes of an object. So you should probably come up with a naming convention to signify which nodes you want to actually retrieve. Let me know if you have any problems.
Attached Files
File Type: zip geoffrey.zip (6.2 KB, 13355 views)
Reply With Quote
  #7  
Old 02-09-2006, 01:37 PM
Geoffrey Geoffrey is offline
Member
 
Join Date: Feb 2006
Posts: 8
thanks alot farshizzo !
Ill work a bit with this, and let you know if I have more troubles

thanks again,
geoffrey.
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


All times are GMT -7. The time now is 06:45 AM.


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