POV-Ray : Newsgroups : povray.animations : Morph an object from one object to another during an animation Server Time
23 Nov 2024 17:27:20 EST (-0500)
  Morph an object from one object to another during an animation (Message 1 to 4 of 4)  
From: Chrisir
Subject: Morph an object from one object to another during an animation
Date: 29 Oct 2006 07:05:00
Message: <web.454498597874ed745445f790@news.povray.org>
Hello!

How can I morph an object from one object to another during an animation?

I use the clock-value and would like a sphere changing during its flight
from a sphere to a cube.

I use the following code from this forum which
changes the color of Obj during the flight from color c1 to c2.



#macro ObjSpline1(Obj,Size,c1,c2,Spline)

        // Leads an Object Obj of a Size over a Spline
        // and changes its color from c1 to c2.

        #declare index = 0;

        //#while (index < 100)
                #declare Value = clock / 99; // or you can use: 100/99;
clock/99; index/99;
                object {
                        Obj
                        scale Size
                        translate Spline(Value)
                        pigment { rgb (c1*(1-Value) + c2*(Value)) }
                }
                // #declare index = index + 1;
        //#end   // end of while
#end  // end of macro


How can I add the feature to have Obj1 and Obj2 and change from the first to
the second?

Thanks!

Greetings,

Chrisir


Context:


// ----------------------------------------

// macros
#macro MSpline(P1,P2,M1,M2,M3)
  spline {
    cubic_spline
    -1,M1
     0,P1
     0.5,M2
     1,P2
     2,M3
  }
#end  // end of macro

#macro ObjSpline1_Test(Obj,Size,c1,c2,Spline)

        // TESTING

        // Leads an Object Obj of a Size over a Spline
        // and changes its color from c1 to c2.

        #declare index = 0;

        #while (index < 100)
                #declare Value = index / 99; // or you can use: 100/99;
clock/99; index/99;
                object {
                        Obj
                        scale Size
                        translate Spline(Value)
                        pigment { rgb (c1*(1-Value) + c2*(Value)) }
                }
                #declare index = index + 1;
        #end   // end of while
#end  // end of macro


#macro ObjSpline1(Obj,Size,c1,c2,Spline)

        // Leads an Object Obj of a Size over a Spline
        // and changes its color from c1 to c2.

        #declare index = 0;

        //#while (index < 100)
                #declare Value = clock / 99; // or you can use: 100/99;
clock/99; index/99;
                object {
                        Obj
                        scale Size
                        translate Spline(Value)
                        pigment { rgb (c1*(1-Value) + c2*(Value)) }
                }
                // #declare index = index + 1;
        //#end   // end of while
#end  // end of macro

#macro MyLine1(P1,c1,P2,c2,M1,M2,M3)

    // Connects two points P1 and P2 with a spline
    // which is modified ("M") by the points M1, M2
    // and M3.
    // Point P1 has the color c1, Point P2 has the color c2.

    #local MSplineMy = MSpline( P1,P2,M1,M2,M3 );

    ObjSpline1( sphere{0,1}, 0.5, (c1*(1/255)), (c2*(1/255)), MSpline(
P1,P2,M1,M2,M3 ) )

     // sphere { P2, .5 pigment { rgb (c2*(1/255)) } }
    // sphere { P1, .5 pigment { rgb c1 } }

#end  // end of macro

// ----------------------------------------

// calling of macro


MyLine1 ( <4,96,90>,<255,0,0>,<0,100,90>,<52,38,35>,
<72.5793946507462,57.3587176873891,45.6400501916966>,<7.48227266731511,71.6078999202244,47.1569606753151>,<42.926831759
8488,57.2162114660836,52.5076042410804>)
// 4


Post a reply to this message

From: Warp
Subject: Re: Morph an object from one object to another during an animation
Date: 29 Oct 2006 07:20:21
Message: <45449c85@news.povray.org>
Chrisir <nomail@nomail> wrote:
> How can I morph an object from one object to another during an animation?

  You can't.

  If you model both objects as an isosurface each, it can easily be done,
but otherwise it's not possible.

-- 
                                                          - Warp


Post a reply to this message

From: Roman Reiner
Subject: Re: Morph an object from one object to another during an animation
Date: 29 Oct 2006 08:00:00
Message: <web.4544a4a96917fbbd393f72490@news.povray.org>
If it's just about transforming a sphere into a box you might want to use
the superellipsoid object. otherwise use isosurfaces as warp suggested.

Hope this helps
Regards Roman


Post a reply to this message

From: MichaelC
Subject: Re: Morph an object from one object to another during an animation
Date: 21 Dec 2006 09:40:00
Message: <web.458a9c506917fbbd4599c17c0@news.povray.org>
"Chrisir" <nomail@nomail> wrote:
> Hello!
>
> How can I morph an object from one object to another during an animation?
>
> I use the clock-value and would like a sphere changing during its flight
> from a sphere to a cube.
>
> I use the following code from this forum which
> changes the color of Obj during the flight from color c1 to c2.
>
>

Depending on how precise you want your morph to look, you can try something
like this.  Draw both the sphere and cube at the same point, but scale them
inversely.  Square starts at scale .01 and sphere starts at scale 10.  As
each clock cycle goes by and you move them, increase the cube and decrease
the sphere.  Adjust the scaling to get the desired look.  It's not really a
morph, but it may get you by for a square and a cube.  It might not work so
well for more complex objects though.

Michael


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.