POV-Ray : Newsgroups : povray.animations : Morph an object from one object to another during an animation : Morph an object from one object to another during an animation Server Time
2 Jun 2024 14:46:19 EDT (-0400)
  Morph an object from one object to another during an animation  
From: Chrisir
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

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