# meta_scale2.py
doc = MQSystem.getDocument()
curidx = doc.currentObjectIndex
if curidx != -1:
obj = doc.object[curidx]
if not (obj is None):
MQSystem.println(obj.name)
# show global inverse matrix
mtx = doc.getGlobalInverseMatrix(obj)
for r in range(1,5):
MQSystem.println("|%(a) .3f %(b) .3f %(c) .3f %(d) .3f|" % {"a":mtx.get(r,1), "b":mtx.get(r,2), "c":mtx.get(r,3), "d":mtx.get(r,4)})
MQSystem.println(str(obj.scaling))
scl=obj.scaling
scl.x= 2 #x方向拡大率
scl.y= 0.5 #y方向拡大率
scl.z= 1.5 #z方向拡大率
obj.scaling=scl
MQSystem.println(str(obj.scaling))
mtx2 = doc.getGlobalMatrix(obj)
MQSystem.println(str(mtx2))
obj2 = MQSystem.newObject()
# show vertices
numVert = obj.numVertex
for i in range(0,numVert):
pos = obj.vertex[i].getPos()
MQSystem.println(" v[" + `i` + "] " + str(mtx2.mult(pos)))
obj2.addVertex(mtx2.mult(pos))
obj2.addFace([0,3,2,1]) #4kakusui
obj2.addFace([4,1,2])
obj2.addFace([4,2,3])
obj2.addFace([4,3,0])
obj2.addFace([4,0,1])
doc.deleteObject(curidx)
doc.addObject( obj2 )
拡大率に-1を入れれば、裏返し反転ですね。CGの基礎基本勉強になります。ありがとうございます。
- -
- -