RDS笔记

13 篇文章 4 订阅

maya node

  • closetPointOnSurface 最近点到面,计算面上的UV
  • pointOnSurfacelnfo 计算Surface一个UV点位置,UV两个方向的切线,法线
  • nearestPointOnCurve 计算点到曲线最近的点位置和曲线的U值
  • decomposeMatrix
  • fourByFourMatrix
  • remapValue


maya cmds

  • createNode 创建节点

  • listRelatives 列出父级、子级和shape

  • connectAttr 属性连接

  • polyEvaluate 返回指定对象所需的计数

  • 查询节点有没有连接

import maya.cmds as cmds
nucleus = 'nucleus1'
bb = 0
while cmds.connectionInfo(nucleus+'.outputObjects[%s]'%(bb), ies=True) == True:
    bb += 1
    print bb
else:
    print bb


pyhon

  • json文件主要储存和读取数据

  • 将字典写入json文件

import json
import os
#字典
aa = {'xiaoming': 26, 'xiaohong': 25,  'dafu': 28}

#字典转为json内容
bb = json.dumps(aa)
with open('/路径/文件名.json', mode='a') as fp:
	fp.write(dd+'\n')
  • 读取json文件
import json
import os

gg = []
#读取文件
ff = open('/路径/文件名.json', mode='r')
#循环解读json文件内的每一行
for line in ff.readlines():
	dic = json.loads(line)
	gg.append(dic)	
  • 列表内浮点数保小数点后几位
lr = [1.11111,2,3,3.222222]
lrr = [str(round(x,2)) for x in lr]


教程

智伤帝
Pinterest
LB

动态设置
https://www.youtube.com/watch?v=PfTPsD3IEBE
https://www.youtube.com/watch?v=2iz_g8rij-k

import maya.cmds as cmds
import maya.mel as mel
if cmds.window('RDS', ex=True):
    cmds.deleteUI('RDS', window=True)    
cmds.window('RDS', t='RDS_v001')
cmds.columnLayout(adj=True, cat=['both', 5], rs=(5))
cmds.separator(style='double', h=5)


cmds.window('RDS', e=True, w=300, h=120)
cmds.showWindow('RDS')

更具曲线创建骨骼链函数

def BoneChain(SelCurve, JntNumber, Name): 
    sel_curve = str(SelCurve)
    sel_curve_shape = cmds.listRelatives(sel_curve, s=True)
    if cmds.nodeType(sel_curve_shape) == 'nurbsCurve':
        locator_obj = cmds.spaceLocator(position=(0, 0, 0))
        motionPath_JD = cmds.createNode(u'motionPath')
        cmds.setAttr(motionPath_JD + u'.fractionMode', True)
        cmds.connectAttr(sel_curve_shape[0] + u'.worldSpace[0]', motionPath_JD + u'.geometryPath')
        
        addDoubleLinear01_JD = cmds.createNode(u'addDoubleLinear')
        cmds.connectAttr(motionPath_JD + u'.xCoordinate', addDoubleLinear01_JD + u'.input1')
        cmds.connectAttr(addDoubleLinear01_JD + u'.output', locator_obj[0] + u'.translateX')
        
        addDoubleLinear02_JD = cmds.createNode(u'addDoubleLinear')
        cmds.connectAttr(motionPath_JD + u'.yCoordinate', addDoubleLinear02_JD + u'.input1')
        cmds.connectAttr(addDoubleLinear02_JD + u'.output', locator_obj[0] + u'.translateY')
        
        addDoubleLinear03_JD = cmds.createNode(u'addDoubleLinear')
        cmds.connectAttr(motionPath_JD + u'.zCoordinate', addDoubleLinear03_JD + u'.input1')
        cmds.connectAttr(addDoubleLinear03_JD + u'.output', locator_obj[0] + u'.translateZ')
        
        jnt_Number = int(JntNumber)
        for a in range(jnt_Number + 1):
            cmds.setAttr(motionPath_JD + u'.uValue', float(a) / float(jnt_Number))
            locator_transform = cmds.xform(locator_obj[0], q=True, worldSpace=True, translation=True)
            jntobj = cmds.joint(name='{}{}_{}'.format(Name, str(a).rjust(2, '0'), 'jnt'), position=(locator_transform))
            if a == 0:
                firstJnt = jntobj
                
            if a == jnt_Number:
                lastJnt = jntobj
    
        cmds.delete(motionPath_JD, addDoubleLinear01_JD, addDoubleLinear02_JD, addDoubleLinear03_JD,locator_obj)
        cmds.select(firstJnt)
        cmds.joint(e=True, orientJoint='xyz', secondaryAxisOrient='yup', children=True, zeroScaleOrient=True)
        cmds.joint(lastJnt, e=True, orientation=(0, 0, 0))
        cmds.select(cl=True)
    
    else:
        print ('Please select the curve')

Make Selected Curves Dynamic

#sel_curve = SelCurve
sel_curve = 'curve2'
#GRP
follicleGRP = cmds.createNode('transform', n='{}_{}'.format('Name', 'follicleGRP'))
outputGRP = cmds.createNode('transform', n='{}_{}'.format('Name', 'Dyn_outputGRP'))

#time
time = 'time1'

#nucleus
if cmds.nodeType(cmds.ls(type='nucleus')) == None:
    nucleus = cmds.createNode('nucleus', n='{}_{}'.format('Dyn', 'nucleus'))
else:
    nucleus = cmds.ls(type='nucleus')[0]
hairSystem = cmds.rename(cmds.listRelatives(cmds.createNode('hairSystem'),p=True), '{}_{}'.format('Name', 'hairSystem'))
hairSystem_shape = cmds.listRelatives(hairSystem, s=True)
cmds.setAttr(hairSystem_shape[0]+'.active', 1)


#time connectAttr
if cmds.connectionInfo(nucleus+'.currentTime', id=True) == False:  
    cmds.connectAttr(time+'.outTime', nucleus+'.currentTime')
cmds.connectAttr(time+'.outTime', hairSystem_shape[0]+'.currentTime')

#nucleus connectAttr
Index = 0
while cmds.connectionInfo(nucleus+'.outputObjects[%s]'%(Index), ies=True) == True:
    Index += 1
cmds.connectAttr(nucleus+'.outputObjects[%s]'%Index, hairSystem_shape[0]+'.nextState')
cmds.connectAttr(nucleus+'.startFrame', hairSystem_shape[0]+'.startFrame')


sel_curve_shape = cmds.listRelatives(sel_curve, s=True)
outputCurve = cmds.duplicate(sel_curve, n='{}_{}'.format(sel_curve, 'output'))
outputCurve_Shape = cmds.listRelatives(outputCurve, s=True)
cmds.parent(outputCurve, outputGRP)

follicle = cmds.rename(cmds.listRelatives(cmds.createNode('follicle'),p=True), '{}_{}'.format(sel_curve, 'follicle'))
follicle_shape = cmds.listRelatives(follicle, s=True)
cmds.setAttr(follicle_shape[0]+'.startDirection', 1)
cmds.parent(follicle, follicleGRP)
cmds.parent(sel_curve, follicle)

#hairSystem connectAttr
Index = 0
while cmds.connectionInfo(nucleus+'.inputActive[%d]'%(Index), id=True) == True:
    Index += 1
    print Index
cmds.connectAttr(hairSystem_shape[0]+'.currentState', nucleus+'.inputActive[%d]'%Index)

Index = 0
while cmds.connectionInfo(nucleus+'.inputActiveStart[%d]'%Index, id=True) == True:
    Index += 1 
cmds.connectAttr(hairSystem_shape[0]+'.startState', nucleus+'.inputActiveStart[%d]'%Index)

Index = 0
while cmds.connectionInfo(hairSystem_shape[0]+'.outputHair[%d]'%Index, id=True) == True:
    Index += 1 
cmds.connectAttr(hairSystem_shape[0]+'.outputHair[%d]'%Index, follicle_shape[0]+'.currentPosition')

#follicle connectAttr
cmds.connectAttr(follicle_shape[0]+'.outCurve', outputCurve_Shape[0]+'.create')
Index = 0
while cmds.connectionInfo(hairSystem_shape[0]+'.outputHair[%d]'%Index, id=True) == True:
    Index += 1 
cmds.connectAttr(follicle_shape[0]+'.outHair', hairSystem_shape[0]+'.inputHair[%d]'%Index)

#curve connectAttr
cmds.connectAttr(sel_curve_shape[0]+'.local', follicle_shape[0]+'.startPosition')
cmds.connectAttr(sel_curve+'.worldMatrix[0]', follicle_shape[0]+'.startPositionMatrix')

创建控制器

import maya.cmds as cmds
CVPoint = [(1,0,0), (0.707,-0.707,0), (0,-1,0), (-0.707,-0.707,0), (-1,0,0), (-0.707,0.707,0), (0,1,0), (0.707,0.707,0), (1,0,0), (0.707,-0.707,0), (0,-1,0)]
CV = cmds.curve(d=3, p=CVPoint, k=range(13), per=True, name='{}_{}'.format('name', 'ctrl'))
CV_shape = cmds.listRelatives(CV, s=True)
cmds.setAttr(CV_shape[0]+'.overrideEnabled', 1)
cmds.setAttr(CV_shape[0]+'.overrideColor', 17)
cmds.setAttr(CV_shape[0]+'.lineWidth', 2)
drve_grp = cmds.createNode('transform', name='{}_{}'.format('name', 'drve'))
grp = cmds.createNode('transform', name='{}_{}'.format('name', 'grp'))
jnt = cmds.createNode('joint', name='{}_{}'.format('name', 'jnt'))
cmds.parent(jnt, CV)
cmds.parent(CV, drve_grp)
cmds.parent(drve_grp, grp)
###正方形控制器
Cube_point = [(1,1,1), (1,1,-1), (-1,1,-1), (-1,1,1), (1,1,1), (1,-1,1), (1,-1,-1),(-1,-1,-1), (-1,-1,1),
(1,-1,1), (1,-1,-1), (1,1,-1), (-1,1,-1), (-1,-1,-1), (-1,-1,1), (-1,1,1)]
ctrl_grp = cmds.createNode('transform')
ctrl = cmds.curve(d=1, p=Cube_point, k=range(len(Cube_point)))
cmds.parent(ctrl, ctrl_grp)

次级绑定双倍位移
用次级控制器组的世界反向矩阵链接次级权重节点Bind Pre Matrix
在这里插入图片描述
模型位移过大导致模型坏掉
1、制器组的世界反向矩阵链接次级权重节点Bind Pre Matrix
2、将模型放在大环控制器下
制器组的世界反向矩阵链接次级权重节点Bind Pre Matrix
3、用模型组的world matrix 链接skinCluster节点上Geom matrix
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值