Hi there, I am trying to make some adjustments to the arrow cap function of the line mat. I am using the included GestureCapture example in the techniques pallatte. I adjusted the line end cap to be an arrow, but I am having an issue controlling the way that arrow ends up. Basically, it seems that if the cursor moves backwards or sideways by 1 pixel whenever I let go of the click, the arrow will snap in that direction. I need some way to make it stay pointing in the direction of say the last 50 pixels of the line, so that the arrow looks natural. Photos attached of the issue. Any idea how this could be done? Thanks!
So I’ve tried that, however I think the issue I am running stems from the way the cap is drawn at the end of the line. I’ve included a video of the issue here, which occurs not only when the line is finished drawing, but also while it is being drawn.
I assume the cap is drawn based on the direction of the previous two pixel positions, but is there a way to maybe make it sample the vector of the last 10?
hmmm that’s a tough one. It looks like you are already using a resample SOP, but maybe use the “max length” for segments.
That might get rid of your last point’s location (where the arrow should actually be) so you would have to reverse the line (Sort SOP reverse point order) and put your arrow at the start of the now reversed line since resample will start resampling from the first point of the line. You could turn on “maintain last vertex” instead of reversing it, but I’m pretty sure that would make the arrow MUCH more erratic
If not, I don’t think there’s a way to do what you want with the Line MAT, so you may need to roll your own arrow with another Geo COMP that puts a triangle at the last point rotated in the direction you want.
I’m not even really sure how to make that (a triangle that rotates based on the last X points) off the top of my head… would probably take a few hours of me mucking around - but I bet there are people (maybe you) that could whip it up in a couple minutes using “mathematics”
I’ll have to play around in that case. I had experimented with drawing my own arrow cap as its own shape, but I also struggled with the rotation. Maybe an AI tool could help write some expression
Any possibility this could be a feature request for the line sop? Cap direction based on last X number of points?
In gestureCapture is a “lineMaster0” component which is copied for every stroke. Using CHOPs it does smoothing and adds metrics and a bit of trim, before converting it to SOPs that you then render with arrows.
If your beginning and ending of lines are a bit jittery, you may want to add a Trim CHOP and a Filter CHOP before the out2 CHOP and cut a few samples and maybe smooth the whole result further. See pic.
( You can use CHOPs to do fancier things like mix the smoothed version with the unsmoothed version using a curve that blends one at the beginning and end and the other in the middle. )
“Cap direction based on last X number of points” make be good as an option, or last T seconds. It’s hard to anticipate what defects you need to deal with.
My solution ended up being a mix of that, I trim the end of the line by a little bit, as well as sampling as many points as possible. It helped cut down the issues a bit, but it still isn’t perfect. I think that feature add is the solution.