Maybe something like this might help for the first part of the problem?

import maya.cmds as cmdsimport maya.OpenMaya as om
# This point would refer to our particle birth location
point = om.MPoint(*cmds.xform(q=True, t=True, ws=True))
# Loading the curve, in case we didn't have it already
curve = om.MObject()
sel = om.MSelectionList()
om.MGlobal.getSelectionListByName("curveShape1", sel)
sel.getDependNode(0, curve)

curveFn = om.MFnNurbsCurve(curve)
# Have to use pointers to get double data
double1 = om.MScriptUtil(0.0)
double2 = om.MScriptUtil(0.0)
ptr1 = double1.asDoublePtr()
ptr2 = double2.asDoublePtr()
# Get the parameter range of the curve
curveFn.getKnotDomain(ptr1, ptr2)
start = double1.getDouble(ptr1)
end = double2.getDouble(ptr2)
# Get the parameter value for our point location
curveFn.getParamAtPoint(point, ptr1, 0.5)
param = double1.getDouble(ptr1)
# Normalize to 0-1
norm = param / (end-start)

​

This might get you the scaled value of the point on the curve?



On Fri, Jun 13, 2014 at 5:47 PM, Eric Corriel <[email protected]>
wrote:

> Imagine there's:
>
>    - curve1
>    - particles1 emitted from curve1
>    - black to white ramp1
>
>
> I'd like to:
>
>    - use a black to white ramp to control the lifespan of particles being
>    emitted along a curve
>    - by somehow mapping particle1.lifespanPP to ramp1.getValueAtPosition()
>    - where the argument passed into getValueAtPosition() is the
>    normalized value of where the particle was born on the curve (a float from
>    0 to 1, where 0 represents one end of the curve and 1 represents the other
>    end)
>
> So the two problems are:
>
>    1. Find, on a scale of 0 to 1, where a particle was born along the
>    length of the curve
>    2. Once that's found, how can I use the ramp as something like a
>    lookup table to get a value to set particle1.lifespanPP?
>
> Any help would be greatly appreciated.  If there's an easier way of doing
> this, I'm all ears.  Also greatly appreciated would be explaining this to
> me like I'm 5…Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/46b14d6f-4446-45a1-b484-0d5d2a108fee%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/46b14d6f-4446-45a1-b484-0d5d2a108fee%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2dT%3Des1sGHvCWyG0okLcjzZ049QBwK%3DuWniJ%2B3%3DBnmbg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to