Scripts:
- Jean-Baptiste Perin updated his bvh to armatures script to use the new armature module. - Johnny Matthews (guitargeek) contributed "Shape Widget Wizard". (Moved it to the Animation menu in Scripts win) - Benoit Foucque (dienben) contributed "Blender Lip Synchro". Thanks to the three authors!
This commit is contained in:
602
release/scripts/blenderLipSynchro.py
Normal file
602
release/scripts/blenderLipSynchro.py
Normal file
@@ -0,0 +1,602 @@
|
||||
#!BPY
|
||||
|
||||
"""
|
||||
Name: 'BlenderLipSynchro'
|
||||
Blender: 239
|
||||
Group: 'Animation'
|
||||
Tooltip: 'Import phonemes from Papagayo or JLipSync for lip synchronisation'
|
||||
"""
|
||||
|
||||
__author__ = "Dienben: Benoit Foucque dienben_mail@yahoo.fr"
|
||||
__url__ = ("blenderLipSynchro Blog, http://blenderlipsynchro.blogspot.com/",
|
||||
"Papagayo (Python), http://www.lostmarble.com/papagayo/index.shtml",
|
||||
"JLipSync (Java), http://jlipsync.sourceforge.net/")
|
||||
__version__ = "1.2"
|
||||
__bpydoc__ = """\
|
||||
Description:
|
||||
|
||||
This script imports Voice Export made by Papagayo or JLipSync and maps the export with your shapes.
|
||||
|
||||
Usage:
|
||||
|
||||
Import a Papagayo or JLipSync voice export file and link it with your shapes.
|
||||
|
||||
Note:<br>
|
||||
- Naturally, you need files exported from one of the supported lip synching
|
||||
programs. Check their sites to learn more and download them.
|
||||
|
||||
"""
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# BlenderLipSynchro
|
||||
# --------------------------------------------------------------------------
|
||||
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# ***** END GPL LICENCE BLOCK *****
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
#il y a 3 etapes
|
||||
#la deuxieme on charge le dictionnaire de correspondance
|
||||
#la troisieme on fait le choix des correpondance
|
||||
#la quatrieme on construit les cles a partir du fichiers frame
|
||||
|
||||
#there are 3 stage
|
||||
#the second one load the mapping dictionnary
|
||||
#the tird make the mapping
|
||||
#the fourth make the key in the IPO Curve
|
||||
|
||||
#voici mes differents imports
|
||||
#the imports
|
||||
import os
|
||||
import Blender
|
||||
|
||||
from Blender import Ipo
|
||||
from Blender.Draw import *
|
||||
from Blender.BGL import *
|
||||
|
||||
|
||||
|
||||
#ici commencent mes fonctions
|
||||
#here begin my functions
|
||||
#cette fonction trace l'interface graphique
|
||||
#this functions draw the User interface
|
||||
def trace():
|
||||
#voici mes variables pouvant etre modifie
|
||||
#my variables
|
||||
global fichier_dico,repertoire_dictionaire,iponame,repertoire_phoneme,fichier_text,nbr_phoneme
|
||||
global let01, let02, let03, let04,let05, let06, let07, let08, let09, let10
|
||||
global let11, let12, let13, let14,let15, let16, let17, let18, let19, let20
|
||||
global let21, let22, let23, let24
|
||||
|
||||
global let01selectkey,let02selectkey,let03selectkey,let04selectkey,let05selectkey
|
||||
global let06selectkey,let07selectkey,let08selectkey,let09selectkey,let10selectkey,let11selectkey
|
||||
global let12selectkey,let13selectkey,let14selectkey,let15selectkey,let16selectkey,let17selectkey
|
||||
global let18selectkey,let19selectkey,let20selectkey,let21selectkey,let22selectkey,let23selectkey
|
||||
global let24selectkey
|
||||
|
||||
glClearColor(0.4,0.5,0.6 ,0.0)
|
||||
glClear(GL_COLOR_BUFFER_BIT)
|
||||
|
||||
glColor3d(1,1,1)
|
||||
glRasterPos2i(87, 375)
|
||||
Text("Blendersynchro V 1.1")
|
||||
glColor3d(1,1,1)
|
||||
glRasterPos2i(84, 360)
|
||||
Text("Programation: Dienben")
|
||||
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(13, 342)
|
||||
Text("Papagayo File importer")
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(13, 326)
|
||||
Text("Thanks to Chris Clawson and Liubomir Kovatchev")
|
||||
|
||||
glColor3d(1,1,1)
|
||||
glRasterPos2i(5, 320)
|
||||
Text("_______________________________________________________")
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(6, 318)
|
||||
Text("_______________________________________________________")
|
||||
|
||||
|
||||
if (etape==1):
|
||||
#cette etape permet de choisi la correspondance entre les phonemes et les cles
|
||||
#this stage offer the possibility to choose the mapping between phonems and shapes
|
||||
|
||||
glColor3d(1,1,1)
|
||||
glRasterPos2i(140, 300)
|
||||
Text("Objet: "+Blender.Object.GetSelected()[0].getName() )
|
||||
|
||||
glColor3d(1,1,1)
|
||||
glRasterPos2i(5, 215)
|
||||
Text("Assign phonems to shapes:")
|
||||
|
||||
#on mesure la taille de la liste de phonemes
|
||||
#this is the lenght of the phonem list
|
||||
nbr_phoneme=len(liste_phoneme)
|
||||
|
||||
#on dessine les listes de choix
|
||||
#we draw the choice list
|
||||
|
||||
let01 = String(" ", 4, 5, 185, 30, 16, liste_phoneme[0], 3)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(40, 188)
|
||||
Text("=")
|
||||
let01selectkey = Menu(key_menu, 50, 50, 185, 70, 16, let01selectkey.val)
|
||||
|
||||
|
||||
let02 = String(" ", 4, 150, 185, 30, 16, liste_phoneme[1], 2)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(185, 188)
|
||||
Text("=")
|
||||
let02selectkey = Menu(key_menu, 51, 195, 185, 70, 16, let02selectkey.val)
|
||||
|
||||
|
||||
let03 = String(" ", 4, 5, 165, 30, 16, liste_phoneme[2], 2)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(40, 168)
|
||||
Text("=")
|
||||
let03selectkey = Menu(key_menu, 52, 50, 165, 70, 16, let03selectkey.val)
|
||||
|
||||
|
||||
let04 = String(" ", 4, 150, 165, 30, 16, liste_phoneme[3], 2)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(185, 168)
|
||||
Text("=")
|
||||
let04selectkey = Menu(key_menu, 53, 195, 165, 70, 16, let04selectkey.val)
|
||||
|
||||
|
||||
let05 = String(" ", 4, 5, 145, 30, 16, liste_phoneme[4], 2)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(40, 148)
|
||||
Text("=")
|
||||
let05selectkey = Menu(key_menu, 54, 50, 145, 70, 16, let05selectkey.val)
|
||||
|
||||
|
||||
let06 = String(" ", 4, 150, 145, 30, 16, liste_phoneme[5], 2)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(185, 148)
|
||||
Text("=")
|
||||
let06selectkey = Menu(key_menu, 55, 195, 145, 70, 16, let06selectkey.val)
|
||||
|
||||
|
||||
let07 = String(" ", 4, 5, 125, 30, 16, liste_phoneme[6], 2)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(40, 128)
|
||||
Text("=")
|
||||
let07selectkey = Menu(key_menu, 56, 50, 125, 70, 16, let07selectkey.val)
|
||||
|
||||
#
|
||||
let08 = String(" ", 4, 150, 125, 30, 16, liste_phoneme[7], 2)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(185, 128)
|
||||
Text("=")
|
||||
let08selectkey = Menu(key_menu, 57, 195, 125, 70, 16,let08selectkey.val)
|
||||
|
||||
|
||||
let09 = String(" ", 4, 5, 105, 30, 16, liste_phoneme[8], 2)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(40, 108)
|
||||
Text("=")
|
||||
let09selectkey = Menu(key_menu, 58, 50, 105, 70, 16,let09selectkey.val)
|
||||
|
||||
|
||||
let10 = String(" ", 4, 150, 105, 30, 16, liste_phoneme[9], 2)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(185, 108)
|
||||
Text("=")
|
||||
let10selectkey = Menu(key_menu, 59, 195, 105, 70, 16, let10selectkey.val)
|
||||
|
||||
#soft_type = 0:Papagayo
|
||||
#soft_type = 1:JLipSync
|
||||
if (soft_type==1):
|
||||
let11 = String(" ", 4, 5, 85, 30, 16, liste_phoneme[10], 2)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(40, 88)
|
||||
Text("=")
|
||||
let11selectkey = Menu(key_menu, 60, 50, 85, 70, 16, let11selectkey.val)
|
||||
|
||||
let12 = String(" ", 4, 150, 85, 30, 16, liste_phoneme[11], 2)
|
||||
glColor3d(0,0,0)
|
||||
Text("=")
|
||||
let12selectkey = Menu(key_menu, 61, 195, 85, 70, 16, let12selectkey.val)
|
||||
|
||||
let13 = String(" ", 4, 5, 65, 30, 16, liste_phoneme[12], 2)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(40, 68)
|
||||
Text("=")
|
||||
let13selectkey = Menu(key_menu, 62, 50, 65, 70, 16, let13selectkey.val)
|
||||
|
||||
let14 = String(" ", 4, 150, 65, 30, 16, liste_phoneme[13], 2)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(185, 68)
|
||||
Text("=")
|
||||
let14selectkey = Menu(key_menu, 63, 195, 65, 70, 16, let14selectkey.val)
|
||||
|
||||
let15 = String(" ", 4, 5, 45, 30, 16, liste_phoneme[14], 2)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(40, 48)
|
||||
Text("=")
|
||||
let15selectkey = Menu(key_menu, 64, 50, 45, 70, 16, let15selectkey.val)
|
||||
|
||||
let16 = String(" ", 4, 150, 45, 30, 16, liste_phoneme[15], 2)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(185, 48)
|
||||
Text("=")
|
||||
let16selectkey = Menu(key_menu, 65, 195, 45, 70, 16, let16selectkey.val)
|
||||
|
||||
let17 = String(" ", 4, 295, 185, 30, 16, liste_phoneme[16], 2)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(330, 188)
|
||||
Text("=")
|
||||
let17selectkey = Menu(key_menu, 66, 340, 185, 70, 16, let17selectkey.val)
|
||||
|
||||
let18 = String(" ", 4, 440, 185, 70, 16, liste_phoneme[17], 8)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(515, 188)
|
||||
Text("=")
|
||||
let18selectkey = Menu(key_menu, 67, 525, 185, 70, 16, let18selectkey.val)
|
||||
|
||||
let19 = String(" ", 4, 295, 165, 30, 16, liste_phoneme[18], 2)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(330, 168)
|
||||
Text("=")
|
||||
let19selectkey = Menu(key_menu, 68, 340, 165, 70, 16, let19selectkey.val)
|
||||
|
||||
let20 = String(" ", 4, 440, 165, 70, 16, liste_phoneme[19], 8)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(515, 168)
|
||||
Text("=")
|
||||
let20selectkey = Menu(key_menu, 69, 525, 165, 70, 16, let20selectkey.val)
|
||||
|
||||
let21 = String(" ", 4, 295, 145, 30, 16, liste_phoneme[20], 2)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(330, 148)
|
||||
Text("=")
|
||||
let21selectkey = Menu(key_menu, 70, 340, 145, 70, 16, let21selectkey.val)
|
||||
|
||||
let22 = String(" ", 4, 440, 145, 70, 16, liste_phoneme[21], 8)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(515, 148)
|
||||
Text("=")
|
||||
let22selectkey = Menu(key_menu, 71, 525, 145, 70, 16, let22selectkey.val)
|
||||
|
||||
let23 = String(" ", 4, 295, 125, 30, 16, liste_phoneme[22], 2)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(330, 128)
|
||||
Text("=")
|
||||
let23selectkey = Menu(key_menu, 72, 340, 125, 70, 16,let23selectkey.val)
|
||||
|
||||
let24 = String(" ", 4, 440, 125, 70, 16, liste_phoneme[23], 8)
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(515, 128)
|
||||
Text("=")
|
||||
let24selectkey = Menu(key_menu, 73, 525, 125, 70, 16, let24selectkey.val)
|
||||
|
||||
|
||||
Button("Import Text", 3, 155, 5, 145, 22)
|
||||
Button("Choose Voice Export", 4, 120, 250, 250, 22)
|
||||
|
||||
|
||||
if (etape==2):
|
||||
glColor3d(1,1,1)
|
||||
glRasterPos2i(125, 200)
|
||||
Text("Operation Completed")
|
||||
|
||||
if (etape==0):
|
||||
glColor3d(1,1,1)
|
||||
glRasterPos2i(125, 200)
|
||||
Text("Please select a Mesh'Object and Create all the IPO Curves for your Shapes")
|
||||
|
||||
if (etape==3):
|
||||
Button("Papagayo", 5, 155, 250, 250, 22)
|
||||
Button("JlipSync", 6, 155, 225, 250, 22)
|
||||
|
||||
glColor3d(1,1,1)
|
||||
glRasterPos2i(6, 40)
|
||||
Text("_______________________________________________________")
|
||||
glColor3d(0,0,0)
|
||||
glRasterPos2i(6, 38)
|
||||
Text("_______________________________________________________")
|
||||
|
||||
Button("Exit", 1, 305, 5, 80, 22)
|
||||
|
||||
|
||||
|
||||
|
||||
#cette fonction sur evenement quite en cas d'ESC
|
||||
#this functions catch the ESC event and quit
|
||||
def event(evt,val):
|
||||
if (evt == ESCKEY and not val): Exit()
|
||||
|
||||
#cette fonction gere les evenements
|
||||
#the event functions
|
||||
def bevent(evt):
|
||||
global etape,soft_type,liste_phoneme
|
||||
|
||||
if (evt == 1):
|
||||
Exit()
|
||||
|
||||
|
||||
elif (evt == 4):
|
||||
#c'est le choix de l'export pamela
|
||||
#we choose the papagayo export
|
||||
Blender.Window.FileSelector(selectionner_export_papagayo,"Choose Export")
|
||||
|
||||
|
||||
elif (evt == 3):
|
||||
#c'est l'import Papagayo
|
||||
#we import
|
||||
lecture_chaine(mon_fichier_export_pamela,dico_phoneme_export_pamela)
|
||||
construction_dico_correspondance()
|
||||
construction_lipsynchro()
|
||||
#on change d'etape
|
||||
#we change the stage
|
||||
etape=2
|
||||
|
||||
elif (evt == 5):
|
||||
#we choose papagayo
|
||||
soft_type=0
|
||||
liste_phoneme=liste_phoneme_papagayo
|
||||
etape=1
|
||||
|
||||
elif (evt == 6):
|
||||
#we choose jlipsync
|
||||
soft_type=1
|
||||
liste_phoneme=liste_phoneme_jlipsinch
|
||||
etape=1
|
||||
|
||||
Blender.Redraw()
|
||||
|
||||
#cette fonction recupere le nom et le chemin du fichier dictionnaire
|
||||
#we catch the name and the path of the dictionnary
|
||||
def selectionner_export_papagayo(filename):
|
||||
global mon_fichier_export_pamela
|
||||
#debut
|
||||
mon_fichier_export_pamela=filename
|
||||
|
||||
#fonction de lecture de la liste frame phoneme
|
||||
#we read the frame and phonems
|
||||
def lecture_chaine(fichier,liste):
|
||||
mon_fichier=open(fichier)
|
||||
|
||||
#je lis la premiere ligne qui contiens la version de moho
|
||||
#first, we read the moho version
|
||||
mon_fichier.readline()
|
||||
|
||||
#je lis jusqu'a la fin
|
||||
#then we read until the end of the file
|
||||
while 1:
|
||||
ma_ligne=mon_fichier.readline()
|
||||
if ma_ligne=='':
|
||||
break
|
||||
decoup=ma_ligne.split()
|
||||
liste[decoup[0]]=decoup[1]
|
||||
print liste
|
||||
|
||||
|
||||
|
||||
|
||||
#fonction qui construit la liste dictionnaire simple
|
||||
#we make the dictionnary
|
||||
def construction_dictionnaire_phoneme():
|
||||
index_liste=0
|
||||
#je transforme mon dictionnaire en list de tulpes
|
||||
#we transform the list in tulpes
|
||||
ma_liste=dico_phoneme.items()
|
||||
#je parcours ma liste a la recherche d'elements non existant
|
||||
#we read the list to find non existing elements
|
||||
print dico_phoneme
|
||||
for index in range(len(ma_liste)):
|
||||
if ma_liste[index][1] not in liste_phoneme:
|
||||
liste_phoneme[index_liste:index_liste]=[ma_liste[index][1]]
|
||||
index_liste=index_liste+1
|
||||
print liste_phoneme
|
||||
|
||||
|
||||
|
||||
#cette fonction recupere les courbes cible
|
||||
#this functon catch the IPO curve
|
||||
def recuperation_courbe():
|
||||
global key_menu,dico_key
|
||||
|
||||
#on recupere le nom des shapes
|
||||
#we catch the shapes
|
||||
key=Blender.Object.GetSelected()[0].getData().getKey().getBlocks()
|
||||
for n in range(len(key)):
|
||||
#on vire la premi<6D>re cle (en effet basic n'est pas une cle en tant que telle)
|
||||
#we threw away the basic shapes
|
||||
if (n>0):
|
||||
key_menu=key_menu+key[n].name + " %x" + str(n-1) + "|"
|
||||
dico_key[str(n-1)]=Blender.Object.GetSelected()[0].getData().getKey().getIpo().getCurves()[n-1]
|
||||
|
||||
|
||||
print "dico_key"
|
||||
print dico_key
|
||||
print 'end dico_key'
|
||||
|
||||
#cette fonction construit un dictionnaire de correspondance entre les phonemes prononces et les cles a utiliser
|
||||
#we make the dictionnary for the mapping between shapes and phonems
|
||||
def construction_dico_correspondance():
|
||||
global dico_correspondance
|
||||
#je parcours les phonemes
|
||||
#we read the phonems
|
||||
dico_correspondance[liste_phoneme[0]]=dico_key[str(let01selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[1]]=dico_key[str(let02selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[2]]=dico_key[str(let03selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[3]]=dico_key[str(let04selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[4]]=dico_key[str(let05selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[5]]=dico_key[str(let06selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[6]]=dico_key[str(let07selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[7]]=dico_key[str(let08selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[8]]=dico_key[str(let09selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[9]]=dico_key[str(let10selectkey.val)]
|
||||
|
||||
if (soft_type==1):
|
||||
dico_correspondance[liste_phoneme[10]]=dico_key[str(let11selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[11]]=dico_key[str(let12selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[12]]=dico_key[str(let13selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[13]]=dico_key[str(let14selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[14]]=dico_key[str(let15selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[15]]=dico_key[str(let16selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[16]]=dico_key[str(let17selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[17]]=dico_key[str(let18selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[18]]=dico_key[str(let19selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[19]]=dico_key[str(let20selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[20]]=dico_key[str(let21selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[21]]=dico_key[str(let22selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[22]]=dico_key[str(let23selectkey.val)]
|
||||
dico_correspondance[liste_phoneme[23]]=dico_key[str(let24selectkey.val)]
|
||||
|
||||
print dico_correspondance
|
||||
|
||||
|
||||
#cette fonction ajoute un points a la cle donnee a la frame donnee
|
||||
#we add a point to the IPO curve Target
|
||||
def ajoute_point(cle,frame,valeur):
|
||||
cle.setInterpolation('Linear')
|
||||
cle.addBezier((frame,valeur))
|
||||
cle.Recalc()
|
||||
|
||||
#cette fonction parcours le dictionnaire des frame <20> ajouter et construit les points
|
||||
#we add all the point to the IPO Curve
|
||||
def construction_lipsynchro():
|
||||
print "je construit"
|
||||
doublet_old=""
|
||||
#construction de la liste des frame
|
||||
cpt=0
|
||||
liste_frame=[]
|
||||
for frame in dico_phoneme_export_pamela:
|
||||
liste_frame.append(int(frame))
|
||||
cpt=cpt+1
|
||||
liste_frame.sort()
|
||||
print "listeframe"
|
||||
print liste_frame
|
||||
print "fini"
|
||||
|
||||
for doublet in liste_frame:
|
||||
ajoute_point(dico_correspondance[dico_phoneme_export_pamela[str(doublet)]],doublet,1)
|
||||
if (doublet_old==""):
|
||||
ajoute_point(dico_correspondance[dico_phoneme_export_pamela[str(doublet)]],(doublet-2),0)
|
||||
if (doublet_old!=''):
|
||||
if (dico_correspondance[dico_phoneme_export_pamela[str(doublet)]]!=dico_correspondance[dico_phoneme_export_pamela[doublet_old]]):
|
||||
print "doublet:"+str(doublet)
|
||||
print "doublet old:"+doublet_old
|
||||
ajoute_point(dico_correspondance[dico_phoneme_export_pamela[doublet_old]],(int(doublet_old)+2),0)
|
||||
ajoute_point(dico_correspondance[dico_phoneme_export_pamela[str(doublet)]],(doublet-2),0)
|
||||
doublet_old=str(doublet)
|
||||
|
||||
|
||||
#end of my functions we begin the execution
|
||||
#je commence l execution-----------------------------------------------------------------------------------------------
|
||||
#voici mes variables
|
||||
|
||||
#declaration et instanciation
|
||||
#decleration and instanciation
|
||||
#ce sont les repertoires
|
||||
repertoire_dictionaire=Create('C:/')
|
||||
repertoire_phoneme=Create('c:/')
|
||||
|
||||
#ce sont ls fichiers
|
||||
fichier_dico=Create("sample.mot")
|
||||
fichier_text=Create("")
|
||||
|
||||
#voici mon objet de travail
|
||||
objet_travail=Create(0)
|
||||
|
||||
#my soft type
|
||||
soft_type=1
|
||||
|
||||
#voici la liste des phoneme effectivement utilise
|
||||
#the phonems'list
|
||||
liste_phoneme_papagayo=['AI','E','O','U','FV','L','WQ','MBP','etc','rest']
|
||||
liste_phoneme_jlipsinch=['A','B','C','Closed','D','E','F','G','I','K','L','M','N','O','P','Q','R','S','SH','T','TH','U','V','W']
|
||||
|
||||
liste_phoneme=liste_phoneme_jlipsinch
|
||||
#voici mon dictionnaire des frames o
|
||||
dico_phoneme_export_pamela = Create(0)
|
||||
dico_phoneme_export_pamela={}
|
||||
|
||||
|
||||
|
||||
#voici mes cle
|
||||
key_menu=""
|
||||
dico_key={}
|
||||
|
||||
#voici mes ipo
|
||||
dico_bloc={}
|
||||
iponame = Create(0)
|
||||
|
||||
#voici mon dictionnaire de correspondance
|
||||
dico_correspondance={}
|
||||
|
||||
try:
|
||||
#on verifie est bien une mesh et qu'il a des courbes
|
||||
if ((Blender.Object.GetSelected()[0].getType()=='Mesh')):
|
||||
#on verifie que l'objet a bien toute ses Courbes
|
||||
if (len(Blender.Object.GetSelected()[0].getData().getKey().getBlocks())-1==Blender.Object.GetSelected()[0].getData().getKey().getIpo().getNcurves()):
|
||||
etape=3
|
||||
#on lance la creation du dictionnaire
|
||||
recuperation_courbe()
|
||||
else:
|
||||
print "not the good number of IPO Curve"
|
||||
etape = 0
|
||||
else:
|
||||
print "error: bad object Type:"
|
||||
print Blender.Object.GetSelected()[0].getType()
|
||||
etape = 0
|
||||
except:
|
||||
print 'error: exception'
|
||||
etape = 0
|
||||
|
||||
|
||||
#voici le fichier dictionnaire
|
||||
mon_fichier_dico=""
|
||||
|
||||
#voici le fichier export pamela
|
||||
mon_fichier_export_pamela=""
|
||||
|
||||
|
||||
let01selectkey = Create(0)
|
||||
let02selectkey = Create(0)
|
||||
let03selectkey = Create(0)
|
||||
let04selectkey = Create(0)
|
||||
let05selectkey = Create(0)
|
||||
let06selectkey = Create(0)
|
||||
let07selectkey = Create(0)
|
||||
let08selectkey = Create(0)
|
||||
let09selectkey = Create(0)
|
||||
let10selectkey = Create(0)
|
||||
let11selectkey = Create(0)
|
||||
let12selectkey = Create(0)
|
||||
let13selectkey = Create(0)
|
||||
let14selectkey = Create(0)
|
||||
let15selectkey = Create(0)
|
||||
let16selectkey = Create(0)
|
||||
let17selectkey = Create(0)
|
||||
let18selectkey = Create(0)
|
||||
let19selectkey = Create(0)
|
||||
let20selectkey = Create(0)
|
||||
let21selectkey = Create(0)
|
||||
let22selectkey = Create(0)
|
||||
let23selectkey = Create(0)
|
||||
let24selectkey = Create(0)
|
||||
|
||||
|
||||
Register (trace,event,bevent)
|
||||
@@ -1,40 +1,62 @@
|
||||
#!BPY
|
||||
"""
|
||||
Name: 'BVH Empties to Armature'
|
||||
Blender: 237
|
||||
Name: 'Empties to Armature'
|
||||
Blender: 239
|
||||
Group: 'Animation'
|
||||
Tooltip: 'Create Armature from Empties created by BVH importer'
|
||||
Tooltip: 'Create Armature from a parented-empties chain'
|
||||
"""
|
||||
__author__ = " Jean-Baptiste PERIN (jb_perin(at)yahoo.fr)"
|
||||
__url__ = ("blender", "elysiun",
|
||||
"BVH 2 ARMATURE, http://www.zoo-logique.org/3D.Blender/index.php3?zoo=dld&rep=zip ",
|
||||
"BVH 2 ARMATURE, http://perso.wanadoo.fr/jb.perin/",
|
||||
"Communicate problems and errors, http://www.zoo-logique.org/3D.Blender/newsportal/thread.php?group=3D.Blender")
|
||||
|
||||
__version__ = "2.2"
|
||||
__version__ = "2.4"
|
||||
|
||||
__bpydoc__ = """ BVH2ARM.py v2.2
|
||||
__bpydoc__ = """ BVH2ARM.py
|
||||
|
||||
Script for generating armature on BVH empties.
|
||||
|
||||
This script generates an armature and make bones
|
||||
follow empties created by Blender BVH import script.
|
||||
|
||||
This script generates an armature upon an empty-made parented chain,
|
||||
and make the armature follow the hip bone of the chain.
|
||||
User only have to set up IKSolver contraints on every end effector bone.
|
||||
|
||||
Usage:<br>
|
||||
- Import a bvh in Blender (File->Import->BVH);<br>
|
||||
- Launch this script (Alt-P);<br>
|
||||
- Select the root empty of the hierarchical chain.<br>
|
||||
- Launch this script ;<br>
|
||||
- Set up variables:<br>
|
||||
"hipbonename": the name of the main bone;<br>
|
||||
"hipbonename": the name of the main bone (automatically set to the selected empty).<br>
|
||||
"startframe": the first frame of your anim;<br>
|
||||
"endframe": the last frame of your anim;<br>
|
||||
"decimation": the frequency (in number of frame) to which the armature is updated;<br>
|
||||
"scale" to size the created armature.<br>
|
||||
- Press "Create Armature".
|
||||
"""
|
||||
"decimation": the frequency (in number of frame) to which the armature's pos is updated;<br>
|
||||
- Press "Create Armature".<br>
|
||||
- Set IKSolver for every end effector bone (targeting)
|
||||
|
||||
#----------------------------------------------
|
||||
# (c) Jean-Baptiste PERIN june 2005, released under Blender Artistic Licence
|
||||
# for the Blender 2.34-2.36 Python Scripts Bundle.
|
||||
#----------------------------------------------
|
||||
Notes: <br>
|
||||
- The start frame configuration is used as the rest pose for the armature.<br>
|
||||
- If the armature already exists when script is launched, the current armature is re-used.
|
||||
"""
|
||||
# --------------------------------------------------------------------------
|
||||
# BVH2ARM.py
|
||||
# --------------------------------------------------------------------------
|
||||
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# ***** END GPL LICENCE BLOCK *****
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@@ -278,30 +300,47 @@ def computeScaledPos(vec):
|
||||
#########
|
||||
def createBone (armature, empty, bone, empties):
|
||||
children = getChildren(empty, empties)
|
||||
for ch in children:
|
||||
if len(children) != 0:
|
||||
for ch in children:
|
||||
if len(children) >= 2:
|
||||
bonename = empty.getName()[1:len(empty.getName())]+'_'+ch.getName()[1:len(ch.getName())]
|
||||
else :
|
||||
bonename = empty.getName()[1:len(empty.getName())]
|
||||
b=Blender.Armature.Bone.New(bonename)
|
||||
b.setHead(computeScaledPos(empty.getMatrix('worldspace').translationPart()))
|
||||
b.setTail(computeScaledPos(ch.getMatrix('worldspace').translationPart()))
|
||||
#b.setParent(bone)
|
||||
matrice = empty.getMatrix('worldspace')
|
||||
invmatrice = empty.getMatrix('worldspace')
|
||||
invmatrice.invert()
|
||||
invmatricet=empty.getMatrix('worldspace')
|
||||
invmatricet.invert()
|
||||
invmatricet.transpose()
|
||||
dicEmptiesRestMatrix[empty.getName()] = matrice
|
||||
dicEmptiesInvRestMatrix[empty.getName()] = invmatrice
|
||||
armature.addBone(b)
|
||||
invbonerest=b.getRestMatrix()
|
||||
invbonerest.invert()
|
||||
dicBoneRestMatrix[b.getName()] = b.getRestMatrix()
|
||||
dicBoneRestInvEmpRest[b.getName()]=b.getRestMatrix()*invmatrice*invmatricet
|
||||
dicEmpRestInvBoneRest[b.getName()]=matrice*invbonerest
|
||||
dicBone[b.getName()]=b
|
||||
print "creating Bone %s"%(bonename)
|
||||
b=Blender.Armature.Editbone()
|
||||
b.head = (computeScaledPos(empty.getMatrix('worldspace').translationPart()))
|
||||
b.tail = (computeScaledPos(ch.getMatrix('worldspace').translationPart()))
|
||||
b.parent = bone
|
||||
# armature.makeEditable() should already be editable????
|
||||
armature.bones[bonename] = b
|
||||
#armature.update()
|
||||
## #b.setParent(bone)
|
||||
## matrice = empty.getMatrix('worldspace')
|
||||
## invmatrice = empty.getMatrix('worldspace')
|
||||
## invmatrice.invert()
|
||||
## invmatricet=empty.getMatrix('worldspace')
|
||||
## invmatricet.invert()
|
||||
## invmatricet.transpose()
|
||||
## dicEmptiesRestMatrix[empty.getName()] = matrice
|
||||
## dicEmptiesInvRestMatrix[empty.getName()] = invmatrice
|
||||
## #armature.addBone(b)
|
||||
## #????armature.bones[b.name]=b
|
||||
## #invbonerest=b.getRestMatrix()
|
||||
## #invbonerest.invert()
|
||||
## invbonerest=Blender.Mathutils.Matrix(b.matrix)
|
||||
## invbonerest.resize4x4()
|
||||
## invbonerest[3][3]=1.0
|
||||
## invbonerest.invert()
|
||||
##
|
||||
## #dicBoneRestMatrix[b.getName()] = b.matrix
|
||||
## tmpmat = b.matrix.resize4x4()
|
||||
## tmpmat[3][3] = 1.0
|
||||
## dicBoneRestMatrix[b.name] = tmpmat
|
||||
##
|
||||
## #dicBoneRestInvEmpRest[b.getName()]=b.getRestMatrix()*invmatrice*invmatricet
|
||||
## dicBoneRestInvEmpRest[b.name]=tmpmat*invmatrice*invmatricet
|
||||
## dicEmpRestInvBoneRest[b.name]=matrice*invbonerest
|
||||
## dicBone[b.name]=b
|
||||
createBone(armature, ch, b, empties)
|
||||
|
||||
#########
|
||||
@@ -310,13 +349,12 @@ def createBone (armature, empty, bone, empties):
|
||||
# out :
|
||||
#########
|
||||
def f_createBone (armData, empty, bone, empties):
|
||||
bones = armData.getBones()
|
||||
|
||||
bones = armData.bones.values()
|
||||
def getBone(bonename):
|
||||
bone = None
|
||||
for b in bones:
|
||||
#print b.getName()
|
||||
if b.getName() == bonename:
|
||||
if b.name == bonename:
|
||||
bone = b
|
||||
return bone
|
||||
|
||||
@@ -328,24 +366,35 @@ def f_createBone (armData, empty, bone, empties):
|
||||
bonename = empty.getName()[1:len(empty.getName())]
|
||||
#b=Blender.Armature.Bone.New(bonename)
|
||||
b=getBone(bonename)
|
||||
b.head = (computeScaledPos(empty.getMatrix('worldspace').translationPart()))
|
||||
b.tail = (computeScaledPos(ch.getMatrix('worldspace').translationPart()))
|
||||
b.parent = bone
|
||||
#b.setHead(empty.getMatrix('worldspace').translationPart())
|
||||
#b.setTail(ch.getMatrix('worldspace').translationPart())
|
||||
#b.setParent(bone)
|
||||
matrice = empty.getMatrix('worldspace')
|
||||
invmatrice = empty.getMatrix('worldspace')
|
||||
invmatrice.invert()
|
||||
invmatricet=empty.getMatrix('worldspace')
|
||||
invmatricet.invert()
|
||||
invmatricet.transpose()
|
||||
dicEmptiesRestMatrix[empty.getName()] = matrice
|
||||
dicEmptiesInvRestMatrix[empty.getName()] = invmatrice
|
||||
#armature.addBone(b)
|
||||
invbonerest=b.getRestMatrix()
|
||||
invbonerest.invert()
|
||||
dicBoneRestMatrix[b.getName()] = b.getRestMatrix()
|
||||
dicBoneRestInvEmpRest[b.getName()]=b.getRestMatrix()*invmatrice*invmatricet
|
||||
dicEmpRestInvBoneRest[b.getName()]=matrice*invbonerest
|
||||
dicBone[b.getName()]=b
|
||||
## matrice = empty.getMatrix('worldspace')
|
||||
## invmatrice = empty.getMatrix('worldspace')
|
||||
## invmatrice.invert()
|
||||
## invmatricet=empty.getMatrix('worldspace')
|
||||
## invmatricet.invert()
|
||||
## invmatricet.transpose()
|
||||
## dicEmptiesRestMatrix[empty.getName()] = matrice
|
||||
## dicEmptiesInvRestMatrix[empty.getName()] = invmatrice
|
||||
## #armature.addBone(b)
|
||||
## #invbonerest=b.getRestMatrix()
|
||||
## #invbonerest.invert()
|
||||
## invbonerest=Blender.Mathutils.Matrix(b.matrix)
|
||||
## invbonerest.resize4x4()
|
||||
## invbonerest[3][3]=1.0
|
||||
## invbonerest.invert()
|
||||
## #dicBoneRestMatrix[b.getName()] = b.getRestMatrix()
|
||||
## tmpmat = b.matrix.resize4x4()
|
||||
## tmpmat[3][3] = 1.0
|
||||
## dicBoneRestMatrix[b.name] = tmpmat
|
||||
##
|
||||
## dicBoneRestInvEmpRest[b.name]=tmpmat*invmatrice*invmatricet
|
||||
## dicEmpRestInvBoneRest[b.name]=matrice*invbonerest
|
||||
dicBone[b.name]=b
|
||||
#print "Ajout de ", b.getName()," au dictionnaire"
|
||||
f_createBone(armData, ch, b, empties)
|
||||
|
||||
@@ -355,29 +404,55 @@ def f_createBone (armData, empty, bone, empties):
|
||||
# in :
|
||||
# out :
|
||||
#########
|
||||
def createArmature (rootEmpty, empties):
|
||||
armData=Blender.Armature.New('monArmature')
|
||||
def createArmature (armObj, rootEmpty, empties):
|
||||
armData=Blender.Armature.Armature('monArmature')
|
||||
children = getChildren(rootEmpty, empties)
|
||||
armObj.link(armData)
|
||||
armData.makeEditable()
|
||||
for ch in children:
|
||||
b=Blender.Armature.Bone.New(rootEmpty.getName()[1:len(rootEmpty.getName())] + ch.getName()[1:len(ch.getName())])
|
||||
b.setHead(computeScaledPos(rootEmpty.getMatrix('worldspace').translationPart()))
|
||||
b.setTail(computeScaledPos(ch.getMatrix('worldspace').translationPart()))
|
||||
armData.addBone(b)
|
||||
matrice = ch.getMatrix('worldspace')
|
||||
invmatrice = ch.getMatrix('worldspace')
|
||||
invmatrice.invert()
|
||||
invmatricet=ch.getMatrix('worldspace')
|
||||
invmatricet.invert()
|
||||
invmatricet.transpose()
|
||||
dicEmptiesRestMatrix[rootEmpty.getName()] = matrice
|
||||
dicEmptiesInvRestMatrix[rootEmpty.getName()] = invmatrice
|
||||
invbonerest=b.getRestMatrix()
|
||||
invbonerest.invert()
|
||||
dicBoneRestMatrix[b.getName()] = b.getRestMatrix()
|
||||
dicBoneRestInvEmpRest[b.getName()]=b.getRestMatrix()*invmatrice*invmatricet
|
||||
dicEmpRestInvBoneRest[b.getName()]=matrice*invbonerest
|
||||
dicBone[b.getName()]=b
|
||||
b=Blender.Armature.Editbone()
|
||||
bonename = rootEmpty.getName()[1:len(rootEmpty.getName())] + ch.getName()[1:len(ch.getName())]
|
||||
print "creating Bone %s"%(bonename)
|
||||
|
||||
#print b, dir([b])
|
||||
b.head=(computeScaledPos(rootEmpty.getMatrix('worldspace').translationPart()))
|
||||
b.tail=(computeScaledPos(ch.getMatrix('worldspace').translationPart()))
|
||||
armData.bones[bonename] = b
|
||||
#armData.update()
|
||||
#armData.addBone(b)
|
||||
#matrice = ch.getMatrix('worldspace')
|
||||
#print dir (ch.matrix)
|
||||
## matrice = Blender.Mathutils.Matrix(ch.getMatrix('worldspace'))
|
||||
## matrice.resize4x4()
|
||||
## matrice[3][3]=1.0
|
||||
## #print matrice
|
||||
## #eval("invmatrice = Blender.Mathutils.Matrix(ch.getMatrix('worldspace'))" ) #??
|
||||
## invmatrice = Blender.Mathutils.Matrix(ch.getMatrix('worldspace')) #??
|
||||
## invmatrice.invert()
|
||||
## #invmatrice.resize4x4()
|
||||
## invmatricet= Blender.Mathutils.Matrix(ch.getMatrix('worldspace')) #??
|
||||
## invmatricet.invert()
|
||||
## invmatricet.transpose()
|
||||
## #invmatricet.resize4x4()
|
||||
## dicEmptiesRestMatrix[rootEmpty.getName()] = matrice
|
||||
## dicEmptiesInvRestMatrix[rootEmpty.getName()] = invmatrice
|
||||
## #invbonerest=b.getRestMatrix()
|
||||
## invbonerest=Blender.Mathutils.Matrix(b.matrix)
|
||||
## invbonerest.resize4x4()
|
||||
## invbonerest[3][3]=1.0
|
||||
## invbonerest.invert()
|
||||
## #dicBoneRestMatrix[b.getName()] = b.getRestMatrix()
|
||||
## tmpmat = b.matrix.resize4x4()
|
||||
## tmpmat[3][3] = 1.0
|
||||
## dicBoneRestMatrix[b.name] = tmpmat
|
||||
## #print tmpmat
|
||||
## #print invmatrice
|
||||
## #print invmatricet
|
||||
## dicBoneRestInvEmpRest[b.name]=tmpmat*invmatrice*invmatricet
|
||||
## dicEmpRestInvBoneRest[b.name]=matrice*invbonerest
|
||||
## dicBone[b.name]=b
|
||||
createBone(armData, ch, b, empties)
|
||||
armData.update()
|
||||
return armData
|
||||
|
||||
|
||||
@@ -388,33 +463,43 @@ def createArmature (rootEmpty, empties):
|
||||
# out :
|
||||
#########
|
||||
def f_createArmature (rootEmpty, empties, armData):
|
||||
bones = armData.getBones()
|
||||
armData.makeEditable()
|
||||
bones = armData.bones.values()
|
||||
|
||||
|
||||
def getBone(bonename):
|
||||
bone = None
|
||||
for b in bones:
|
||||
#print b.getName()
|
||||
if b.getName() == bonename:
|
||||
if b.name == bonename:
|
||||
bone = b
|
||||
return bone
|
||||
|
||||
children = getChildren(rootEmpty, empties)
|
||||
for ch in children:
|
||||
b=getBone(rootEmpty.getName()[1:len(rootEmpty.getName())] + ch.getName()[1:len(ch.getName())])
|
||||
matrice = ch.getMatrix('worldspace')
|
||||
invmatrice = ch.getMatrix('worldspace')
|
||||
invmatrice.invert()
|
||||
invmatricet=ch.getMatrix('worldspace')
|
||||
invmatricet.invert()
|
||||
invmatricet.transpose()
|
||||
dicEmptiesRestMatrix[rootEmpty.getName()] = matrice
|
||||
dicEmptiesInvRestMatrix[rootEmpty.getName()] = invmatrice
|
||||
invbonerest=b.getRestMatrix()
|
||||
invbonerest.invert()
|
||||
dicBoneRestMatrix[b.getName()] = b.getRestMatrix()
|
||||
dicBoneRestInvEmpRest[b.getName()]=b.getRestMatrix()*invmatrice*invmatricet
|
||||
dicEmpRestInvBoneRest[b.getName()]=matrice*invbonerest
|
||||
dicBone[b.getName()]=b
|
||||
## matrice = Blender.Mathutils.Matrix(ch.getMatrix('worldspace'))
|
||||
## invmatrice = Blender.Mathutils.Matrix(ch.getMatrix('worldspace'))
|
||||
## invmatrice.invert()
|
||||
## invmatricet=Blender.Mathutils.Matrix(ch.getMatrix('worldspace'))
|
||||
## invmatricet.invert()
|
||||
## invmatricet.transpose()
|
||||
## dicEmptiesRestMatrix[rootEmpty.getName()] = matrice
|
||||
## dicEmptiesInvRestMatrix[rootEmpty.getName()] = invmatrice
|
||||
## print b.matrix
|
||||
## invbonerest=Blender.Mathutils.Matrix(b.matrix)
|
||||
## invbonerest.resize4x4()
|
||||
## invbonerest[3][3] = 1.0
|
||||
## invbonerest.invert()
|
||||
## #dicBoneRestMatrix[b.getName()] = b.getRestMatrix()
|
||||
## #dicBoneRestMatrix[b.name] = b.matrix
|
||||
## tmpmat = b.matrix.resize4x4()
|
||||
## tmpmat[3][3] = 1.0
|
||||
## dicBoneRestMatrix[b.name] = tmpmat
|
||||
##
|
||||
## dicBoneRestInvEmpRest[b.name]=tmpmat*invmatrice*invmatricet
|
||||
## dicEmpRestInvBoneRest[b.name]=matrice*invbonerest
|
||||
dicBone[b.name]=b
|
||||
#print "Ajout de ", b.getName()," au dictionnaire"
|
||||
|
||||
f_createBone(armData, ch, b, empties)
|
||||
@@ -435,8 +520,8 @@ def moveBones(armature, empty, empties):
|
||||
bonename = empty.getName()[1:len(empty.getName())]
|
||||
bone = dicBone[bonename]
|
||||
#bone.setLoc(computeRootPos(empty,bone))
|
||||
bone.setLoc(computeRelativePos(empty,bone))
|
||||
bone.setQuat(computeRootQuat2(empty,bone))
|
||||
#???? what can replace bone.setLoc(computeRelativePos(empty,bone))
|
||||
#???? what can replace bone.setQuat(computeRootQuat2(empty,bone))
|
||||
chch = dicEmptyChild[ch.getName()]
|
||||
if len(chch) >= 1:
|
||||
moveBones(armature, ch, empties)
|
||||
@@ -453,20 +538,11 @@ def moveArmature (armature, empties):
|
||||
for ch in children:
|
||||
b=dicBone[hipbonename[1:len(hipbonename)] + ch.getName()[1:len(ch.getName())]]
|
||||
#b.setLoc(computeRootPos(root, b))
|
||||
b.setLoc([0.0, 0.0, 0.0])
|
||||
b.setQuat(computeRootQuat2(root, b))
|
||||
#???? what can replace b.setLoc([0.0, 0.0, 0.0])
|
||||
#???? what can replace b.setQuat(computeRootQuat2(root, b))
|
||||
moveBones(armature, ch, empties)
|
||||
|
||||
|
||||
def eraseIPO (objectname):
|
||||
object = Blender.Object.Get(objectname)
|
||||
lIpo = object.getIpo()
|
||||
if lIpo != None:
|
||||
nbCurves = lIpo.getNcurves()
|
||||
for i in range(nbCurves):
|
||||
nbBezPoints = lIpo.getNBezPoints(i)
|
||||
for j in range(nbBezPoints):
|
||||
lIpo.delBezPoint(i)
|
||||
|
||||
|
||||
########################################################################
|
||||
@@ -512,7 +588,7 @@ def Main():
|
||||
|
||||
lesEmpties = getEmpties()
|
||||
#print dicEmptyChild
|
||||
|
||||
print "creating armature"
|
||||
#armData = createArmature(em0, lesEmpties)
|
||||
objects = Blender.Object.Get()
|
||||
if 'OBArmature' in map(names,objects):
|
||||
@@ -523,15 +599,15 @@ def Main():
|
||||
#print armData.getBones()
|
||||
f_createArmature(em0, lesEmpties, armData)
|
||||
else:
|
||||
armData= createArmature(em0, lesEmpties)
|
||||
armObj=Blender.Object.New('Armature', 'OBArmature')
|
||||
armObj.link(armData)
|
||||
armData= createArmature(armObj, em0, lesEmpties)
|
||||
#armObj.link(armData)
|
||||
scn = Blender.Scene.getCurrent()
|
||||
scn.link (armObj)
|
||||
|
||||
print 'OBArmature'+' was created'
|
||||
#return myobj
|
||||
|
||||
armData.drawType = Blender.Armature.STICK
|
||||
##-----------
|
||||
## Creation de l'ipo de l'armature
|
||||
##-----------
|
||||
@@ -540,7 +616,11 @@ def Main():
|
||||
curvX = GetOrCreateCurve(lipo, 'LocX')
|
||||
curvY = GetOrCreateCurve(lipo, 'LocY')
|
||||
curvZ = GetOrCreateCurve(lipo, 'LocZ')
|
||||
curvrX = GetOrCreateCurve(lipo, 'RotX')
|
||||
curvrY = GetOrCreateCurve(lipo, 'RotY')
|
||||
curvrZ = GetOrCreateCurve(lipo, 'RotZ')
|
||||
|
||||
print "animating armature"
|
||||
|
||||
#armData.drawAxes(1)
|
||||
#armData.drawNames(1)
|
||||
@@ -553,9 +633,9 @@ def Main():
|
||||
## Enregistrement de la position de l'armature
|
||||
##-----------
|
||||
|
||||
bones = armData.getBones()
|
||||
for bo in bones:
|
||||
bo.setPose([Blender.Armature.Bone.ROT, Blender.Armature.Bone.LOC])
|
||||
bones = armData.bones.values()
|
||||
#??? for bo in bones:
|
||||
#??? bo.setPose([Blender.Armature.Bone.ROT, Blender.Armature.Bone.LOC])
|
||||
|
||||
curvX.addBezier((Blender.Get("curframe"), getEmpty(hipbonename).getMatrix('worldspace').translationPart()[0]*scalef))
|
||||
curvY.addBezier((Blender.Get("curframe"), getEmpty(hipbonename).getMatrix('worldspace').translationPart()[1]*scalef))
|
||||
@@ -566,6 +646,12 @@ def Main():
|
||||
curvY.setExtrapolation('Constant')
|
||||
curvZ.setInterpolation('Linear')
|
||||
curvZ.setExtrapolation('Constant')
|
||||
curvrX.setInterpolation('Linear')
|
||||
curvrX.setExtrapolation('Constant')
|
||||
curvrY.setInterpolation('Linear')
|
||||
curvrY.setExtrapolation('Constant')
|
||||
curvrZ.setInterpolation('Linear')
|
||||
curvrZ.setExtrapolation('Constant')
|
||||
|
||||
Blender.Redraw()
|
||||
|
||||
@@ -576,18 +662,21 @@ def Main():
|
||||
## Positionnement des os
|
||||
##-----------
|
||||
|
||||
moveArmature(armData, lesEmpties)
|
||||
#moveArmature(armData, lesEmpties)
|
||||
|
||||
|
||||
##-----------
|
||||
## Enregistrement de la position de l'armature
|
||||
##-----------
|
||||
|
||||
for bo in bones:
|
||||
bo.setPose([Blender.Armature.Bone.ROT, Blender.Armature.Bone.LOC])
|
||||
# ???? for bo in bones:
|
||||
# ???? bo.setPose([Blender.Armature.Bone.ROT, Blender.Armature.Bone.LOC])
|
||||
curvX.addBezier((Blender.Get("curframe"), (getEmpty(hipbonename).getMatrix('worldspace').translationPart()[0])*scalef))
|
||||
curvY.addBezier((Blender.Get("curframe"), (getEmpty(hipbonename).getMatrix('worldspace').translationPart()[1])*scalef))
|
||||
curvZ.addBezier((Blender.Get("curframe"), (getEmpty(hipbonename).getMatrix('worldspace').translationPart()[2])*scalef))
|
||||
curvrX.addBezier((Blender.Get("curframe"), (getEmpty(hipbonename).getMatrix('worldspace').rotationPart().toEuler()[0])*scalef/10))
|
||||
curvrY.addBezier((Blender.Get("curframe"), (getEmpty(hipbonename).getMatrix('worldspace').rotationPart().toEuler()[1])*scalef/10))
|
||||
curvrZ.addBezier((Blender.Get("curframe"), (getEmpty(hipbonename).getMatrix('worldspace').rotationPart().toEuler()[2])*scalef/10))
|
||||
|
||||
##-----------
|
||||
## Passage a la frame suivante
|
||||
@@ -596,6 +685,12 @@ def Main():
|
||||
print num_frame
|
||||
Blender.Set("curframe", num_frame)
|
||||
|
||||
curvX.Recalc()
|
||||
curvY.Recalc()
|
||||
curvZ.Recalc()
|
||||
curvrX.Recalc()
|
||||
curvrY.Recalc()
|
||||
curvrZ.Recalc()
|
||||
Blender.Set("curframe",startframe)
|
||||
Blender.Redraw()
|
||||
|
||||
@@ -627,11 +722,11 @@ def button_event(evt):
|
||||
global endframe, startframe, insertionframe, hipbonename, framedecimation , scalef
|
||||
if evt==1:
|
||||
startframe = SFrame2.val
|
||||
insertionframe = IFrame.val
|
||||
insertionframe = 100 #IFrame.val
|
||||
endframe = EFrame.val
|
||||
hipbonename = HBName.val
|
||||
framedecimation = FrameDecimation.val
|
||||
scalef= eval(str(ScaleF.val))
|
||||
scalef= 1.0 #eval(str(ScaleF.val))
|
||||
#print "scalef = ", scalef
|
||||
if startframe>=endframe:
|
||||
Msg = 'Start frame must be lower than End frame'
|
||||
@@ -646,6 +741,7 @@ def button_event(evt):
|
||||
else:
|
||||
#Blender.Draw.Exit()
|
||||
Main()
|
||||
#Main()
|
||||
else:
|
||||
Msg = 'Empty '+ hipbonename+ ' not found'
|
||||
|
||||
@@ -671,13 +767,18 @@ def GUI():
|
||||
Blender.BGL.glClear(Blender.BGL.GL_COLOR_BUFFER_BIT)
|
||||
Blender.BGL.glColor3f(1,1,1)
|
||||
Blender.BGL.glRasterPos2i(20,200)
|
||||
Blender.Draw.Text ("BVH 2 ARMATURE v2.2 by Jean-Baptiste PERIN", 'normal')
|
||||
HBName = Blender.Draw.String("HipBoneName: ", 0, 20, 175, 250, 20, '_Hips', 100)
|
||||
selobj = Blender.Object.GetSelected()
|
||||
if len(selobj) == 1 and type (selobj[0]) == Blender.Types.ObjectType:
|
||||
hipname = selobj[0].getName()
|
||||
else:
|
||||
hipname = '_Hips'
|
||||
Blender.Draw.Text ("BVH 2 ARMATURE v%s by %s"%(__version__, __author__), 'normal')
|
||||
HBName = Blender.Draw.String("HipBoneName: ", 0, 20, 175, 250, 20, hipname, 100)
|
||||
SFrame2 = Blender.Draw.Number("Startframe: ", 0, 20, 150, 250, 20, 1, 1,3000,"Start frame of anim")
|
||||
EFrame = Blender.Draw.Number("Endframe: ", 0, 20, 125, 250, 20, Blender.Get("endframe"), 1,3000,"Last frame of anim")
|
||||
#IFrame = Blender.Draw.Number("Insertionframe: ", 0, 20, 100, 250, 20, Blender.Get("staframe"), 1,3000,"")
|
||||
FrameDecimation = Blender.Draw.Number("FrameDecimation: ", 0, 20, 75, 250, 20,5, 1,10,'number of frame to skip between two action keys')
|
||||
ScaleF = Blender.Draw.Number("Scale: ", 0, 20, 50, 250, 20, 1.0, 0.0, 10.0, 'Scale Factor')
|
||||
FrameDecimation = Blender.Draw.Number("FrameDecimation: ", 0, 20, 75, 250, 20,1, 1,10,'number of frame to skip between two action keys')
|
||||
# ScaleF = Blender.Draw.Number("Scale: ", 0, 20, 50, 250, 20, 1.0, 0.0, 10.0, 'Scale Factor')
|
||||
Blender.Draw.Toggle("Create Armature", 1, 20, 10, 100, 20, 0, "Create Armature")
|
||||
#Blender.Draw.Toggle("Remove Empties", 2, 200, 10, 100, 20, 0, "Remove Empties")
|
||||
Blender.BGL.glRasterPos2i(20,40)
|
||||
|
||||
913
release/scripts/widgetwizard.py
Normal file
913
release/scripts/widgetwizard.py
Normal file
@@ -0,0 +1,913 @@
|
||||
#!BPY
|
||||
|
||||
"""
|
||||
Name: 'Shape Widget Wizard'
|
||||
Blender: 238
|
||||
Group: 'Animation'
|
||||
Tip: 'Adds Widgets for Driven Shapes'
|
||||
"""
|
||||
|
||||
__author__ = ["Johnny Matthews (guitargeek)"]
|
||||
__url__ = ("blender", "elysiun")
|
||||
__version__ = "0.0.9 12/15/05"
|
||||
|
||||
__bpydoc__ = """\
|
||||
"Shape Widget Wizard" creates objects that drive shape channels.
|
||||
|
||||
Explanation:
|
||||
|
||||
Shapes define morph targets and sometimes it is helpful to animate with a GUI
|
||||
control panel of widgets. This script lets you define several different types
|
||||
of controls that (depending on the type) control 1 to 4 shapes with a single
|
||||
controller.
|
||||
|
||||
Usage:
|
||||
|
||||
1. Click where you want the widget to go<br>
|
||||
2. Highlight the object that has shapes<br>
|
||||
3. Run the script<br>
|
||||
4. Choose the type of widget (there are next and back buttons if you pick the wrong kind)<br>
|
||||
5. Click next and choose what shapes go where on the widget<br>
|
||||
6. Choose a display name for the widget<br>
|
||||
7. Click finish
|
||||
|
||||
The widget is added and you are returned to the first screen for adding another widget.
|
||||
|
||||
"""
|
||||
|
||||
###################################################################
|
||||
# #
|
||||
# Shape Widget Wizard #
|
||||
# #
|
||||
# all versions (C) December 2005 Johnny Matthews (guitargeek) #
|
||||
# #
|
||||
# Released under the GPL #
|
||||
# #
|
||||
# Works in Blender 2.4 and higher #
|
||||
# #
|
||||
# This script can be found online at: #
|
||||
# http://guitargeek.superihost.com/widgetmaker #
|
||||
# #
|
||||
# email: johnny.matthews@gmail.com #
|
||||
###################################################################
|
||||
# History #
|
||||
# 0.9 #
|
||||
# Added Name Objects #
|
||||
# 0.81 #
|
||||
# Added Single Shape Toggle #
|
||||
# #
|
||||
# 0.8 #
|
||||
# Controller is Transform Locked and can only move #
|
||||
# in appropriate directions #
|
||||
# #
|
||||
# 0.7 #
|
||||
# Controller is named the same as the range + ".ctrl" #
|
||||
# #
|
||||
###################################################################
|
||||
|
||||
import Blender
|
||||
from Blender import Mesh,Object,Material,Window,IpoCurve,Ipo,Text3d
|
||||
from Blender.BGL import *
|
||||
from Blender.Draw import *
|
||||
print "----------------------"
|
||||
|
||||
SHAPE1_ONE_MONE = 1
|
||||
SHAPE1_ONE_ZERO = 2
|
||||
SHAPE1_ZERO_MONE = 3
|
||||
SHAPE1_TOGGLE = 12
|
||||
SHAPE2_EXCLUSIVE = 4
|
||||
SHAPE2_V = 5
|
||||
SHAPE2_T = 6
|
||||
SHAPE2_INVT = 7
|
||||
SHAPE2_PLUS = 8
|
||||
SHAPE3_T = 9
|
||||
SHAPE3_INVT = 10
|
||||
SHAPE4_X = 11
|
||||
|
||||
|
||||
stage = 1
|
||||
numshapes = Create(1)
|
||||
widmenu = Create(1)
|
||||
rangename = Create("Range")
|
||||
shapes = [Create(0),Create(0),Create(0),Create(0)]
|
||||
drawtype = 0
|
||||
|
||||
|
||||
#get rid of an ipo curve by deleting all its points
|
||||
def delCurve(ipo):
|
||||
while len(ipo.getPoints()) > 0:
|
||||
ipo.delBezier(0)
|
||||
ipo.recalc()
|
||||
|
||||
#if a given ipocurve is not there create it, otherwise get it
|
||||
def verifyIpocurve(ky,index):
|
||||
ipo = ky.ipo
|
||||
if ipo == None:
|
||||
nip = Ipo.New("Key","keyipo")
|
||||
ky.ipo = nip
|
||||
ipo = ky.ipo
|
||||
idx = "Key " + str(index)
|
||||
crv = ipo.getCurve(index)
|
||||
if crv == None:
|
||||
crv = ipo.addCurve(idx)
|
||||
crv.setInterpolation("Linear")
|
||||
return crv
|
||||
|
||||
# Add the Drivers and Curves
|
||||
def setupDrivers(ob,ctrl,type):
|
||||
global shapes
|
||||
me = ob.getData()
|
||||
ky = me.getKey()
|
||||
|
||||
if type in [SHAPE1_ONE_MONE,SHAPE1_ONE_ZERO,SHAPE1_ZERO_MONE]:
|
||||
ctrl.protectFlags = int("111111011",2)
|
||||
ipo = verifyIpocurve(ky,shapes[0].val)
|
||||
ipo.driver = 1
|
||||
ipo.driverObject = ctrl
|
||||
ipo.driverChannel = IpoCurve.LOC_Z
|
||||
ipo.recalc()
|
||||
|
||||
delCurve(ipo)
|
||||
if type == 1:
|
||||
ipo.addBezier((-1,-1))
|
||||
ipo.addBezier((0,0))
|
||||
ipo.addBezier((1,1))
|
||||
if type == 2:
|
||||
ipo.addBezier((0,0))
|
||||
ipo.addBezier((1,1))
|
||||
if type == 3:
|
||||
ipo.addBezier((-1,-1))
|
||||
ipo.addBezier((0,0))
|
||||
ipo.recalc()
|
||||
|
||||
if type == SHAPE1_TOGGLE:
|
||||
ctrl.protectFlags = int("111111011",2)
|
||||
ipo = verifyIpocurve(ky,shapes[0].val)
|
||||
ipo.driver = 1
|
||||
ipo.driverObject = ctrl
|
||||
ipo.driverChannel = IpoCurve.LOC_Z
|
||||
ipo.recalc()
|
||||
delCurve(ipo)
|
||||
ipo.addBezier((0,0))
|
||||
ipo.addBezier((0.5,0))
|
||||
ipo.addBezier((0.500001,1))
|
||||
ipo.addBezier((1,1))
|
||||
ipo.recalc()
|
||||
|
||||
if type == SHAPE2_EXCLUSIVE:
|
||||
ctrl.protectFlags = int("111111011",2)
|
||||
ipo = verifyIpocurve(ky,shapes[0].val)
|
||||
ipo.driver = 1
|
||||
ipo.driverObject = ctrl
|
||||
ipo.driverChannel = IpoCurve.LOC_Z
|
||||
ipo.recalc()
|
||||
delCurve(ipo)
|
||||
ipo.addBezier((0,0))
|
||||
ipo.addBezier((1,1))
|
||||
ipo.recalc()
|
||||
|
||||
ipo2 = verifyIpocurve(ky,shapes[1].val)
|
||||
ipo2.driver = 1
|
||||
ipo2.driverObject = ctrl
|
||||
ipo2.driverChannel = IpoCurve.LOC_Z
|
||||
ipo2.recalc()
|
||||
delCurve(ipo2)
|
||||
ipo2.addBezier((-1,1))
|
||||
ipo2.addBezier((0,0))
|
||||
ipo2.recalc()
|
||||
|
||||
if type == SHAPE2_T:
|
||||
ctrl.protectFlags = int("111111010",2)
|
||||
ipo = verifyIpocurve(ky,shapes[0].val)
|
||||
ipo.driver = 1
|
||||
ipo.driverObject = ctrl
|
||||
ipo.driverChannel = IpoCurve.LOC_Z
|
||||
ipo.recalc()
|
||||
delCurve(ipo)
|
||||
ipo.addBezier((-1,-1))
|
||||
ipo.addBezier((0,0))
|
||||
ipo.recalc()
|
||||
|
||||
ipo2 = verifyIpocurve(ky,shapes[1].val)
|
||||
ipo2.driver = 1
|
||||
ipo2.driverObject = ctrl
|
||||
ipo2.driverChannel = IpoCurve.LOC_X
|
||||
ipo2.recalc()
|
||||
delCurve(ipo2)
|
||||
ipo2.addBezier((-1,-1))
|
||||
ipo2.addBezier((1,1))
|
||||
ipo2.recalc()
|
||||
|
||||
if type == SHAPE2_INVT:
|
||||
ctrl.protectFlags = int("111111010",2)
|
||||
ipo = verifyIpocurve(ky,shapes[0].val)
|
||||
ipo.driver = 1
|
||||
ipo.driverObject = ctrl
|
||||
ipo.driverChannel = IpoCurve.LOC_Z
|
||||
ipo.recalc()
|
||||
delCurve(ipo)
|
||||
ipo.addBezier((0,0))
|
||||
ipo.addBezier((1,1))
|
||||
ipo.recalc()
|
||||
|
||||
ipo2 = verifyIpocurve(ky,shapes[1].val)
|
||||
ipo2.driver = 1
|
||||
ipo2.driverObject = ctrl
|
||||
ipo2.driverChannel = IpoCurve.LOC_X
|
||||
ipo2.recalc()
|
||||
delCurve(ipo2)
|
||||
ipo2.addBezier((-1,-1))
|
||||
ipo2.addBezier((1,1))
|
||||
ipo2.recalc()
|
||||
|
||||
if type == SHAPE2_PLUS:
|
||||
ctrl.protectFlags = int("111111010",2)
|
||||
ipo = verifyIpocurve(ky,shapes[0].val)
|
||||
ipo.driver = 1
|
||||
ipo.driverObject = ctrl
|
||||
ipo.driverChannel = IpoCurve.LOC_Z
|
||||
ipo.recalc()
|
||||
delCurve(ipo)
|
||||
ipo.addBezier((-1,-1))
|
||||
ipo.addBezier((1,1))
|
||||
ipo.recalc()
|
||||
|
||||
ipo2 = verifyIpocurve(ky,shapes[1].val)
|
||||
ipo2.driver = 1
|
||||
ipo2.driverObject = ctrl
|
||||
ipo2.driverChannel = IpoCurve.LOC_X
|
||||
ipo2.recalc()
|
||||
delCurve(ipo2)
|
||||
ipo2.addBezier((-1,-1))
|
||||
ipo2.addBezier((1,1))
|
||||
ipo2.recalc()
|
||||
|
||||
if type == SHAPE2_V: # 2 Shape Mix
|
||||
ctrl.protectFlags = int("111111010",2)
|
||||
ipo = verifyIpocurve(ky,shapes[0].val)
|
||||
ipo.driver = 1
|
||||
ipo.driverObject = ctrl
|
||||
ipo.driverChannel = IpoCurve.LOC_Z
|
||||
delCurve(ipo)
|
||||
ipo.addBezier((0,0))
|
||||
ipo.addBezier((1,1))
|
||||
ipo.recalc()
|
||||
|
||||
ipo2 = verifyIpocurve(ky,shapes[1].val)
|
||||
ipo2.driver = 1
|
||||
ipo2.driverObject = ctrl
|
||||
ipo2.driverChannel = IpoCurve.LOC_X
|
||||
delCurve(ipo2)
|
||||
ipo2.addBezier((0,0))
|
||||
ipo2.addBezier((1,1))
|
||||
ipo2.recalc()
|
||||
|
||||
|
||||
if type == SHAPE3_INVT:
|
||||
ctrl.protectFlags = int("111111010",2)
|
||||
ipo = verifyIpocurve(ky,shapes[0].val)
|
||||
ipo.driver = 1
|
||||
ipo.driverObject = ctrl
|
||||
ipo.driverChannel = IpoCurve.LOC_Z
|
||||
ipo.recalc()
|
||||
delCurve(ipo)
|
||||
ipo.addBezier((0,0))
|
||||
ipo.addBezier((1,1))
|
||||
ipo.recalc()
|
||||
|
||||
ipo2 = verifyIpocurve(ky,shapes[1].val)
|
||||
ipo2.driver = 1
|
||||
ipo2.driverObject = ctrl
|
||||
ipo2.driverChannel = IpoCurve.LOC_X
|
||||
ipo2.recalc()
|
||||
delCurve(ipo2)
|
||||
ipo2.addBezier((-1,1))
|
||||
ipo2.addBezier((0,0))
|
||||
ipo2.recalc()
|
||||
|
||||
ipo2 = verifyIpocurve(ky,shapes[2].val)
|
||||
ipo2.driver = 1
|
||||
ipo2.driverObject = ctrl
|
||||
ipo2.driverChannel = IpoCurve.LOC_X
|
||||
ipo2.recalc()
|
||||
delCurve(ipo2)
|
||||
ipo2.addBezier((0,0))
|
||||
ipo2.addBezier((1,1))
|
||||
ipo2.recalc()
|
||||
|
||||
if type == SHAPE3_T:
|
||||
ctrl.protectFlags = int("111111010",2)
|
||||
ipo = verifyIpocurve(ky,shapes[0].val)
|
||||
ipo.driver = 1
|
||||
ipo.driverObject = ctrl
|
||||
ipo.driverChannel = IpoCurve.LOC_Z
|
||||
ipo.recalc()
|
||||
delCurve(ipo)
|
||||
ipo.addBezier((-1,-1))
|
||||
ipo.addBezier((0,0))
|
||||
ipo.recalc()
|
||||
|
||||
ipo2 = verifyIpocurve(ky,shapes[1].val)
|
||||
ipo2.driver = 1
|
||||
ipo2.driverObject = ctrl
|
||||
ipo2.driverChannel = IpoCurve.LOC_X
|
||||
ipo2.recalc()
|
||||
delCurve(ipo2)
|
||||
ipo2.addBezier((-1,1))
|
||||
ipo2.addBezier((0,0))
|
||||
ipo2.recalc()
|
||||
|
||||
ipo2 = verifyIpocurve(ky,shapes[2].val)
|
||||
ipo2.driver = 1
|
||||
ipo2.driverObject = ctrl
|
||||
ipo2.driverChannel = IpoCurve.LOC_X
|
||||
ipo2.recalc()
|
||||
delCurve(ipo2)
|
||||
ipo2.addBezier((0,0))
|
||||
ipo2.addBezier((1,1))
|
||||
ipo2.recalc()
|
||||
|
||||
if type == SHAPE4_X:
|
||||
ctrl.protectFlags = int("111111010",2)
|
||||
ipo = verifyIpocurve(ky,shapes[0].val)
|
||||
ipo.driver = 1
|
||||
ipo.driverObject = ctrl
|
||||
ipo.driverChannel = IpoCurve.LOC_Z
|
||||
delCurve(ipo)
|
||||
ipo.addBezier((0,0))
|
||||
ipo.addBezier((1,1))
|
||||
ipo.recalc()
|
||||
|
||||
ipo2 = verifyIpocurve(ky,shapes[1].val)
|
||||
ipo2.driver = 1
|
||||
ipo2.driverObject = ctrl
|
||||
ipo2.driverChannel = IpoCurve.LOC_X
|
||||
delCurve(ipo2)
|
||||
ipo2.addBezier((0,0))
|
||||
ipo2.addBezier((1,1))
|
||||
ipo2.recalc()
|
||||
|
||||
ipo3 = verifyIpocurve(ky,shapes[2].val)
|
||||
ipo3.driver = 1
|
||||
ipo3.driverObject = ctrl
|
||||
ipo3.driverChannel = IpoCurve.LOC_X
|
||||
delCurve(ipo3)
|
||||
ipo3.addBezier((-1,1))
|
||||
ipo3.addBezier((0,0))
|
||||
ipo3.recalc()
|
||||
|
||||
ipo4 = verifyIpocurve(ky,shapes[3].val)
|
||||
ipo4.driver = 1
|
||||
ipo4.driverObject = ctrl
|
||||
ipo4.driverChannel = IpoCurve.LOC_Z
|
||||
delCurve(ipo4)
|
||||
ipo4.addBezier((-1,1))
|
||||
ipo4.addBezier((0,0))
|
||||
ipo4.recalc()
|
||||
|
||||
#The Main Call to Build the Widget
|
||||
|
||||
def build(type):
|
||||
global shapes,widmenu,rangename
|
||||
sce = Blender.Scene.getCurrent()
|
||||
loc = Window.GetCursorPos()
|
||||
range = makeRange(type,rangename.val)
|
||||
controller = makeController(rangename.val)
|
||||
text = makeText(rangename.val)
|
||||
|
||||
sce.link(range)
|
||||
sce.link(controller)
|
||||
sce.link(text)
|
||||
|
||||
range.setLocation(loc)
|
||||
controller.setLocation(loc)
|
||||
text.setLocation(loc)
|
||||
|
||||
range.makeParent([controller],1)
|
||||
range.makeParent([text],0)
|
||||
|
||||
sce.update()
|
||||
|
||||
ob = Object.GetSelected()[0]
|
||||
setupDrivers(ob,controller,widmenu.val)
|
||||
|
||||
#Create the text
|
||||
|
||||
def makeText(name):
|
||||
ob = Object.New("Text",name+".name")
|
||||
txt = Text3d.New(name+".name")
|
||||
txt.setDrawMode(Text3d.DRAW3D)
|
||||
txt.setAlignment(Text3d.MIDDLE)
|
||||
txt.setText(name)
|
||||
ob.link(txt)
|
||||
ob.setEuler(3.14159/2,0,0)
|
||||
return ob
|
||||
|
||||
|
||||
#Create the mesh controller
|
||||
|
||||
def makeController(name):
|
||||
ob = Object.New("Mesh",name+".ctrl")
|
||||
me = Mesh.New(name+".ctrl")
|
||||
|
||||
me.verts.extend(-0.15,0, 0)
|
||||
me.verts.extend( 0,0, 0.15)
|
||||
me.verts.extend( 0.15,0, 0)
|
||||
me.verts.extend( 0,0,-0.15)
|
||||
v = me.verts
|
||||
c = [(v[0],v[1],v[2],v[3])]
|
||||
me.edges.extend(c)
|
||||
ob.link(me)
|
||||
return ob
|
||||
|
||||
#Create the mesh range
|
||||
|
||||
def makeRange(type,name):
|
||||
ob = Object.New("Mesh",name)
|
||||
#ob.setDrawMode(8) # Draw Name
|
||||
me = Mesh.New(name)
|
||||
|
||||
l=[]
|
||||
|
||||
if type == SHAPE1_ONE_ZERO:
|
||||
me.verts.extend(-0.15,0,0)
|
||||
me.verts.extend( 0.15,0,0)
|
||||
me.verts.extend(-0.15,0,1)
|
||||
me.verts.extend( 0.15,0,1)
|
||||
me.verts.extend(-0.25,0,.1)
|
||||
me.verts.extend(-0.25,0,-.10)
|
||||
me.verts.extend(0.25,0,.1)
|
||||
me.verts.extend(0.25,0,-0.10)
|
||||
v = me.verts
|
||||
l = [(v[0],v[1],v[3],v[2]),(v[4],v[5],v[0]),(v[6],v[7],v[1])]
|
||||
me.edges.extend(l)
|
||||
ob.link(me)
|
||||
|
||||
elif type == SHAPE1_TOGGLE:
|
||||
me.verts.extend(-0.15,0,-0.5)
|
||||
me.verts.extend( 0.15,0,-0.5)
|
||||
me.verts.extend( 0.15,0, 0.5)
|
||||
me.verts.extend(-0.15,0, 0.5)
|
||||
me.verts.extend(-0.15,0, 1.5)
|
||||
me.verts.extend( 0.15,0, 1.5)
|
||||
v = me.verts
|
||||
l = [(v[0],v[1],v[2],v[3]),(v[3],v[4],v[5],v[2])]
|
||||
me.edges.extend(l)
|
||||
ob.link(me)
|
||||
|
||||
elif type == SHAPE1_ZERO_MONE:
|
||||
me.verts.extend(-0.15,0,0)
|
||||
me.verts.extend( 0.15,0,0)
|
||||
me.verts.extend(-0.15,0,-1)
|
||||
me.verts.extend( 0.15,0,-1)
|
||||
me.verts.extend(-0.25,0,.1)
|
||||
me.verts.extend(-0.25,0,-.10)
|
||||
me.verts.extend(0.25,0,.1)
|
||||
me.verts.extend(0.25,0,-0.10)
|
||||
v = me.verts
|
||||
l = [(v[0],v[1],v[3],v[2]),(v[4],v[5],v[0]),(v[6],v[7],v[1])]
|
||||
me.edges.extend(l)
|
||||
ob.link(me)
|
||||
|
||||
elif type in [SHAPE1_ONE_MONE,SHAPE2_EXCLUSIVE]:
|
||||
me.verts.extend(-0.15,0,-1)
|
||||
me.verts.extend( 0.15,0,-1)
|
||||
me.verts.extend(-0.15,0,1)
|
||||
me.verts.extend( 0.15,0,1)
|
||||
me.verts.extend(-0.25,0,.1)
|
||||
me.verts.extend(-0.25,0,-.10)
|
||||
me.verts.extend(0.25,0,.1)
|
||||
me.verts.extend(0.25,0,-0.10)
|
||||
me.verts.extend(-0.15,0,0)
|
||||
me.verts.extend( 0.15,0,0)
|
||||
|
||||
v = me.verts
|
||||
l = [(v[0],v[1],v[3],v[2]),(v[4],v[5],v[8]),(v[6],v[7],v[9])]
|
||||
me.edges.extend(l)
|
||||
ob.link(me)
|
||||
|
||||
elif type == SHAPE2_T:
|
||||
me.verts.extend(-1,0,0)
|
||||
me.verts.extend( 1,0,0)
|
||||
me.verts.extend( 1,0,-1)
|
||||
me.verts.extend(-1,0,-1)
|
||||
|
||||
v = me.verts
|
||||
l = [(v[0],v[1],v[2],v[3])]
|
||||
me.edges.extend(l)
|
||||
ob.link(me)
|
||||
|
||||
elif type == SHAPE2_INVT:
|
||||
me.verts.extend(-1,0,0)
|
||||
me.verts.extend( 1,0,0)
|
||||
me.verts.extend( 1,0,1)
|
||||
me.verts.extend(-1,0,1)
|
||||
|
||||
v = me.verts
|
||||
l = [(v[0],v[1],v[2],v[3])]
|
||||
me.edges.extend(l)
|
||||
ob.link(me)
|
||||
|
||||
elif type == SHAPE2_PLUS:
|
||||
me.verts.extend(-1,0,-1)
|
||||
me.verts.extend( 1,0,-1)
|
||||
me.verts.extend( 1,0,1)
|
||||
me.verts.extend(-1,0,1)
|
||||
|
||||
v = me.verts
|
||||
l = [(v[0],v[1],v[2],v[3])]
|
||||
me.edges.extend(l)
|
||||
ob.link(me)
|
||||
|
||||
elif type == SHAPE2_V:
|
||||
me.verts.extend(0,0,0)
|
||||
me.verts.extend(1,0,0)
|
||||
me.verts.extend(1,0,1)
|
||||
me.verts.extend(0,0,1)
|
||||
v = me.verts
|
||||
l = [(v[0],v[1],v[2],v[3])]
|
||||
me.edges.extend(l)
|
||||
ob.link(me)
|
||||
ob.setEuler(0,-0.78539,0)
|
||||
|
||||
elif type == SHAPE3_INVT:
|
||||
me.verts.extend(-1,0,0)
|
||||
me.verts.extend( 1,0,0)
|
||||
me.verts.extend( 1,0,1)
|
||||
me.verts.extend(-1,0,1)
|
||||
|
||||
v = me.verts
|
||||
l = [(v[0],v[1],v[2],v[3])]
|
||||
me.edges.extend(l)
|
||||
ob.link(me)
|
||||
|
||||
elif type == SHAPE3_T:
|
||||
me.verts.extend(-1,0,0)
|
||||
me.verts.extend( 1,0,0)
|
||||
me.verts.extend( 1,0,-1)
|
||||
me.verts.extend(-1,0,-1)
|
||||
|
||||
v = me.verts
|
||||
l = [(v[0],v[1],v[2],v[3])]
|
||||
me.edges.extend(l)
|
||||
ob.link(me)
|
||||
|
||||
|
||||
elif type == SHAPE4_X:
|
||||
me.verts.extend(0,0,-1)
|
||||
me.verts.extend(1,0,-1)
|
||||
me.verts.extend(1,0,0)
|
||||
me.verts.extend(1,0,1)
|
||||
me.verts.extend(0,0,1)
|
||||
me.verts.extend(-1,0,1)
|
||||
me.verts.extend(-1,0,0)
|
||||
me.verts.extend(-1,0,-1)
|
||||
v = me.verts
|
||||
l = [(v[0],v[1]),(v[1],v[2]),(v[2],v[3]),(v[3],v[4]),(v[4],v[5]),(v[5],v[6]),(v[6],v[7]),(v[7],v[0])]
|
||||
me.edges.extend(l)
|
||||
ob.link(me)
|
||||
ob.setEuler(0,-0.78539,0)
|
||||
|
||||
return ob
|
||||
|
||||
|
||||
def create():
|
||||
main()
|
||||
|
||||
####################### gui ######################
|
||||
|
||||
|
||||
EVENT_NONE = 1
|
||||
EVENT_EXIT = 100
|
||||
EVENT_WIDGET_MENU = 101
|
||||
EVENT_NEXT = 102
|
||||
EVENT_BACK = 103
|
||||
|
||||
#get the list of shapes from the selected object
|
||||
|
||||
def shapeMenuText():
|
||||
if len(Object.GetSelected()) == 0:
|
||||
return ""
|
||||
ob = Object.GetSelected()[0]
|
||||
me = ob.getData()
|
||||
key= me.getKey()
|
||||
if key == None:
|
||||
return ""
|
||||
blocks = key.getBlocks()
|
||||
menu = "Choose Shape %t|"
|
||||
for n in range(len(blocks)):
|
||||
menu = menu + blocks[n].name + " %x" + str(n) + "|"
|
||||
return menu
|
||||
|
||||
|
||||
#draw the widget for the gui
|
||||
|
||||
def drawWidget(type):
|
||||
global shapes
|
||||
if type == SHAPE1_ONE_MONE:# 1 to -1 Single Shape
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(150,50)
|
||||
glVertex2i(170,50)
|
||||
glVertex2i(170,150)
|
||||
glVertex2i(150,150)
|
||||
glVertex2i(150,50)
|
||||
glEnd()
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(140,100)
|
||||
glVertex2i(190,100)
|
||||
glEnd()
|
||||
glRasterPos2d(180,140)
|
||||
Text("1","normal")
|
||||
glRasterPos2d(180,60)
|
||||
Text("-1","normal")
|
||||
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 190, 100, 100, 18, shapes[0].val, "Choose Shape.")
|
||||
elif type == SHAPE1_TOGGLE:# Toggle Single Shape
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(150,50)
|
||||
glVertex2i(170,50)
|
||||
glVertex2i(170,100)
|
||||
glVertex2i(150,100)
|
||||
glVertex2i(150,50)
|
||||
glEnd()
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(170,100)
|
||||
glVertex2i(170,150)
|
||||
glVertex2i(150,150)
|
||||
glVertex2i(150,100)
|
||||
glEnd()
|
||||
glRasterPos2d(180,140)
|
||||
Text("On","normal")
|
||||
glRasterPos2d(180,60)
|
||||
Text("Off","normal")
|
||||
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 190, 100, 100, 18, shapes[0].val, "Choose Shape.")
|
||||
elif type == SHAPE1_ONE_ZERO: # 1 to 0 Single Shape
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(150,50)
|
||||
glVertex2i(170,50)
|
||||
glVertex2i(170,150)
|
||||
glVertex2i(150,150)
|
||||
glVertex2i(150,50)
|
||||
glEnd()
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(140,50)
|
||||
glVertex2i(190,50)
|
||||
glEnd()
|
||||
glRasterPos2d(180,140)
|
||||
Text("1","normal")
|
||||
glRasterPos2d(180,60)
|
||||
Text("0","normal")
|
||||
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 190, 100, 100, 18, shapes[0].val, "Choose Shape.")
|
||||
elif type == SHAPE1_ZERO_MONE:
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(150,50)
|
||||
glVertex2i(170,50)
|
||||
glVertex2i(170,150)
|
||||
glVertex2i(150,150)
|
||||
glVertex2i(150,50)
|
||||
glEnd()
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(140,150)
|
||||
glVertex2i(190,150)
|
||||
glEnd()
|
||||
glRasterPos2d(180,140)
|
||||
Text("0","normal")
|
||||
glRasterPos2d(180,60)
|
||||
Text("-1","normal")
|
||||
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 190, 100, 100, 18, shapes[0].val, "Choose Shape.")
|
||||
elif type == SHAPE2_EXCLUSIVE:
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(150,50)
|
||||
glVertex2i(170,50)
|
||||
glVertex2i(170,150)
|
||||
glVertex2i(150,150)
|
||||
glVertex2i(150,50)
|
||||
glEnd()
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(140,100)
|
||||
glVertex2i(190,100)
|
||||
glEnd()
|
||||
glRasterPos2d(180,140)
|
||||
Text("1","normal")
|
||||
glRasterPos2d(180,60)
|
||||
Text("1","normal")
|
||||
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 195, 135, 100, 18, shapes[0].val, "Choose Shape 1.")
|
||||
shapes[1] = Menu(shapeMenuText(), EVENT_NONE, 195, 52, 100, 18, shapes[1].val, "Choose Shape 2.")
|
||||
elif type == SHAPE2_T:
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(150,75)
|
||||
glVertex2i(250,75)
|
||||
glVertex2i(250,125)
|
||||
glVertex2i(150,125)
|
||||
glVertex2i(150,75)
|
||||
glEnd()
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(140,125)
|
||||
glVertex2i(260,125)
|
||||
glEnd()
|
||||
glRasterPos2d(200,140)
|
||||
Text("0","normal")
|
||||
glRasterPos2d(200,60)
|
||||
Text("-1","normal")
|
||||
glRasterPos2d(250,140)
|
||||
Text("1","normal")
|
||||
glRasterPos2d(150,140)
|
||||
Text("-1","normal")
|
||||
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 220, 52, 100, 18, shapes[0].val, "Choose Shape 1.")
|
||||
shapes[1] = Menu(shapeMenuText(), EVENT_NONE, 260, 135, 100, 18, shapes[1].val, "Choose Shape 2.")
|
||||
elif type == SHAPE2_INVT:
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(150,75)
|
||||
glVertex2i(250,75)
|
||||
glVertex2i(250,125)
|
||||
glVertex2i(150,125)
|
||||
glVertex2i(150,75)
|
||||
glEnd()
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(140,75)
|
||||
glVertex2i(260,75)
|
||||
glEnd()
|
||||
glRasterPos2d(200,60)
|
||||
Text("0","normal")
|
||||
glRasterPos2d(200,140)
|
||||
Text("1","normal")
|
||||
glRasterPos2d(250,60)
|
||||
Text("1","normal")
|
||||
glRasterPos2d(150,60)
|
||||
Text("-1","normal")
|
||||
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 220, 135, 100, 18, shapes[0].val, "Choose Shape 1.")
|
||||
shapes[1] = Menu(shapeMenuText(), EVENT_NONE, 260, 52, 100, 18, shapes[1].val, "Choose Shape 2.")
|
||||
elif type == SHAPE2_PLUS:
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(150,50)
|
||||
glVertex2i(250,50)
|
||||
glVertex2i(250,150)
|
||||
glVertex2i(150,150)
|
||||
glVertex2i(150,50)
|
||||
glEnd()
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(140,100)
|
||||
glVertex2i(260,100)
|
||||
glEnd()
|
||||
glRasterPos2d(200,105)
|
||||
Text("0","normal")
|
||||
glRasterPos2d(200,140)
|
||||
Text("1","normal")
|
||||
glRasterPos2d(200,55)
|
||||
Text("-1","normal")
|
||||
glRasterPos2d(250,105)
|
||||
Text("1","normal")
|
||||
glRasterPos2d(150,105)
|
||||
Text("-1","normal")
|
||||
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 220, 155, 100, 18, shapes[0].val, "Choose Shape 1.")
|
||||
shapes[1] = Menu(shapeMenuText(), EVENT_NONE, 260, 100, 100, 18, shapes[1].val, "Choose Shape 2.")
|
||||
elif type == SHAPE2_V:
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(150,70)
|
||||
glVertex2i(185,105)
|
||||
glVertex2i(150,141)
|
||||
glVertex2i(115,105)
|
||||
glVertex2i(150,70)
|
||||
glEnd()
|
||||
glRasterPos2d(110,105)
|
||||
Text("1","normal")
|
||||
glRasterPos2d(190,105)
|
||||
Text("1","normal")
|
||||
glRasterPos2d(150,80)
|
||||
Text("0","normal")
|
||||
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 20, 125, 100, 18, shapes[0].val, "Choose Shape 1.")
|
||||
shapes[1] = Menu(shapeMenuText(), EVENT_NONE, 195, 125, 100, 18, shapes[1].val, "Choose Shape 2.")
|
||||
|
||||
|
||||
|
||||
elif type == SHAPE3_T:
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(150,75)
|
||||
glVertex2i(250,75)
|
||||
glVertex2i(250,125)
|
||||
glVertex2i(150,125)
|
||||
glVertex2i(150,75)
|
||||
glEnd()
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(140,125)
|
||||
glVertex2i(260,125)
|
||||
glEnd()
|
||||
glRasterPos2d(200,140)
|
||||
Text("0","normal")
|
||||
glRasterPos2d(200,60)
|
||||
Text("-1","normal")
|
||||
glRasterPos2d(250,140)
|
||||
Text("1","normal")
|
||||
glRasterPos2d(150,140)
|
||||
Text("1","normal")
|
||||
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 220, 52, 100, 18, shapes[0].val, "Choose Shape 1.")
|
||||
shapes[1] = Menu(shapeMenuText(), EVENT_NONE, 45, 135, 100, 18, shapes[1].val, "Choose Shape 2.")
|
||||
shapes[2] = Menu(shapeMenuText(), EVENT_NONE, 260, 135, 100, 18, shapes[2].val, "Choose Shape 3.")
|
||||
elif type == SHAPE3_INVT:
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(150,75)
|
||||
glVertex2i(250,75)
|
||||
glVertex2i(250,125)
|
||||
glVertex2i(150,125)
|
||||
glVertex2i(150,75)
|
||||
glEnd()
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(140,75)
|
||||
glVertex2i(260,75)
|
||||
glEnd()
|
||||
glRasterPos2d(200,60)
|
||||
Text("0","normal")
|
||||
glRasterPos2d(200,140)
|
||||
Text("1","normal")
|
||||
glRasterPos2d(250,60)
|
||||
Text("1","normal")
|
||||
glRasterPos2d(150,60)
|
||||
Text("1","normal")
|
||||
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 220, 135, 100, 18, shapes[0].val, "Choose Shape 1.")
|
||||
shapes[1] = Menu(shapeMenuText(), EVENT_NONE, 45, 52, 100, 18, shapes[1].val, "Choose Shape 2.")
|
||||
shapes[2] = Menu(shapeMenuText(), EVENT_NONE, 260, 52, 100, 18, shapes[2].val, "Choose Shape 3.")
|
||||
|
||||
|
||||
elif type == SHAPE4_X:
|
||||
glBegin(GL_LINE_STRIP)
|
||||
glVertex2i(150,70)
|
||||
glVertex2i(185,105)
|
||||
glVertex2i(150,141)
|
||||
glVertex2i(115,105)
|
||||
glVertex2i(150,70)
|
||||
glEnd()
|
||||
glRasterPos2d(120,125)
|
||||
Text("1","normal")
|
||||
glRasterPos2d(180,125)
|
||||
Text("1","normal")
|
||||
glRasterPos2d(120,80)
|
||||
Text("1","normal")
|
||||
glRasterPos2d(180,80)
|
||||
Text("1","normal")
|
||||
|
||||
glRasterPos2d(145,105)
|
||||
Text("0","normal")
|
||||
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 10, 125, 100, 18, shapes[0].val, "Choose Shape 1.")
|
||||
shapes[1] = Menu(shapeMenuText(), EVENT_NONE, 195, 125, 100, 18, shapes[1].val, "Choose Shape 2.")
|
||||
shapes[2] = Menu(shapeMenuText(), EVENT_NONE, 10, 60, 100, 18, shapes[2].val, "Choose Shape 3.")
|
||||
shapes[3] = Menu(shapeMenuText(), EVENT_NONE, 195, 60, 100, 18, shapes[3].val, "Choose Shape 4.")
|
||||
|
||||
#the gui callback
|
||||
|
||||
def draw():
|
||||
global widmenu,numshapes,stage,type, shapes,rangename
|
||||
glRasterPos2d(5,200)
|
||||
Text("Shape Widget Wizard","large")
|
||||
PushButton("Quit", EVENT_EXIT, 5, 5, 50, 18)
|
||||
|
||||
if stage == 1:
|
||||
name = "Choose Widget Type %t|\
|
||||
1 Shape: 1 / -1 %x" +str(SHAPE1_ONE_MONE) +"|\
|
||||
1 Shape: 1,0 %x" +str(SHAPE1_ONE_ZERO) +"|\
|
||||
1 Shape: 0,-1 %x" +str(SHAPE1_ZERO_MONE)+"|\
|
||||
1 Shape: Toggle %x" +str(SHAPE1_TOGGLE) +"|\
|
||||
2 Shape Exclusive %x"+str(SHAPE2_EXCLUSIVE)+"|\
|
||||
2 Shape - V %x" +str(SHAPE2_V) +"|\
|
||||
2 Shape - T %x" +str(SHAPE2_T) +"|\
|
||||
2 Shape - Inv T %x" +str(SHAPE2_INVT) +"|\
|
||||
2 Shape - + %x" +str(SHAPE2_PLUS) +"|\
|
||||
3 Shape - T %x" +str(SHAPE3_T) +"|\
|
||||
3 Shape - Inv T%x" +str(SHAPE3_INVT) +"|\
|
||||
4 Shape - Mix %x" +str(SHAPE4_X)
|
||||
widmenu = Menu(name, EVENT_NONE, 5, 120, 200, 40, widmenu.val, "Choose Widget Type.")
|
||||
PushButton("Next", EVENT_NEXT, 5, 25, 50, 18)
|
||||
|
||||
elif stage == 2:
|
||||
glRasterPos2d(60,140)
|
||||
rangename = String("Name: ", EVENT_NONE, 5, 170, 200, 18, rangename.val, 50, "Name for Range Object")
|
||||
drawWidget(widmenu.val)
|
||||
PushButton("Back", EVENT_BACK, 5, 25, 50, 18)
|
||||
PushButton("Finish", EVENT_NEXT, 55, 25, 50, 18)
|
||||
return
|
||||
|
||||
|
||||
|
||||
def event(evt, val):
|
||||
if (evt == QKEY and not val):
|
||||
Exit()
|
||||
|
||||
|
||||
def bevent(evt):
|
||||
global widmenu,stage,drawtype
|
||||
######### Manages GUI events
|
||||
if evt==EVENT_EXIT:
|
||||
Exit()
|
||||
elif evt==EVENT_BACK:
|
||||
if stage == 2:
|
||||
stage = 1
|
||||
Redraw()
|
||||
elif evt==EVENT_NEXT:
|
||||
if stage == 1:
|
||||
stage = 2
|
||||
Redraw()
|
||||
elif stage == 2:
|
||||
build(widmenu.val)
|
||||
stage = 1
|
||||
Window.RedrawAll()
|
||||
|
||||
|
||||
Register(draw, event, bevent)
|
||||
Reference in New Issue
Block a user