|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I'd like to try adding a feature to POV-Ray, to let me use splines to
arbitrarily scale objects in a non-linear fashion. For a very simple
example, I'm thinking of something along the lines of:
#declare Spline1 = control_spline {
cubic_spline 5,
<0,-3>, <1,-2>, <1.5,0>, <1,2>, <0,3>,
}
box { <-2,-0.5,-0.5>, <2,0.5,0.5>
spline_scale y*Spline1
pigment { colour rgb <0,1,1> }
}
...which would produce a box with a top and bottom that curve outwards
in the middle (see http://www.gate.net/~shipbrk/raytrace/wishlist.jpg
for an example of what it would look like).
Unfortunately, I'm very bad at maths, and the POV-Ray source code is a
bit daunting; I don't have the foggiest idea where to begin. Would
anybody be willing to give me some pointers as to how I could accomplish
this (or even if it's possible)?
Many thanks,
--
Jeff Lee shi### [at] gatenet http://www.gate.net/~shipbrk/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Jeff Lee <shi### [at] gatenet> wrote:
Hi Jeff!
> I'd like to try adding a feature to POV-Ray, to let me use splines to
> arbitrarily scale objects in a non-linear fashion.
Actually this is something I tried to implement quite a long time ago,
but failed. I assume now know the basics of how a raytracer works, ie
sending of a "ray" from the cammera throught the viewplane and check
which object it hits (and bouncing,etc...). The difficult part of what
you are suggesting is to determine when such a ray hits the spline
scaled object. For a sphere or another primitive it's is fairly easy
(in advance) write a simple function that determines when and if a ray
hits the object, but with a spline scale the object can be so distorted
so that it's quite difficult to determine the intersection of the ray.
Remeber that not all polynomials of degree 4 or more *can* be solved
analytically. But!
We can probably find the intersection nummerically. The simples way to
do it would be to use the isosurface patch which can draw any shape you
like as long as you can described it as a function.
The following example shows how to distort the object described by F1
(a sphere with radius 1) along a simple spline (with only one segment)
in the xy-plane. Example:
#declare F1 = function { sqr(x)+sqr(y)+sqr(z) - 1 }
#declare SPLINE = function { x*x + x - 1 }
#declare RESULT = function { F1(x,y+SPLINE(x,y,z),z) }
isosurface {
function RESULT
bounded_by { box{ <-2,-2,-2> <2,2,2> } }
max_gradient 10.0
method 2
pigment { color rgb <1,1,0> }
finish {
phong 0.5
}
}
The only problem with this approach is that it's slow, you can't distort
any object you like (you must describe it as a function) and it would be
cumbersome to have intricate spline objects. To simplify things you
probably could make a smart includefile which creates an isosurface
for every segment in the spline etc... or maybe the macro facility in
the isosurface patch could come in handy.
/ Mathias Broxvall
PS. I am not a naitive english speaker, therfore my "mathematical terms"
could be quite wrong... I have just tried to translate them from swedish
.DS
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|