POV-Ray : Newsgroups : povray.advanced-users : struggle with splines : Re: struggle with splines Server Time
6 Oct 2024 13:05:43 EDT (-0400)
  Re: struggle with splines  
From: Chrisir
Date: 5 Oct 2006 15:30:01
Message: <web.452559f0d128f936800c89c60@news.povray.org>
Well guys,

you definetly made my day.
Thanks so much!

What I did now, was to take the
sophisticated code from Random Pete
(I wrote
pigment { rgb (c1*(1-Value) + c2*(Value)) }
instead of
pigment { rgb c1*(1-ctr) + c2*(2-ctr)
the 2- bit seems to be wrong).

I then used the
Basic programming "trick" from
Warp which boils down to
#declare Index = 0;
#while(Index < 100)
  #declare ctr = Index/99;

For reasons of completeness
here the whole scene. To do
more splines just add more
    // calling of macro
    MyLine1 [.........]
with different values.

Thanks you all so much!!!

Greetings, Chrisir



// Persistence of Vision Ray Tracer Scene Description File
// File Path:
// File Name: temp05_10_2006_20_23_51.pov
// Vers: 3.6
// Desc: Scene
// Date: 05.10.2006

#version 3.6;

#declare Photons=off;
#declare Radiosity=off;

// ==== Standard POV-Ray Includes ====
// #include "colors.inc"      // Standard Color definitions
// #include "textures.inc"    // Standard Texture definitions
// #include "functions.inc"  // internal functions
// #include "glass.inc"      // Glass

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

// Light
light_source {
  <500,500,-500>       // light's position
  color rgb <1, 1, 1>  // light's color
}

light_source {
  <700,700,-500>       // light's position
  color rgb <1, 1, 1>  // light's color
}

light_source {
  <450, 650, 50>       // light's position
  color rgb<1, 1, 1> } // light's color

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

// camera
camera {
    location <0, 0, -144>
    look_at <0, 22, 0>
  }

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

// 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 ObjSpline(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)
                // or you can use: 100/99; clock/99; index/99;
                #declare Value = 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 MSpline1 = MSpline( P1,P2,M1,M2,M3 );
    ObjSpline( sphere{0,1},0.5, rgb c1, rgb c2, MSpline1 )
#end  // end of macro

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

// calling of macro
MyLine1 ( <39,13,1>, <1,0,0>,       // First point and its color red
          <4,96,40>, <0,1,0>,       // Second point and its color green
          <35.18321,24.38798,-15.29158>,     // Modifiers
          <-2.2529,44.63106,36.97918>,
          <16.93481,-3.899466,50.60338>
        )

// ----------------------------------------
// end of scene.
// ----------------------------------------


Post a reply to this message

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