|
|
Here is an example on how to make a "preview" of an isosurface shape.
(Also see my post "Fast preview for complex isosurfaces" to
povray.binaries.images some minues ago.)
The sampled torus function in this example will actually render
slower than the same function in its original form. But I used it
here just to make the example simpler. (There will be speed
increases when using more complex functions.)
To use this code you'll need the "Density_File Extension Patch".
This patch (and an executable for Windows) can be found here:
http://staff.aist.go.jp/r-suzuki/e/povray/iso/df_body.htm
The macro below can be used to "sample" any isosurface function.
One just has to specify the coordinates for the 2 corners of the
"contained by" box and the sample resolutions in the x, y and z
directions (as a 3D vector).
Tor Olav
// ===== 1 ======= 3 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Copyright 2003 by Tor Olav Kristensen
// Email: t o r _ o l a v _ k [ a t ] h o t m a i l . c o m
// http://home.no/t-o-k
// ===== 1 ======= 3 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
#include "functions.inc" // For f_torus()
#version unofficial dfe 3.5; // POV-Ray patch by Ryoichi Suzuki
// ===== 1 ======= 3 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
#macro SampleFunction(Fn, pMin, pMax, vSample)
#local vD = (pMax - pMin)/(vSample - <1, 1, 1>);
#local pA = pMin - vD;
#local pB = pMax + vD;
#local Trans = transform { translate -pA scale <1, 1, 1>/(pB - pA) }
#local TransFn = function { transform { Trans } }
#local InvTransFn = function { transform { Trans inverse } }
#local NewFn =
function {
pattern {
density_file
function vSample.x, vSample.y, vSample.z {
Fn(
InvTransFn(x, y, z).x,
InvTransFn(x, y, z).y,
InvTransFn(x, y, z).z
)
}
interpolate 2
frequency 0
}
}
function {
NewFn(
TransFn(x, y, z).x,
TransFn(x, y, z).y,
TransFn(x, y, z).z
)
}
#end // macro SampleFunction
// ===== 1 ======= 3 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
#declare Rmaj = 10;
#declare Rmin = 3;
#declare TorusFn = function { f_torus(x, y, z, Rmaj, Rmin) }
#declare pMin = -<Rmaj + Rmin, Rmin, Rmaj + Rmin>;
#declare pMax = <Rmaj + Rmin, Rmin, Rmaj + Rmin>;
#declare vSample = <1, 1, 1>*20; // Experiment with this number
isosurface {
// function { TorusFn(x, y, z) }
SampleFunction(TorusFn, pMin, pMax, vSample)
// max_gradient 2
contained_by { box { pMin, pMax } }
pigment { color rgb <1, 1, 1> }
}
// ===== 1 ======= 3 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
background { color blue 0.5 }
light_source { <3, 2, -2>*100 color rgb <1, 1, 1> }
camera {
location < 0, 1, -2>*15
look_at <0, -1, 0>
}
// ===== 1 ======= 3 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
Post a reply to this message
|
|