|
|
Ok
min_sides: the minimum number of sides your cristal will have
max_sides: the maximum;
diam: the edges are on a circle of diameter diam
height: the heigth of the crown
var: the variance of the points
top: the absolute topmost points
rand_seed... welll
ex:
mesh_cristal(4,7, 1, 3, 0.1, 4, s)
produces a cristal of 4 to 7 faces, contained in a cylinder of diameter 1,
that have its pointy end starting at 3 +- 0.1, and culminates at 4.
Same with the two-ended version
best,
S.
#macro mesh_cristal(min_sides,max_sides,diam, height,var,top,rand_seed)
#local nb_sides = min_sides+floor (0.5 +
(max_sides-min_sides)*rand(rand_seed) );
#declare angles = array [ nb_sides ]; // angles
#declare bases = array [ nb_sides ];
#declare mi_hauteurs = array [ nb_sides ];
#declare sommets = array [ nb_sides] ;
// some random values
#local i=0;
#while (i<nb_sides)
#declare angles[i]=rand(rand_seed) * 360;
#declare i=i+1;
#end
// sort them
#local i=0;
#while (i < nb_sides - 1 )
#local j=i+1;
#while (j < nb_sides )
#if (angles[i]>angles[j])
#local temp = angles[i];
#declare angles[i]=angles[j];
#declare angles[j]=temp;
#end //if
#declare j=j+1;
#end // while (j
#declare i=i+1;
#end // while (i
#local i=0;
#while (i<nb_sides)
#declare bases[i] = vrotate( < 0,0,diam>, <0,angles[i],0 >);
#declare mi_hauteurs[i]=bases[i]+<0,height+rand(rand_seed)*var,0>;
#declare i=i+1;
#end
mesh
{
#local i=0;
#while (i<nb_sides)
triangle { bases[i],mi_hauteurs[i],mi_hauteurs[mod(i+1,nb_sides)] }
triangle { bases[i],bases[mod(i+1,nb_sides)],
mi_hauteurs[mod(i+1,nb_sides)] }
#declare i=i+1;
#end
#declare sommets = bases ;
#local random_vect = vrotate(<0,0,10>,rand(rand_seed)*360); // some
vector in the x-z plane
#local random_angle = rand(rand_seed)*15;
#local i=0;
#while (i<nb_sides)
#declare sommets[i]=vaxis_rotate(sommets[i]/2,random_vect,random_angle)
+ <0,top,0>;
#declare i=i+1;
#end
#local i=0;
#while (i<nb_sides)
triangle { sommets[i],mi_hauteurs[i],mi_hauteurs[mod(i+1,nb_sides)] }
triangle { sommets[i],sommets[mod(i+1,nb_sides)],
mi_hauteurs[mod(i+1,nb_sides)] }
#declare i=i+1;
#end
#local i=0;
#while (i<nb_sides)
triangle { bases[0],bases[i],bases[mod(i+1,nb_sides)] }
triangle { sommets[0],sommets[i],sommets[mod(i+1,nb_sides)] }
#declare i=i+1;
#end
} // mesh
#end // macro
//////////////////////////////////////////////////////////////
#macro two_ended_mesh_cristal(min_sides,max_sides,diam,
height,var,top,rand_seed)
#local nb_sides = min_sides+floor (0.5 +
(max_sides-min_sides)*rand(rand_seed) );
#declare angles = array [ nb_sides ]; // angles
#declare bases = array [ nb_sides ];
#declare mi_hauteurs = array [ nb_sides ];
#declare mi_profondeurs = array[ nb_sides ];
#declare sommets = array [ nb_sides ] ;
#declare fonds = array [ nb_sides ];
// some random values
#local i=0;
#while (i<nb_sides)
#declare angles[i]=rand(rand_seed) * 360;
#declare i=i+1;
#end
// sort them
#local i=0;
#while (i < nb_sides - 1 )
#local j=i+1;
#while (j < nb_sides )
#if (angles[i]>angles[j])
#local temp = angles[i];
#declare angles[i]=angles[j];
#declare angles[j]=temp;
#end //if
#declare j=j+1;
#end // while (j
#declare i=i+1;
#end // while (i
#local i=0;
#while (i<nb_sides)
#declare bases[i] = vrotate( < 0,0,diam>, <0,angles[i],0 >);
#declare mi_hauteurs[i]=bases[i]+<0,height+rand(rand_seed)*var,0>;
#declare mi_profondeurs[i]=bases[i]-<0,height+rand(rand_seed)*var,0>;
#declare i=i+1;
#end
mesh
{
#local i=0;
#while (i<nb_sides)
triangle {
mi_profondeurs[i],mi_hauteurs[i],mi_hauteurs[mod(i+1,nb_sides)] }
triangle { mi_profondeurs[i],mi_profondeurs[mod(i+1,nb_sides)],
mi_hauteurs[mod(i+1,nb_sides)] }
#declare i=i+1;
#end
// sommets
#declare sommets = bases ;
#local random_vect = vrotate(<0,0,10>,rand(rand_seed)*360); // some
vector in the x-z plane
#local random_angle = rand(rand_seed)*15;
#local i=0;
#while (i<nb_sides)
#declare sommets[i]=vaxis_rotate(sommets[i]/2,random_vect,random_angle)
+ <0,top,0>;
#declare i=i+1;
#end
#local i=0;
#while (i<nb_sides)
triangle { sommets[i],mi_hauteurs[i],mi_hauteurs[mod(i+1,nb_sides)] }
triangle { sommets[i],sommets[mod(i+1,nb_sides)],
mi_hauteurs[mod(i+1,nb_sides)] }
#local i=i+1;
#end
#local i=0;
#while (i<nb_sides)
triangle { sommets[0],sommets[i],sommets[mod(i+1,nb_sides)] }
#local i=i+1;
#end
// fonds
#declare fonds = bases ;
#local random_vect = vrotate(<0,0,10>,rand(rand_seed)*360); // some
vector in the x-z plane
#local random_angle = rand(rand_seed)*15;
#local i=0;
#while (i<nb_sides)
#declare fonds[i]=vaxis_rotate(fonds[i]/2,random_vect,random_angle) -
<0,top,0>;
#local i=i+1;
#end
#local i=0;
#while (i<nb_sides)
triangle {
fonds[i],mi_profondeurs[i],mi_profondeurs[mod(i+1,nb_sides)] }
triangle { fonds[i],mi_profondeurs[mod(i+1,nb_sides)],
fonds[mod(i+1,nb_sides)] }
#local i=i+1;
#end
#local i=0;
#while (i<nb_sides)
triangle { fonds[0],fonds[i],fonds[mod(i+1,nb_sides)] }
#local i=i+1;
#end
} // mesh
#end // macro
Post a reply to this message
|
|
|
|
"Dennis Miller" <dhm### [at] attbicom> wrote in message
news:3d091cee$1@news.povray.org...
> Could you post a sample .pov file?
Nope. Absolutely not.
But of course!!!
----------------------------------------------------------------------------
-
#include "Colors.inc"
#include "Glass.inc"
#include "cristals.inc"
#declare PHOTONS=1;
global_settings
{
ambient_light 0.1
assumed_gamma 1
/*
radiosity
{
recursion_limit 3
pretrace_start 0.08
pretrace_end 0.01
count 350
nearest_count 5
error_bound 0.2
low_error_factor .5
gray_threshold 0.0
minimum_reuse 1/1024 // 0.015
brightness 1
adc_bailout 0.01/2
}
*/
photons
{
#if (PHOTONS=1)
max_trace_level 5
#else
max_trace_level 0
#end
count 2000000
spacing 0.005
gather 40,50
autostop 0
jitter 0
}
}
//////////////////////////////////////////////////////////////
camera
{
location <5,15,-10> // <5,15,-10>
look_at <0,5,0>
}
#if (PHOTONS=0)
light_source { <10,10,10> color White }
#end
light_source
{
<0,5,0> color White*5
//fade_power 2
//fade_distance 4
#if (PHOTONS=1)
photons
{
refraction on
reflection on
}
#end
}
/*
light_source
{
<10,10,10>
color White
spotlight
point_at <0,7,0>
radius 2
falloff 3
#if (PHOTONS=1)
photons
{
refraction on
reflection on
}
#end
}
*/
plane { y, 0 pigment { rgb <0.5,0.5,1.0> } finish { reflection 0.1 } photons
{ collect on } }
//////////////////////////////////////////////////////////////
#macro CRISTAL()
texture { pigment { color rgbf<0.7, 0.7, 1, 0.8> } } // slightly bluish
interior
{
ior 2.5
dispersion 1.10
dispersion_samples 20
}
finish
{
ambient 0
diffuse 0
reflection 0.25
phong 0.3
phong_size 60
}
#if (PHOTONS=1)
photons
{
target
reflection on
refraction on
collect on
}
#end
#end // macro CRISTAL
//////////////////////////////////////////////////////////////
#declare rand_seed = seed(1);
//////////////////////////////////////////////////////////////
#declare ECHELLE = 40;
blob
{
#local i=0;
#while (i<200)
#local _x = (rand(rand_seed)-rand(rand_seed))*ECHELLE;
#local _z = (rand(rand_seed)-rand(rand_seed))*ECHELLE;
#local _y = log( _x * _x + _z * _z );
#local _d = 1 + sqrt( _x * _x + _z * _z )/5.5;
//component _d, _d, <_x,_y,_z>
sphere { <_x,_y,_z> , _d, _d }
#local i=i+1;
#end
threshold 0.5
//pigment { Yellow }
//texture { T_Glass2 }
CRISTAL()
normal { wrinkles }
normal { ripples scale 0.5 }
}
//////////////////////////////////////////////////////////////
object
{
two_ended_mesh_cristal(5,5,1, 2,1,4,seed(2))
translate <0, 5, 0>
//texture { pigment { Green } }
CRISTAL()
}
Post a reply to this message
|
|