hi Michael! 

I just used the default MItGeometry that was provide in the deform method 
to set the final positions and everything works perfect now! My original 
intention was to used a different way set the final result, but I guess I 
was over complicated the code by doing this whole "MItGeometry outIter" 
thing. But still, thank you so much for your help, you are my hero of the 
day!!!!

sincerely
flin

On Friday, December 21, 2018 at 12:55:38 AM UTC-5, Michael Boon wrote:
>
> I have to admit I haven't written a modifier before and I don't see 
> anything obvious wrong with what you've done.
> It seems strange that you are using a MItGeometry outIter to set the 
> positions. It would seem more direct to me to set the positions on your 
> MFnMesh fnOutmesh, which controls hOutputGeom. I'm not sure if that's the 
> problem but that's my best guess right now. Hopefully there are others here 
> with more experience.
>
> On Friday, 21 December 2018 14:46:30 UTC+11, Fleming Lin wrote:
>>
>> hi Michael, 
>>
>>
>> thanks for the sweet advise! unfortunately, it has nothing to do with 
>> the  outIter.setAllPositions(originalPnts), I changed it back to 
>> finalPnts, still wont works. however, I just used two cubes to test my 
>> deformer, and get some interesting result.
>>
>> here is the code
>>
>> [image: internet_finalhelp2.PNG]
>>
>> the result in perspective view
>>
>> [image: internet_finalhelp1.PNG]
>>
>> in front view, ( xy coordinate)
>>
>> [image: internet_finalhelp0.PNG]
>>
>>
>> so it turned out I did something wrong with the intersector 
>> getClosestpoint...but even I stored the wrong finalPnt in the finalPnts 
>> array, how can the deformer mesh stays the same shape??(....maya...I dont 
>> know...maya.....)
>>
>> sincerely
>> flin
>>
>>
>>
>> On Thursday, December 20, 2018 at 9:04:43 PM UTC-5, Michael Boon wrote:
>>>
>>> We're not making sense to each other here :)
>>>
>>> Are these points all where you expect them to be?
>>> - deformerWorldPnt
>>> - collisionPoint 
>>> - finalPnt 
>>> It might be worth colliding one cube against another, just because it's 
>>> much easier to do the math in your head and know when the results are what 
>>> you expect them to be.
>>>
>>> Actually, in the code you shared, it looks like you use originalPnts to 
>>> set the output mesh, not finalPnts. It looks like you intended to copy 
>>> originalPnts into finalPnts and then use that to set the output. Could it 
>>> be just that simple mistake?
>>> finalPnts.set(finalPnt, i);
>>> ...
>>> outIter.setAllPositions(originalPnts); // Should this be finalPnts?
>>>
>>>
>>>
>>> On Friday, 21 December 2018 12:42:16 UTC+11, Fleming Lin wrote:
>>>>
>>>> hi Michaek, thanks for taking time reading my code... and the problem 
>>>> here is my code doesnt move the corresponding point on the deformer 
>>>> surface(sorry I should be clearer at the beginning)  in other words, 
>>>> nothing happened at all when I collide them(and this is the part drive me 
>>>> crazy, it's like maya is dead....)... 
>>>>
>>>> Have you tried printing out the old and new locations of each point (in 
>>>> world space and/or local space)? 
>>>>
>>>> yes I did, and I had created a MPoint difference = collision point - 
>>>> deformer point, and ask maya to print out the "difference.x, y and z" but 
>>>> all I got is 0,0,0.
>>>> And I'm sure the point I passed in the intersecoter.getClosestPoint is 
>>>> in the world space, however I'm not sure about what space the returned 
>>>> closest point is in, (I'm assuming it is in world space now, but I think I 
>>>> have done some quick test by multiply the closest point by the collider 
>>>> local to world matrix before, but still, nothing happened when collide.) 
>>>>
>>>> Have you confirmed that values set in finalPts are actually used to set 
>>>> positions of vertices in the output mesh?
>>>>
>>>> I'm sorry but I'm not quick sure what you mean here, I assuming after I 
>>>> update the finalPnts and use it in the iterGeo.setAllpositions ( or 
>>>> outIter.setAllpositions( just another MItGeometry iterator I created for 
>>>> the outputgeom attribute, I heard from someone else that this might solve 
>>>> the problem, but I have tried them both, none of them works) ),     the 
>>>> deformer surface will be update automatically?  ( and I have also tried 
>>>> fnMesh::updataSurface, but nothing happend...) 
>>>>
>>>> thanks
>>>> flin
>>>>
>>>> On Thursday, December 20, 2018 at 8:04:01 PM UTC-5, Michael Boon wrote:
>>>>>
>>>>> What is not working? Your code finds the correct points, and prints 
>>>>> out the correct indices, but it doesn't move them correctly? So what is 
>>>>> it 
>>>>> doing wrong when it moves them? Is it not moving them at all? Moving them 
>>>>> to the wrong place? I see you calculating finalPnt and then entering it 
>>>>> into finalPnts, but I'm not sure what happens from there.
>>>>>
>>>>> Have you tried printing out the old and new locations of each point 
>>>>> (in world space and/or local space)? 
>>>>> Have you confirmed that values set in finalPts are actually used to 
>>>>> set positions of vertices in the output mesh?
>>>>>
>>>>> On Friday, 21 December 2018 11:26:23 UTC+11, Fleming Lin wrote:
>>>>>>
>>>>>> hello internet....I have been working on this collision deformer node 
>>>>>> for a long time and still cant get it right....I have done many research 
>>>>>> and even ask people for the reference code but IT JUST WONT 
>>>>>> WORKS!!!!!!!!...
>>>>>>
>>>>>> the big idea for my collision deformer is
>>>>>> first do a intersection test between the collider bounding box and 
>>>>>> deformer bounding box
>>>>>>     if intersected, check if the collider bounding box contain the 
>>>>>> deformer vertex( in world coordinate)...
>>>>>>       if contained, do allintersection test for the vertex to see if 
>>>>>> it is inside the the collider mesh or not , using   
>>>>>>                (if (hitPoints.length() % 2 == 1))
>>>>>> and then do the deformation and save the point to the finalpnts 
>>>>>> array( used later to set all positions )
>>>>>>
>>>>>> for debugging purpose I asked the maya to print out the collision 
>>>>>> point index, and it works fine, but the deformation algorithm I have in 
>>>>>> that same if loop just wont works........I have no idea why and really 
>>>>>> ran 
>>>>>> out of idea..please help....
>>>>>>
>>>>>> here is the test result
>>>>>>
>>>>>> [image: internet_help.PNG]
>>>>>>
>>>>>>
>>>>>>
>>>>>> here is the c++ code I have.
>>>>>>
>>>>>> https://github.com/fleminglin/sos/blob/master/flinCollide.cpp
>>>>>>
>>>>>>
>>>>>> sincerely
>>>>>> flin
>>>>>>
>>>>>

-- 
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/563ad028-13df-4811-96a6-cbc1d819baa5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to