POV-Ray : Newsgroups : povray.advanced-users : Following an isosurface (sphere) Server Time
24 Nov 2024 17:28:57 EST (-0500)
  Following an isosurface (sphere) (Message 1 to 3 of 3)  
From: Jonathan
Subject: Following an isosurface (sphere)
Date: 24 Jan 2006 10:40:13
Message: <43d64a5d@news.povray.org>
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 }}
        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 }


Post a reply to this message

From: Alain
Subject: Re: Following an isosurface (sphere)
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

From: Skip Talbot
Subject: Re: Following an isosurface (sphere)
Date: 4 Feb 2006 18:47:52
Message: <43e53d28$1@news.povray.org>
How about using the trace function to build a natural spline.  Define 
your path spline, and then run trace every few units (the more units the 
smoother the spline) to determine the height of the spline points.  You 
should get a nice smooth, flowing path.  You'll probably want to test 
for height maxes in the terrain to prevent from hitting sharp peaks.

Skip


Post a reply to this message

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