POV-Ray : Newsgroups : povray.binaries.images : An Asteroid macro: first draft [74k] : Re: An Asteroid macro: actual code Server Time
4 Oct 2024 09:14:33 EDT (-0400)
  Re: An Asteroid macro: actual code  
From: Steve
Date: 22 Apr 1999 19:53:23
Message: <371FA060.A324C25A@ndirect.co.uk>
Impressive, I'll have a play with the macro tomorrow.

Thanks
Steve

=?iso-8859-1?Q?J=E9r=E9mie?= Aubouin wrote:
> 
> Spider wrote :
> > Try to write the blobs into a pre-made .inc file, taht way the parsing should be
> > decreaaased to some part.
> 
> Simon de Vet wrote :
> > BTW, any chance of making something to export to the .blb files? (These are
> > supported by Moray, and I think it's a pretty straightforward text format....)
> 
> I just made a new version of the macro which can export to moray .blb AND Povray
> .inc
> files.
> 
> Here is the code of the macro :
> 
> // Start here
> 
> #macro Random(A,B,S)
>    A(B-A)*rand(S)
> #end
> 
> #declare Asteroid_Texture = texture {
>    pigment {
>       bozo
>       turbulence 1 lambda 2 omega 0.6 octaves 6
>       color_map {
>          [ 0 color rgb<127,129,129>/255 ]
>          [ 1 color rgb<79,81,81>/255  ]
>       }
>       scale 0.25
>    }
>    normal {
>       average
>       normal_map {
>          [ 1
>             granite 0.6
>             turbulence 1 lambda 2.5 omega 0.5 octaves 6
>             scale 2
>          ]
>          [ 1
>             leopard 1
>             turbulence 0.5 lambda 1.5 omega 0.8 octaves 6
>             slope_map {
>                [ 0.00 <1.0,0> ]
>                [ 0.10 <0.6,1> ]
>                [ 1.00 <0.0,0> ]
>             }
>             scale 0.2
>          ]
>       }
>    }
>    finish { ambient 0.2 diffuse 1 }
> }
> 
> #macro
> Asteroid(Nb_Body,Nb_Big_Crater,Nb_Small_Crater,Sca_Ast,Export,file_name,S)
>    blob {
>       threshold 0.5
> 
>       // Output to file
>       #if ( (Export=1) | (Export=2) )
>          #fopen file_blob file_name write
>          #if (Export=2)
>             #write (file_blob,"[blob1.0]\n")
>             #write (file_blob,"threshold =   0.5\n")
>          #else
>             #write (file_blob,"blob {\n   threshold 0.5\n")
>          #end
>       #end
>       //
> 
>       // Body
>       #local Cpt = 0 ;
>       #while (Cpt<Nb_Body)
>          #local RotX = Random(0,360,S) ;
>          #local RotY = Random(0,360,S) ;
>          #local PosZ = Random(1.5,2.4,S) ;
>          #local Rad  = -PosZ/1.8  7/3 ;
>          #local Position = Sca_Ast*vrotate(<0,0,PosZ>,<RotX,RotY,0>) ;
>          sphere { Position,Rad,1 }
> 
>          // Output to file
>          #if (Export=2)
>             #write (file_blob,"sphere    =   ",Position.x," ",Position.z,"
> ",Position.y," ",Rad," 1\n")
>          #end
>          #if (Export=1)
>             #write (file_blob,"   sphere { ",Position," , ",Rad," , 1 }\n")
>          #end
>          //
> 
>          #local Cpt = Cpt  1 ;
>       #end
> 
>       // Big Craters
>       #local Cpt = 0 ;
>       #while (Cpt<Nb_Big_Crater)
>          #local RotX = Random(0,360,S) ;
>          #local RotY = Random(0,360,S) ;
>          #local PosZ = Random(2,3,S);
>          #local Rad  = PosZ - 1.5 ;
>          #local Position = Sca_Ast*vrotate(<0,0,PosZ>,<RotX,RotY,0>) ;
>          sphere { Position,Rad,-5 }
> 
>          // Output to file
>          #if (Export=2)
>             #write (file_blob,"sphere    =   ",Position.x," ",Position.z,"
> ",Position.y," ",Rad," -5\n")
>          #end
>          #if (Export=1)
>             #write (file_blob,"   sphere { ",Position," , ",Rad," , -5 }\n")
>          #end
>          //
> 
>          #local Cpt = Cpt  1 ;
>       #end
> 
>       // Small Craters
>       #local Cpt = 0 ;
>       #while (Cpt<Nb_Small_Crater)
>          #local RotX = Random(0,360,S) ;
>          #local RotY = Random(0,360,S) ;
>          #local PosZ = Random(3,3.5,S) ;
>          #local Rad  = PosZ/2 - 1 ;
>          #local Position = Sca_Ast*vrotate(<0,0,PosZ>,<RotX,RotY,0>) ;
>          sphere { Position,Rad,-1 }
> 
>          // Output to file
>          #if (Export=2)
>             #write (file_blob,"sphere    =   ",Position.x," ",Position.z,"
> ",Position.y," ",Rad," -1\n")
>          #end
>          #if (Export=1)
>             #write (file_blob,"   sphere { ",Position," , ",Rad," , -1 }\n")
>          #end
>          //
> 
>          #local Cpt = Cpt  1 ;
>       #end
>       texture { Asteroid_Texture }
> 
>       // Output to file
>       #if ( (Export=1) | (Export=2) )
>          #if (Export=1)
>             #write (file_blob,"   texture { Asteroid_Texture }\n}\n")
>          #end
>          #fclose file_blob
>       #end
>       //
>    no_shadow
>    }
> #end
> 
> // End of macro
> 
> And here is the code for the Asteroid picture I made:
> 
> #declare R1 = seed(100) ;
> Asteroid(600,30,1200,<1,1,1.5>,0,"",R1)
> 
> The parameters:
>    Asteroid(
>       Number of components for the body ,
>       Number of components for the big craters ,
>       Number of components for the small craters ,
>       Scale vector: scales the position of each component, not the radius ,
>       Export parameter: 0=no export / 1=povray .inc export / 2=moray .blb export
> ,
>       Name of the file to export ,
>       pseudo-random stream
>    )
> 
> Of course, these parameters will change in the future.
> The macro is still under construction...
> 
> With the .blb exporter, I can visualize with Moray where the spheres are. And I
> discovered that many are useless. I'll try to decrease this number without
> affecting the look of the Asteroid.
> 
> I discovered another problem: when I reduce the number of spheres for the body
> to 300, the strength of the body is smaller: the holes created by negative
> spheres are deeper.
> 
> I tried to create more small/sharp craters, but in this case, I need 1200
> components, and many of them are unused (too far from the body).
> 
> And I think that many other problems will appear.
> 
> Thank you for your suggestions.
> 
> I'll try to integrate most of them into a new beta version of the macro.
> 
> If you have other ideas, don't hesitate to modify the macro source code.
> 
> ___________________________________________________
> Jrmie Aubouin
> 
> Pour me rpondre, enlever le Z de mon adresse.
> To answer me, remove the Z from my adress.


Post a reply to this message

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