WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-09-2006, 09:03 AM
Geoffrey Geoffrey is offline
Member
 
Join Date: Feb 2006
Posts: 8
retrieve Object names

Hello,

I want to know wich object is under given screencoordinates.
(In this test-case these are the mousecoordinates..)
How can I access the name of the object ??

Code:
import viz

viz.go()

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)

def mijntimer(num):
	line = viz.screentoworld(viz.mousepos())
	begin = line[:3]
	end = line[3:]
	info = viz.intersect(begin,end)
	if info.intersected:
		print 'you are over object : ', info.object.id
		#mijntest = info.object
		#mijntest.Name() ...??
		#I want the name of the object.. Cube1, Cube2 or Cube3
		
viz.callback(viz.TIMER_EVENT,mijntimer)
viz.starttimer(0,0.5,viz.FOREVER)
for now the output is :

Code:
Loading File: theCube.ac
Loading File: theCube.ac
Loading File: theCube.ac
** Load Time: 0.38 seconds
you are over object :  0
you are over object :  1
you are over object :  2
you are over object :  2
you are over object :  1
you are over object :  2
I would like it to be :
you are over object : Cube1
you are over object : Cube2
you are over object : Cube3

can anyone help me ?
thanks,

geoffrey.

btw : I attached the file theCube.ac but changed the extention to txt (otherwise I could not attach it)
Attached Files
File Type: txt theCube.txt (2.0 KB, 5118 views)
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


All times are GMT -7. The time now is 07:17 AM.


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