Strange, it is python file that I rename into a pdf in order to post it on
my blog( it can be found in the download section...)
the meat of this plugin is:
def compute(self,Plug,Data):
targetPosition_Hdle = Data.inputValue(self.targetPosition)
outputHandle = Data.outputValue(self.outRotate )
theTargetVector = targetPosition_Hdle.asVector().normal()
referenceVector = OpenMaya.MVector(1,0,0)
aimQuaternion = OpenMaya.MQuaternion()
aimQuaternion = referenceVector.rotateTo(theTargetVector)
eulerRotationValue = aimQuaternion.asEulerRotation()
outputHandle.set3Double(
eulerRotationValue.x,eulerRotationValue.y,eulerRotationValue.z )
Data.setClean(Plug)
( the euler value is in radians and the output attribute is directly 3
MAngle value in order to prevent maya to insert a unitconversion node(
which is logical ))
This node expect the Driven object to be at position 0 0 0 under an offset
group.
Le lundi 12 novembre 2012 11:00:31 UTC+1, Roy Nieterau a écrit :
>
> Hey Guys,
>
> I'm looking into creating a custom Stretchy Spline IK setup that doesn't
> pop (over & under extends in extreme situations).
> But I seem to be unable to wrap my head around how to calculate
> orientations on points on the curve.
> Since the points on the curve don't have any orientation (well, they do
> have tangents or something like that?) I have no clue on how to actually
> start with this.
>
> My main references of tools in Maya would be the Motion Path and the
> Spline IK (with Advanced Twist controlled by a start and end object).
> If anybody has any starting points for this it would be greatly
> appreciated!
>
> Thanks in advance.
>
> Regards,
> Roy
>
--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings:
http://groups.google.com/group/python_inside_maya/subscribe
import math, sys
import maya.OpenMaya as OpenMaya
import maya.OpenMayaMPx as OpenMayaMPx
kPluginNodeName = "quatermainNode"
kPluginNodeId = OpenMaya.MTypeId(0xAAC0F773)
class quatermainNode(OpenMayaMPx.MPxNode):
targetPosition = OpenMaya.MObject()
rotate = OpenMaya.MObject()
def __init__(self):
OpenMayaMPx.MPxNode.__init__(self)
def compute(self,Plug,Data):
targetPosition_Hdle = Data.inputValue(self.targetPosition)
outputHandle = Data.outputValue(self.outRotate )
theTargetVector = targetPosition_Hdle.asVector().normal()
referenceVector = OpenMaya.MVector(1,0,0)
aimQuaternion = OpenMaya.MQuaternion()
aimQuaternion = referenceVector.rotateTo(theTargetVector)
eulerRotationValue = aimQuaternion.asEulerRotation()
outputHandle.set3Double( eulerRotationValue.x,eulerRotationValue.y,eulerRotationValue.z )
Data.setClean(Plug)
return OpenMaya.kUnknownParameter
def nodeCreator():
return OpenMayaMPx.asMPxPtr(quatermainNode())
def nodeInitializer():
nAttr = OpenMaya.MFnNumericAttribute()
mAttr = OpenMaya.MFnMatrixAttribute()
unitAttr = OpenMaya.MFnUnitAttribute()
quatermainNode.targetPosition = nAttr.create( "targetPosition", "trgPos", OpenMaya.MFnNumericData.k3Double )
nAttr.setStorable(0)
nAttr.setKeyable(1)
nAttr.setHidden(0)
quatermainNode.addAttribute( quatermainNode.targetPosition )
defaultAngle = OpenMaya.MAngle ( 0.0, OpenMaya.MAngle.kDegrees )
quatermainNode.outRotateX = unitAttr.create( "outRotateX", "orx", defaultAngle)
quatermainNode.outRotateY = unitAttr.create( "outRotateY", "ory", defaultAngle)
quatermainNode.outRotateZ = unitAttr.create( "outRotateZ", "orz", defaultAngle)
quatermainNode.outRotate = nAttr.create( "outRotate", "or", quatermainNode.outRotateX,quatermainNode.outRotateY,quatermainNode.outRotateZ)
nAttr.setStorable(1)
nAttr.setKeyable(0)
nAttr.setHidden(0)
quatermainNode.addAttribute( quatermainNode.outRotate )
quatermainNode.attributeAffects( quatermainNode.targetPosition, quatermainNode.outRotate )
return OpenMaya.MStatus.kSuccess
def initializePlugin(mobject):
mplugin = OpenMayaMPx.MFnPlugin(mobject, "Bazillou cedric2009", "1.0", "Any")
try:
mplugin.registerNode( kPluginNodeName, kPluginNodeId, nodeCreator, nodeInitializer, OpenMayaMPx.MPxNode.kDependNode)
except:
sys.stderr.write( "Failed to register node: %s" % kPluginNodeName ); raise
def uninitializePlugin(mobject):
mplugin = OpenMayaMPx.MFnPlugin(mobject)
try:
mplugin.deregisterNode( kPluginNodeId )
except:
sys.stderr.write( "Failed to deregister node: %s" % kPluginNodeName ); raise