Hello,
So, I've got a bunch of objects (let's say 100) and I only want to apply a force (let's say Gravity) to the ones that have had at least one collision with another object.
In POPs, I'd use $NUMHIT, how do I do this in DOPs? I tried to be clever and use
-10*dophasfield(“/obj/dopnet1”,$OBJNAME,“Solver/Colliders”,“Basic”,0,“creationtime”)
or something like that in the Gravity DOP, to no avail. It seems like the Colliders field always exists after frame 1?
I have searched through the Details view but cannot find any count of the number of hits which I could then extract and use via an expression.
I'm stumped (
EDIT So, in some cases I get Impacts data that seems like it's moving towards what I want (though even there I don't see a NUMHIT type number). However, in my test case (using a field of objects created via the Instance attribute in SOPs) I never get that Impact field.
Cheers,
Peter B
DOPs: Getting $NUMHIT type info
6151 10 2- pbowmar
- Member
- 7025 posts
- Joined: July 2005
- Offline
- craig
- Member
- 557 posts
- Joined: July 2005
- Offline
The basic structure of something like this is to use Empty Data followed by Modify Data. You “modify” the data when you find the event you want, and that creates it and sets a value. Then you can update the value on subsequent frames if you want.
I've attached an example of this that sets a boolean when an object has had an impact, and then uses a test of that boolean to change the velocity of an object. You can create variations on this theme to save the frame that an object was first impacted, or to accumulate the total number of impacts, or whatever.
I've attached an example of this that sets a boolean when an object has had an impact, and then uses a test of that boolean to change the velocity of an object. You can create variations on this theme to save the frame that an object was first impacted, or to accumulate the total number of impacts, or whatever.
- pbowmar
- Member
- 7025 posts
- Joined: July 2005
- Offline
Hey Craig,
Cool, thanks for this. I can't pretend to fully understand right now but I'll plug away at it. DOPs has a long way to go to match POPs' intuitiveness )
So, the Impact data only exists _on_ an impact frame, I take it? If so, it looks like the Index value is the number of hits, which gets me what I need, I think )
Cheers,
Peter B
Cool, thanks for this. I can't pretend to fully understand right now but I'll plug away at it. DOPs has a long way to go to match POPs' intuitiveness )
So, the Impact data only exists _on_ an impact frame, I take it? If so, it looks like the Index value is the number of hits, which gets me what I need, I think )
Cheers,
Peter B
- pbowmar
- Member
- 7025 posts
- Joined: July 2005
- Offline
Hey Craig,
So, I _almost_ got it ) I use the dopnumrecords() but it doesn't work the way I expect. If I look at the Impacts data, for one thing it bounces around, so clearly does not hold the numhits.
Regardless, though, the numbers don't jive. dopnumrecords() sometimes returns the number of Index entries, and sometimes it returns something else, apparently at random.
Where is all this stuff documented? Like, if I want to know what Index actually is telling me, where do I look? If I have to jump through hoops just to do a simple NUMHIT type thing, which is fine, how would I have ever figured this out on my own? Or is DOPs the ultimate Campfire Lore area of Houdini now? )
Cheers,
Peter B
So, I _almost_ got it ) I use the dopnumrecords() but it doesn't work the way I expect. If I look at the Impacts data, for one thing it bounces around, so clearly does not hold the numhits.
Regardless, though, the numbers don't jive. dopnumrecords() sometimes returns the number of Index entries, and sometimes it returns something else, apparently at random.
Where is all this stuff documented? Like, if I want to know what Index actually is telling me, where do I look? If I have to jump through hoops just to do a simple NUMHIT type thing, which is fine, how would I have ever figured this out on my own? Or is DOPs the ultimate Campfire Lore area of Houdini now? )
Cheers,
Peter B
- craig
- Member
- 557 posts
- Joined: July 2005
- Offline
Yes, Impact data is transitory. It's there when there are impacts, and not when there aren't. So if you want to keep around impact info, you have to do it yourself.
Not quite. You want this value:
`dopnumrecords(“/obj/dopnet1”, $OBJID, “Impacts”, “Impacts”)`
which will return the number of impacts (in that timestep only). Then you can access each one (if you care) with the dopfield() command. Normally, the record number in this command is 0, but in this case, you would use the record number to access the particular impact data you were interested in.
This is all easier to see in the Details View than it is to describe!
(BTW, I notice the dopnumrecords() call is slightly incorrectly documented in the help)
Edit: It seems I sent this at the same time you sent your followup. See below.
f so, it looks like the Index value is the number of hits, which gets me what I need, I think
Not quite. You want this value:
`dopnumrecords(“/obj/dopnet1”, $OBJID, “Impacts”, “Impacts”)`
which will return the number of impacts (in that timestep only). Then you can access each one (if you care) with the dopfield() command. Normally, the record number in this command is 0, but in this case, you would use the record number to access the particular impact data you were interested in.
This is all easier to see in the Details View than it is to describe!
(BTW, I notice the dopnumrecords() call is slightly incorrectly documented in the help)
Edit: It seems I sent this at the same time you sent your followup. See below.
Edited by - Feb. 13, 2006 14:23:16
- craig
- Member
- 557 posts
- Joined: July 2005
- Offline
I'm not sure what you mean by “bounces around” and “random values”. When I step through your version, it does what I'd expect. Keep in mind that in your simpler setup, you only have one impact on the frame in question, whereas in my original, ball_3 was getting 7 impacts on frame 122, and 21 impacts on frame 216.
The other thing to realize is that if you want to latch data, as opposed to update it, it gets more complex. For example, here's one that saves the frame number that an object first had an impact. The expression for this is trickier, because you don't want to update this value on any subsequent impact. I was quite pleased with this, but it did take me 30 minutes to work out…
As to documentation… well, most of this stuff is written down, but you have to look at the help cards and especially the helpcard examples, and cross reference with the command help in the textport, and then you have to cheat and ask R&D a lot of questions. So yes, right now there is a lot of oral history in this, but I'm hoping to change that a little at a time.
The other thing to realize is that if you want to latch data, as opposed to update it, it gets more complex. For example, here's one that saves the frame number that an object first had an impact. The expression for this is trickier, because you don't want to update this value on any subsequent impact. I was quite pleased with this, but it did take me 30 minutes to work out…
As to documentation… well, most of this stuff is written down, but you have to look at the help cards and especially the helpcard examples, and cross reference with the command help in the textport, and then you have to cheat and ask R&D a lot of questions. So yes, right now there is a lot of oral history in this, but I'm hoping to change that a little at a time.
- jason_iversen
- Member
- 12479 posts
- Joined: July 2005
- Offline
Hey all,
I think there is a ScriptSolver example to record NUMHITS over time, isn't there? None of this is exactly easy..
I think there is a ScriptSolver example to record NUMHITS over time, isn't there? None of this is exactly easy..
Jason Iversen, Technology Supervisor & FX Pipeline/R+D Lead @ Weta FX
also, http://www.odforce.net [www.odforce.net]
also, http://www.odforce.net [www.odforce.net]
- pbowmar
- Member
- 7025 posts
- Joined: July 2005
- Offline
- craig
- Member
- 557 posts
- Joined: July 2005
- Offline
- pbowmar
- Member
- 7025 posts
- Joined: July 2005
- Offline
- craig
- Member
- 557 posts
- Joined: July 2005
- Offline
-
- Quick Links