GALERIE    EN COURS    SCENES    MACROS    GUIDE    A PROPOS


 

Utilisation d'une boucle while et de la la macro "colorsConvert".

helice
Voir l'image 640x480 - 164Ko

 


Source:
// -----------------------------------------------------------------------------------
// louis bellotto - louisbel @ free.fr - septmebre 2000
//
//		Utilisation d'une boucle "while".
//		Utilisation de la macro "colorsConvert".
// -----------------------------------------------------------------------------------
#version unofficial MegaPov 0.7;


// -------------------------------------------------------------------------------------------
#include "colors.inc"
#include "axes.inc"
#include "colorsConvert.inc"


// -------------------------------------------------------------------------------------------
#declare drawAxes = false;	// true pour afficher les axes
#declare verbose = false;	// true pour afficher le resultat des calculs de convertions


// -------------------------------------------------------------------------------------------
camera {
	location <10, 10, 10>
	look_at <0, 0, 0>
	}


// -------------------------------------------------------------------------------------------
light_source {
	<100, 100, 100>
	color White
	}



// -------------------------------------------------------------------------------------------
background {
	color Black
	}


// -------------------------------------------------------------------------------------------
#if(drawAxes)
	drawAxis(15, 0.10)
#end


// -------------------------------------------------------------------------------------------
// declaration de l'objet de base, ici une sphere
#declare boule = sphere {
	<0, 0, 0>
	0.50
	}


// -------------------------------------------------------------------------------------------
// premiere couleur
#declare startRGB = rgb <1, 0, 0>;
#declare startHSV = rgb2hsv(startRGB);
#if (startHSV.red=0)
	#declare startHSV=<360, startHSV.green, startHSV.blue>;
#end

// derniere couleur
#declare lastRGB = rgb <0, 0, 1>;
#declare lastHSV = rgb2hsv(lastRGB);

// nombre de rotations de l'helice
#declare rotation = 360*3;

// rayon d'une sphre
#declare rayon = 5.00;

// angle de rotation
#declare angleSteep = 10;
#declare nbSteep = rotation/angleSteep;

// calculs de differences
#declare deltaH = 1.0*lastHSV.red-1.0*startHSV.red;
#declare deltaS = 1.0*lastHSV.green-1.0*startHSV.green;
#declare deltaV = 1.0*lastHSV.blue-1.0*startHSV.blue;

// calcul des increments
#declare steepH = deltaH/nbSteep;
#declare steepS = deltaS/nbSteep;
#declare steepV = deltaV/nbSteep;

// si 'verbose' egale 'true', affichage du resultat des convertions
#if (verbose)
	#debug "\n\n"
	#debug concat("\nStart color R = ",str(startRGB.red,4,2)," G = ",str(startRGB.green,4,2)," B = ",str(startRGB.blue,4,2))
	#debug concat("\n            H = ",str(startHSV.red,4,2)," S = ",str(startHSV.green,4,2)," V = ",str(startHSV.blue,4,2))
	#debug concat("\n  End color R = ",str(lastRGB.red,4,2)," G = ",str(lastRGB.green,4,2)," B = ",str(lastRGB.blue,4,2))
	#debug concat("\n            H = ",str(lastHSV.red,4,2)," S = ",str(lastHSV.green,4,2)," V = ",str(lastHSV.blue,4,2))
	#debug concat("\n Delta H = ",str(deltaH,5,3)," S = ",str(deltaS,5,3)," V = ",str(deltaV,5,3))
	#debug concat("\n Steep H = ",str(steepH,5,3)," S = ",str(steepS,5,3)," V = ",str(steepV,5,3))
#end


// initialisation des variables
#declare angleIndex = 0;
#declare currentHSV = rgb rgb2hsv(lastRGB);
#declare currentHSV = currentHSV+<steepH, steepS, steepV>;


// boucle
#while (angleIndex<rotation)
	// calcul des coordonnes <x,y,z> du point de l'helice
	#declare xPos = rayon*cos(radians(angleIndex));
	#declare yPos = radians(angleIndex)-(radians(720)/2);
	#declare zPos = rayon*sin(radians(angleIndex));
	
	// calcul de la couleur
	#declare currentHSV = currentHSV-<steepH, steepS, steepV>;
	#declare currentRGB = rgb hsv2rgb(currentHSV);
	
	// affichage de la sphere
	object {
		boule
		translate <xPos, yPos*0.50, zPos> // deplacement au nouveau point sur l'helice
		pigment { color currentRGB } // donne la couleur 
		finish { ambient 0.30 phong 0.90 phong_size 50 } // et la finition
		}
	// sphere qui va former le cylindre au centre
	sphere {
		<0, yPos*0.50, 0> 0.50
		pigment { color currentRGB }
		finish { ambient 0.30 phong 0.90 phong_size 50 }
		}
	// rayon du cylindre central a la sphere
	cylinder {
		<xPos, yPos*0.50, zPos> <0, yPos*0.50, 0> 0.05
		pigment { color currentRGB }
		finish { ambient 0.30 phong 0.90 phong_size 50 }
		}
	#set angleIndex=angleIndex+angleSteep;
#end


Haut de la page | Sommaire ]