POV-Ray : Newsgroups : povray.advanced-users : Following an isosurface (sphere) : Re: Following an isosurface (sphere) Server Time
28 Jul 2024 10:15:40 EDT (-0400)
  Re: Following an isosurface (sphere)  
From: Alain
Date: 24 Jan 2006 17:13:45
Message: <43d6a699$1@news.povray.org>
Jonathan nous apporta ses lumieres en ce 24/01/2006 10:38:
> Hope this is the right group... Ok, trying to simulate a small planetoid and
> follow the terrian in an animation. I manage to figure out how to follow the
> surface using the trace function, but I would like for my camera angle to
> "more smoothly" follow the surface. I'm thinking I might could use a search
> macro that traces a few points ahead to find the terrian slope, tests for
> the edge of the slope within a range of angles and point the camera there.
> Ideas, comments, code and constructive critism are welcome.
> 
> Thanks in advance
> Jonathan
> red### [at] redmasqcom
> 
> Current code (minus textures, lighting, and other irrelivant stuff):
> 
> #macro MyVec(MaxRad, MyObject, Long, Lat)
>         // I know, I never bothered to look up the actual formula to
> calculate Long and Lat
>         // But it behaves close enough for tests.
>          #local Start=vrotate(vrotate(<0,0,-MaxRad>,<Lat,0,0>), <0,Long,0>);
>          trace(MyObject, Start, <0,0,0>-Start)
> #end
> 
> #declare PlanetSize = 50000;
> #declare ThePlanet = isosurface {
>         // Borrowed from the help files
>         function { f_sphere(x, y, z, 20)-fn_Pigm(x/2, y/2, z/2).gray*0.5 }
>                 contained_by { sphere{ <0,0,0>,PlanetSize/100 }}
Here, it's probably faster to use .red, .green, .blue, .x, .y or .z
This work whenever your pigment goes from black to white, or from 0 to 1.
.gray calculate the average of red, green and blue whitch is useless as they are all
the same.
>         max_gradient 4.5
>         pigment { color <.7,.6,0,0,0> }
> 
>         scale 2230
>         finish { ambient 1 }
>         }
> #declare MyLong = clock*45;
> #declare MyLat = 0;
> #declare CameraVec=MyVec(PlanetSize*10/10, ThePlanet, MyLong, MyLat);
> #declare LookAtVec=MyVec(PlanetSize*10/10, ThePlanet, mod(MyLong+10,360),
> MyLat);
> 
> camera { location 0
>         look_at CameraVec*2
>         translate y*vlength(CameraVec)
>         look_at VPerp_To_Vector(LookAtVec)
>         }
>         object { ThePlanet }
> 
> 
> 
> 
If the surface is relatively smooth, no sharp angles for example, just taking a single
point some 
distance in front of the current location should be OK.
If the profile is rather harsh, you may need to take 2 or 3, maybe 4, samples and
average them with 
some ponderation. The closest point been more importent than the second, whitch is
more importent 
than the third.
Another way may be to use the normal at the camera position and orient the camera
acording to it. 
The camera will remain parallel to the ground exactly under it.
You can combine the two to have the camera respond to both the difference in elevation
and the 
inclination of the ground.


-- 
Alain
-------------------------------------------------
Fine day to work off excess energy.  Steal something heavy.


Post a reply to this message

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