diff --git a/Makefile b/Makefile index a66268b..6b8afcd 100644 --- a/Makefile +++ b/Makefile @@ -1,170 +1,41 @@ -BLEND = avatar_cartoon_v1.0.0.blend -BLENDER = blender -BLUE = \33[34;5m -CACHE = ./__pycache__ +BLEND = avatar_cartoon_v2.70.blend CONTROLLER = controller.py -CORE = git@git.lavid.ufpb.br:wikilibras-core -DONE = [$(GREEN)Finalizado$(NONE)] -FAIL = [$(RED)Falhou$(NONE)] Codigo: $$? -GREEN = \33[32;5m -JSON = '{"userId": 2, "rightHand": ["circular", "plano", "horario", 1, 2, 0, 50, 20], "leftHand":[], "facialExp": [6], "signName":"teste_circular"}' MAIN = libras.py -MODULE = Wikilibras -NONE = \33[m +# Circular: ['circular', x, x, Raio=1, Voltas=3 CfM=0, PAr=80, Ori=0] +JSON = '{"userId": 4, "rightHand": ["circular", "plano", "horario", 1, 3, 0, 80, 0], "leftHand":[], "facialExp": [1], "signName": "teste circular"}' +#JSON = '{"userId": 4, "rightHand": ["pontual", 55, 81, 21], "leftHand":[], "facialExp": [], "signName": "teste pontual"}' +#JSON = '{"userId": 4, "rightHand": ["pontual", 0, 80, 1], "leftHand":[], "facialExp": [1], "signName": "teste facial 1"}' +#JSON = '{"userId": 4, "rightHand": ["pontual", 0, 80, 2], "leftHand":[], "facialExp": [21], "signName": "teste facial 2"}' +BLENDER = blender +CACHE += "./__pycache__" +CACHE += "./users" +CACHE += "./events.log" +DONE = [\33[32;5mFinalizado\33[m] +FAIL = [\33[31;5mFalhou\33[m] Codigo: $$? PYTHON = python3 -RED = \33[31;5m -WHITE = \33[37;5m -__default__: py +.PHONY: py bpy clean help -.clscr: - @echo -n "\033c" +py: + @echo "[\33[32;5mExecutando\33[m]\33[34;5m $(PYTHON) "$(CONTROLLER)" {JSON} ...\33[m"; $(PYTHON) "$(CONTROLLER)" $(JSON) && echo "$(DONE)" || echo "$(FAIL)" bpy: - @echo "[$(GREEN)Executando$(NONE)]$(BLUE) $(BLENDER) -b "$(BLEND)" -P "$(MAIN)" JSON ...$(NONE)";\ - $(BLENDER) -b "$(BLEND)" -P "$(MAIN)" $(JSON)\ - && echo "$(DONE)" || { echo "$(FAIL)"; exit $$?; } - -clean: .clscr - @echo -n "$(WHITE)Limpando... $(NONE) ";\ - rm -rf "$(CACHE)"\ - && echo "$(DONE)" || { echo "$(FAIL)"; exit $$?; } - -git-clone: - @input="";\ - while [ "$$input" != "s" ] && [ "$$input" != "n" ];\ - do\ - echo -n "$(GREEN)Clonar $(BLUE)$(CORE)?$(NONE) (s/n): ";\ - read input;\ - input="`echo $$input | tr [:upper:] [:lower:]`";\ - done;\ - if [ "$$input" = "s" ];\ - then\ - git clone $(CORE);\ - else\ - exit 0;\ - fi\ - && echo "$(DONE)" || { echo "$(FAIL)"; exit $$?; } - -git-config: - @echo -n "$(GREEN)Nome:$(BLUE) ";\ - git config --global user.name;\ - echo -n "$(GREEN)Email:$(BLUE) ";\ - git config --global user.email;\ - input="";\ - while [ "$$input" != "s" ] && [ "$$input" != "n" ];\ - do\ - echo -n "$(GREEN)Configurar Git?$(NONE) (s/n): ";\ - read input;\ - input="`echo $$input | tr [:upper:] [:lower:]`";\ - done;\ - if [ "$$input" = "s" ];\ - then\ - name="";\ - while [ -z "$$name" ];\ - do\ - echo -n "$(GREEN)Digite seu nome:$(NONE) ";\ - read name;\ - done;\ - email="";\ - while [ -z "$$email" ];\ - do\ - echo -n "$(GREEN)Digite seu email:$(NONE) ";\ - read email;\ - done;\ - input="";\ - while [ "$$input" != "s" ] && [ "$$input" != "n" ];\ - do\ - echo -n "$(GREEN)Confirma dados?$(NONE) (s/n): ";\ - read input;\ - input="`echo $$input | tr [:upper:] [:lower:]`";\ - done;\ - if [ "$$input" = "s" ];\ - then\ - git config --global user.name "$$name";\ - git config --global user.email "$$email";\ - git config --global color.diff auto;\ - git config --global color.status auto;\ - git config --global color.branch auto;\ - git config --global color.ui true;\ - git config --global push.default simple;\ - else\ - exit 0;\ - fi;\ - else\ - exit 0;\ - fi\ - && echo "$(DONE)" || { echo "$(FAIL)"; exit $$?; } + @echo "[\33[32;5mExecutando\33[m]\33[34;5m $(BLENDER) -b "$(BLEND)" -P "$(MAIN)" {JSON} ...\33[m"; $(BLENDER) -b "$(BLEND)" -P "$(MAIN)" $(JSON) && echo "$(DONE)" || echo "$(FAIL)" help: @echo "" - @echo " $(WHITE) Make $(NONE)" + @echo " \33[37;5m Make \33[m" @echo "" - @echo " $(GREEN) $(NONE) $(BLUE) $(NONE)" + @echo " \33[32;5m \33[m \33[34;5m \33[m" @echo "" - @echo " $(GREEN) bpy $(NONE) $(BLUE) Executa: $(BLENDER) <$(MAIN)> com parametros JSON do Makefile $(NONE)" - @echo " $(GREEN) clean $(NONE) $(BLUE) Remove pasta(s) temporaria(s): $(CACHE) $(NONE)" - @echo " $(GREEN) git-clone $(NONE) $(BLUE) Clona repositorio: \"$(CORE)\" na pasta atual $(NONE)" - @echo " $(GREEN) git-config $(NONE) $(BLUE) Configura Git para o primeiro uso $(NONE)" - @echo " $(GREEN) help $(NONE) $(BLUE) Exibe ajuda $(NONE)" - @echo " $(GREEN) py $(NONE) $(BLUE) Executa: $(PYTHON) <$(CONTROLLER)> com parametros JSON do Makefile $(NONE)" - @echo " $(GREEN) recv $(NONE) $(BLUE) Recebe dados do repositorio: \"$(CORE)\" $(NONE)" - @echo " $(GREEN) send $(NONE) $(BLUE) Envia dados para o repositorio: \"$(CORE)\" $(NONE)" + @echo " \33[32;5m bpy \33[m \33[34;5m Executa: $(BLENDER) <$(MAIN)> com parametros JSON do Makefile \33[m" + @echo " \33[32;5m clean \33[m \33[34;5m Remove pasta(s) temporaria(s): $(CACHE) \33[m" + @echo " \33[32;5m help \33[m \33[34;5m Exibe ajuda \33[m" + @echo " \33[32;5m py \33[m \33[34;5m Executa: $(PYTHON) <$(CONTROLLER)> com parametros JSON do Makefile \33[m" @echo "" -py: - @echo "[$(GREEN)Executando$(NONE)]$(BLUE) $(PYTHON) "$(CONTROLLER)" JSON ...$(NONE)";\ - $(PYTHON) "$(CONTROLLER)" $(JSON)\ - && echo "$(DONE)" || { echo "$(FAIL)"; exit $$?; } - -recv: - @input="";\ - while [ "$$input" != "s" ] && [ "$$input" != "n" ];\ - do\ - echo -n "$(GREEN)Receber dados alterados?$(NONE) (s/n): ";\ - read input;\ - input="`echo $$input | tr [:upper:] [:lower:]`";\ - done;\ - if [ "$$input" = "s" ];\ - then\ - git pull;\ - else\ - exit 0;\ - fi\ - && echo "$(DONE)" || { echo "$(FAIL)"; exit $$?; } +.clscr: + @echo -n "\033c" -send: - @input="";\ - while [ "$$input" != "s" ] && [ "$$input" != "n" ];\ - do\ - echo -n "$(GREEN)Enviar alteracoes realizadas?$(NONE) (s/n): ";\ - read input;\ - input="`echo $$input | tr [:upper:] [:lower:]`";\ - done;\ - if [ "$$input" = "s" ];\ - then\ - comment="";\ - while [ -z "$$comment" ];\ - do\ - echo -n "$(GREEN)Digite o comentario das alteracoes:$(NONE) ";\ - read comment;\ - done;\ - input="";\ - while [ "$$input" != "s" ] && [ "$$input" != "n" ];\ - do\ - echo -n "$(GREEN)Enviar dados?$(NONE) (s/n): ";\ - read input;\ - input="`echo $$input | tr [:upper:] [:lower:]`";\ - done;\ - if [ "$$input" = "s" ];\ - then\ - git add .;\ - git commit -m "$$comment";\ - git push;\ - else\ - exit 0;\ - fi;\ - else\ - exit 0;\ - fi\ - && echo "$(DONE)" || { echo "$(FAIL)"; exit $$?; } +clean: .clscr + @echo -n "\33[37;5mLimpando... \33[m "; rm -rf $(CACHE); echo "$(DONE)" diff --git a/avatar_cartoon_v1.0.0.blend b/avatar_cartoon_v1.0.0.blend deleted file mode 100755 index 175007a..0000000 Binary files a/avatar_cartoon_v1.0.0.blend and /dev/null differ diff --git a/avatar_cartoon_v2.70.blend b/avatar_cartoon_v2.70.blend new file mode 100755 index 0000000..fdf1b7a Binary files /dev/null and b/avatar_cartoon_v2.70.blend differ diff --git a/controller.py b/controller.py index 4b3e3f5..e50a365 100644 --- a/controller.py +++ b/controller.py @@ -8,15 +8,15 @@ getcwd = dirname(abspath(__file__)) from pyutil import printStackTrace -blend_path = join(getcwd, "avatar_cartoon_v1.0.0.blend") +blend_path = join(getcwd, "avatar_cartoon_v2.70.blend") main_path = join(getcwd, "libras.py") -restult = 0 +result = 0 try: # Caso seja necessário gravar logs do blender utilizar a linha de código abaixo - # restult = call(['blender', '-b', blend_path, '-P', main_path, argv[1]], stdout = open( 'bpy.log', 'w')) - restult = call(['blender', '-b', blend_path, '-P', main_path, argv[1]]) + # result = call(['blender', '-b', blend_path, '-P', main_path, argv[1]], stdout = open('bpy.log', 'w')) + result = call(['blender', '-b', blend_path, '-P', main_path, argv[1]]) except: - restult = printStackTrace(__file__) + result = printStackTrace(__file__) -exit(restult) +exit(result) diff --git a/libras.py b/libras.py index 8507f0c..d0f2e56 100644 --- a/libras.py +++ b/libras.py @@ -43,8 +43,8 @@ def setHandConfiguration(actions, handParam, positionFrames, bones): util.setPose(actions, handParam, positionFrames, bones) # Função responsável por setar a configuração da face -def setFaceConfiguration(handParam, positionFrames, bones): - util.setPose([7], handParam, positionFrames, bones) +def setFaceConfiguration(handParam, positionFrames, bones): + util.setPose(['007_Facial'], handParam, positionFrames, bones) # Sugestao: Alguma forma de uniformizar o calculo do endFrame (atualizado aqui e no movimento circular) initialFrame, endFrame = 15, util.get_endFrame(json_input, util.hands_frames_retilineo) @@ -65,10 +65,10 @@ def configureHands(): move = json_input[hands[i]][0] pose = util.armature.pose.bones[iks[i]] handParam = json_input[hands[i]][-3:] - + if(move in ["pontual", "circular", "semicircular", "retilineo", "senoidal"]): setHandConfiguration(actions[i], handParam, util.hands_default_frames, bones_[i]) - + if(move in ["circular", "semicircular"]): orientation, direction, radius, laps = json_input[hands[i]][1:5] endFrame = moves.circular_or_semiCircular(pose, orientation, direction, radius, laps, 5) @@ -87,7 +87,6 @@ def configureHands(): def configureFace(): global endFrame if(json_input["facialExp"] != []): - # Set face setFaceConfiguration(json_input["facialExp"], [endFrame/4], util.faceBonesConf) poseDefault([1]) diff --git a/moves.py b/moves.py index fc9e1e6..a09e849 100644 --- a/moves.py +++ b/moves.py @@ -170,7 +170,7 @@ def locationCircular(center, radius, i_axis, j_axis, k_axis, pose, initialPositi pose.location[i_axis] = center[i_axis] + sqrt22 pose.location[j_axis] = center[j_axis] + rad2 pose.location[k_axis] = center[k_axis] + rad2 - util.keyframe_insert(pose, 'location', initialPosition) + util.keyframe_insert(pose, 'location', currentFrame) currentFrame += frameJump if ((l % 8) == 2): pose.location[i_axis] = center[i_axis] @@ -182,7 +182,7 @@ def locationCircular(center, radius, i_axis, j_axis, k_axis, pose, initialPositi elif(turn == -1): pose.location[j_axis] = center[j_axis] + sqrt22 pose.location[k_axis] = center[k_axis] + sqrt22 - util.keyframe_insert(pose, 'location', initialPosition) + util.keyframe_insert(pose, 'location', currentFrame) currentFrame += frameJump if ((l % 8) == 3): pose.location[i_axis] = center[i_axis] - sqrt22 @@ -196,7 +196,7 @@ def locationCircular(center, radius, i_axis, j_axis, k_axis, pose, initialPositi pose.location[i_axis] = center[i_axis] - sqrt22 pose.location[j_axis] = center[j_axis] + rad2 pose.location[k_axis] = center[k_axis] + rad2 - util.keyframe_insert(pose, 'location', initialPosition) + util.keyframe_insert(pose, 'location', currentFrame) currentFrame += frameJump if ((l % 8) == 4): -- libgit2 0.21.2