Hi,
So I'm trying to tweak (art direct) a destruction simulation by going into the rbd bulletsolver and adding some forces.
I'm mainly using POP drag,POP dragspin and POP force. You can use VEXpressions to specify in my case where the force should be applied.
Currently I'm doing it manually like this, inside the popdrag VEXpression:
if(@P.x >= 523 && @P.x <= 539 &&
@P.y >= 40 && @P.y <= 43 &&
@P.z >= -187 && @P.z <= -181)
{
airresist = 10.0;
}
else
{
airresist = 0.001;
}
But I would like to make it easier to visualise and change. So I tried adding a box object and using the box bounds to check if a piece is inside the bounds of the box and add the force if it's the case. So I can visually see where the bounds are and change it easily, but I can't get a box in the dopnnet(or reference a box from the geometry level) and don't know how i would even define it in VEX.
Any seggestions on how I would do it?
How to check if piece is inside box bounds VEX
3520 7 2- EliasCyborn
- Member
- 5 posts
- Joined: Feb. 2022
- Offline
- npetit
- Staff
- 413 posts
- Joined: Feb. 2008
- Offline
- akirasun_sh
- Member
- 26 posts
- Joined: Dec. 2019
- Offline
- EliasCyborn
- Member
- 5 posts
- Joined: Feb. 2022
- Offline
- EliasCyborn
- Member
- 5 posts
- Joined: Feb. 2022
- Offline
akirasun_shthanks for your response!
getbbox or volumesample should work
Not sure how to actually code the if statement on how to compare each piece location to the bounds of the box that i get from that function. could you elaborate?
Or do i still just code it the same way like
if(P.x >= Bounds.xmin && P.Y <= Bounds.xmax && P.y >= ....)
or is there a faster way?
- Robbert
- Member
- 55 posts
- Joined: Feb. 2017
- Offline
EliasCybornakirasun_shthanks for your response!
getbbox or volumesample should work
Not sure how to actually code the if statement on how to compare each piece location to the bounds of the box that i get from that function. could you elaborate?
Or do i still just code it the same way like
if(P.x >= Bounds.xmin && P.Y <= Bounds.xmax && P.y >= ....)
or is there a faster way?
If you are using the bbox functions; getbbox_size() and getbbox_center() you could compare positions as you describe above, you just simply have to take into account the position of the box AND the scale. So @P.x > bboxcenter.x - (bboxsize.x / 2) and @P.x < bboxcenter.x + (bboxsize.x /2). However, the downside of this is that it is not very compact to write, and you can only use a box, preferably one without any rotations. Instead you can convert the box to a SDF with the VDB from polygons node in SOPS. You can then use volumesample() function to get the value of the SDF and if that is under 0, your point is inside of the box. This gives you more flexibility to use any arbitrary shape.
This great video might be able to clear up the whole topic; https://www.youtube.com/watch?v=QgzxBN1m9WE [www.youtube.com]
References to the functions;
https://www.sidefx.com/docs/houdini/vex/functions/getbbox_center.html [www.sidefx.com]
https://www.sidefx.com/docs/houdini/vex/functions/getbbox_size.html [www.sidefx.com]
https://www.sidefx.com/docs/houdini/vex/functions/volumesample.html [www.sidefx.com]
Edited by Robbert - Aug. 26, 2022 05:30:48
Technical VFX artist @ Housemarque / Sony Interactive Entertainment
- fuat
- Member
- 585 posts
- Joined: March 2014
- Offline
you can also use the windingNumber SOP to check if points are inside a geometry.
since packed geo is just "points" representing transforms of your pieces (plus collision hulls and a few other attributes and properties attached to them for RBD sims), you can then group those points (based on their winding number) and in DOPs simply apply your desired force to that group only.
hope this helps
since packed geo is just "points" representing transforms of your pieces (plus collision hulls and a few other attributes and properties attached to them for RBD sims), you can then group those points (based on their winding number) and in DOPs simply apply your desired force to that group only.
hope this helps
Edited by fuat - Aug. 27, 2022 17:34:22
Fuat Yüksel
FX Supervisor | RISE Visual Effects Studios
FX Supervisor | RISE Visual Effects Studios
- tamte
- Member
- 8833 posts
- Joined: July 2007
- Offline
use POP Group DOP (unless you really wanted to do it in VEX)
it has Bounding Option, where you can specify BBox, BSphere explicitly or BObject,BVolume and point to specific SOP
which in theory should cover all custom solution above
then either specify it in a Group parm of your POP nodes to limit their scope
or even use in VExpression if you want to control your values for in and out of group like in your screenshot
it has Bounding Option, where you can specify BBox, BSphere explicitly or BObject,BVolume and point to specific SOP
which in theory should cover all custom solution above
then either specify it in a Group parm of your POP nodes to limit their scope
or even use in VExpression if you want to control your values for in and out of group like in your screenshot
airresist = @group_MyGroup ? 10.0 : 0.001;
Edited by tamte - Aug. 28, 2022 05:16:07
Tomas Slancik
FX Supervisor
Method Studios, NY
FX Supervisor
Method Studios, NY
-
- Quick Links