|
|
Hugo Asm wrote:
>>this is a toy, from the transformers collection, ever heard of it?
>
>
> Ahaaa. No, I never heard of it until now. But that doesn't make your
> accomplishment any less. It's just a different kind of task to recreate
> something exactly. It's not easy, especially without blueprints.
>
> You seem to have a talent for working with scripts and math. As I recall you
> can get far in no time. Have you been active in other 3d-graphical
> applications?
Actually it's pretty easy... sure, I have no blueprints... but, *cough*,
I got the real thing! ;-)
This took almost a week, due to the fact I wanted rounded edges just
everywhere... so... a simple thing like the robot's head could cause me
several hours of headache:
//-----testa
#declare testa1 =
union {
//----frontale superiore
difference {
mesh {
#declare r2 = 0.02;
#declare _h = 0.3;
quad (-1.7/2*x, 1.7/2*x, 1.7/2*x-0.125*z, -1.7/2*x-0.125*z, y,
0*x, y+x, /*h1 = 2.1; h2 = 1.05; d1 = 0.125; d2 = 1.05;*/ y+#declare _n
= norm (-1.7/2*x-0.125*z, 1.7/2-0.125*z, -(2.1-1.05)*y-(1.05-0.125)*z);
_n, y-x, r2)
quad (<-1.7/2, 0, -0.125>, <1.7/2, 0, -0.125>, <1.5/2, #declare
_y =-(2.1-1.05)*(0.5-0.125)/(1.05-0.125); _y, -0.5>, <-1.5/2, _y, -0.5>,
_n, y+_n, _n+norm (<1.7/2, 0, -0.125>, <1.7/2, _y, -0.125>, <1.5/2, _y,
-0.5>), 0*x, _n-norm (<-1.7/2, 0, -0.125>, <-1.7/2, _y, -0.125>,
<-1.5/2, _y, -0.5>), r2)
quad (<-1.5/2, _y, -0.5>, <1.5/2, _y, -0.5>, <0.2, -(2.1-1.05),
-1.05>, <-0.2, -(2.1-1.05), -1.05>, _n, 0*x, _n+ norm (<1.5/2, _y,
-0.5>, <1.5/2, _y-0.5, -0.5>, <0.2, -(2.1-1.05), -1.05>), _n+#declare
_n2 = norm (<-0.2, -(2.1-1.05), -1.05>, <0, -(2.1-1.05), -1.05>,
<-0.2-0.05/1.6*(1.5-0.2), -(2.1-0.9)+0.05/1.6*0.2, -1>); _n2, _n-norm
(<-1.5/2, _y, -0.5>, <-1.5/2, _y-0.5, -0.5>, <-0.2, -(2.1-1.05),
-1.05>), r2)
quad (<-0.2, -(2.1-1.05), -1.05>, <0.2, -(2.1-1.05), -1.05>,
<0.2+0.05/1.6*(1.5-0.2), -(2.1-0.9)+0.05/1.6*0.2, -1>,
<-0.2-0.05/1.6*(1.5-0.2), -(2.1-0.9)+0.05/1.6*0.2, -1>, _n2, _n+_n2,
_n2+norm (<1.5/2, _y, -0.5>, <1.5/2, _y-0.5, -0.5>, <0.2, -(2.1-1.05),
-1.05>), _n2-norm (<0.2+0.05/1.6*(1.5-0.2), -(2.1-0.9)+0.05/1.6*0.2,
-1>, <-0.2-0.05/1.6*(1.5-0.2), -(2.1-0.9)+0.05/1.6*0.2,
-1>,(_y-0.5-_h)*y), _n2-norm (<-1.5/2, _y, -0.5>, <-1.5/2, _y-0.5,
-0.5>, <-0.2, -(2.1-1.05), -1.05>), r2)
quad (<-1.5/2, _y, -0.5>, <-0.2, -(2.1-1.05), -1.05>,
<-0.2-0.05/1.6*(1.5-0.2), -(2.1-0.9)+0.05/1.6*0.2, -1>, <-1.5/2, _y-0.5,
-0.5>, -norm (<-1.5/2, _y, -0.5>, <-1.5/2, _y-0.5, -0.5>, <-0.2,
-(2.1-1.05), -1.05>), -norm (<-1.5/2, _y, -0.5>, <-1.5/2, _y-0.5, -0.5>,
<-0.2, -(2.1-1.05), -1.05>)+_n, -norm (<-1.5/2, _y, -0.5>, <-1.5/2,
_y-0.5, -0.5>, <-0.2, -(2.1-1.05), -1.05>)+_n2, -norm (<-1.5/2, _y,
-0.5>, <-1.5/2, _y-0.5, -0.5>, <-0.2, -(2.1-1.05), -1.05>)+norm (
<-1.7/2, _y-0.5, -0.125>, <-1.5/2, _y-0.5, -0.5>,
<-0.2-0.05/1.6*(1.5-0.2), -(2.1-0.9)+0.05/1.6*0.2, -1>), -norm (<-1.5/2,
_y, -0.5>, <-1.5/2, _y-0.5, -0.5>, <-0.2, -(2.1-1.05), -1.05>) -norm
(<-1.7/2, 0, -0.125>, <-1.7/2, _y, -0.125>, <-1.5/2, _y, -0.5>), r2)
quad (<1.5/2, _y, -0.5>, <0.2, -(2.1-1.05), -1.05>,
<0.2+0.05/1.6*(1.5-0.2), -(2.1-0.9)+0.05/1.6*0.2, -1>, <1.5/2, _y-0.5,
-0.5>, norm (<1.5/2, _y, -0.5>, <1.5/2, _y-0.5, -0.5>, <0.2,
-(2.1-1.05), -1.05>), norm (<1.5/2, _y, -0.5>, <1.5/2, _y-0.5, -0.5>,
<0.2, -(2.1-1.05), -1.05>)+_n, norm (<1.5/2, _y, -0.5>, <1.5/2, _y-0.5,
-0.5>, <0.2, -(2.1-1.05), -1.05>)+_n2, norm (<1.5/2, _y, -0.5>, <1.5/2,
_y-0.5, -0.5>, <0.2, -(2.1-1.05), -1.05>)-norm ( <1.7/2, _y-0.5,
-0.125>, <1.5/2, _y-0.5, -0.5>, <0.2+0.05/1.6*(1.5-0.2),
-(2.1-0.9)+0.05/1.6*0.2, -1>), norm (<1.5/2, _y, -0.5>, <1.5/2, _y-0.5,
-0.5>, <0.2, -(2.1-1.05), -1.05>) +norm (<1.7/2, 0, -0.125>, <1.7/2, _y,
-0.125>, <1.5/2, _y, -0.5>), r2)
quad (-1.7/2*x, -1.7/2*x-0.125*z, <-1.7/2, _y-0.5, -0.125>,
<-1.7/2, _y-0.5, 0>, -x, -x+y, -x-norm (<-1.7/2, 0, -0.125>, <-1.7/2,
_y, -0.125>, <-1.5/2, _y, -0.5>), 0*x, 0*x, r2)
quad (1.7/2*x, 1.7/2*x-0.125*z, <1.7/2, _y-0.5, -0.125>, <1.7/2,
_y-0.5, 0>, x, x+y, x+norm (<1.7/2, 0, -0.125>, <1.7/2, _y, -0.125>,
<1.5/2, _y, -0.5>), 0*x, 0*x, r2)
quad (-1.7/2*x-0.125*z, <-1.5/2, _y, -0.5>, <-1.5/2, _y-0.5,
-0.5>, <-1.7/2, _y-0.5, -0.125>, -norm (<-1.7/2, 0, -0.125>, <-1.7/2,
_y, -0.125>, <-1.5/2, _y, -0.5>), -norm (<-1.7/2, 0, -0.125>, <-1.7/2,
_y, -0.125>, <-1.5/2, _y, -0.5>)+_n, -norm (<-1.7/2, 0, -0.125>,
<-1.7/2, _y, -0.125>, <-1.5/2, _y, -0.5>) -norm (<-1.5/2, _y, -0.5>,
<-1.5/2, _y-0.5, -0.5>, <-0.2, -(2.1-1.05), -1.05>), -norm (<-1.7/2, 0,
-0.125>, <-1.7/2, _y, -0.125>, <-1.5/2, _y, -0.5>)+norm ( <-1.7/2,
_y-0.5, -0.125>, <-1.5/2, _y-0.5, -0.5>, <-0.2-0.05/1.6*(1.5-0.2),
-(2.1-0.9)+0.05/1.6*0.2, -1>), -norm (<-1.7/2, 0, -0.125>, <-1.7/2, _y,
-0.125>, <-1.5/2, _y, -0.5>)-x, r2)
quad (1.7/2*x-0.125*z, <1.5/2, _y, -0.5>, <1.5/2, _y-0.5, -0.5>,
<1.7/2, _y-0.5, -0.125>, norm (<1.7/2, 0, -0.125>, <1.7/2, _y, -0.125>,
<1.5/2, _y, -0.5>), norm (<1.7/2, 0, -0.125>, <1.7/2, _y, -0.125>,
<1.5/2, _y, -0.5>)+_n, norm (<1.7/2, 0, -0.125>, <1.7/2, _y, -0.125>,
<1.5/2, _y, -0.5>) +norm (<1.5/2, _y, -0.5>, <1.5/2, _y-0.5, -0.5>,
<0.2, -(2.1-1.05), -1.05>), norm (<1.7/2, 0, -0.125>, <1.7/2, _y,
-0.125>, <1.5/2, _y, -0.5>)-norm ( <1.7/2, _y-0.5, -0.125>, <1.5/2,
_y-0.5, -0.5>, <0.2+0.05/1.6*(1.5-0.2), -(2.1-0.9)+0.05/1.6*0.2, -1>),
norm (<1.7/2, 0, -0.125>, <1.7/2, _y, -0.125>, <1.5/2, _y, -0.5>)+x, r2)
triangolo (<0.2+0.05/1.6*(1.5-0.2), -(2.1-0.9)+0.05/1.6*0.2, -1>,
<-0.2-0.05/1.6*(1.5-0.2), -(2.1-0.9)+0.05/1.6*0.2, -1>,(_y-0.5-_h)*y,
-norm (<0.2+0.05/1.6*(1.5-0.2), -(2.1-0.9)+0.05/1.6*0.2, -1>,
<-0.2-0.05/1.6*(1.5-0.2), -(2.1-0.9)+0.05/1.6*0.2, -1>,(_y-0.5-_h)*y),
0*x, 0*x, 0*x, r2)
quad (<-1.7/2, _y-0.5, -0.125>, <-1.5/2, _y-0.5, -0.5>,
<-0.2-0.05/1.6*(1.5-0.2), -(2.1-0.9)+0.05/1.6*0.2, -1>,(_y-0.5-_h)*y,
norm ( <-1.7/2, _y-0.5, -0.125>, <-1.5/2, _y-0.5, -0.5>,
<-0.2-0.05/1.6*(1.5-0.2), -(2.1-0.9)+0.05/1.6*0.2, -1>), norm ( <-1.7/2,
_y-0.5, -0.125>, <-1.5/2, _y-0.5, -0.5>, <-0.2-0.05/1.6*(1.5-0.2),
-(2.1-0.9)+0.05/1.6*0.2, -1>) -norm (<-1.7/2, 0, -0.125>, <-1.7/2, _y,
-0.125>, <-1.5/2, _y, -0.5>), norm ( <-1.7/2, _y-0.5, -0.125>, <-1.5/2,
_y-0.5, -0.5>, <-0.2-0.05/1.6*(1.5-0.2), -(2.1-0.9)+0.05/1.6*0.2,
-1>)-norm (<-1.5/2, _y, -0.5>, <-1.5/2, _y-0.5, -0.5>, <-0.2,
-(2.1-1.05), -1.05>), 0*x, 0*x, r2)
triangolo (<-1.7/2, _y-0.5, 0>, <-1.7/2, _y-0.5, -0.125>,
(_y-0.5-_h)*y, norm (<-1.7/2, _y-0.5, 0>, <-1.7/2, _y-0.5, -0.125>,
(_y-0.5-_h)*y), 0*x, 0*x, 0*x, r2)
quad (<1.7/2, _y-0.5, -0.125>, <1.5/2, _y-0.5, -0.5>,
<0.2+0.05/1.6*(1.5-0.2), -(2.1-0.9)+0.05/1.6*0.2, -1>,(_y-0.5-_h)*y,
-norm ( <1.7/2, _y-0.5, -0.125>, <1.5/2, _y-0.5, -0.5>,
<0.2+0.05/1.6*(1.5-0.2), -(2.1-0.9)+0.05/1.6*0.2, -1>), -norm ( <1.7/2,
_y-0.5, -0.125>, <1.5/2, _y-0.5, -0.5>, <0.2+0.05/1.6*(1.5-0.2),
-(2.1-0.9)+0.05/1.6*0.2, -1>) +norm (<1.7/2, 0, -0.125>, <1.7/2, _y,
-0.125>, <1.5/2, _y, -0.5>), -norm ( <1.7/2, _y-0.5, -0.125>, <1.5/2,
_y-0.5, -0.5>, <0.2+0.05/1.6*(1.5-0.2), -(2.1-0.9)+0.05/1.6*0.2,
-1>)+norm (<1.5/2, _y, -0.5>, <1.5/2, _y-0.5, -0.5>, <0.2, -(2.1-1.05),
-1.05>), 0*x, 0*x, r2)
triangolo (<1.7/2, _y-0.5, 0>, <1.7/2, _y-0.5, -0.125>,
(_y-0.5-_h)*y, -norm (<1.7/2, _y-0.5, 0>, <1.7/2, _y-0.5, -0.125>,
(_y-0.5-_h)*y), 0*x, 0*x, 0*x, r2)
quad (-1.7/2*x, 1.7/2*x, <1.7/2, _y-0.5, 0>, <-1.7/2, _y-0.5, 0>,
z, 0*x, 0*x, 0*x, 0*x, r2)
triangolo (<-1.7/2, _y-0.5, 0>, <1.7/2, _y-0.5, 0>,
(_y-0.5-_h)*y, z, 0*x, 0*x, 0*x, r2)
inside_vector z
}
sphere {
0, 1
scale <1.7/2-0.2, 2.1-1.05-0.1, 1.5*10>
}
}
//-------superiore
intersection {
union {
box {
<-1.5/2, -0.05, 0>, <1.5/2, -1, -.3>
}
intersection {
cylinder {
-1.5/2*x, 1.5/2*x, 1
}
plane {
z, 0
}
plane {
-y, -0.05
}
scale <1, 1, 0.65>
translate <0, -1-0.05, -0.3>
}
}
#declare _v = <.7, -1.05, 0.3>;
#declare _r = 1.53;
sphere {
_v, _r
}
sphere {
_v*<-1,1,1>, _r
}
}
//-----elmo
difference {
#declare _r2 = 0.015;
Round_Box_Union (<-0.25/2, -_r2, -_r2>, <0.25/2, 0.5+_r2, 0.5>, _r2)
box {
<-0.1, 0.15, -0.1>,<0.1, 0.45, 0.025>
}
#declare ang1 = -10;
#declare _d = 0.95;
#declare _h = 1;
rotate ang1*x
translate -_d*z-_h*y
}
object {
Round_Box_Union (<-0.25/2, -_r2, -_r2>, <0.25/2, 0.7+_r2, 0.5>, _r2)
#declare ang2 = 30;
rotate ang2*x
translate vrotate (0.5*y, ang1*x)+<0, -_h, -_d>
}
intersection {
object {
Round_Box_Union (<-0.25/2, _r2, -_r2>, <0.25/2, -0.5, 1>, _r2)
translate vrotate (0.7*y, ang2*x)+vrotate (0.5*y, ang1*x)+<0,
-_h, -_d>
}
plane {
z, 0
}
}
object {
Round_Box_Union (<-0.1, _r2, -0.15>, <0.1, -0.5, 0.2>, _r2)
translate vrotate (0.7*y, ang2*x)+vrotate (0.5*y, ang1*x)+<0, -_h, -_d>
}
}
#declare testa2 =
union {
isosurface {
function {
f_rounded_box (
x, y, z,
#declare r = 0.015; r,
(0.15/2+z/0.6*0.15/2)*select (x, 1, 0) + 0.15/2,
0.8 + 0.15*z/0.35 + (0.4-0.15*0.6/0.35)*(z+0.35)/.25*select (z +
0.35, 1, 0),
.6
)
}
contained_by {
box {
<-0.15, 0, 0>, <0.15/2, 0.8, -0.6>
}
}
max_gradient 5
translate (0.15-1.7/2)*x
}
isosurface {
function {
f_rounded_box (
x, y, z,
r,
(0.15/2+z/0.6*0.15/2)*select (x, 1, 0) + 0.15/2,
0.8 + 0.15*z/0.35 + (0.4-0.15*0.6/0.35)*(z+0.35)/.25*select (z +
0.35, 1, 0),
.6
)
}
contained_by {
box {
<-0.15, 0, 0>, <0.15/2, 0.8, -0.6>
}
}
max_gradient 5
scale <-1,1,1>
translate -(0.15-1.7/2)*x
}
isosurface {
function {
f_rounded_box (
x, y, z,
r,
.7,
0.8 + 0.15*z/0.35,
.35
)
}
contained_by {
box {
<-0.7, 0, 0>, <0.7, 0.8, -0.35>
}
}
max_gradient 5
}
intersection {
#declare R = 2;
#declare r = 0.015;
#declare p1 = <-1.7/2+3/2*0.15, 0.65, -0.35>;
#declare p2 = <0, 0.65, -.7>;
#declare x1 = p1.x;
#declare x2 = p2.x;
#declare y1 = p1.z;
#declare y2 = p2.z;
#declare a = 1 + pow ((x1-x2)/(y1-y2), 2);
#declare b = -2*x1 -(x1-x2)*(x1*x1-x2*x2+y1*y1-y2*y2)/pow(y1-y2, 2)
+ 2*(x1-x2)/(y1-y2)*y1;
#declare c = x1*x1 + y1*y1 + pow(x1*x1-x2*x2+y1*y1-y2*y2, 2)/4/pow
(y1-y2, 2) - y1/(y1-y2)*(x1*x1-x2*x2+y1*y1-y2*y2) -
R*R;
#declare x0 = (-b + sqrt (b*b - 4*a*c))/(2*a);
#declare y0 = 1/2/(y1-y2)*(x1*x1-x2*x2+y1*y1-y2*y2-2*(x1-x2)*x0);
object {
Round_Cylinder_Union (0*x, 0.5*y, R, r)
translate <x0, 0, y0>
translate -p2+0.15*y
Shear_Trans (x, y-z/4, z)
translate p2-0.15*y
}
plane {
x, 0
}
plane {
z, -0.3
}
translate 0.15*y
}
intersection {
object {
Round_Cylinder_Union (0*x, 0.5*y, R, r)
translate <x0, 0, y0>
translate -p2+0.15*y
Shear_Trans (x, y-z/4, z)
translate p2-0.15*y
}
plane {
x, 0
}
plane {
z, -0.3
}
translate 0.15*y
scale <-1,1,1>
}
box {
<-1.7/2, 0, -0.00000001>, <1.7/2, 0.6, 0.3>
Shear_Trans (x, y, z+y/3)
translate 0.2*y
}
//-----naso
object {
Round_Box_Union (<-0.15/2, -r, 0>, <0.15/2, 0.3+r, 0.3>, r)
Shear_Trans (x, y+z/2, z)
translate p2+0.035*z
}
//-------occhi
polygon {
4,
<0,0>, <0, 0.5>, <-1, 0.5>, <-1, 0>
rotate 43*y
translate p2+0.15*z-0.05*x
#if (USE_TEX) texture {plastica_rossa} #end
}
polygon {
4,
<0,0>, <0, 0.5>, <-1, 0.5>, <-1, 0>
rotate 43*y
translate p2+0.15*z-0.05*x
scale <-1,1,1>
#if (USE_TEX) texture {plastica_rossa} #end
}
//-----orecchie
difference {
union {
cylinder {
-1.7/2*x, 1.7/2*x, 0.35
}
cone {
-1.7/2*x, 0.35, -(1.7/2+0.05)*x, 0.3
}
cone {
1.7/2*x, 0.35, (1.7/2+0.05)*x, 0.3
}
}
plane {
-z, 0
}
cylinder {
-(1.7/2+0.01)*x, -x, 0.05
translate <0, 0.1, -0.2>
}
cylinder {
-(1.7/2+0.01)*x, -x, 0.05
translate <0, -0.1, -0.2>
}
cylinder {
-(1.7/2+0.01)*x, -x, 0.05
translate <0, 0.1, -0.2>
scale <-1,1,1>
}
cylinder {
-(1.7/2+0.01)*x, -x, 0.05
translate <0, -0.1, -0.2>
scale <-1,1,1>
}
box {
<-1, -0.05, 0>, <-1.7/2-0.01001, 0.05, -0.2>
translate <0, 0.1, -0.2>
}
box {
<-1, -0.05, 0>, <-1.7/2-0.01001, 0.05, -0.2>
translate <0, -0.1, -0.2>
}
box {
<-1, -0.05, 0>, <-1.7/2-0.01001, 0.05, -0.2>
translate <0, 0.1, -0.2>
scale <-1,1,1>
}
box {
<-1, -0.05, 0>, <-1.7/2-0.01001, 0.05, -0.2>
translate <0, -0.1, -0.2>
scale <-1,1,1>
}
translate <0, 1, 0.3>
}
}
#declare testa3 =
union {
difference {
Round_Box_Union (<-1.7/2, -0.2, -0.2>, <1.7/2, 2.1, 0.35>, r2)
plane {
z, 0
}
cylinder {
-0.2*z, 0.5*z, 1
scale <1.7/2-0.2, 2.1-1.05-0.1, 1.5*10>
translate 2.1*y
}
cylinder {
-0.1*z, 0.4*z, 0.25
translate 1.25*y
}
}
box {
<-1.7/2, 0, 0>, <1.7/2, -0.3, 0.3>
Shear_Trans (x, y, z+y/3)
translate <0, 0.2-_eps, -0.3+1e-6>
}
difference {
union {
cylinder {
-1.7/2*x, 1.7/2*x, 0.35
}
cone {
-1.7/2*x, 0.35, -(1.7/2+0.05)*x, 0.3
}
cone {
1.7/2*x, 0.35, (1.7/2+0.05)*x, 0.3
}
}
plane {
z, 0
}
cylinder {
-0.1*z, 0.4*z, 0.25
translate .25*y
}
translate y
}
intersection {
box {
<-1.5/2, 2.1-0.05, 0>, <1.5/2, 1, .35>
}
sphere {
_v+2.1*y, _r
}
sphere {
_v*<-1,1,1>+2.1*y, _r
}
cylinder {
-0.1*z, 0.4*z, 0.25
translate 1.25*y
inverse
}
}
object {
vite
rotate ran()*360*y
rotate 90*x
translate 1.25*y
}
difference {
Round_Box_Union (<-1, 0, 0.35>, <1, -1, -1.1>, 0.01)
box {
<-0.5, 0.001, 0>, <0.5, -0.2, -0.2>
rotate 45*x
translate -z
}
}
}
#declare testa =
union {
object {
testa1 translate 2.1*y
}
object {
testa2 translate -0.3*z
}
object {
testa3 translate _eps*z
#if (USE_TEX) texture {t_testa_posteriore} #end
}
#if (USE_TEX) texture {t_testa_anteriore} #end
}
Argh, I'm gonna hate numbers... quad, triangolo and norm are very...
very... *basic* macros.
Cheers!
--
Jonathan.
Post a reply to this message
|
|