PDA

View Full Version : Several quads layered one over another by draworder


Marco
05-26-2014, 03:28 PM
Hi everyone,

seems that I can't get out of troubleshooting in my script, so I'm asking for some help.

What i'm trying to do is to play 12 videos for a test of the FOV. They should be played one after another, skipped by a keypress-action. The videos are preloaded and played like this:

# Preload all videos
PLAYLIST = ['Media/Mercury/1.avi','Media/Mercury/2.avi','Media/Mercury/3.avi']
DRAWORDER = 100
def playVideos(videos):

# Create quads
Quadleft1 = viz.addTexQuad()
Quadleft1.setScale(.4,.225)
Quadleft1.setPosition([0,0,0])
Quadleft1.drawOrder(DRAWORDER)
posleft = viz.link(viz.MainView,Quadleft1)
posleft.preTrans([-0.022,0,.1])
Quadleft1.disable(viz.RENDER_RIGHT)

Quadright1 = viz.addTexQuad()
Quadright1.setScale(.4,.225)
Quadright1.setPosition([0,0,0])
Quadright1.drawOrder(DRAWORDER)
posright = viz.link(viz.MainView,Quadright1)
posright.preTrans([0.022,0,.1])
Quadright1.disable(viz.RENDER_LEFT)

# Go through playlist
PLAYLIST = ([ viz.addVideo(filename) for filename in videos ])

# Play next video from 0
video.setTime(0)

Quadleft1.texture(video)
Quadright1.texture(video)

video.play()

# Wait for keypress # I'm trying to fade out layers step by step
yield viztask.waitKeyDown(viz.KEY_UP)

Quadleft1.alpha(Quadleft1.getAlpha() - 0.066)
Quadright1.alpha(Quadright1.getAlpha() - 0.066)

Quadleft1.drawOrder(DRAWORDER + 10)
Quadright1.drawOrder(DRAWORDER + 10)

viztask.schedule(playVideos(PLAYLIST))


I'm using the Oculus for my tests, but that shouldn't be the problem. The problem is, that I want the first video to play until KEY_UP is pressed. Then i want the first video to stop, but keep it visible with (e.g.) alpha (0.8). Following this, a second video should start and be played above the first… so the first is still visible a bit through the first. All 12 videos should be layered one over another. I think there's a more easy way to do that, but I feel like a ran into a knife!

Can anyone tell me what I'm doing wrong with the draworder (if so) or post a quick solution!

Thanks in advance
Cheers

Marco
05-27-2014, 01:36 AM
Sorry… of course I got a FOR statement in the code… so it looks like this:

# Preload all videos
PLAYLIST = ['Media/Mercury/1.avi','Media/Mercury/2.avi','Media/Mercury/3.avi']
DRAWORDER = 100
def playVideos(videos):

# Create quads
Quadleft1 = viz.addTexQuad()
Quadleft1.setScale(.4,.225)
Quadleft1.setPosition([0,0,0])
Quadleft1.drawOrder(DRAWORDER)
posleft = viz.link(viz.MainView,Quadleft1)
posleft.preTrans([-0.022,0,.1])
Quadleft1.disable(viz.RENDER_RIGHT)

Quadright1 = viz.addTexQuad()
Quadright1.setScale(.4,.225)
Quadright1.setPosition([0,0,0])
Quadright1.drawOrder(DRAWORDER)
posright = viz.link(viz.MainView,Quadright1)
posright.preTrans([0.022,0,.1])
Quadright1.disable(viz.RENDER_LEFT)

# Go through playlist
PLAYLIST = ([ viz.addVideo(filename) for filename in videos ])

for video in PLAYLIST:

# Play next video from 0
video.setTime(0)

Quadleft1.texture(video)
Quadright1.texture(video)

video.play()

# Wait for keypress # I'm trying to fade out layers step by step
yield viztask.waitKeyDown(viz.KEY_UP)

Quadleft1.alpha(Quadleft1.getAlpha() - 0.066)
Quadright1.alpha(Quadright1.getAlpha() - 0.066)

Quadleft1.drawOrder(DRAWORDER + 10)
Quadright1.drawOrder(DRAWORDER + 10)

viztask.schedule(playVideos(PLAYLIST))