I have a slight problem. Farshizzo has so kindly helped me with using the crosshair as a 3d object. The problem is that I am also trying import the scaffold scene. The problem I'm having is that when I insert the scaffold scene the crosshair disappears. I'm thinking it has to do w/the textures, but I'm not sure. Is it possible to use the crosshair with the scaffold?
Here is the code I used to insert the scaffold scene:
Code:
sunlight = viz.add(viz.LIGHT)
sunlight.position(10,10,-20)
sunlight.direction(-0.5,-0.5,1)
sunlight.color(1,1,1)
sky = viz.add('skydome.dlc',0,'',15)
env = viz.add(viz.ENVIRONMENT_MAP,'sky.bmp')
sky.texture(env)
sky.disable(viz.FOG)
#Add 3D objects
panorama = viz.add('full_cyl1.wrl')
#ground = viz.add('bottom.wrl')
#scaffold = viz.add('scaffold2.wrl')
court = viz.add('scaffold2.wrl')
court.scale(0.5,0.5,0.5)
court.rotate(0,1,0,-90)
court.translate(-5,0,-10)
court.appearance(viz.MODULATE)
court.disable(viz.LIGHT0)
Here is the code for the crosshair insertion:
Code:
crosshair = viz.add(viz.TEXQUAD)
crosshair.texture(viz.add('crosshair.tif'))
crosshair.scale(0.01,0.01,0.01)
Here is the code to control the movement of the crosshair (within a timer):
Code:
linepos = viz.mousepos()
#line = viz.screentoworld(viz.mousepos())
line = viz.screentoworld(linepos[0]+.11,linepos[1])
v = viz.Vector(viz.get(viz.HEAD_POS))
dir = viz.Vector(line[3:]) - viz.Vector(line[:3])
dir.normalize()
dir *= 0.1 #Place crosshair 1/10th meter in front of user
v += dir
crosshair.translate(v.get())
crosshair.rotatequat(viz.get(viz.VIEW_QUAT))