calculating the contour of a particular cross section ;//

58 views
Skip to first unread message

e955...@gmail.com

unread,
Oct 15, 2014, 2:22:22 PM10/15/14
to python_in...@googlegroups.com
Hello duders,

this i think may not be possible, but wanted to check whether anyone knew anyhing:

so basically imagine you have a human (polygon) character and you select a vert on one of the legs. I want to know if it is possible to write a script which, given a specific vector, can analyse the (contiguous) cross section of the surface at that point.

Then to have locators created at regular intervals around that perimeter cross section.

hope this makes some sort of sense. Im working in python, but guess this would be an api sort of job.

Any general hints would be great,

thanks,
Sam

Janos Hunyadi

unread,
Oct 16, 2014, 8:25:00 AM10/16/14
to python_in...@googlegroups.com, e955...@gmail.com
If I understand your question right, you have to do a circular ray cast around a given vector (inside a mesh) and find the closest intersection and build an edge loop selection around the found points (which is tricky). Or find the closest intersection edges (which is tricky too if you want to cut the mesh) and connect those.

Janos

e955...@gmail.com

unread,
Oct 16, 2014, 12:30:23 PM10/16/14
to python_in...@googlegroups.com, e955...@gmail.com
cool yeah, i have a little script that can fire a ray in a specific direction. Have no idea how i can fire a ray in every direction in a circular motion though ha,

will investigate, thanks,
Sam

Marcus Ottosson

unread,
Oct 16, 2014, 12:51:40 PM10/16/14
to python_in...@googlegroups.com, e955...@gmail.com

so basically imagine you have a human (polygon) character and you select a vert on one of the legs. I want to know if it is possible to write a script which, given a specific vector, can analyse the (contiguous) cross section of the surface at that point.

With a little trickery, you can. :)

  1. On the target mesh, use Cut Faces Tool to generate the contiguous edge
  2. Convert generated edge-loop to NURBS, with a degree of 1
  3. Attach any geometry on a Motion-path, the geo will animate along the curve
  4. Create a Animation Snapshot of the geometry, you’ll get one mesh at each frame
  5. Delete shape from the transform of the mesh
  6. Create locator
  7. Parent locator shape to transform
  8. Delete Cut Faces history from target mesh

Works with polygonal surfaces of any complexity and should compute relatively quickly, given you don’t need too many locators (1000+).

Step 3-7 can be further optimised if you instead utilise the nearestPointOnCurve node to lookup the position along the curve and create the locators by hand. That should give you near-real-time performance. As a next step, you could potentially start looking at utilising the Cut Faces manipulator to run your script interactively.

Good luck!

Best,
Marcus

Sam

--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/38699b06-edbf-448f-838d-c5ff8f8e7ea4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Marcus Ottosson
konstr...@gmail.com

Janos Hunyadi

unread,
Oct 18, 2014, 1:25:01 PM10/18/14
to python_in...@googlegroups.com, e955...@gmail.com
It's really easy.

deg = 360.0 / sides # how many rays you want

y = 0.0 #replace with the y position of the source pos
r
= 1.0
#radius

for j in xrange(sides):
    angle
= deg * j / 180.0 * M_PI
    x
= math.cos( angle ) * r
    z
= math.sin( angle ) * r

   
pnt = OpenMaya.MPoint( x, y, z ) #add this to an MPointArray

Janos Hunyadi

unread,
Oct 18, 2014, 1:26:46 PM10/18/14
to python_in...@googlegroups.com, e955...@gmail.com
To add a rotation you have to multiply it by a rotation matrix though.

e955...@gmail.com

unread,
Oct 18, 2014, 1:56:06 PM10/18/14
to python_in...@googlegroups.com, e955...@gmail.com
wow thankyou Janos, very useful. Yep im learning about rotation matrixes right now.
Sam;)

Marcus Ottosson

unread,
Oct 18, 2014, 2:00:20 PM10/18/14
to python_in...@googlegroups.com
Did my solution not work for you, Sam?

On 18 October 2014 18:56, <e955...@gmail.com> wrote:
wow thankyou Janos, very useful. Yep im learning about rotation matrixes right now.
Sam;)
--
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 python_inside_m...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

e955...@gmail.com

unread,
Oct 18, 2014, 2:10:43 PM10/18/14
to python_in...@googlegroups.com
Hey Marcus, i was still in the process testing out your solution. Very grateful for checking this stuff out for me. thanks alot;)

Sam

Reply all
Reply to author
Forward
0 new messages