View Full Version : Using a texquad to cover a window
Enlil
01-30-2012, 11:55 AM
Hello,
I was using texquads to blank out a window I made with viz.add(viz.Window) in Vizard 3, but it looks to me like the way texquads work with windows has changed in Vizard 4 (it appears the texquad is in effect behind instead of in front of the window).
So, is there a way to either attach a texquad to a window or is there a better way to fade to black?
Thanks,
Christian
farshizzo
01-30-2012, 02:37 PM
Can you post some sample code? The following script shows one way to use a quad to fade the scene in/out:import viz
import vizact
viz.go()
viz.addChild('gallery.osgb')
fadeQuad = viz.addTexQuad(parent=viz.ORTHO)
fadeQuad.setScale([5000,5000,1])
fadeQuad.color(viz.BLACK)
fadeQuad.alpha(0)
fadeQuad.alignment(viz.ALIGN_LEFT_BOTTOM)
fadeQuad.visible(0)
fadeOut = vizact.sequence( vizact.method.visible(1), vizact.fadeTo(1.0,speed=1.0) )
fadeIn = vizact.sequence( vizact.fadeTo(0.0,speed=1.0), vizact.method.visible(0) )
vizact.onkeydown(' ', fadeQuad.runAction, vizact.choice([fadeOut,fadeIn]) )
Enlil
02-01-2012, 08:20 AM
Sure! I should have done that in the first place. My problem is not covering the whole screen - that still works. It is when I try to cover a sub-window I have a problem, as shown in the following code:
import viz
viz.go()
env = viz.add('tankmaze.wrl')
UpperRightWindow = viz.add(viz.WINDOW)
# NEED TO TEST REPLACING THESE COMMANDS FOR VIZARD 4
UpperRightWindow.setPosition(0.5, 1.0)
UpperRightWindow.setSize(0.5, 0.5)
UpperRightWindow.visible(0,viz.SCREEN)
'''
quad = viz.addTexQuad(parent=viz.ORTHO, scale=[12.0, 10.0, 10.0],color=viz.BLACK)
quad.alpha(.5)
'''
vq = ViewQuad()
#quad = viz.add(viz.TEXQUAD)
lake = viz.add('lake3.jpg')
#quad.billboard(viz.BILLBOARD_YAXIS)
#blackScreen = viz.addTexQuad(parent=viz.SCREEN,scale=[100.0]*3,color=viz.BLACK)
blackScreen = viz.addTexQuad(parent=viz.SCREEN,scale=[12.0, 10.0, 10.0],color=viz.BLACK)
blackScreen.setPosition([.5, .5, 0])
blackScreen.texture(lake)
blackScreen.alpha(0.0)
vizact.onkeydown(' ',blackScreen.runAction,vizact.fadeTo(1.0,time=2.0 ))
The quad covers the screen, but not the window. Normally I am only trying to cover the subwindow, but this shows the difference better.
Thanks,
Christian
When the parent of the quad is viz.ORTHO you can specify the subwindow to add the quad to with the scene argument:
import viz
viz.go()
viz.addChild('gallery.osgb')
subWindow = viz.addWindow()
blackScreen = viz.addTexQuad(parent=viz.ORTHO,scene=subWindow,sc ale=[500]*3,color=viz.BLACK)
blackScreen.alpha(0.0)
vizact.onkeydown(' ',blackScreen.runAction,vizact.fadeTo(1.0,time=2.0 ))
Enlil
02-07-2012, 03:13 PM
Thanks, that was just what I needed.
Christian
vBulletin® v3.8.7, Copyright ©2000-2024, vBulletin Solutions, Inc.