Wilson357

14:34

Scripts para animações com POV-ray Parte 1(PovAnime.py)

Este é o primeiro script a ser executado. Ele irá gerar um arquivo de configuração INI para a renderização da cena.
---
#!/usr/bin/python
#povAnime.py
import os
##################################################
#Valida On/Off
#
def YesNo(YN):
if(YN == "s" or YN == "S"):
return "ON"
else:
return "OFF"
#
#fim valida
#################################################
#Escreve o arquivo
#
def Escreve():
fp=file("conf.ini","w")
fp.write( "; conf.ini.\n \
Antialias="+ AntiAliasing +"\n \
Antialias_Threshold="+ Antialias_Threshold +"\n \
Antialias_Depth="+ Antialias_Depth +"\n \
Input_File_Name="+ NomeArq +"\n \
Initial_Frame="+ KFI +"\n \
Final_Frame="+ KFF +"\n \
Initial_Clock="+ KI +"\n \
Final_Clock="+ KF +"\n \
Cyclic_Animation="+ Cyclic_Animation +"\n \
Pause_when_Done="+ Pause_when_Done)
fp.close()
#
#fim escreve o arquivo
################################################
# Coleta informacoes
#
print "Vericar argumentos. [valor padrao]"
AntiAliasing = raw_input("Ativar AntiAliasing? s/n [n]")
Antialias_Threshold = raw_input("AntiAlias_Threshold: [0.1]")
Antialias_Depth = raw_input("Ativar AntiAlias_Depth: [2]")
NomeArq = raw_input("Nome do arquivo de cena: [cena.pov]")
KFI = raw_input("Key Frame inicial: [0]")
KFF = raw_input("Key Frame final: [6]")
KI = raw_input("Clock inicial: [0]")
KF = raw_input("Clock final: [24]")
Cyclic_Animation = raw_input("Ativar Ciclo de Animacao? s/n [s]")
Pause_when_Done = raw_input("Ativar Pause when Done? s/n [n]")
Compilar = raw_input("Compilar a cena? s/n [s]")
#
#fim coleta informacoes
###################################################
#Verifica validade dos argumentos
#
AntiAliasing = YesNo(AntiAliasing)
Cyclic_Animation = YesNo(Cyclic_Animation)
Pause_when_Done = YesNo(Pause_when_Done)
Compilar = YesNo(Compilar)
#
#fim verifica validade dos argumentos
##################################################
#Escreve o script
#
Escreve()
#
#Fim escreve o script
##################################################
#Compila a cena
if(Compilar == "ON"):
Largura = raw_input("Largura: [200]")
Altura = raw_input("Altura: [200]")
cmd="povray conf.ini +w"+ Altura +" +h"+ Largura
if(not os.system(cmd)):
print "Ocorreu algum erro com o script. Edite o arquivo ou digite corretamente o valor dos argumentos."
#Fim compila
##################################################

0 comentários: