HexaCone/gadgets.inc
2026-02-16 18:10:58 +01:00

320 lines
7.8 KiB
PHP

/*
* H E X A C O N E - G A D G E T S
* nouveau projet du Thu Dec 5 11:37:05 AM UTC 2024
*/
/* ======================================================= */
/* moved here from 'contexte.inc' */
#declare Repere = object
{
union {
#local R = 0.015;
#local R2 = R * 2.33;
#local LC = 1.15;
merge {
cylinder { 0, <1, 0, 0>, R }
cone { <1, 0, 0>, R2, <LC, 0, 0>, 0 }
texture { R_Texture }
}
merge {
cylinder { 0, <0, 1, 0>, R }
cone { <0, 1, 0>, R2, <0, LC, 0>, 0 }
texture { G_Texture }
}
merge {
cylinder { 0, <0, 0, 1>, R }
cone { <0, 0, 1>, R2, <0, 0, LC>, 0 }
texture { B_Texture }
}
}
}
#declare Fleche = object
{
union {
cylinder { -5*x, 5*x, 0.09 }
cone { 5*x, 0.27, 6.66*x, 0.00007 }
}
texture { LeGris }
}
// ------------------------------------------------------ ##
#declare R_C = 0.335;
/* ce truc mérite un nom plus parlant ! */
#macro Chose_le_pied ()
merge {
#local RCP = R_C * 0.666;
cylinder { 0, y/2, 0.07 }
sphere { 0, RCP scale <1, 0.17, 1> translate y*0.125 }
cylinder { 0, y*0.125, RCP }
#local R = rand(Rng1);
#if (R < 0.25) texture { tPlasticOrange }
#elseif (R < 0.50) texture { tPlasticBlue }
#elseif (R < 0.75) texture { tPlasticPrune }
#else texture { tPlasticGreen }
#end // if
}
// #debug "== Fin chose le pied\n"
#end // macro
// ------------------------------------------------------ ##
/*
* Il doit être possible de dissocier le noyau des tiges
* 29 novembre 2025, je tente l'expérience
*/
#macro Chose_les_tiges ()
union {
#local CK = NormClock * (7.876+rand(Rng1));
#for (Foo, 0, 7)
#local CK2 = CK + Foo;
#local C2X = (R_C + 0.1) * sin(CK2+rand(Rng1)) * sin(CK*3);
#local C2Z = (R_C + 0.1) * (sin(-CK2+rand(Rng1)) *
cos(CK*(rand(Rng1))));
#local Rt = 0.015+(0.03*Cos_010(NormClock));
#local B = <0, -0.05, 0>;
#local H = 0.80;
cylinder { B, <C2X, H, C2Z>, Rt }
sphere { <C2X, H, C2Z>, Rt }
#end
#local R = rand(Rng1);
#if (R < 0.25) texture { tPlasticOrange }
#elseif (R < 0.50) texture { tPlasticBlue }
#elseif (R < 0.75) texture { tPlasticPrune }
#else texture { tPlasticGreen }
#end // if
translate y*0.87
}
// #debug "== Fin chose les tiges\n"
#end // macro
// ------------------------------------------------------ ##
#macro Chose_le_corps () // = object
difference {
#local H = 0.42 + (0.10 * rand(Rng1));
cone { 0, R_C*0.52, y*H, R_C }
sphere { y*H, R_C*0.75 }
#local R = rand(Rng1);
#if (R < 0.25) texture { tPlasticOrange }
#elseif (R < 0.50) texture { tPlasticBlue }
#elseif (R < 0.75) texture { tPlasticPrune }
#else texture { tPlasticGreen }
#end // if
translate y*0.48
}
// #debug "== Fin chose le corps\n"
#end // macro
// ------------------------------------------------------ ##
#macro Chose ()
union {
Chose_le_pied ()
Chose_le_corps ()
Chose_les_tiges ()
}
#end // macro
/* ======================================================= */
/* ------------------------------------------------------------ */
#declare HexaBlob = object
{
#declare RHBlo = 0.24;
#declare RHBlo2 = RHBlo * 0.777;
blob {
// threshold 0.01 + NormClock
threshold 0.07
sphere { <0, 0, 0>, RHBlo, 1 }
#local E = RHBlo * 1.210; // XXX
#local W = 0.15;
sphere { <-E, 0, 0>, RHBlo2, W }
sphere { < E, 0, 0>, RHBlo2, W }
sphere { < 0, -E, 0>, RHBlo2, W }
sphere { < 0, E, 0>, RHBlo2, W }
sphere { < 0, 0, -E>, RHBlo2, W }
sphere { < 0, 0, E>, RHBlo2, W }
}
texture { T_WIP_bluewave scale 0.21 rotate <clock, clock/2, clock/3> }
}
/* ======================================================= */
#declare Horloge = object
{
#local Texte = str(NormClock, 6, 3);
#debug concat("Texte horloge ", Texte, "\n\n")
text {
// ttf "datas/DSEG7Classic-Regular.ttf" Texte 0.1, 0
ttf "datas/ComicMono-Bold.ttf" Texte 0.1, 0
texture { tPlasticBlue }
}
scale 1.96
rotate 90*x
translate <-4.5, 0.046, 0>
}
// =======================================================
// nouveau du 3 janvier 2026
#local Horloge2 = object
{
object { Horloge scale <1, 0.28, 1> rotate -x*90
translate <0.802, 0.18, 0> }
}
#declare HorlogeDouble = object
{
union {
box { <-3.20, 0.0, -0.07>, <3.20, 1.68, 0.07>
texture { LeGris } }
#local EC = 0.12;
object { Horloge2 rotate y*180 translate z*EC }
object { Horloge2 translate -z*EC }
}
scale 0.51
translate y*0.999
}
// =======================================================
/*
* need more work !
*/
#macro Base_hexapole ()
prism {
linear_sweep
linear_spline
0, // sweep the following shape from here ...
1, // ... up through here
7, // the number of points making up the shape ...
<3,5>, <-3,5>, <-5,0>, <-3,-5>, <3, -5>, <5,0>, <3,5>
#if (rand(Rng1) < 0.5) texture { T_Beton_1 }
#else texture { T_Beton_2 }
#end // if
scale 0.621 // WTF ?
/* Pourquoi ce scale ?
* parce que la spline est 'hardcoded' quelques
* lignes plus haut, et qu'il y a des méthodes
* probablement bien tordues pour rendre ça en
* même temps kitch et technofutile
*/
}
#end // macro
// ------------------------------------------------------ ##
#macro HexaPole_tubes ()
#local R = 0.033;
#local E = 0.49;
#local H = H_cone*0.705;
union {
#for (A, 0, 359, 60)
#local Xp = E * cos(radians(A));
#local Zp = E * sin(radians(A));
union {
#local H2 = H + rand(Rng1) + rand(Rng1);
cylinder { 0, y*H2, R }
sphere { 0, R*3 scale <1, 0.555, 1> }
sphere { 0, R*2 scale <1, 1.555, 1> translate y*H2 }
#local Ra = rand(Rng1);
#if (Ra < 0.25) texture { T_Chrome_1A }
#elseif (Ra < 0.50) texture { T_Chrome_4D }
#elseif (Ra < 0.75) texture { T_Brass_2C }
#else texture { Soft_Silver }
#end
translate <Xp, 0, Zp>
}
#end
}
#undef E
#undef H
#undef R
#end
// ------------------------------------------------------ ##
/*
* l'assemblage en grand cercle de ces trucs est
* dans le fichier "contexte.inc"
*/
#macro HexaPole ()
union {
object { Base_hexapole () scale <0.24, 0.2, 0.24> }
object { HexaPole_tubes () translate y*0.15 }
rotate y*(53*rand(Rng1))
}
#end // macro
// =======================================================
#macro OpenBox (D, R)
union {
/* les verticales */
cylinder { <-D, -D, -D>, <-D, D, -D>, R }
cylinder { < D, -D, -D>, < D, D, -D>, R }
cylinder { <-D, -D, D>, <-D, D, D>, R }
cylinder { < D, -D, D>, < D, D, D>, R }
/* en bas */
cylinder { < D, -D, D>, <-D, -D, D>, R }
cylinder { < D, -D, -D>, <-D, -D, -D>, R }
cylinder { <-D, -D, D>, <-D, -D, -D>, R }
cylinder { < D, -D, D>, < D, -D, -D>, R }
/* en haut */
cylinder { < D, D, D>, <-D, D, D>, R }
cylinder { < D, D, -D>, <-D, D, -D>, R }
cylinder { <-D, D, D>, <-D, D, -D>, R }
cylinder { < D, D, D>, < D, D, -D>, R }
/* les 8 coins */
#local R2 = R * 1.38;
sphere { <-D, -D, -D>, R2 }
sphere { < D, -D, -D>, R2 }
sphere { <-D, -D, D>, R2 }
sphere { < D, -D, D>, R2 }
sphere { <-D, D, -D>, R2 }
sphere { < D, D, -D>, R2 }
sphere { <-D, D, D>, R2 }
sphere { < D, D, D>, R2 }
texture { Soft_Silver scale 6.50 }
}
#end
// =======================================================
/*
* first written macro for testing the generation of
* differente instances of the same shape.
*/
#macro Bubble ()
sphere {
0, 0.070
#local R = rand(Rng1);
#if ( R < 0.25 ) texture { Ruby_Glass }
#elseif ( R < 0.50 ) texture { Orange_Glass }
#elseif ( R < 0.75 ) texture { Shadow_Clouds }
#else texture { Gold_Nugget }
#end
#undef R
scale <1.414, 1.000, 1.414>
}
#end
#macro Un_Machin ()
union {
#for (Y, 1, 8, 1)
object { Bubble() translate y*Y*0.115 }
#end
}
#end
// ------------------------------------------------------ ##
#declare Les_Machins = object
{
union {
#local Rk = 3.90 + NormClock;
#for (foo, 0, 359, 45)
#local Xpos = Rk * sin(radians(foo));
#local Zpos = Rk * cos(radians(foo));
object { Un_Machin () translate <Xpos, 0.22, Zpos> }
#end
#undef Rk
}
}
// =======================================================