connecting to curve control points


#4

Hi thanks for the reply!

yeah thats what Im trying to do. I think its tidier just using transforms for points and then adding nodes just when I need world coords. (instead of using just locators all over)

Is that decomposeMatrix a plugin node? maya doesnt recognize it…

and do you have any idea why maya wont let me use vectorProduct for the same thing anymore?? is using it some taboo I was unaware of?


#5

The decomposeMatrix node plugin should come with maya but I don’t think it’s loaded by default. Check your plugin manager and auto-load it. 'tis a very handy node to have.
:¬)


#6

yeah the decompose matrix should do the trick . but anyway a simple unit conversion shouldnt give any trouble you can easly bypass it handling the data that comes before the node or after


#7

Hi there, I was about to script something like this, but I get stuck when I need to plug each locator to each cv of the curve… as you can see I did put [6] but of course is wrong… there is something missing or wrong in that specific for loop.
Here is the code:

//creating curve guide
string $createCurveGuide = curve -d 1 -p 0 0 0 -p 0 30 0 -k 0 -k 1 -n ("Spline" + "_crv");
string $curveGuide[] = rebuildCurve -ch 1 -rpo 1 -rt 0 -end 1 -kr 0 -kcp 0 -kep 1 -kt 0 -s 5 -d 3 -tol 0.01 $createCurveGuide;
string $curveGuideShape[] = listRelatives -s $curveGuide[0] ;

//STORE SOME VARIABLES–
string $selCurve[] = $curveGuide ;
int $noSelCurve = size($selCurve);

//THIS IS THE FOR LOOP FOR CREATING JOINT CHAIN ON SELECTED CURVES—
for ($i=0;$i<($noSelCurve);$i++)
{
select -r ($selCurve[$i] + “.cv[li]”);
[/li] string $cvPos[] = ls -sl -flatten;

//THIS LOOP CREATES A Locator FOR EACH CV IN THE CURVE---

    string $oldLoc = "";
    for ($cv in $cvPos)
    {
    string $createLocPos[] = ` spaceLocator `;    
    string $createSplineLocName[] = ` js_hashRename ("_Spline" + "_POS_##") `;
    string $decompMatrix = ` createNode decomposeMatrix -n ("_decMat") `;
    
    float $xyz[] = ` xform -a -ws -q -t $cv `;
    xform -a -ws -t $xyz[0] $xyz[1] $xyz[2] $createSplineLocName[0];
    
    // connecting each loc worldspace to each cv in curve, in order to follow
            string $locMatrix[] = $createSplineLocName ;
            int $noLocMatrix = `size($locMatrix)`;
            
            for ($i=0;$i&lt;($noLocMatrix);$i++)
            {
               connectAttr -f ($createSplineLocName[$i] + ".worldMatrix[0]") ($decompMatrix + ".inputMatrix") ;
               connectAttr -f ($decompMatrix + ".outputTranslate") ($curveGuideShape[0] + ".controlPoints[6]");
            }
            
        if ($oldLoc != "")
        {
            parent $createSplineLocName[0] $oldLoc;
        }
        $oldLoc = $createSplineLocName[0];
    }
}

#8

Thanks to giordi, sorted.


#9

Hey just out of interest, why do this over skinning or clustering a curve? Just wondering what the benefits are.


#10

The main benefit is a cleaner looking connection graph in the hypergraph. With clusters you have groupParts, groupIDs, the cluster and the clusterHandle and the whole thing graphs out looking like a staircase as you’re looking at a full construction history on the curve. However if you use decomposeMatrix you have a much clearer relationship between the curve and what’s driving it.
:¬)


#11

totally agree. Also i dont see why i have to use a deformer like clusters when cna be easily done with cleaner way .


#12

Hi guys, I’ve got these warnings here :

// Warning: file: Cannot add the following items to the set since the set has restrictions on membership: charNameSpline_crv.ep[4] // 
// Warning: file:  None of the items can be added to the set // 

Which are slowing down my script a lot… any ideas ?
Cheers


#13

I guess not :).


#14

It’s hard to know where these warnings are coming from without any context. Could you elaborate?
:¬)


#15

Yes sure.

Basically here’s a chunk of code:

for ($counter = 1; $counter < ($NumberOfCV - 1); $counter++) { select -r ($ii + ".ep[" + $x + "] "); string $TempCluster_[] = `cluster -n TempCluster`; float $clusterxyz[] = `xform -q -rp $TempCluster_[1]`; float $jointX = $clusterxyz[0]; float $jointY = $clusterxyz[1]; float $jointZ = $clusterxyz[2];

If you replace .ep with .cv I don’t get those warnings anymore, there must be something related to the clusters or the type of selections…
Hope it’s clearer …


#16

Yeah, I was going to say that you should be using CVs instead of EPs.
:¬)


#17

I know but the number and the position of the objects that I get is not what I want with the cv…


#18

So do you want to build a curve from the position of some transforms but also have the curve fit those nodes?

If so, you might have some luck by building a degree 1 curve from the transforms, connecting them to the CVs (through a decomposeMatrix for example) and then doing a fitBspline on it.

:¬)


#19

I recently came across the Point On Curve Deformer. It may be a good alternative for you. It only creates two nodes, a locator (which you could use, or replace the shape node of the locator with a curve shape if that’s preferred), and one other node called ‘leastSquaresModifier’. Ok, there’s another hidden object that is created, because this is a deformer, the original shape is stored and becomes an intermediate object. The great thing about it is that when you move the locator, the curve always ‘sticks’ to it, unlike the results when moving a CV.

[ol]
[li]Create a curve.[/li][li]Select an EP (not a CV). Or, select all of your EPs, the deformer will create one locator for each EP.[/li][li]Go to Animation>Create Deformers>Point On Curve.[/li][li]Select the newly created Locator(s) and Modify>Center Pivot. (The pivot is at the origin by default)[/li][/ol]


#20

Hello Mats, Brad and everyone

Just a quick tip:

My first try , when I wanted to simplify my network( apart from creating asset container )was to use the locator shape worldPosition attribute. If the driven curve is parented to a group with inherits transform off and don’t move it’s fine but ( a fool proof ) more solid approach is to include the parent transform with a pointMatrixMult node


The next step was to compact these point/matrix multiplication into a python node(a really simple exercice, but fun nonetheless).

Why duplicating node to retrieve a position in world space? The last step was to use a regular transform worldMatrix as an incoming information.


#21

For your curve that pass through a set of points and are not interpolated between them , maya lets you do this with an editpoint curve:
The same functionality is exposed in the API:

  • curve creation with cv position and knotVector list
  • or just edit point position…

a python node that feed a regular nurbsCurve

This node gather a list of point position and ouput curve data, you can control the curve degree with a simple int attribute. It works but the curve tangent are not controllable with this method: this is the same behavior with maya leastSquare node.

you can grab a zip archive with this 3 node here: http://circecharacterworks.files.wordpress.com/2012/04/cv_driver_tools.pdf ( dont forget to replace ‘.pdf’ by ‘.zip’ )


#22

that s cool example nice one .

Did you make the input attribute as an array right?


#23

@ giordi: yeah the 3 nodes have input array attribute of type double3.

Conceptually having each cv separated with different nodes doesn’t trigger all the output information but even with 150 element and a python node this type of computation remains fast.

One possible extension to this concept is to write a transform node where we can directly plug a matrix attribute and perhaps choose what transformation is active