Locking particles to vertices


#1

This is pretty much a continuation of this thread:
http://forums.cgsociety.org/showthread.php?t=731693

I’m using almost exactly the same method as irwit, except I’m using a script operator because I only want to apply the script to the first event and use those particles to spawn trails.

Strangely, the script works fine when I scrub through the timeline, but when I play forward the particles don’t move, and when I render I see absolutely nothing happening. I’m guessing it’s not getting the vertices from the proper frame despite the “at time”, but I have no clue what I’m doing wrong. Anyone have an idea?

Here’s my birth script (works fine, just posting for the sake of completeness):


on ChannelsUsed pCont do
(
	 pCont.usePosition = true
)

on Init pCont do 
(
	global emitterObj = $emitterLine
)

on Proceed pCont do 
(
	t = pCont.getTimeEnd()
	if emitterObj != undefined do
	(
		if (t < -99) do
		(
			for i = 1 to emitterObj.numVerts do
			(
				pCont.AddParticle()
				pCont.particleIndex = pCont.NumParticles()
				pCont.particlePosition = polyop.getVert emitterObj i node: nullBox
			)
		)
	)
)

on Release pCont do 
(
 
)

And here’s the script operator:


on ChannelsUsed pCont do
(
	pCont.usePosition = true
)

on Init pCont do 
(
	
)

on Proceed pCont do 
(
	count = pCont.NumParticles()
	lockObj = $emitterLine

	for p in 1 to count do
	(
		pCont.particleIndex = p
		pos = at time pCont.particleAge polyop.getVert lockObj p node: nullBox
		pCont.particlePosition = pos
	)
)

on Release pCont do 
(
 
)

If I could I’d use lock/bond from pf toolbox 1 but I’m short on cash at the moment and really can’t afford it, plus it seems like overkill since it’s just 12 verts I need to lock on to.


#2

Hi noouch,

Just looking at it, you should have the time channel enabled (pCont.useTime = true) since you are calling the .getTimeEnd function. Else I am not sure, it looks to be correct AFAIK.

The only other thing I might suggest (something from Bobo) is to create a clone of your mesh and delete it upon completion of your for loop.


#3

You don’t have to enable anything to call the getTimeEnd() method because it is getting data from the container and not from a particle channel. It might be a good idea to enable the Age channel, but it seems to work without.

For some reason, these two scripts work for me (I just removed the node: parameter to use the original node’s transforms). It appears to be both playing and rendering here (Max 2008, both Scanline and mental ray), so there might be something else that is different. I created both a position animation, rotation animation and a vertex level keyframed animation (moving vertices around) and the PFlow particles followed the vertices.


#4

You can use Verticies Random in the Position Object Op to do this. Set your particle count to match the object verts and set your Seperation to a value such as .01 (basically you need this value to be smaller than the shortest distance between any two verts on the objet). Then you can check Lock On Emitter.


#5

Sorry about that, thanks for clearing that up Bobo :slight_smile: I was under (obviously the wrong impression) that all time related needed the .usetime. It totally makes sense that it is only channel related.


#6

Thanks for all the help :slight_smile:
Weird that it works for you bobo… Maybe it has something to do with the fact that the emitter has another animated object as a parent. I’ll try baking the animation when I get back to work tomorrow, but for now I’ve gone with a completely different approach.


#7

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.