Track
7
CEDEC2024-実演-カットシーンでの素材を置き換えたい
RANK
AZSTOKE_CEDEC2024_FOOTREPLACE
import sys
sys.path.append(RPR_GetResourcePath() + r"/UserPlugins")
from RIGDOCKS_python import *
from AZSTOKE_BRONZE_python import *
from AZSTOKE_SILVER_python import *
def replaceFoot(originTrackID, sourceFolderPath):
# 1 GetOriginMediaPos
count = AZ_GetTrackMediaTypeCount(0, originTrackID, 'wav', 0, 0)[3]
mediaList = []
for i in range(count):
mediaList.append(
{
'Name' : AZ_GetTrackMediaName(0, originTrackID, i, "", 1024)[3],
'StartPos' : AZ_GetTrackMediaStartTimeSeconds(0, originTrackID, i, 0)[3]
}
)
# 2 CreateTrack
parentTrack = RPR_GetParentTrack(AZ_GetTrackItemSelect(0, originTrackID,0))
replaceTrack = AZ_InsertChildTrack(parentTrack, 0)[0]
replaceTrackName = AZ_GetPathInfo(sourceFolderPath)['FileName']
AZ_SetTrackItemName(replaceTrack, replaceTrackName)
# 3 InsertReplaceAudio
originTrackName = AZ_GetTrackIdName(0, originTrackID, "", 1024)[2]
for media in mediaList:
sourceName = AZ_ReplaceSearchString(media['Name'], originTrackName, replaceTrackName, "", 1024)[3]
path = sourceFolderPath + '\\' + sourceName + ".wav"
AZ_InsertMediaTrackItemSecond(replaceTrack, path, 0, media['StartPos'])
def main():
originTrack = AZ_GetTrackItemSelect(0,0,1)
originTrackName = AZ_GetTrackItemName(originTrack, "", 1024)[1]
originTrackId = AZ_GetTrackItemIndex(originTrack)
rootPath = ""
retval,inputList = AZ_GetUserInputList("SourceImportPath",1,"rootPath :",rootPath)
if not retval:
return
rootPath = inputList[0]
footList = ["armor", "barefoot", "boot", "boot_snow", "boot_water", "heel", "sneaker"]
for foot in footList:
if foot != originTrackName:
replaceFoot(originTrackId, rootPath + "\\" + foot)
main()
import sys
sys.path.append(RPR_GetResourcePath() + r"/UserPlugins")
from RIGDOCKS_python import *
from AZSTOKE_BRONZE_python import *
from AZSTOKE_SILVER_python import *
・BRONZE/SILVERのAPI利用可能にする
def replaceFoot(originTrackID, sourceFolderPath):
・replaceFoot関数の枠を用意
# 1 GetOriginMediaPos
count = AZ_GetTrackMediaTypeCount(0, originTrackID, 'wav', 0, 0)[3]
・指定トラックIDのWavの数を出力してcountに代入
mediaList = []
・配列を用意
for i in range(count):
・countの数分 Forで繰り返し処理を実行
mediaList.append(
{
'Name' : AZ_GetTrackMediaName(0, originTrackID, i, "", 1024)[3],
'StartPos' : AZ_GetTrackMediaStartTimeSeconds(0, originTrackID, i, 0)[3]
}
・配列に追加していくNameとStartPos
)
# 2 CreateTrack
parentTrack = RPR_GetParentTrack(AZ_GetTrackItemSelect(0, originTrackID,0))
・指定IDトラックの親トラックを取得
replaceTrack = AZ_InsertChildTrack(parentTrack, 0)[0]
・親トラックに子トラックを追加
replaceTrackName = AZ_GetPathInfo(sourceFolderPath)['FileName']
・Pathのファイル名を取得してreplaceTrackNameに代入する
AZ_SetTrackItemName(replaceTrack, replaceTrackName)
・子トラックに名前を設定する
# 3 InsertReplaceAudio
originTrackName = AZ_GetTrackIdName(0, originTrackID, "", 1024)[2]
・指定トラックIDの名前を取得
for media in mediaList:
・mediaListの配列数分forを繰り返し処理
sourceName = AZ_ReplaceSearchString(media['Name'], originTrackName, replaceTrackName, "", 1024)[3]
・メディア名にトラック名の部分一致させてリネームしたものをsourceNameに代入
path = sourceFolderPath + '\\' + sourceName + ".wav"
・パス情報を作成
AZ_InsertMediaTrackItemSecond(replaceTrack, path, 0, media['StartPos'])
・パス情報に沿って波形データをインサート
def main():
・メイン関数を設定
originTrack = AZ_GetTrackItemSelect(0,0,1)
・選択しているトラックを取得してoriginTrackに代入
originTrackName = AZ_GetTrackItemName(originTrack, "", 1024)[1]
・トラックの名前を取得してoriginTrackNameに代入
originTrackId = AZ_GetTrackItemIndex(originTrack, 0)[2]
・トラックアイテムからIDを取得してoriginTrackIdに代入
rootPath = ""
retval,inputList = AZ_GetUserInputList("SourceImportPath",1,"rootPath :",rootPath)
・入力用テキストボックスを生成 パス情報をいれられるようにする
if not retval:
return
・もしキャンセルした場合は関数を途中終了させる。
rootPath = inputList[0]
・インプットした情報をrootPathに代入
footList = ["armor", "barefoot", "boot", "boot_snow", "boot_water", "heel", "sneaker"]
・Foot配列を用意
for foot in footList:
if foot != originTrackName:
replaceFoot(originTrackId, rootPath + "\\" + foot)
・オリジナルトラック名ではない場合、replaceFoot関数を実行
main()
・main関数を実行
ベースの足音を並べておく
命名規則に従って別種類の足音を制作しておく