Notifications
Clear all

[Closed] Birth to center of polygons with orientation

I learned how to do it with position and verts.

Now I would like to birth at the center of faces… I’m sure I’m missing something simple.

–Sorry for the massive Tabage. They seem to grow in the thread post…

on ChannelsUsed pCont do
  	(
  		pCont.useTime = true
  		pCont.usePosition = true
  		pCont.useOrientation = true
  	)
  on Init pCont do
  	(
  		global baseObj = $Sphere01
  	)
  
  on Proceed pCont do
  	(
  		if baseObj != undefined do
  			(
  				t = pCont.getTimeStart() as float
  				NumFaces = getNumFaces baseObj
  				
  				if t < 0 do
  					(
  						for i = 1 to NumFaces do
  							(
  								pCont.AddParticle()
  								pCont.particleIndex = pCont.NumParticles()
  								pCont.particlePosition = polyop.getFaceCenter baseObj i
  								pCont.particleOrientation = polyop.getFaceNormal baseObj i
  							)
  					)
  			)
  
  	)
  
  on Release pCont do ()
  
8 Replies

humm…
post a preview (gif or video), so we can take a look what you tring to do…

I have learned how to birth particles (in a birth script in PFLOW) to the position of verts of an EditablePoly. I would like to learn how to birth to the center of faces with the particles aligned to the normals of the face

yup, i’ve dug through the help and I’ve read most of those threads.

I don’t know how the Maya Mel thread will help me with MXS specifics. I understand what the procedure is:

Define the mesh
Count the faces
For i in 1 to number of faces do
add a particle
set the particle index
set the position of the particle to the position of the face
set the orientation of th eparticle to the normal of the face

I didn’t find a polyop.faceTM or anything like that.

Can you see what is wrong with my script in the first post?

1 Reply
(@polimeno)
Joined: 11 months ago

Posts: 0

Thanks for all your help.

Almost there…

on ChannelsUsed pCont do
 	  (
 		  pCont.useTime = true
 		  pCont.usePosition = true
 		  pCont.useTM = true
 		
 	  )
   on Init pCont do
 	  (
 		  baseObj = $Sphere01
 	  )
   
   on Proceed pCont do
 	  (
 		  if baseObj != undefined do
 			  (
 				  t = pCont.getTimeStart() as float
 				  NumFaces = getNumFaces baseObj
 				  
 				  if t < 0 do
 					  (
 						  for i = 1 to NumFaces do
 							  (
 								  pCont.AddParticle()
 								  pCont.particleIndex = pCont.NumParticles()
 								polyCenter = (polyop.getFaceCenter baseObj i)
 								pCont.particlePosition = polyCenter
 								  faceNormal = (in coordsys baseObj polyop.getFaceNormal baseObj i)
 								worldUpVector = [0,0,1]
 								rightVector = normalize (cross worldUpVector faceNormal)
 								upVector = normalize (cross rightVector faceNormal)
 								theMatrix = matrix3 rightVector upVector faceNormal polyCenter
 								pCont.particleTM = theMatrix
 							)
 					  )
 			  )
   
 	  )
   
   on Release pCont do ()
1 Reply
(@decapitator)
Joined: 11 months ago

Posts: 0

You could rotate them the easy way by adding a rotation speed space follow and speed by surface out of normal on a speed like 0.01 in the event and then send out and do the rest of the flow.

uh… oh yeah… thanks. then all I need from the script is the position. I got so caught up in the birth script i fogot about the basics. I learned a bit in the process though. Something is still not right with my little TM calculation.