|
|
I've added my lightning in but there are empty spaces between the branches.
I'm not quite sure why.
Nekar
#version unofficial MegaPov 0.6;
camera{location <0.0, 0.5, -10.0> look_at <2, 1, 0.0>}
// use any object as your building block (needs to take 2 co-ords)
#macro Cylinder_Object(CStart, CEnd, CWidth)
cylinder{CStart, CEnd, CWidth}
#end
#macro Box_Object(BCorner1, BCorner2)
box{BCorner1, BCorner2}
#end
// plane{y, 0 pigment{checker Gray, Green}}
#macro Bolt (LightnStart, LightnEnd, Scale,Seed)
#ifndef (Seed)
#local Seed=seed(0) ;
#end
#ifndef (LightnStart)
#local LightnStart=<0,0,0> ;
#end
#ifndef (LightnEnd)
#local LightnEnd=<0,0,0> ;
#end
#ifndef (Scale)
#local Scale=0.05 ;
#end
// #ifndef (Color)
// #local Color=<1,1,1> ;
// #end
#local Seed = seed(Seed);
#local BlobPosition = LightnStart ;
blob{
threshold 1 // 0.6
sphere { <0,0,0>, 0.1, 0.1
scale Scale
translate LightnStart
}
///// Add random blob closer to lightnEnd
#while (vlength(BlobPosition - LightnEnd) > 0.1)
#local Rx=rand(Seed); #local Ry=rand(Seed); #local Rz=rand(Seed);
#local BlobPosition = ( BlobPosition + (<0.5-Rx, 0.5-Ry,
0.5-Rz> * 0.04 ) ) ;
#if ( ( vlength(BlobPosition - LightnEnd) > vlength (LightnStart -
LightnEnd) ))
#local BlobPosition = (BlobPosition - ( 2*(BlobPosition -
LightnStart) )) ;
#end
#local LightnStart = BlobPosition ;
sphere { <0,0,0>, 1, 1
scale Scale
translate LightnStart
}
#end
sphere { <0,0,0>, 1, 1
scale Scale
translate LightnEnd }
// pigment{rgbt 1}interior{media{emission Color }}hollow
}
#end
#macro Make_Bolt(LArraySize, LSeed, LWidth, LHeight, LSpread, LBranch,
LCutoff)
#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 segPosB = segPosA;
#declare arrayCount = arrayCount + 1;
#declare xPlus = (rand(myRand)-0.5)*LSpread;
#declare zPlus = (rand(myRand)-0.5)*LSpread;
#declare no_base = true;
#while(segPosB.y < LHeight)
#declare xShift = segPosB.x + xPlus;
#declare yShift = segPosB.y + (rand(myRand)/5);
#declare zShift = segPosB.z + zPlus;
#if (yShift > LHeight)
#declare yShift = LHeight;
#end
#declare segPosB = <xShift, yShift, zShift>;
#declare randNum = rand(myRand);
#if (randNum < LBranch & segPosB.y > LCutoff) // we only need a new
cylinder here
// Bolt (LightnStart, LightnEnd, Scale, Seed)
Bolt (segPosA, segPosB,LWidth,myRand)
// Cylinder_Object(segPosA, segPosB, LWidth*2)
// Box_Object(segPosA, segPosB)
#declare no_base = false;
#declare segPosA = segPosB;
#declare highCount = highCount + 1;
#declare myArray[highCount] = segPosA;
#end
#end
#if(no_base & segPosB.y < LHeight)
Bolt (segPosA, segPosB,LWidth,myRand)
// Cylinder_Object(segPosA, segPosB, LWidth*2)
// Box_Object(segPosA, segPosB)
#end
#declare LWidth = (LWidth*0.95);
#end
}
#end
// #macro Make_Bolt(LArraySize, LSeed, LWidth, LHeight, LSpread, LBranch,
LCutoff)
Make_Bolt(500, 11, 0.05, 6, 0.1, 0.06, 0.5)
object{
Lightning_Bolt
pigment{rgbt 1}
interior{media{emission<3,4,5>}}
hollow
rotate x*180
no_shadow
translate y*5
}
Post a reply to this message
|
|