Query about Morph program in this site


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Query about Morph program in this site

  1. #1
    Join Date
    Mar 2005
    Posts
    6

    Query about Morph program in this site

    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

  2. #2
    Join Date
    Jan 2005
    Location
    Reisterstowwn, MD
    Posts
    72
    Quote Originally Posted by AK_47
    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.

    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();
    }
    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.

    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.
    Last edited by customwoodtek; 04-04-2005 at 10:16 PM.
    Java has 99 problems but a pointer ain't one

  3. #3
    Join Date
    Mar 2004
    Posts
    635
    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.

  4. #4
    Join Date
    Mar 2005
    Posts
    6
    I need this code for a university project and was told its using the
    cross -dissolve algorithm, but is that definitely not the case?

  5. #5
    Join Date
    Mar 2005
    Posts
    6
    Quote Originally Posted by Phaelax
    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.
    this program also allows more than one image to be morphed.

  6. #6
    Join Date
    Mar 2005
    Posts
    6
    Is tweening another name for mesh warping if not can you tell me what the difference is.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center