POV-Ray : Newsgroups : povray.binaries.animations : Creating tunnels... (MPGs, 2x126 kb) : Re: Creating tunnels... (MPGs, 2x126 kb) Server Time
19 Jul 2024 00:58:44 EDT (-0400)
  Re: Creating tunnels... (MPGs, 2x126 kb)  
From: Rune
Date: 11 Feb 2004 11:26:37
Message: <402a57bd$1@news.povray.org>
Rune wrote:
> Tim Nikias v2.0 wrote:
>> With the technique you mentioned, and have to do
>> some inbetween calculations to get the desired
>> angles, like projecting the forward vector onto
>> a plane with the sky-vector, thus getting vectors
>> with which I can calculate the "internal" spin to
>> get the up-vectors lined up...
>
> I'm not sure I understand. Why do you need any sky-vector in the first
> place? Why do you need to know anything about the spin of the tunnel?

Here's some crude and simple code to explain the basic idea. The
algorithm is simpler than I remembered. Just use the VPerp_Adjust()
macro to make the last up-vector perpendicular to the current
forward-vector and then use that as the current up-vector... The code
here just aligns boxes and does not create a tunnel out of a mesh, but
the basic idea is the same.

#include "transforms.inc"
#include "math.inc"
camera {location <-2,1,-3> look_at 0}
light_source {<-1,2,-3>*1000, color 1}
background {rgb 1}
#declare Spline = spline {
   cubic_spline
   -2, -x,
   -1, -x,

    0, -y,
    1, -z,
    2, y,
    3, z,
    4, x,
    5, x+y,

    6, y+z,
    7, y+z
}
#declare C = 0;
#declare Samples = 50;
#declare Range = 5;
#declare LastY = y;
#while (C<=Samples)
   #declare Val = C/Samples*Range;
   #declare P = Spline(Val);
   #declare Z = vnormalize(Spline(Val+0.001)-Spline(Val-0.001));
   #declare Y = VPerp_Adjust(LastY,Z);
   #declare X = vcross(Y,Z);
   #declare T = Matrix_Trans(X,Y,Z,P)
   #declare LastY = Y;
   superellipsoid {<0.2,0.2> scale 0.1 transform {T} pigment {rgb 1}}
   #declare C = C+1;
#end


Rune
--
3D images and anims, include files, tutorials and more:
rune|vision:  http://runevision.com **updated Jan 29**
POV-Ray Ring: http://webring.povray.co.uk


Post a reply to this message

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