Better Points Control or a Script?

General Moho topics.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
rocken
Posts: 28
Joined: Wed Mar 21, 2018 1:30 am

Better Points Control or a Script?

Post by rocken »

Hello House,
I wish to ask the gurus in scripting if adding a function to manipulate lines in between Bezier handles {without having to mess with Bezier handles) would be a big issue in Moho?. I feel this would make point animation more easier.
Attached is a gif to show what I'm talking about.
https://ibb.co/0qdkBQx
Image
I wish we could have similar controls with Affinity Designer where with the node tool, one can easily drag curves without having to tweak individual Bezier handles. Also having this embedded with the Transform point tools would be a better workflow. I have always hated the idea of the Curvature tool in Moho. How delighted would I be if this could be considered in a future release of Moho.
User avatar
hayasidist
Posts: 3857
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Better Points Control or a Script?

Post by hayasidist »

is what you're asking:

grab somewhere in the path; shift it and automatically adjust the Bezier handles for that segment in the control points for the segment?
User avatar
SimplSam
Posts: 1218
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Re: Better Points Control or a Script?

Post by SimplSam »

For some reason you can't see the cursor in the example, but Yes - just drag on the path to reshape the curve, and the neighbouring handles adjust automatically.

It's a very handy feature of Affinity, Illustrator, Inkscape, Krita, After Effects ...
Last edited by SimplSam on Mon Apr 26, 2021 5:52 pm, edited 1 time in total.
Moho 14.3 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.3 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
User avatar
Lukas
Posts: 1336
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Better Points Control or a Script?

Post by Lukas »

That would be very useful. I often use the 'add point' tool on a straight curve to quickly make it bend to get the shape I want (not when animating obviously). This would be just as quick and with better shapes.
Daxel
Posts: 1088
Joined: Wed Mar 27, 2019 8:34 pm

Re: Better Points Control or a Script?

Post by Daxel »

I would like to have something like this too, but right now editing bezier handles can trigger some bugs while animating bones like happens here: viewtopic.php?f=13&t=32881
So I would love to see those bug fixed first so I can start using them for animation.
User avatar
Greenlaw
Posts: 10466
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Better Points Control or a Script?

Post by Greenlaw »

Just to add: Technically, the issues in animated Bezier vector shapes with bones is not a bug, it's just the nature of using Bezier curves with bones. My suggestion is to avoid using Bezier when the vectors are meant to be deformed by bones. But if you really need to do this, Victor has a technique that works for some users. A search in these forums should turn that up.

Personally, I hide the Bezier handles so I don't accidentally activate Bezier mode until I need it. There is a Curvature tool mod by Synthsin75 that adds this option to the tool, where's it's easy to accidentally activate Bezier mode. BTW, when you do accidentally activate Bezier points, just select the point and use Peak or Smooth to reset the point back into a 'classic' point mode.

As mentioned, I usually avoid Bezier because it's unpredictable for bones animation. To get equivalent or similar curves, I just use the Curvature tool and click/drag over the point, and, where necessary, I will add more points along the curve.

This isn't to say I don't use Bezier points at all. For static items, I do find this mode very useful.

Hope this helps.
Last edited by Greenlaw on Sat Apr 10, 2021 3:30 pm, edited 1 time in total.
User avatar
hayasidist
Posts: 3857
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Better Points Control or a Script?

Post by hayasidist »

hayasidist wrote: Fri Apr 09, 2021 12:04 pm is what you're asking: grab somewhere in the path; shift it and automatically adjust the Bezier handles for that segment in the control points for the segment?
SimplSam wrote: Fri Apr 09, 2021 1:04 pm Yes - just drag on the path to reshape the curve, and the neighbouring handles adjust automatically.
Daxel wrote: Fri Apr 09, 2021 3:21 pm I would like to have something like this too, but right now editing bezier handles can trigger some bugs while animating bones like happens here: viewtopic.php?f=13&t=32881
...
So, to answer the OP's question - yes - feasible but ...

it won't solve the "odd" behaviours associated with animation of points with "moved" bezier handles (points that just use "curvature" are ok). Part of the issue is that Moho doesn't directly store the bezier handles, but - for what I guess are compatibility reasons - stores a parametrisation of them in subchannels of the "point curvature" channel -- and (I am in the realms of guesswork here) when a point moves (under bone influence) relative to its neighbour, re-evaluation and interpolation of these subchannels, doesn't work well.

and, as others have pointed out there's a fairly simple way to do this without a script, if you're prepared to have an actual point on that segment instead of an imaginary one (e.g.)
Lukas wrote: Fri Apr 09, 2021 1:15 pm I often use the 'add point' tool on a straight curve to quickly make it bend to get the shape I want (not when animating obviously). This would be just as quick and with better shapes.
And the scripted solution I'd suggest would be based on making that actual point a "hidden" point that remains hidden but which becomes accessible to the script when that part of the curve is selected. I did a lash up of this by way of proof of concept and it worked ok. Now, if you don't use modified bezier handles on the end points of the segment but rely on moving this hidden point around, it might actually avoid some of the issues that arise from making the shape of the curve change by using bezier handles?
rocken
Posts: 28
Joined: Wed Mar 21, 2018 1:30 am

Re: Better Points Control or a Script?

Post by rocken »

Do you mean you made a script on it? Would be nice to see...Very very interested please....
hayasidist wrote: Sat Apr 10, 2021 11:46 am
hayasidist wrote: Fri Apr 09, 2021 12:04 pm is what you're asking: grab somewhere in the path; shift it and automatically adjust the Bezier handles for that segment in the control points for the segment?
SimplSam wrote: Fri Apr 09, 2021 1:04 pm Yes - just drag on the path to reshape the curve, and the neighbouring handles adjust automatically.
Daxel wrote: Fri Apr 09, 2021 3:21 pm I would like to have something like this too, but right now editing bezier handles can trigger some bugs while animating bones like happens here: viewtopic.php?f=13&t=32881
...
So, to answer the OP's question - yes - feasible but ...

it won't solve the "odd" behaviours associated with animation of points with "moved" bezier handles (points that just use "curvature" are ok). Part of the issue is that Moho doesn't directly store the bezier handles, but - for what I guess are compatibility reasons - stores a parametrisation of them in subchannels of the "point curvature" channel -- and (I am in the realms of guesswork here) when a point moves (under bone influence) relative to its neighbour, re-evaluation and interpolation of these subchannels, doesn't work well.

and, as others have pointed out there's a fairly simple way to do this without a script, if you're prepared to have an actual point on that segment instead of an imaginary one (e.g.)
Lukas wrote: Fri Apr 09, 2021 1:15 pm I often use the 'add point' tool on a straight curve to quickly make it bend to get the shape I want (not when animating obviously). This would be just as quick and with better shapes.
And the scripted solution I'd suggest would be based on making that actual point a "hidden" point that remains hidden but which becomes accessible to the script when that part of the curve is selected. I did a lash up of this by way of proof of concept and it worked ok. Now, if you don't use modified bezier handles on the end points of the segment but rely on moving this hidden point around, it might actually avoid some of the issues that arise from making the shape of the curve change by using bezier handles?
Daxel
Posts: 1088
Joined: Wed Mar 27, 2019 8:34 pm

Re: Better Points Control or a Script?

Post by Daxel »

Greenlaw wrote: Fri Apr 09, 2021 5:19 pm Just to add: Technically, the issues in animated Bezier vector shapes with bones is not a bug, it's just the nature of using Bezier curves with bones. My suggestion is to avoid using Bezier when the vectors are meant to be deformed by bones. But if you really need to do this, Victor has a technique that works for some users. A search in these forums should turn that up.
Yeah beziers are harder to animate in general but in my specific case it totally looked like a bug and it was reported by Wes.
User avatar
hayasidist
Posts: 3857
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Better Points Control or a Script?

Post by hayasidist »

rocken wrote: Sat Apr 10, 2021 7:40 pm Do you mean you made a script on it? Would be nice to see...Very very interested please....
It's proof of concept only and runs inside my test harness, so:

it doesn't have all the "other stuff" that a script needs ...
it doesn't try to see which segment is active etc etc ...
it just finds the first hidden point and then moves it to wherever the mouse goes...
I ran it against a moho document that had one vector layer with a shape consisting of three points - stroke only, in a straight line - I hid the middle one manually

Code: Select all

local movePt

function HS_Test_Paths:OnMouseDown(moho, mouseEvent)
	local mesh = moho:Mesh()
	local i
	local ct = mesh:CountPoints()
	
	movePt = nil
	for i = 0, ct-1 do
		pt = mesh:Point(i)
		if pt.fHidden then 
			movePt = pt
			break
		end
	end
	return
end

function HS_Test_Paths:OnMouseMoved(moho, mouseEvent)
	if movePt then 
		movePt:SetPos(mouseEvent.vec, 0)
	end
	return
end
a real script would need to check the active segment to decide if it had a hidden point and either use it, or create a new hidden point... it shouldn't assume frame 0 (as done here)
it would also need a load of error / exception handling -- e.g. at present there's no meta data services in Moho to indicate reliably if a point was hidden and has now been unhidden by the user from the standard UI - as that would change the user's view of the segment count etc etc etc ...
and it would need all the "housekeeping" functionality - e.g. timeline keying, creating "undo" checkpoints ...

so - whilst the core of this is "find a point and move it" - and this can be accomplished in very few lines of code - there'll be another couple of hundred lines to make the thing robust
rocken
Posts: 28
Joined: Wed Mar 21, 2018 1:30 am

Re: Better Points Control or a Script?

Post by rocken »

Oh I see
Thanks for taking your time out to test this.
I wish I understood scripting
Or better still, I wish I could sponsor your research.
i find that having such a functionality would speed up the drawing process in Moho and one could easily turn straight lines to curves, sharp corners to rounded corners.
Thanks once again for the effort
hayasidist wrote: Sun Apr 11, 2021 9:44 am
rocken wrote: Sat Apr 10, 2021 7:40 pm Do you mean you made a script on it? Would be nice to see...Very very interested please....
It's proof of concept only and runs inside my test harness, so:

it doesn't have all the "other stuff" that a script needs ...
it doesn't try to see which segment is active etc etc ...
it just finds the first hidden point and then moves it to wherever the mouse goes...
I ran it against a moho document that had one vector layer with a shape consisting of three points - stroke only, in a straight line - I hid the middle one manually

Code: Select all

local movePt

function HS_Test_Paths:OnMouseDown(moho, mouseEvent)
	local mesh = moho:Mesh()
	local i
	local ct = mesh:CountPoints()
	
	movePt = nil
	for i = 0, ct-1 do
		pt = mesh:Point(i)
		if pt.fHidden then 
			movePt = pt
			break
		end
	end
	return
end

function HS_Test_Paths:OnMouseMoved(moho, mouseEvent)
	if movePt then 
		movePt:SetPos(mouseEvent.vec, 0)
	end
	return
end
a real script would need to check the active segment to decide if it had a hidden point and either use it, or create a new hidden point... it shouldn't assume frame 0 (as done here)
it would also need a load of error / exception handling -- e.g. at present there's no meta data services in Moho to indicate reliably if a point was hidden and has now been unhidden by the user from the standard UI - as that would change the user's view of the segment count etc etc etc ...
and it would need all the "housekeeping" functionality - e.g. timeline keying, creating "undo" checkpoints ...

so - whilst the core of this is "find a point and move it" - and this can be accomplished in very few lines of code - there'll be another couple of hundred lines to make the thing robust
User avatar
hayasidist
Posts: 3857
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Better Points Control or a Script?

Post by hayasidist »

an update on this ... I ditched the hidden point idea .. it worked like a dream, but I couldn't come up with a way of keeping a hidden point completely hidden to everything except the proposed tool. So I went off in another direction based on the inkscape logic.

here's the result...

http://www.lostmarble.com/forum/viewtop ... 12&t=33928
Post Reply