WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #11  
Old 10-19-2016, 05:12 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Quote:
I try to use viz.mainview.pickrect as you suggested but the problem is that it gives me nodes that doesn't mean anything to me like viz.vizchild(18). My question is: if i will change my nodes names in the inspector to meaningful names such as sqaure for square object it will give me meaningful names?
You can check the nodes returned by the pickRect command against the node names defined in the script:

Code:
'''
Press the spacebar to call the pickRect command
'''

import viz
import vizinfo
import vizact
import vizshape

viz.go()

vizinfo.InfoPanel()

#Define pickRect coordinates
LEFT = 0.4
BOTTOM = 0.4
RIGHT = 0.6
TOP = 0.6

viz.move([0,0,-1])

dojo = viz.addChild('dojo.osgb')

pyramid = vizshape.addPyramid(base=(0.2,0.2),height=0.2,pos=[-0.5,1.7,1],alpha=0.7)
torus = vizshape.addTorus(radius=0.1,tubeRadius=0.015,axis=vizshape.AXIS_X, pos=[0,1.7,1])
box = vizshape.addCube(size=0.1, pos=[0.5,1.7,1],alpha=0.8)
pyramid.texture(viz.addTexture('images/tile_slate.jpg'))
torus.texture(viz.addTexture('images/tile_wood.jpg'))

# Visualize the area used by the pick operation
viz.startLayer(viz.LINE_LOOP)
viz.vertex([LEFT, BOTTOM, 0])
viz.vertex([LEFT, TOP, 0])
viz.vertex([RIGHT, TOP, 0])
viz.vertex([RIGHT, BOTTOM, 0])
rectangle = viz.endLayer(parent=viz.SCREEN)
rectangle.alpha(.8)

def pickNodes():

	# Get all nodes within the rectangle
	picked = viz.MainWindow.pickRect([LEFT,BOTTOM,RIGHT,TOP])
	for node in picked:
		if node == pyramid:
			print 'pyramid picked'
		elif node == torus:
			print 'torus picked'
		elif node == box:
			print 'box picked'
			
vizact.onkeydown(' ',pickNodes)
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
getPosition and getEuler using oculus with xbox or keyboard bbb Vizard 3 01-13-2016 07:52 AM
MainView and getEuler shivanangel Vizard 1 01-20-2012 11:31 AM
Problem with getEuler and setEuler Sandro Holzer Vizard 6 10-21-2008 06:01 AM


All times are GMT -7. The time now is 02:31 PM.


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