Jump to content
CinnamonMetal

Apply attribute based on object id in RBD

Recommended Posts

I have a sop solver inside a dopnet for a RBD.  This is what is inside the point wrangler, but it's not working for only the packed geometry with an objid of one and three ?

if(i@objid == 1 && 3){
@bounce = 1.75;
}

forLoop_objid.jpg.72d4ce16fa4aa5e71346ddff9aaf116b.jpg

Share this post


Link to post
Share on other sites
Posted (edited)

why would you bother using a for each ?

- the pointwrangle (or attrwrangle) is already a loop....it loops thru points (or prims) (and subgroups if you specify them)

- a point can't have objid = BOTH 1 and 3....it's equal 1 or 3.

Edited by Noobini

Share this post


Link to post
Share on other sites
Posted (edited)

noobini is right in both points. The pointwrangle is executed for every point in input 1. Think about it from a single points perspective: It can have an id of EITHER 1 OR 3 for your code to fire. Its a single integer attribute, so how is it ever supposed to be both 1 AND 3?

you'd have to use if(i@id ==1 || i@id ==3) {}

look at the simple example attached - with these things its often easiest to test them outside of the dopnet if possible. you can even use an expression in the group field to achieve the same.

pointwrangle.hiplc

Edited by nuki

Share this post


Link to post
Share on other sites

When I'm outside of a SOPSolver but remain inside of a dopnet, each packed primitive has their own point; although when I'm inside the SOPSolver inside the DOPNet those same single points have multiple points over lapping ?

Therefore my wrangle doesn't do what I want because of the overlapping points ?

Share this post


Link to post
Share on other sites
Posted (edited)

you are fetching the impact points tho, not the packed prims? The impact positions could be overlapping if your object is just bouncing in place. Maybe you could share the scene so we are on the same page here.

Edited by nuki

Share this post


Link to post
Share on other sites
Posted (edited)

If I use @objid == 1 within a SOPSolver does that know to get the packed primitive with an id of 1 within a rbd dopnet ?

Edited by CinnamonMetal

Share this post


Link to post
Share on other sites

The ObjId has nothing to do with your packed geoemtry. Your ObjId describes the different dynamic objects.

 

for example your RBDpackedobject1 node has objid == 0 

image.png.bc83c551572098b39cfa5601c06a2927.png

and your groundplane has objid == 1

image.png.6303ccc5dca70ee8a49747d6eb2d7d87.png

I am a little confused as what you are trying to add a color to? Is it the cubes or the constraints?

Share this post


Link to post
Share on other sites

Do packed geometry have an object id; and if so, how can I use it so forces or color is applied to only the object id for which I want to apply it ?

Share this post


Link to post
Share on other sites

yes you can use the s@name string attribute to identify your pieces with. This is why we setup unique names for our packed geometry. So the solver can keep track of each individual piece. 

Share this post


Link to post
Share on other sites

Considering that there is a name attribute but on primitives in the form of op:/<path> (string) how do I use this path in a SopSolver ?

Share this post


Link to post
Share on other sites
2 hours ago, CinnamonMetal said:

Considering that there is a name attribute but on primitives in the form of op:/<path> (string) how do I use this path in a SopSolver ?

you are mixing things together. That is not a name attribute on the primitives. That is a path attribute. You name attribute exists on the points. Each individual cube is represented by a point. This is what happens when you pack the geometry.image.thumb.png.7eebbc3bbec9db61be9d4eb79cdbcef8.png

So in order to color some of the cubes for instance you need the sop solver to be attached  to the rigid body solver. Not the constraint solver. (unless you are trying to color the constraint primitives.) See below

image.png.662746f66970d81c6e0873b80bcebec9.png

Lastly in order to access the cube geometry (the points) you need to work from the dop_geometry node inside the sop solver and not the Impacts.

image.png.e33abe51211669a1c0449c0993ba6ffe.png

Once all of that has been setup you can then write your code.

 

Your code should look something like this:

image.thumb.png.acb802204590af5660cd10017f323d19.png

Take note of the fact that the wrangle node is running over the points and not primitives. Since your geometry is packed I only have one point or one primitive available per cube. The name attribute exists on the points, so we have to run over points. A simple string condition does the trick to isolate the desired cubes.
Inside the if statement I choose to add my color attribute to the primitive instead of the point which I am running over. This is simply just because Houdini is not very good at displaying colors that sits as a point attribute when dealing with packed geometry. So in order for it to show in the viewport I added the color in a primitive attribute instead.

 

  • Like 1

Share this post


Link to post
Share on other sites

in order to do that you would in another if statement check if they have collided with the ground. Same concept

Share this post


Link to post
Share on other sites

@Jesper Rahlff It appears from your screen shots, that you didn't create an if statement within the SOPSolver, yet when the boxes hit the ground they are being colored. Unless there is something that isn't visible in the screen shots ?

Share this post


Link to post
Share on other sites
3 hours ago, CinnamonMetal said:

@Jesper Rahlff It appears from your screen shots, that you didn't create an if statement within the SOPSolver, yet when the boxes hit the ground they are being colored. Unless there is something that isn't visible in the screen shots ?

image.png.abe555e918ed86e09187b5c8bf588c82.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×