Hi there!

I'm trying to make this work, but i can't find what I'm doing wrong.
It's working fine with a float output, but i'm not able to do it with
a "vector" or float3 output.
Any guess?

Thanks!!!!

import maya.cmds as cmds
import maya.OpenMaya as om
import maya.OpenMayaAnim as oma
import maya.OpenMayaMPx as omx
import math

#INIT
PLUGIN______________________________________________________________>

nodeTypeName = "dc_stretchNode"
stretchNodeId = om.MTypeId(0x8700)

# Node definition
class stretchNode(omx.MPxNode):

        squash = om.MObject()
        stretch = om.MObject()
        outputScale = om.MObject()

        def __init__(self):
                omx.MPxNode.__init__(self)
        def compute(self,plug,dataBlock):
                if ( plug == stretchNode.outputScale ):
                        #set inputs
                        dataHandle = dataBlock.inputValue( stretchNode.stretch )
                        stretchFloat = dataHandle.asFloat()

                        dataHandle = dataBlock.inputValue( stretchNode.squash )
                        squashFloat = dataHandle.asFloat()

                        #get values
                        scales = dc_stretchNode(stretchFloat,squashFloat)

                        #set outputs
                        outputScaleHandle =
dataBlock.outputValue( stretchNode.outputScale )
                        
outputScaleHandle.set3Float(scales[0],scales[1],scales[2])

                        dataBlock.setClean( plug )

                return om.kUnknownParameter

# creator
def nodeCreator():
        return omx.asMPxPtr( stretchNode() )

# initializer
def nodeInitializer():

        # output SCALE
        nAttr = om.MFnNumericAttribute()
        stretchNode.outputScale = nAttr.create( "outputScale", "outputScale",
om.MFnNumericData.k3Float, 0.0)
        #stretchNode.outputScale = nAttr.createPoint( "outputScale",
"outputScale")#asi se consigue una salida attributo tipo vector
        nAttr.setStorable(1)
        nAttr.setWritable(1)

        #Stretch Value
        nAttr = om.MFnNumericAttribute()
        stretchNode.stretch = nAttr.create( "stretch", "stretch",
om.MFnNumericData.kFloat, 0.0 )
        nAttr.setStorable(1)
        nAttr.setKeyable(1)
        nAttr.setChannelBox(0)

        #Squash Value
        nAttr = om.MFnNumericAttribute()
        stretchNode.squash = nAttr.create( "squash", "squash",
om.MFnNumericData.kFloat, 0.0 )
        nAttr.setStorable(1)
        nAttr.setKeyable(1)
        nAttr.setChannelBox(0)
        nAttr.setMin(0)
        nAttr.setMax(1)

        # add attributes
        stretchNode.addAttribute( stretchNode.stretch )
        stretchNode.addAttribute( stretchNode.squash )
        stretchNode.addAttribute( stretchNode.outputScale )

        stretchNode.attributeAffects( stretchNode.stretch,
stretchNode.outputScale )
        stretchNode.attributeAffects( stretchNode.squash,
stretchNode.outputScale )

# initialize the script plug-in
def initializePlugin(mobject):
        mplugin = omx.MFnPlugin(mobject)
        try:
                mplugin.registerNode( nodeTypeName, stretchNodeId, nodeCreator,
nodeInitializer )
        except:
                sys.stderr.write( "Failed to register node: %s" % nodeTypeName )
                raise

# uninitialize the script plug-in
def uninitializePlugin(mobject):
        mplugin = omx.MFnPlugin(mobject)
        try:
                mplugin.deregisterNode( stretchNodeId )
        except:
                sys.stderr.write( "Failed to deregister node: %s" % 
nodeTypeName )
                raise

#UN INIT
PLUGIN__________________________________________________________________________________________________>

def dc_stretchNode(stretch,squash):
        value = math.pow(stretch+1,-squash)
        return [stretch+1,value,value]
--~--~---------~--~----~------------~-------~--~----~
Yours,
Maya-Python Club Team.
-~----------~----~----~----~------~----~------~--~---

Reply via email to