Hi all.
I'm trying to make an vpython scene work as an xscreensaver hack.
Everything seemed to be easy, just had to add a line in .xscreensaver like:
- "My hack" python /opt/ozp/xss.py & \n\
and use scene.fullscreen=1 in my script.
The new hack appears in the list and I can choose it.
It is launched after inactivity and my scene looks quite well, but after
~30s it just dissappears.
I've read a lot and think the problem can be that the scene should be shown
in the root window and not just in a fullscreen window.
Now I don't know how to attack the problem.
I need help. Any idea?
Thank you very much.
If someone's interested, here's the script wich I wanted to be a screensaver
(it's quite simple but funny):
#!/usr/bin/python
# -*- coding: utf-8 -*-
from visual import *
from random import *
# Número total de partículas
parts=200
# Esta variable nos mostrará una visión objetiva (-1) o subjetiva (1) de la
escena
visual=1
scene=display()
scene.title='Chaothic Knot Conga'
scene.autoscale=0
scene.userzoom=0
scene.userspin=0
scene.fullscreen=1
# Paisaje
suelo=box(pos=(0,-10,0),color=color.blue,size=(30,0.01,30))
curve(color=color.blue,pos=[(15,10,15),(-15,10,15),(-15,10,-15),(15,10,-15),(15,10,15)])
curve(color=color.blue,pos=[(15,10,15),(15,-10,15)])
curve(color=color.blue,pos=[(-15,10,15),(-15,-10,15)])
curve(color=color.blue,pos=[(-15,10,-15),(-15,-10,-15)])
curve(color=color.blue,pos=[(15,10,-15),(15,-10,-15)])
print windowname
# Sólo genera un vector aleatorio
def seguidor():
"Genera posiciones aleatoriamente en un cubo de lado 20"
return(randint(-10,10),randint(-10,10),randint(-10,10))
seguidores=[]
segsvel=[]
i=0.
while i < parts:
"Genera partículas con un gradiente de color"
seg=sphere(pos=seguidor(),radius=0.1,color=((parts-i)/parts,1-(parts-i)/parts,0.0))
seguidores.append(seg)
vel=vector(seguidor())
segsvel.append(vel)
i+=1
dt=1./25.
while 1:
while mag2(segsvel[parts-1]) > 0.0001:
"Mientras no se pare (o casi) la última"
rate(25)
i=1
while i < parts:
"Cada partícula persigue a su predecesora"
seguidores[i].pos+=(segsvel[i])*dt
segsvel[i]=(seguidores[i-1].pos-seguidores[i].pos)*2
i+=1
if visual == 1:
"Perspectiva subjetiva"
scene.center=seguidores[parts-1].pos
scene.forward=segsvel[parts-1]
scene.range=(.5,.5,.5)
else:
"Perspectiva objetiva"
scene.center=(0,0,0)
scene.forward=(0,0,-1)
scene.range=(10,10,10)
if scene.kb.keys:
"Cambio de perspectiva"
key=scene.kb.getkey()
if key=='v':
visual=visual*(-1)
for i in seguidores:
"Recolocación aleatoria de las partículas"
i.pos=seguidor()
segsvel[parts-1]=vector(1,1,1)
--
(^< -- Saludos, nerdigo
//'\
V_/_
|