POV-Ray : Newsgroups : povray.general : Lightning : Re: Lightning Server Time
19 Nov 2024 13:46:17 EST (-0500)
  Re: Lightning  
From: Tom Melly
Date: 25 Feb 2002 05:17:02
Message: <3c7a0f1e$1@news.povray.org>
"Timothy R. Cook" <tim### [at] scifi-fantasycom> wrote in message
news:3C7709EC.1D49E3CC@scifi-fantasy.com...
> How make?

There was some code for this in images a few months ago (one code example was
mine).

Hang on... (this is for megapov, but I think it will work with 3.5 - also you
could speed it up by changing the merge to a union)

#macro Make_Bolt(LArraySize, LSeed, LWidth, LHeight, LSpread, LBranch,
LCutoff, LSpike)
  #declare myArray = array[LArraySize]
  #declare checkCount = -1;
  #declare highCount = 0;
  #declare arrayCount = 0;
  #declare myArray[arrayCount] = <0,0,0>;
  #declare myRand = seed(LSeed);
  #declare Lightning_Bolt =
    merge{
    #while (checkCount < highCount)
      #declare checkCount = checkCount + 1;
      #declare segPosA = myArray[arrayCount];
      #declare arrayCount = arrayCount + 1;
      #declare xPlus = (rand(myRand)-0.5)*LSpread;
      #declare zPlus = (rand(myRand)-0.5)*LSpread;
      #while(segPosA.y < LHeight)
        #declare xShift = segPosA.x + ((rand(myRand)-0.5)*LSpike) + xPlus;
        #declare yShift = segPosA.y + (rand(myRand)/5);
        #declare zShift = segPosA.z + ((rand(myRand)-0.5)*LSpike) + zPlus;
        #if (yShift > LHeight)
          #declare yShift = LHeight;
        #end
        #declare segPosB = <xShift, yShift, zShift>;
        cylinder{segPosA, segPosB, LWidth}
        #declare segPosA = segPosB;
        #declare randNum = rand(myRand);
        #if (randNum < LBranch & segPosA.y > LCutoff)
          #declare highCount = highCount + 1;
          #declare myArray[highCount] = segPosA;
        #end
        #declare LWidth = (LWidth*0.995)   ;
      #end
      #declare LWidth = (LWidth*0.9)   ;
    #end
  }
#end

Make_Bolt(500, 11211, 0.03, 6, 0.003, 0.05, 0.5, 0.2)
object{
  Lightning_Bolt
  pigment{rgbt 1}
  interior{media{emission<3,3,5>*5}}
  hollow
  rotate x*180
  no_shadow
  translate y*5
}


Post a reply to this message

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