i was wondering if anybody knows any of the details regarding the morph program available at
http://javaboutique.internet.com/Morph/
i would like to know which algorithm is being used and possibly some other details.
Thank you
in advance
Printable View
i was wondering if anybody knows any of the details regarding the morph program available at
http://javaboutique.internet.com/Morph/
i would like to know which algorithm is being used and possibly some other details.
Thank you
in advance
Looks like tweening to me. Bascially you have two shapes (start and end) and the tweening algorithm slowly (or fast if you want but it won't look as nice) converts each point in the start shape to the end shape. Here is a basic tween i made in openGL over a year ago.Quote:
Originally Posted by AK_47
Basically my drawTween function takes 2 array of points (A represents the start figure, B the end figure). Int n determines how many frames between the start and end, and float t is how much each frame differs from the last. There may be more complex Tweening/Morph methods but i'm not really sure. Anyways, do a google search and i'm sure you'll find some stuff.Code:Point2 Canvas::Tween(Point2 A, Point2 B, float t)
{
float difX = B.getX() - A.getX();
float difY = B.getY() - A.getY();
float tX = A.getX() + (difX*t);
float tY = A.getY() + (difY*t);
Point2 tween(tX,tY);
return(tween);
}
void Canvas::drawTween(Point2 A[], Point2 B[], int n, float t)
{
glBegin(GL_LINE_LOOP);
for(int i=0; i<n; i++)
{
Point2 P;
P= Tween(A[i], B[i], t);
cout << P.getX() << "," << P.getY() << endl;
glVertex2f(P.getX(), P.getY());
}
cout << "----------------" << endl;
glEnd();
glFlush();
}
EDIT: Also note this is a 2 dimensional tween, although it wouldn' be hard to convert to 3D. Also if your confused why the code looks weird thats because it's C++, not Java. As far as i know openGL is not supported in Java? However, you can still do it in Java (obviously, the applet did it) with their native 2D and 3D graphics.
Though the applet flickered a lot, and I barely saw any image, I can tell you the algorithm used. It's simple linear interpolation.
Result = A + (B-A)*k
Where 'A' is picture 1 and 'B' is picture 2, and 'K' is the set[0,1] (between 0 and 1)
A value of 0 would give the full picture of 'A', and 1 would give the full picture of 'B'.
Would you would actually do is get the color of each pixel in the two images for 'A' and 'B' and create a new image.
I need this code for a university project and was told its using the
cross -dissolve algorithm, but is that definitely not the case?
this program also allows more than one image to be morphed.Quote:
Originally Posted by Phaelax
Is tweening another name for mesh warping if not can you tell me what the difference is.