Floor collision in CHOPs

   2015   2   0
User Avatar
Member
51 posts
Joined: 10月 2006
Offline
I have an animated object and some “floor” geometry, I want to adjust object's Y position to the floor - in other words, object's world tx/tz are coming from key-framed animation, ty is calculated according to the floor geometry.
For the special case where the floor is just a single layer, without any overlaps in Y, it seems very easy to do this in CHOPs. See the attached scene. The setup is sketched in the 1st picture - it's essentially a single VOP CHOPs that fires a collision ray from high above using VEX intersect() function. The idea is to cover the entire possible range in Y - in this scene the ray's origin is shifted 100 units upwards and its length is set to 200 units (arbitrary large values).
This will not work in the general case though - see the 2nd picture, if there are overlapping floors the object will jump to the highest position (set /obj/floor/switch1 value to 1 in the example scene to see this in action).
The basic setup works fine for what I'm doing, but I thought it would be just as easy to extend it to support the general case. To do so the ray's origin must be placed somewhere near the recent object position - basically, this means using the adjusted ty from the previous frame.
I tried sampling previous value with an expression like this: chopcf(“.”, 1, $F-1)
but it seems the returned value is always coming from the original channel, it's not the adjusted ty from VOP CHOP.
I'm also experimenting with Feedback CHOP, which seems to be designed for such situations, but no luck so far.

Thanks in advance for any ideas and suggestions!

Attachments:
CHOP_floor1.jpg (89.3 KB)
CHOP_floor2.jpg (39.2 KB)
CHOP_floor.hipnc (82.8 KB)

User Avatar
Member
192 posts
Joined: 11月 2008
Offline
howdy. the type of behavior you're describing (using the previous frame as the starting point for the current frame) is the way the sopsolver behaves. here's your same scene with a sopsolver with a ‘ray sop’ in it replacing the ‘vop chop’ with an ‘intersect vop’ from your file.

Attachments:
sopsolver_floor.hipnc (148.3 KB)

User Avatar
Member
51 posts
Joined: 10月 2006
Offline
Brian, thank you!
This works great - somewhat more complicated than I initially thought it would be… but only slightly so - I just tried replicating your version manually, and it's still a pretty fast setup! Moreover, for what I'm doing, having actual collision checks in SOP context will make certain things much simpler.
  • Quick Links