sineNode.py
이 노드 와 표현 식 의 sin 방법 은 같은 기능 입 니 다.
sin 및 표현 식 사용
http://download.autodesk.com/us/maya/2010help/index.html?url=Useful_functions_sin.htm,topicNumber=d0e175415
sineNode.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
# python:
# import maya
# maya.cmds.loadPlugin("sineNode.py")
# maya.cmds.createNode("spSineNode")
# maya.cmds.getAttr("spSineNode1.output")
#
# Mel:
# loadPlugin sineNode;
# createNode spSineNode;
# getAttr spSineNode1.output;
import math, sys
import maya.OpenMaya as om
import maya.OpenMayaMPx as ompx
# ID
kPluginNodeTypeName = 'spSineNode'
sineNodeId = om.MTypeId( 0x8700 )
# node definition
#
class sineNode( ompx.MPxNode ):
'''
sine node
'''
# class variables
input = om.MObject()
output = om.MObject()
def __init__( self ):
super( sineNode, self ).__init__()
#
# plug MPlug
# dataBlock MDataBlock
def compute( self, plug, dataBlock ):
# sineNode.output
if ( plug == sineNode.output ):
# sineNode.input
# ,
dataHandle = dataBlock.inputValue( sineNode.input )
#
# MDataHandle
inputFloat = dataHandle.asFloat()
# ,
result = math.sin( inputFloat ) * 10.0
# sineNode.output ,
outputHandle = dataBlock.outputValue( sineNode.output )
# result
outputHandle.setFloat( result )
#
dataBlock.setClean( plug )
# creator
#
def nodeCreator():
return ompx.asMPxPtr( sineNode() )
# initializer
#
def nodeInitializer():
# input
#
nAttr = om.MFnNumericAttribute()
# input
sineNode.input = nAttr.create( 'input', 'in',
om.MFnNumericData.kFloat, 0.0 )
nAttr.setStorable( 1 )
# output
#
nAttr = om.MFnNumericAttribute()
# output
sineNode.output = nAttr.create( 'output', 'out',
om.MFnNumericData.kFloat, 0.0 )
nAttr.setStorable( 1 )
nAttr.setWritable( 1 )
# add attributes
#
sineNode.addAttribute( sineNode.input )
sineNode.addAttribute( sineNode.output )
# input output
sineNode.attributeAffects( sineNode.input, sineNode.output )
# initialize the script plug-in
def initializePlugin( mobject ):
mplugin = ompx.MFnPlugin( mobject )
try:
mplugin.registerNode( kPluginNodeTypeName,
sineNodeId,
nodeCreator,
nodeInitializer )
except :
sys.stderr.write( "Failed to register node: %s" %
kPluginNodeTypeName )
raise
# uninitialize the script plug-in
def uninitializePlugin( mobject ):
mplugin = ompx.MFnPlugin( mobject )
try:
mplugin.deregisterNode( sineNodeId )
except :
sys.stderr.write( 'Failed to register node: %s' %
kPluginNodeTypeName )
raise
maya 설치 디 렉 터 리 에 있 는 devkit / plug - ins / scripted 에서 sinenode. py 를 찾 을 수 있 습 니 다.
온라인 판
http://download.autodesk.com/us/maya/2010help/API/sine_node_8py-example.html
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다른 사람의 웹사이트 편집: contenteditable 및 designMode그래도 우리가 그렇게 할 수 있다고 생각하는 것은 멋진 일입니다. 제가 강조하고 싶었던 일종의 관련 API가 실제로 몇 개 있기 때문에 오늘 그것을 가져왔습니다. contenteditable는 "true" 값이 할당...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.