POV-Ray : Newsgroups : povray.general : Making an Asteroid Belt : Re: Making an Asteroid Belt Server Time
5 Nov 2024 05:24:01 EST (-0500)
  Re: Making an Asteroid Belt  
From:
Date: 30 Jun 2003 23:20:05
Message: <3f00fde5$1@news.povray.org>
// Hi Stephen,
//
// I've just posted "Asteroids and more for Stephen ... [46 KB JPEG]" to
// p.b.i. That image was an easter joke, but the asteroids could be a
// starting point for you. The following code is a fragment from this
// scene (but ready-to-render), containing only a minimal scene with
// asteroids made of spheres. Some comments (in english) are added, I
// hope you can live with the german words.
//
//    Sputnik

// P.S. I assume it's OK to post such a small SDL "inline" snippet as a
//      direct answer in this group, or should I have posted it to p.t.s-f?


// +SP8 +EP8 +W1280 +H1024 +A0.1 +AM2 +R3 +B100 -FN


// Asteroids ----------------------------------------------------------------

#declare Number = 300;
#declare Rand = seed(89797234);

#declare I = 0;
#while (I<Number)

  // choose random orbit (see translate statement below), random brightness
  #declare R = rand(Rand)-0.5;
  #declare Brightness = .8-.3*rand(Rand);

  // create an asteroid in the origin; random size 0.04 ... 0.12
  sphere { 0, 0.04+0.08*rand(Rand)

    // put onto orbit at radius 7+some_variation
    // The function 7+(4*R*R+1)*R maps R from the range [-0.5...0.5] to the
    // range [6...8]. Because this function has a steep/not_so_steep/steep
    // shape, the result is more likely to be 7 than 6 or 8, so the asteroid
    // density at 7 is larger than at 6 or 8.
    translate ( 7 + (4*R*R+1)*R ) * x

    // let asteroid orbit to a random angular position
    rotate 360*rand(Rand)*y

    // apply a simple random texture
    texture {
      pigment { color rgb <1, 1-.2*rand(Rand), 1-.2*rand(Rand)>*Brightness }
      finish { ambient .3 diffuse .7 }
      }

    // a must if sun and all asteroids are in the same plane
    no_shadow
    }

  #declare I = I+1;
  #end


// Kamera und Beleuchtung ---------------------------------------------------

#declare Uhr = 360/12;

#declare Aspekt = image_width/image_height;

#declare Uhr = 360/12;

#declare Aspekt = 1024/768;

#declare Bildhoehe = 8;
#declare Bildbreite = Aspekt*Bildhoehe;
#declare Bildentfernung = 2*Bildhoehe;
#declare Fokus = 0;
#declare Fokusentfernung = 33;
#declare Kamerarichtung = 6*Uhr; // als "Uhrzeit"
#declare Kamerahoehe = 23; // in Grad
#declare Linksneigung = 20;

camera {
  location -Fokusentfernung*z
  right Bildbreite/2*x
  up Bildhoehe/2*y
  sky y
  direction Bildentfernung/2*z
  look_at 0
  rotate Linksneigung*z
  rotate <Kamerahoehe, Kamerarichtung-180, 0>
  translate Fokus
  }


light_source { 0, rgb 1 }


// ENDE =====================================================================


Post a reply to this message

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