TouchDesigner 운영자를 Python으로 연결
4608 단어 TouchDesigner파이썬
이 기사에서 전하고 싶은 것
TouchDesigner의 오퍼레이터의 연결을 Python으로 자동 제어하고 싶을 때, 다음의 3개를 기억해 두면 어떻게 됩니다.
to
의 입력으로서 오퍼레이터 from
를 연결하고 싶을 때는 to.inputConnectors[0].connect(from)
로한다. from
의 출력으로서 오퍼레이터 to
를 연결하고 싶을 때는 from.outputConnectors[0].connect(to)
로한다. me.outputConnectors[0].disconnect()
와 같이, disconnect()
를 부른다. 구체적인 예
귀여운 고양이의 이미지를 그물로 잡고 있으면 매우 치유됩니다. 그래서 Twitter에서 "cat"과 검색을 걸었을 때 히트하는 이미지를 취득하여 슬라이드 쇼 표시시키는 것을 만듭니다.

프로그램의 전체도는 다음과 같습니다.

왼쪽 절반의 빨간색 부분에서 이미지 URL을 가져 와서 File
Replicator COMP에서 속성에 지정된 Movie File In TOP을 생성합니다. 그리고 복사 결과를 모두 Switch TOP에 연결하고, 그 Index
프로퍼티를 LFO CHOP로 조작하고 있습니다.
DAT에 이미지의 URL을 수납해, 그 각 성분을 차례로 보는 것으로 각 이미지를 표시하는 Movie File In TOP를 생성하는 방법은, TouchDesigner 사용하면 한번은 통과하는 길: Visual Thinking with TouchDesigner - 프로가 선택하는 실시간 렌더링 및 프로토타이핑의 극의의 3장 14절 「Replicator COMP에서 동적으로 복제한다”에 기재된 것과 동일하므로 여기에서는 자세한 것은 생략합니다.
이제 문제가되고 싶은 것은 복제 된 각 Movie File In TOP을 Switch TOP에 연결하는 것입니다. 여기를이 기사의 첫 번째 코드에서 해결합니다. Replicator COMP에는 콜백용 Text DAT가 붙어 있습니다. 이 Python 코드를 다음과 같이 다시 씁니다.
replicator1_callbacks.py# me - this DAT
#
# comp - the replicator component which is cooking
# allOps - a list of all replicants, created or existing
# newOps - the subset that were just created
# template - table DAT specifying the replicator attributes
# master - the master operator
#
def onReplicate(comp, allOps, newOps, template, master):
switch = op('switch1')
lfo = op('lfo1')
# switchオペレータのIndexが,1から画像の総数まで,1秒ごとにインクリメントされるように設定
lfo.par.frequency = 1.0 / len(newOps)
lfo.par.offset = 1
lfo.par.amp = len(newOps)
for c in newOps:
c.outputConnectors[0].connect(switch)
#c.display = True
#c.render = True
#c.par.display = 1
#c.par.clone = comp.par.master
pass
return
여기에서는 복제된 각 오퍼레이터의 출력으로서 Switch TOP를 연결하고 싶으므로, c.outputConnectors[0].connect(switch)
로 했습니다.
모처럼 노드 기반으로 프로그래밍할 수 있는데 Python으로 연결을 제어하는 장면은 그렇게 생각하지 않지만, 예를 들면 이와 같이 Replicator COMP와 조합하는 것으로, 수고를 줄일 수 있습니다. 구체적인 예에서는 취급하지 않았던 접속을 끊는 코드도 포함해 꼭 도움을 주세요.
Reference
이 문제에 관하여(TouchDesigner 운영자를 Python으로 연결), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/radi_bow/items/24f7384d9bfaafdd5d3c
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
# me - this DAT
#
# comp - the replicator component which is cooking
# allOps - a list of all replicants, created or existing
# newOps - the subset that were just created
# template - table DAT specifying the replicator attributes
# master - the master operator
#
def onReplicate(comp, allOps, newOps, template, master):
switch = op('switch1')
lfo = op('lfo1')
# switchオペレータのIndexが,1から画像の総数まで,1秒ごとにインクリメントされるように設定
lfo.par.frequency = 1.0 / len(newOps)
lfo.par.offset = 1
lfo.par.amp = len(newOps)
for c in newOps:
c.outputConnectors[0].connect(switch)
#c.display = True
#c.render = True
#c.par.display = 1
#c.par.clone = comp.par.master
pass
return
Reference
이 문제에 관하여(TouchDesigner 운영자를 Python으로 연결), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/radi_bow/items/24f7384d9bfaafdd5d3c텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)