|
![](/i/fill.gif) |
Thanks for your help and patience Bart and again for your excellent macros. I
love the increased readability of spline definitions they bring - I know
probably not for everyone, but for me as a novice thinking about splines as a
series of trace actions is easier to understand and manage then a large pile of
points, for me it gives more focus on shape and dimensions. Your macros
provide elegant simplicity - I think your suggestions should be an example in
the help file to help novices get started or even a standard include file
"SplinesForDummies.inc" could be put together by someone way above my pay grade.
In case anyone is interested, I've copied my current feeble efforts to
illustrate a) that I know next to nothing about Pov or Beziers! and b) to show
the kind of mechanisms of how I would like to be able to setup splines. Clearly
I have a long way to go... but having fun ... many thanks again.
Alan
//======================8<======================
// Persistence of Vision Ray Tracer Scene Description File
// File: ?.pov
// Vers: 3.6
// Desc: Basic Scene Example
// Date: mm/dd/yy
// Auth: ?
//
#version 3.6;
#include "colors.inc"
global_settings {
assumed_gamma 1.0
}
// ----------------------------------------
camera {
location <0.0, 18, -4>
direction 1.5*z
right x*image_width/image_height
look_at <0.0, 0.0, 2.0>
}
background { color rgb <0.1, 0.3, 0.8> }
light_source {
<0, 0, 0> // light's position (translated below)
color rgb <1, 1, 1> // light's color
translate <-30, 30, -30>
}
// ----------------------------------------
plane {
y, -0.5-1e-6
pigment { color rgb <0.7,0.5,0.3> }
}
#declare Texture=texture {
pigment {color rgb <0.2,0.5,0.2> }
finish {
ambient 0.1 // ambient surface reflection color [0.1]
diffuse 0.6 // amount [0.6]
brilliance 1.0 // tightness of diffuse illumination [1.0]
phong 0.5 // amount [0.0]
phong_size 40 // (1.0..250+) (dull->highly polished) [40]
metallic 0.8 //[Amount] // give highlight color of surface
reflection {1.0 metallic 1.0}
}
};
#macro BezierLine(A,D)
#local LineVec = D-A;
#local B= A + LineVec * 1/3;
#local C= A + LineVec * 2/3;
A,B,C,D
#declare CurrentPoint = D;
#declare CurrentDirection = vnormalize (LineVec);
#declare CurrentDirection = <CurrentDirection.x, CurrentDirection.y>;
#declare LastControl = C;
#end
//Draw a curve to a delta point with a specified exit direction
#macro CurveBy(dx,dy, ExitVec)
#declare Sharpness =3;
#local Ev = vnormalize(ExitVec);
#local Ev = <Ev.x, Ev.y>;
#local EndPoint = CurrentPoint + <dx,dy>;
#local VecLen = vlength(EndPoint-CurrentPoint);
#local Cp1 = CurrentPoint + CurrentDirection*VecLen/Sharpness;
#local Cp2 = EndPoint - Ev*VecLen/Sharpness;
CurrentPoint, Cp1, Cp2, EndPoint
#declare CurrentPoint = EndPoint;
#declare CurrentDirection = Ev;
#declare CurrentDirection = <CurrentDirection.x, CurrentDirection.y>;
#end
//Record the start point to allow use of closure statements
#macro SplineStart(Pos)
#declare StartingPoint = Pos;
#declare CurrentPoint = Pos;
#declare CurrentDirection = <1,0>;
#end
//Draw a horizontal line
#macro HLine(dx)
BezierLine(CurrentPoint, CurrentPoint + <dx,0>)
#end
//Draw a vertical line
#macro VLine(dy)
BezierLine(CurrentPoint, CurrentPoint + <0,dy>)
#end
//Draw by a delta amount
#macro LineBy(dx,dy)
BezierLine(CurrentPoint, CurrentPoint + <dx,dy>)
#end
#macro SplineCloseWithLine()
BezierLine(CurrentPoint,StartingPoint)
#end
prism {
linear_sweep // or conic_sweep for tapering to a point
bezier_spline // linear_spline | quadratic_spline |
cubic_spline |
-0.5, // height 1
0.1, // height 2
10*4, // number of points
SplineStart(<0,0>)
LineBy(4,4),
VLine(2),
CurveBy(-1.5, 2, < -1, 0>),
CurveBy(-1.5, -3, < -1,-1>),
CurveBy(-1, -0.5, < -1, 0>),
CurveBy(-1, 0.5, < -1, 1> ),
CurveBy(-1.5, 3, < -1, 0> ),
CurveBy(-1.5, -2 < 0,-1> ),
VLine(-2),
SplineCloseWithLine()
//open
texture{Texture}
}
union
{
#declare dx = -5; #while (dx < 5) cylinder{ <dx,-0.5,0> <dx,-0.5,10>
0.01 pigment{Red} } #declare dx = dx + 0.5; #end
#declare dz = 0; #while (dz < 10) cylinder{ <-5,-0.5,dz> <5,-0.5,dz >
0.01 pigment{Blue} } #declare dz = dz + 0.5; #end
translate .1*y
no_shadow
}
Post a reply to this message
|
![](/i/fill.gif) |