Jump to content

particle system constrain rotation sim


Macha

Recommended Posts

I'm trying to constrain a bunch of (copy stamped) objects onto a particle system so that I can simulate them in such a way that their position is defined by the motion of the particles but their rotation is simulated.

For example: imagine elongated boxes copy-stamped onto a particle system. What I want to happen is that when they touch each other they only rotate out of each others way, but more or less remain stuck to the particles' position.

Has anybody done such a thing before. I'm thinking apply relationship dop, but I'm missing a few steps.

Edited by Macha
Link to comment
Share on other sites

Hey Macha!

What I usually do in such case is that I use spring constrain with apply relationship asking object to follow world position of targets. So they fly as particles because they are hooked to the targets but bounce and rotate nicely since it's still rbd sim. Balls on a rubber band so to speak. It's hard to control orientation though, it tends to get crazy when sim gets fast.

Link to comment
Share on other sites

I think my brain isn't working today.

I've done almost exactly that setup a few weeks ago here:

But now I can't figure out how to use a particle system instead of a wire-object as my source points to constrain to.

Edited by Macha
Link to comment
Share on other sites

Hm. I can't seem to get this thing working.

I tried point expression but for some reason I can't access anything inside an geometry node with it. So I tried it inside the dops network with an expression

dopoption("/obj/AutoDopNetwork", stamp("../applyrel1","PIECE_ID",""), "Position", "ty")

but that doesn't work either. Any ideas?

contrainme.hipnc

Link to comment
Share on other sites

Yes, it gave me an error but only on the first frame, so I thought it was just a hiccup and ignored it.

I assumed the AFFECTEDID is the same as the piece number, because both come from the particle points. I thought they are all equal; $AFFECTEDID=$PT=piece_* but I think that's a mistake.

Without even looking at the file I can see that your dopoption expression here is going to generate an error. You need to use stamps() since dopoption expects all its args as strings.

Link to comment
Share on other sites

Most likely. By the time you are applying the relationship your particle system and objects are together in the data stream so IDs are going to become unreliable. You might have better luck creating some data just after creation of each object that holds what point it was created from and using that instead of the id in the lookup.

Link to comment
Share on other sites

I think I have that data: There's a class attribute applied in the sop context.

The question is how to get at this data. Does it automatically get promoted to the DOPS context? And if so, how to I get at it if all I know is the $AFFECTEDID. Is there an expression for getting at the attribute?

Link to comment
Share on other sites

Here's a quick version that seems to be what you were trying to do though the result isn't exactly.

What I did was create some extra data right after creating the boxes and just set the data to $OBJ, which is the local index when that node is processed so piece_0 gets 0, piece_1 gets 1, etc.

Then I used a dopoption() take took the stamped AFFECTEDID value to get the custom data and used that data as the point number for the point expression to your output particle geometry. You could of course access the DOP expression as well. I also set Set Always as the default operation on the node since the positions of the particles are changing.

contrainme.hipnc

Link to comment
Share on other sites

Thanks Graham. Just before I actually had a setup with an expression that produced a similarly weird "not exact" position, so I dismissed it. But since you got the same problem I looked further into it.

It appears that each piece has a pivot in the center of the object, not one pivot per piece, so the farther they are away the more offset. If I enter your expressions in the affected's anchor as an offset then it appears that the pieces are in the right position (although I have to investigate a bit further).

Very interesting. Thanks for teaching me the applydata stuff.

Edited by Macha
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...