Turn Moho curves into Bezier

Discuss ideas for new features with other users. To submit feature requests to Smith Micro, please visit support.smithmicro.com

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
MarkBorok
Posts: 184
Joined: Sat Aug 14, 2004 8:45 pm
Location: Providence, RI
Contact:

Post by MarkBorok »

I'm way out of my depth here, but... why not use bezier curves for elements that don't need to be animated (deformed) such as backgrounds, for instance? If you can't find a solution to make beziers work with bones, you can just disable bones for those shapes.
User avatar
Fazek
Posts: 246
Joined: Thu Apr 13, 2006 1:37 pm
Location: Hungary
Contact:

Post by Fazek »

Yes, that's a natural solution to add a new "class" of curves. But this requires extra work for all of the existing algorythms, point manipulations, rotating, scaling, rendering etc. Think about the many custom Lua scripts. There are many ways to define the missing control points, the most natural is to do it with their coordinates, but there are other solutions too.
- - - Fazek
User avatar
Fazek
Posts: 246
Joined: Thu Apr 13, 2006 1:37 pm
Location: Hungary
Contact:

Post by Fazek »

What DK showed is a quadratic Bezier curve, a new another type of curves. In this case there is only one control point between the two curve points. It is the curve type of Flash. The ming library, what Moho uses to export to SWF, contains a cubic-to-quadratic Bezier conversion algorythm, it adds new points to the curves if neccessary because the cubic Bezier is more flexible than the quadratic type. Moho's curve type seems between the two things, but mathematically it is a kind of cubic Bezier.
- - - Fazek
User avatar
Fazek
Posts: 246
Joined: Thu Apr 13, 2006 1:37 pm
Location: Hungary
Contact:

Post by Fazek »

Now I changed the last version a little bit at the endpoints of open curves. The perpendicular vector is not a good idea for these (and any other) points, so it is the best to find two (usually) linearly independent vectors for each points, from the positions of the neighbouring points. For _P0 (as the first point of an open curve) I used the _P1 - _P0 (this is Moho's original vector here) and _P2 - _P1. This works relatively good, much better than the perpendicular vector of _P1 - _P0.

Download and try:
http://www.firkafilm.com/moho/fa_moho_to_bezier3.lua

I have a new idea now but I must thinking a little bit more. Until now, Moho's original "direction" vector remained -- for a _P1 point, it is (_P2 - _P0) -- because of its deep relation with the Curvature value. But I can define this vector as a combination of _P1 - _P0 and _P2 - _P1, and maybe these are the two vectors I looking for. At the open curve endpoints, where, for example _P0 == _P1, I can use _P2 - _P1 and _P3 - _P2, just like in this actual sample program. But it means the default values of the new parameters will be special for the endpoints of open curves. That's why I don't like the solution and thinking on it further.

ADDED: I found some problems with all of this stuff. The new variables are not modifying the two control points around a point symmetrically. This could cause problems with some "reverse order points" style transformations. Of course it is possible to modify the scripts to handle this problem, but it would be more elegant if the new variables could modify the positions of the two control points with a same, symmetrical way (like the actual Curvature does). I am not quite familiar with the higher mathematics required (like complex numbers, for example) so any ideas are welcomed.
- - - Fazek
Post Reply