Jump to content

Apply attribute based on object id in RBD


CinnamonMetal

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
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 ?

Link to comment
Share on other sites

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
Link to comment
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?

Link to comment
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
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...