You are right Judah, the other node is not mandatory: it was just a 
personal preference: separating data processing( noise point ) from drawing 
( the locator ).If you duplicate your locator you dont need to compute 
several time your point list( when you need the same point list of course 
). In my case it was easier to stick to the regular  maya workflow( data 
flows from one node to another )
I would also use a MVectorArray initialized with your self.pointCount 
value  but its just my way of doing things.

Le jeudi 7 juin 2012 23:11:44 UTC+2, Judah Baron a écrit :
>
> You don't need connect another node to pull the data from the plug and 
> trigger compute. It sounds like you are on the right track with the query 
> in draw. You can either use a real attribute, or create a dummy that is 
> used solely for the purpose of triggering compute. You then need to make 
> sure your attribute dependency is set up properly with attributeAffects, or 
> setDependentsDirty. Once you've done this, pulling the plug's value from 
> within draw will dirty the plug, triggering compute. You'll need to do this 
> early in draw, obviously - befor you draw anything, for the change to take 
> effect.
>
> There is a good sample here:
>
> http://code.google.com/p/mayaprogramming/source/browse/trunk/locator/GrassLocator.cpp?r=4
>
> Good luck,
> -Judah
>
>
> On Thursday, June 7, 2012, cedric bazillou wrote:
>
>> Hello, 
>> (lets call you Nero... )
>>
>> I think you can explain why your compute is not triggered: the dependency 
>> graph in maya is not informed that your output attribute needs to be 
>> update: you have nothing connected to it , right?
>> Nothing original but how about writing a node to compute your pointList 
>> and plug it to your locator that will only draw from a 
>> kPointArray/kVectorArray input attribute? I have play with this idea and it 
>> works: http://forums.cgsociety.org/showpost.php?p=7280472&postcount=14.
>>
>>
>> Le mardi 5 juin 2012 18:35:15 UTC+2, WhileRomeBurns a écrit :
>>>
>>> So basically I've got a python node called *simpleLocator* with an 
>>> attribute called *pointCount *(type *kInt*) which is used to generate 
>>> some random points. These points can be passed out as an array with the 
>>> attribute *outPoints *(type *kDoubleArray *for this example). I've 
>>> setup *attributeAffects*() so that outPoints depends on pointCount, so 
>>> it should update if the user edits the number of points. This node needs to 
>>> draw the points every frame with OpenGL as well, but only compute as 
>>> needed. So far so good. Here's my example code (also attached to this 
>>> post), stripped to the bare essentials and it almost works:
>>>
>>> http://hastebin.com/**vixiyaruda.py <http://hastebin.com/vixiyaruda.py>
>>>
>>>
>>> When compute() is called though, plug never equals aOutPoints. Ever, 
>>> ever.
>>>
>>>     def compute( self, plug, data ):
>>>         if plug == simpleLocator.aOutPoints:
>>>             print( 'aOutPoints needs to be computed, but we never get 
>>> here...' )
>>>             return om.MStatus.kSuccess
>>>         else:
>>>             return om.MStatus.kUnknownParameter
>>>
>>>
>>> What's normal practice here? Should I just query my 
>>> simpleLocator.aPointCount every time draw is called and only 
>>> call generatePoints() if the value of aPointCount has been changed? Should 
>>> I derive from a node other than MPxLocator and implement my own draw 
>>> method? Does MPxLocator behave different in C++? Any help, any insight 
>>> would be greatly appreciated. Thanks.
>>>
>>> -shawn
>>> PS- If you're curious, the real node is generating blue noise for 
>>> thousands of points and is fairly expensive to calculate.
>>>
>>  -- 
>> view archives: http://groups.google.com/group/python_inside_maya
>> change your subscription settings: 
>> http://groups.google.com/group/python_inside_maya/subscribe
>>
>

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to