Jump to content

Want To Place A Particle At Object Centroid And Parent Object To That


frankvw

Recommended Posts

Hello and happy new year!

The start of the new year has brought me a fresh challenge this week.

I have a little crowd-type sim to tackle that is really straight forward but the objects animated (hopefully) need to be animated at the exact centre/centroid of each object for it to work properly. And they need to be arranged at their exact, intial starting position in world space. So I need CopySop or expressions or suchlike to loop through the world positions of a dozen objects, put a particle at their centre point and then make a parent to the object so that when the particles move, the objects will follow them.

What do you think?

Cheers

Link to comment
Share on other sites

Maybe something like this? I think this is what you were trying to get. This example doesn't deal with World Space really but the idea should be able to be adapted to something like that.

Takes each object/model and creates a point group for it. Then adds a point at the centroid. All the objects are then merged together and a delete sop removes all the groups leaving the remaining center points. The center points go into the POP network and spawn the corresponding particles which can then be affected by whatever force etc you might use. The particles are then used as a template for copy stamp which uses the point numbers to select the appropriate object/model network through the switch.

I'm sure there might be a better way to loop through the objects but here is a quick test I did while writing out a sim here at work.

particle_crowd_control.hip

Link to comment
Share on other sites

Hi!

What can I say? Thanks guys, I never get stuck for anything thats thrown at me and my houdini thanks to odforce. Just wish I could contribute more myself ....... :(

So these examples definitely have me on the right track now (if I can produce anything useful at the end of it all, I'll post up an *.hip if its useful for anyone else). The projects growing bigger by the day now as the client is getting enthusiatic about the speed I can get stuff through to him on houdini. :)

So one of the last additions I am wrestling with now is how to set the individual particle sphere diameter (or radius) to the largest x or y or z length of each individual object's bounding box dimension. I don't suppose anyone has tried something like that before in houdini, by chance?

Cheers

Link to comment
Share on other sites

While particles don't exactly have a radius you can use their pscale to change their size. If you put down a point sop you can come up with an expression or whatever to assign each particle it's own custom scale. In your case something that finds it's biggest bounding distance. The pscale will be transfered through the pop network and out and will then influence the objects size when it is copied to it. As was mentioned above, I accidentally turned off my Rotate to Template Normal option off. It should be on. I'm not quite sure what it is you want to do by changing it's radius so this might not turn out exactly like what you were looking for. This merely uniform scales it.

Link to comment
Share on other sites

So here's an updated example I did while watching the football game.

It actually loops through all your input objects this time.

All your objects/models are plugged into a switch sop which is controlled by a copy stamp

that uses a dummy line sop so that it can copy the centroid points together. The number of

points on the line is equal to the number of inputs of the switch sop and the distance is

set to 0 to create all the points at the origin. A connectivty sop is used to separate

the centroid point from the geo points so they can be deleted.

The point sop adds the pscale attribute which is controlled by an expression function

that returns the largest bounding box size value.

particle_crowd_control_v2.hip

Now with fancy colored network boxes and comments.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...