テクスチャ用画像作成
@echo off
setlocal enabledelayedexpansion
set PATH=%PATH%;C:\Program Files\ImageMagick-7.0.9-Q16
for /l %%i in (0, 1, 9999) do (
set N=0000%%i
set N=!N:~-4!
magick convert -background lightblue -fill blue -size 100x100 -pointsize 32 -gravity center label:!N! indices\index_!N!.png
)
キューブ生成
import maya.cmds as cmds
cmds.file(new=True, force=True)
def test(count):
index = 0
z_root = cmds.createNode('transform')
for z in xrange(count):
y_root = cmds.createNode('transform')
for y in xrange(count):
x_root = cmds.createNode('transform')
for x in xrange(count):
cube, _ = cmds.polyCube()
cmds.setAttr('{}.t'.format(cube), -count/2+x, -count/2+y, -count/2+z, type='double3')
cmds.setAttr('{}.s'.format(cube), 0.5, 0.5, 0.5, type='double3')
material = cmds.shadingNode('lambert', asShader=True)
sg = cmds.sets(renderable=True, noSurfaceShader=True, empty=True)
cmds.sets(cube, forceElement=sg)
cmds.connectAttr('{}.outColor'.format(material), '{}.surfaceShader'.format(sg))
file = cmds.createNode('file')
cmds.setAttr('{}.fileTextureName'.format(file), 'indices/index_{:04}.png'.format(index), type='string')
cmds.connectAttr('{}.outColor'.format(file), '{}.color'.format(material))
cmds.select('{}.f[*]'.format(cube), replace=True)
cmds.polyEditUV(pu=0.5, pv=0.5, su=2.3, sv=2.3)
cmds.polyEditUV(u=0, v=0.3);
cmds.parent(cube, x_root)
index += 1
cmds.parent(x_root, y_root)
cmds.parent(y_root, z_root)
test(20)