POV-Ray : Newsgroups : povray.text.scene-files : Rumor (a pov phone cord) Server Time
28 Jul 2024 16:31:46 EDT (-0400)
  Rumor (a pov phone cord) (Message 1 to 1 of 1)  
From: Jerry Anning
Subject: Rumor (a pov phone cord)
Date: 16 Sep 1999 15:23:16
Message: <37e14263.8310976@news.povray.org>
Here is the phone cord code I mentioned on povray.binaries.images.

// Begin POV code

/* This code is my mutation of a file by Jamis Buck that creates the
image using arrays and tmpov.  This version uses the Colefax
spline.inc and standard pov.  The vector stuff in both versions was
heavily modified by me from a sample matrix transform on the Matrix
Page of John vanSickle */

#version 3.1;

#include "colors.inc"
#include "textures.inc"
#include "skies.inc"

#declare wierdy     = on;
#declare water      = off;
#declare inner_cord = off;
#declare outer_cord = on;
#declare backdrop = off;

camera
{
  location <0,6,-12>
  look_at  <0.5,2,0>
}

light_source
{
  <0,20,-40>
  color rgb 1
}

#if ( backdrop )

  sky_sphere { S_Cloud5 }
  
#end

#if ( wierdy )

  #declare wierdy_size = 5000; // bigger number = smoother spiral

  #declare saccuracy = 1/wierdy_size;

  #declare spline_clock  = 0;
  #declare SplineDoNorm = yes;
  #declare SplineNormAc = saccuracy;

  #declare SpiralFreq   = 60;
  #declare SpiralRadius = 0.2;

  #declare V1=<0,1,0>;
  #declare VX1=vnormalize(V1);

 blob { threshold .6
  #while ( spline_clock < 1 )

    #include "Cord.spl"
    
    #if (spline_clock = 0)
      #declare SplineNorm = <0, 0, 0>;
    #else
      #declare SplineNorm = vnormalize(OldPos - spline_pos);
    #end
    #declare OldPos = spline_pos;
    
    #declare scp = spline_clock*pi;

    #declare _r = sin(scp); // this is to set up a texture
    #declare _g = abs(cos(scp));
    #declare _b = abs(sin(2*scp));

    #declare SplineColor = color rgb <_r,_g,_b>;

    #if ( ( inner_cord ) & ( mod( int( wierdy_size*spline_clock ), 2 )
= 0 ) )

      sphere
      {
        0, 0.05, 1
        texture { pigment { color SplineColor } finish { phong 0.8 } }
        translate spline_pos
      }

    #end

    #if ( ( spline_clock >= SplineNormAc ) & ( outer_cord ) )

      #declare BallPos = vrotate( <0,0,SpiralRadius>,
y*spline_clock*(360*SpiralFreq) );

      #declare VX2=vnormalize(SplineNorm); // this stuff basically
gets a normal
      #declare VY=vnormalize(vcross(VX2,VX1)); // to the spline and
calculates
      #declare VZ1=vnormalize(vcross(VY,VX1)); // the location of the
proper
      #declare VZ2=vnormalize(vcross(VY,VX2)); // piece of the spiral
and
      
      #declare A1 = vdot(BallPos, VX1); // these things hand calculate
a couple of
      #declare A2 = vdot(BallPos, VY); // transform matrices in order
to get explicit
      #declare A3 = vdot(BallPos, VZ1); // coordinates to place the
desired
      
      #declare A = <A1, A2, A3>; // piece of the blob-spiral
      
      #declare B1 = <VX2.x, VY.x, VZ2.x>;
      #declare B2 = <VX2.y, VY.y, VZ2.y>;
      #declare B3 = <VX2.z, VY.z, VZ2.z>;
      
      #declare C1 = vdot(A, B1);
      #declare C2 = vdot(A, B2);
      #declare C3 = vdot(A, B3);
      
      #declare C = <C1, C2, C3>;
      
      #declare P = C + spline_pos;

      #if ( spline_clock = SplineNormAc )

        #declare OldP = P - .00001; // initializer

      #end
      
      cylinder { OldP, P, 0.05, 1
        texture { pigment { color SplineColor } finish { phong 0.8 } }
}
      #declare OldP = P;

    #end

    #declare spline_clock = spline_clock + saccuracy;

  #end
  scale 2
}
#end // wierdy

#if ( water )

  #declare WaterTexture =
    texture
    {
      pigment { color rgbf <0.9,0.9,1.0,0.95> }
      normal
      {
        average
        normal_map        {
          [ 0.5 crackle 1.0 turbulence 0.3 ]
          [ 1.0 onion   0.4 turbulence 0.5 scale 2 sine_wave ]
        }
      }
      finish
      {
        ambient    0.1
        diffuse    0.8
        reflection 0.5
        specular   1.0
        roughness  0.001
        refraction on
        ior        1.5
      }
    }

  plane
  {
    y, 0
    texture { WaterTexture scale 0.5 }
  }

  plane
  {
    y, -5
    texture { pigment { color Blue } }
  }

#end // water

// end POV code

// begin spline point file

#declare spline_segments = 3;
#declare spline_loop = true;

#declare point0 = <0,1,0>;
#declare point1 = <1.5,2,1>;
#declare point2 = <3,1,1>;
#declare point3 = <0,0,2>;
#include "Spline.inc"

#declare point2 = <-3,1,0>;
#declare point3 = <-3,0,-2>;
#include "Spline.inc"

#declare point2 = <0,1,0>;
#declare point3 = <1.5,2,1>;
#include "Spline.inc"

// end  spline point file

Jerry Anning
clem "at" dhol "dot" com


Post a reply to this message

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