POV-Ray : Newsgroups : povray.binaries.images : Re: spline macro help need. - explain.jpg (1/1) : Re: spline macro help need. - explain.jpg (1/1) Server Time
14 Nov 2024 12:22:14 EST (-0500)
  Re: spline macro help need. - explain.jpg (1/1)  
From: Kurts
Date: 7 Feb 2004 03:19:49
Message: <kurtzlepirate-60B295.09194907022004@news.povray.org>
In article <40248239@news.povray.org>,
 "Mike Williams" <nos### [at] econymdemoncouk> wrote:

> I can't reproduce the problem you're having at the left side of your chain,
> but I can reproduce and fix the weird effect that happens in the middle. I'd
> have to see more of your code before I can address the problem on the left.
> Are you using some extra options in your create_spline call?

here is a code :
//  --------------------------------------------------------------------------
#include "colors.inc"
// #include "personal.inc"
#include "math.inc"
#include "transforms.inc"
#include "spline.inc" // Chris Colefax macros



//  --------------------------------------------------------------------------
#declare displayAxis = false;

#declare displaySpline = false;
#declare displaySplinePoints = true;

#declare displayMaillon = false;



//  --------------------------------------------------------------------------
//  --- SCENE ----------------------------------------------------------------
//  --------------------------------------------------------------------------
camera {
  location <2,12-2,-10+2>
  // location p2r(284.036, 50.490, 12.961,false) polar2rectangular personal macro
  look_at  <0,2,3>
  }

sky_sphere {
  pigment {
    planar
    poly_wave 2
     color_map {
      [0.0, color <0.2,0.5,1.0>]
      [1.0, color <0.8,0.9,1.0>]
      }
    }
  }

light_source {< 1,2,-2>*1000, color 1.0}
light_source {<-1,2, 1>*1000, color 0.7 shadowless}

plane { // checkered plane
  y, -1
  pigment {
    checker White, White*0.90
    scale 5
    }
  }

#if (displayAxis) drawAxis (16, 0.07) #end


//  --------------------------------------------------------------------------
// The spline
//  --------------------------------------------------------------------------
//#declare MySpline = spline {
//   cubic_spline
//   -2, <-5, 3, 0>, // control point
//   -1, <-2, 2, 0>, // control point
//   00, < 0, 2, 0>, // start
//   01, < 0, 2, 0>,
//   02, < 5, 3, 0>, // through yellow ring
//   03, < 5, 4, 4>,
//   04, < 0, 5, 5>, // around
//   05, <-2, 4, 9>, // the
//   06, < 2, 3, 9>, // green
//   07, < 0, 2, 5>, // pole
//   08, <-5, 2, 4>,
//   09, <-5, 3, 0>, // through blue ring
//   10, <-2, 2, 0>,
//   11, < 0, 2, 0>, // stop
//   12, < 2, 2, 0>, // control point
//   13, < 5, 3, 0>, // control point
//  }
#declare MySplinePoints = array [16]
#declare MySplinePoints[0] =<-5, 3, 0>;
#declare MySplinePoints[1] =<-2, 2, 0>;
#declare MySplinePoints[2] =< 0, 2, 0>;
#declare MySplinePoints[3] =< 0, 2, 0>;
#declare MySplinePoints[4] =< 5, 3, 0>;
#declare MySplinePoints[5] =< 5, 4, 4>;
#declare MySplinePoints[6] =< 0, 5, 5>;
#declare MySplinePoints[7] =<-2, 4, 9>;
#declare MySplinePoints[8] =< 2, 3, 9>;
#declare MySplinePoints[9] =< 0, 2, 5>;
#declare MySplinePoints[10] =<-5, 2, 4>;
#declare MySplinePoints[11] =<-5, 3, 0>;
#declare MySplinePoints[12] =<-2, 2, 0>;
#declare MySplinePoints[13] =< 0, 2, 0>;
#declare MySplinePoints[14] =< 2, 2, 0>;
#declare MySplinePoints[15] =< 5, 3, 0>;
#declare MySpline = create_spline (MySplinePoints, create_cubic_spline)




//  --------------------------------------------------------------------------
// show the spline
//  --------------------------------------------------------------------------
#if (displaySpline)
  #declare C = 0;
  #declare Cmax= 50;
  union {
    #while (C<=Cmax)
      #declare Value1 = C/Cmax*11;
      #declare Value2 = (C+1)/Cmax*11;
      #declare Point1 = -0.5*y+MySpline(Value1);
      #declare Point2 = -0.5*y+MySpline(Value2);
      #if (displaySplinePoints)
        sphere {Point1, 0.2 pigment { color Red } }
      #else
        sphere {Point1, 0.1 pigment { color Yellow } }
      #end
      cylinder {Point1, Point2, 0.1 pigment { color Yellow } }
      #declare C = C+1;
    #end
    }
#end




//  --------------------------------------------------------------------------
// anneau
//  --------------------------------------------------------------------------
#declare halfTorus = difference {
  torus { 0.5, 0.2 }
  plane { x, 0}
  }
#declare maillon = union {
  object { halfTorus translate 1.00*x }
  object { halfTorus rotate 180*y }
  cylinder { <0.00, 0.00, +0.50> <1.00, 0.00, +0.50> 0.2 }
  cylinder { <0.00, 0.00, -0.50> <1.00, 0.00, -0.50> 0.2 }
  
  translate -0.50*x
  }

#if (displayMaillon) object { maillon pigment { color White } } #end




//  --------------------------------------------------------------------------
// chaine
//  --------------------------------------------------------------------------
#declare link_object = object {
  maillon
   pigment { color White*0.60 }
   finish { reflection 0.2 specular 0.8 metallic}
   }

link_spline (MySpline, spline_step_size(1)+spline_step_twist(90))
//  --------------------------------------------------------------------------


thanksss


Post a reply to this message

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