|
|
> Can I have an .inc file? ;)
Sure, why not? =)
Just use this code. Sorry if it wraps. Use it like
createexplosion(explosionsize, explosionpos, explosionid)
explosionpos is the place where the explosion is. explosionsize should be a
number from 0 to explosionlength which determines the amount of time that
has passed. explosionid should be a number that stays constant for each call
of the function for the same explosion but is different for different
explosions. (so that they look diffferent). it's really just a random seed
that changes the orientation of the explosion.
Also change numexplosionpartst (defined in the macro itself) to put more
mini-spheres inside the explosion, and change the numbers after the 'scale'
keyword to change the size (you should probably also change the fire and
smoke colors when changing the size).
there may be an error here or there. for instance, you'll have to define
"shiprad" (ship radius) or change the light_source declaration at the end.
And feel free to manipulate it or improve upon it, just give credit where
due, ok? =)
#declare explosionlength = 2;
#declare firecolor = <1,.7,.3>*1.2;
#declare smokecolor = 1.8;
#macro createexplosion(explosionsize, explosionpos, explosionid)
#declare explosionrnd = seed(explosionid);
#if (explosionsize < explosionlength)
#declare overallintensity = 1-pow(explosionsize/explosionlength,7);
#declare overallsmokeamnt = pow(explosionsize/explosionlength,2);
#declare explosionsize = pow(explosionsize/explosionlength,.3)*shiprad*6;
sphere {
0,1
pigment {rgbt 1}
interior {
#declare animbaseamnt = explosionsize*.1;
#declare thisanimbase = 0;
#declare numexplosionpartst = 5;
#declare explosionpartnumt = 0;
#while (explosionpartnumt < numexplosionpartst)
#declare theta = (explosionpartnumt/(numexplosionpartst-1))*pi-pi/2;
#declare explosionpartnumr = 0;
#while (explosionpartnumr <= numexplosionpartst*cos(theta))
#if (floor(numexplosionpartst*cos(theta)) > 0)
#declare phi = explosionpartnumr/floor(numexplosionpartst*cos(theta))
*2*pi + theta;
#else
#declare phi = theta;
#end
#declare thisanimbase = thisanimbase + pi/10; // pi is arbitrary
#declare thisanimbase = thisanimbase-floor(thisanimbase);
#declare animamnt = thisanimbase + animbaseamnt*3;
#declare animamnt = animamnt-floor(animamnt);
#declare smokeamnt = pow(animamnt,3);
#declare smokeamnt = smokeamnt + (1-smokeamnt)*overallsmokeamnt;
#declare thisintensity = overallintensity*(1-pow(animamnt,5));
media {
emission firecolor*(1-smokeamnt) *thisintensity
absorption smokecolor*(smokeamnt) *thisintensity
#declare translatedir =
<cos(phi)*cos(theta),sin(theta),sin(phi)*cos(theta)>;
density {
spherical
color_map {
[0 rgb <1,0,0>*0]
[.1 rgb <1,.8,.8>*.3]
[.25 rgb .7]
[.5 rgb 1]
}
translate -translatedir*animamnt*2
warp {
turbulence .3
octaves 3
omega .8
lambda 5
}
translate translatedir*animamnt*2
scale .4 + .2*pow(animamnt,6)
translate translatedir*(1-pow(1-animamnt,3)) *.5 //
(1-pow(1-animamnt,2))
}
}
#declare explosionpartnumr = explosionpartnumr + 1;
#end
#declare explosionpartnumt = explosionpartnumt + 1;
#end
}
hollow
rotate <rand(explosionrnd),rand(explosionrnd),rand(explosionrnd)>*360 //
orient randomly
scale explosionsize
translate explosionpos
no_shadow
}
light_source {
explosionpos
rgb firecolor*overallintensity
fade_power 2
fade_distance shiprad*20
}
#end
#end
- Slime
[ http://www.slimeland.com/ ]
Post a reply to this message
|
|