Hi,
while working on my user-interface I encountered the following problem:
Picking objects form screen (as in the soccer-example) works fine to apply certain textures to objects (e.g. assigning materials to projectiles...)
But as I want to use them in the user interface I thought about putting them into the screen, which also works fine, but now the picking and assigning is not possible any more.
There maybe two solutions:
1. There is a command to pick objects from the screen...
2. When the user hits the "select material button' I translate the objects to a certain position in the real world that is e.g. 1 m in front of the user and disable mouse-movement until the user selected the material and than hide the objects again (object.visible(False)) and enable mouse-movement again.
To get the position of the user I guess I need something like viz.get(HEAD_POS)
Thank you,
Johannes
P.S. Code-Example for picking off the screen (which does not seem to work)
Code:
import viz
viz.go()
soccerball1 = viz.add('../resources/soccerball.ive',viz.SCREEN)
soccerball2 = viz.add('../resources/soccerball.ive',viz.SCREEN)
soccerball3 = viz.add('../resources/soccerball.ive',viz.SCREEN)
soccerball4 = viz.add('../resources/soccerball.ive',viz.SCREEN)
soccerball1.translate(0.8,0.1)
soccerball2.translate(0.8,0.3)
soccerball3.translate(0.8,0.5)
soccerball4.translate(0.8,0.7)
arrow = viz.add('../resources/arrow.wrl')
arrow.disable(viz.PICKING)
arrow.scale(.1, .1, .1)
#arrow.visible(viz.OFF)
viz.clearcolor(0.5,0.5,1)
tex1 = viz.add('../resources/joNew/Oak1.tga')
tex2 = viz.add('../resources/joNew/STUCCO.JPG')
texSoccer2=viz.add('../resources/joNew/ball.jpg')
#soccerball3.texture(soccerball4.texture)
soccerball2.texture(texSoccer2)
soccerball1.texture(tex1)
soccerball4.texture(tex2)
objectOld=soccerball3
def mouseclick(button):
global objectOld
if button == viz.MOUSEBUTTON_LEFT:
object = viz.pick()
#if object.valid() and object != arrow:
if (object.valid() and object !=soccerball2):
#print 'obj',object
objectOld=object
print objectOld.getpos()
pos = object.get(viz.POSITION)
pos[1] += 1
print pos
arrow.translate(pos)
arrow.visible(viz.ON)
if (object.valid()and object ==soccerball2):
soccerball3.texture(texSoccer2)
if (object.valid()and object ==soccerball1):
soccerball3.texture(tex1)
if (object.valid()and object ==soccerball4):
soccerball3.texture(tex2)
viz.callback(viz.MOUSEDOWN_EVENT,mouseclick)
viz.mouse(viz.OFF)