![]() |
|
|
|
#1
|
|||
|
|||
|
Hello,
Try the following code to move the slider around to get the correct viz.MainWindow.setOrthoOffset() value. On our sx111, around -196 looks just about right. Code:
import viz
viz.go()
viz.add('tankmaze.wrl')
text = viz.addText('Hello World',parent=viz.ORTHO,fontSize=60,align=viz.TEXT_CENTER_CENTER)
viz.link(viz.CenterCenter,text)
slider = viz.addSlider(pos=(0.5,0.1,0))
slider.set(0.5)
def SetOffset(pos):
offset = vizmat.Interpolate(-400,-100,pos)
viz.MainWindow.setOrthoOffset( offset )
print offset
vizact.onslider(slider,SetOffset)
import nvis
hmd = nvis.nvisorSX111()
Masaki |
|
#2
|
|||
|
|||
|
Thanks, Masaki, for your reply.
I used the code you sent and it indeed worked to have the HUD to display correctly in the HMD. However, when I try to add an image, instead of a text to the hud, it does not display, if I set parent to viz.ORTHO. The way I have it working in mono is the following: Code:
crosshair = viz.addTexQuad(viz.SCREEN,texture=viz.add('crosshair.png'))
crosshair.setPosition([0.5,0.5,0])
Code:
crosshair = viz.addTexQuad(viz.ORTHO,texture=viz.add('crosshair.png'))
w = int(viz.getOption('viz.monitor.width'))
h = int(viz.getOption('viz.monitor.height'))
crosshair.setPosition([0.5*w,0.5*h,0])
Could you point me how I can do the equivalent to the example you sent before, but with an image, instead of text? Thanks a lot! Regis |
|
#3
|
|||
|
|||
|
Hi,
You need to scale your crosshair object much larger and also instead of viz.monitor.width/height you need to do viz.MainWindow.getSize( viz.WINDOW_ORTHO ) and since you're in stereo you need to multiply the width by .25 not .5. Alternatively, you can link it to viz.CenterCenter. Code:
import viz
viz.go(viz.FULLSCREEN)
viz.add('gallery.ive')
crosshair = viz.addTexQuad(viz.ORTHO,texture=viz.add('crosshair.png'))
crosshair.scale(100,100,1)
w,h = viz.MainWindow.getSize( viz.WINDOW_ORTHO )
crosshair.setPosition([0.25*w,0.5*h,0])
slider = viz.addSlider(pos=(0.5,0.1,0))
slider.set(0.5)
def SetOffset(pos):
offset = vizmat.Interpolate(-400,-100,pos)
viz.MainWindow.setOrthoOffset( offset )
print offset
vizact.onslider(slider,SetOffset)
import nvis
hmd = nvis.nvisorSX111()
Masaki |
|
#4
|
|||
|
|||
|
Thanks Masaki, it now works as expected.
I have another similar issue, but now it's with the projector extension. I'm using projected textures to emulate a spotlight in my application. It's not a realistic spotlight, but just a texture shaped like a torus that is semitransparent on the edges and has a transparent hole in the center. It is used to define a guiding path for the user to follow with the eyes, and I did not use the spotlight lighting effect because it would be much more complex as I would've to tessellate the geometry faces, etc. Anyway, this projected texture, I link it to the mainview position, and change it's orientation (pitch and yaw) in an animation path to be followed by the user. Here is the code used for the creation of the spotlight and animation path: Code:
import projector
spotlight = projector.add(viz.add('spotlight.png'))
spotlight.setEuler([15,0,90])
#State the geometry that can have the shadow cast upon them
spotlight.affect(model)
spotlight.setPosition(initial_pos)
spotlight_path = viz.addAnimationPath()
eulers = [[24.11, -4.72, 0.00], [12.95, -16.99, 0.00], ...]
times = [0.07, 1.14, ...]
for x in enumerate(eulers):
#Add the control point to the animation path
#at the new time
cp = viz.addControlPoint()
cp.setEuler(eulers[x])
spotlight_path.add(cp,times[x])
viz.link(spotlight_path, spotlight)
...
spotlight_path.play()
What I couldn't find a way to do was to apply the same offset that is applied to the HUD, now to the projected texture. Attached is an image of the projected spotlight, with the two views. The idea is to have the spotlight (which is a projected texture) illuminating the same geometry in both images. I hope that the explanation was clear enough. Thank you for your help! Regis |
|
#5
|
|||
|
|||
|
Hi,
Does anybody have any suggestion on how to achieve the above? Or perhaps an alternative to the projected textures to produce similar results, yet supporting stereo? Thanks, Regis |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|