Ok je sais, Philippe a déjà inondé les listes de diffusion sur la nouvelle.
Asymptote supporte (ou commence à supporter) le format PRC (développé initialement par une société française rachetée par Adobe) pour l'inclusion 3D. Bien sûr il faut Acrobat Reader pour en profiter.
Voici un exemple : the famous teapot (mais attention ne rien y verser il manque le fond).
Code : Tout sélectionner
import surface;
size(400,0);
triple[][][] P=
{
{
{ (1.4,2.25,0),(1.3375,2.38125,0),(1.4375,2.38125,0),(1.5,2.25,0)},
{ (1.4,2.25,.784),(1.3375,2.38125,.749),(1.4375,2.38125,.805),(1.5,2.25,.84)},
{ (.784,2.25,1.4),(.749,2.38125,1.3375),(.805,2.38125,1.4375),(.84,2.25,1.5)},
{ (0,2.25,1.4),(0,2.38125,1.3375),(0,2.38125,1.4375),(0,2.25,1.5)}
},{
{ (0,2.25,1.4),(0,2.38125,1.3375),(0,2.38125,1.4375),(0,2.25,1.5)},
{ (-.784,2.25,1.4),(-.749,2.38125,1.3375),(-0.805,2.38125,1.4375),(-.84,2.25,1.5)},
{ (-1.4,2.25,.784),(-1.3375,2.38125,.749),(-1.4375,2.38125,.805),(-1.5,2.25,.84)},
{ (-1.4,2.25,0),(-1.3375,2.38125,0),(-1.4375,2.38125,0),(-1.5,2.25,0)}
},{
{ (-1.4,2.25,0),(-1.3375,2.38125,0),(-1.4375,2.38125,0),(-1.5,2.25,0)},
{ (-1.4,2.25,-.784),(-1.3375,2.38125,-.749),(-1.4375,2.38125,-.805),(-1.5,2.25,-.84)},
{ (-.784,2.25,-1.4),(-.749,2.38125,-1.3375),(-.805,2.38125,-1.4375),(-.84,2.25,-1.5)},
{ (0,2.25,-1.4),(0,2.38125,-1.3375),(0,2.38125,-1.4375),(0,2.25,-1.5)}
},{
{ (0,2.25,-1.4),(0,2.38125,-1.3375),(0,2.38125,-1.4375),(0,2.25,-1.5)},
{ (.784,2.25,-1.4),(.749,2.38125,-1.3375),(.805,2.38125,-1.4375),(.84,2.25,-1.5)},
{ (1.4,2.25,-.784),(1.3375,2.38125,-.749),(1.4375,2.38125,-.805),(1.5,2.25,-.84)},
{ (1.4,2.25,0),(1.3375,2.38125,0),(1.4375,2.38125,0),(1.5,2.25,0)}
},//pot
{
{(1.5,2.25,0),(1.75,1.725,0),(2,1.2,0),(2,.75,0)},
{ (1.5,2.25,.84),(1.75,1.725,.98),(2,1.2,1.12),(2,.75,1.12)},
{ (.84,2.25,1.5),(.98,1.725,1.75),(1.12,1.2,2),(1.12,.75,2)},
{ (0,2.25,1.5),(0,1.725,1.75),(0,1.2,2),(0,.75,2)}
},{
{ (0,2.25,1.5),(0,1.725,1.75),(0,1.2,2),(0,.75,2)},
{ (-.84,2.25,1.5),(-.98,1.725,1.75),(-1.12,1.2,2),(-1.12,.75,2)},
{ (-1.5,2.25,.84),(-1.75,1.725,.98),(-2,1.2,1.12),(-2,.75,1.12)},
{ (-1.5,2.25,0),(-1.75,1.725,0),(-2,1.2,0),(-2,.75,0)}
},{
{ (-1.5,2.25,0),(-1.75,1.725,0),(-2,1.2,0),(-2,.75,0)},
{ (-1.5,2.25,-.84),(-1.75,1.725,-.98),(-2,1.2,-1.12),(-2,.75,-1.12)},
{ (-.84,2.25,-1.5),(-.98,1.725,-1.75),(-1.12,1.2,-2),(-1.12,.75,-2)},
{ (0,2.25,-1.5),(0,1.725,-1.75),(0,1.2,-2),(0,.75,-2)}
},{
{ (0,2.25,-1.5),(0,1.725,-1.75),(0,1.2,-2),(0,.75,-2)},
{ (.84,2.25,-1.5),(.98,1.725,-1.75),(1.12,1.2,-2),(1.12,.75,-2)},
{ (1.5,2.25,-.84),(1.75,1.725,-.98),(2,1.2,-1.12),(2,.75,-1.12)},
{ (1.5,2.25,0),(1.75,1.725,0),(2,1.2,0),(2,.75,0)}
},{
{ (2,.75,0),(2,.3,0),(1.5,.075,0),(1.5,0,0)},
{ (2,.75,1.12),(2,.3,1.12),(1.5,.075,.84),(1.5,0,.84)},
{ (1.12,.75,2),(1.12,.3,2),(.84,.075,1.5),(.84,0,1.5)},
{ (0,.75,2),(0,.3,2),(0,.075,1.5),(0,0,1.5)}
},{
{ (0,.75,2),(0,.3,2),(0,.075,1.5),(0,0,1.5)},
{ (-1.12,.75,2),(-1.12,.3,2),(-.84,.075,1.5),(-.84,0,1.5)},
{ (-2,.75,1.12),(-2,.3,1.12),(-1.5,.075,.84),(-1.5,0,.84)},
{ (-2,.75,0),(-2,.3,0),(-1.5,.075,0),(-1.5,0,0)}
},{
{ (-2,.75,0),(-2,.3,0),(-1.5,.075,0),(-1.5,0,0)},
{ (-2,.75,-1.12),(-2,.3,-1.12),(-1.5,.075,-.84),(-1.5,0,-.84)},
{ (-1.12,.75,-2),(-1.12,.3,-2),(-.84,.075,-1.5),(-.84,0,-1.5)},
{ (0,.75,-2),(0,.3,-2),(0,.075,-1.5),(0,0,-1.5)}
},{
{ (0,.75,-2),(0,.3,-2),(0,.075,-1.5),(0,0,-1.5)},
{ (1.12,.75,-2),(1.12,.3,-2),(.84,.075,-1.5),(.84,0,-1.5)},
{ (2,.75,-1.12),(2,.3,-1.12),(1.5,.075,-.84),(1.5,0,-.84)},
{ (2,.75,0),(2,.3,0),(1.5,.075,0),(1.5,0,0)}
},{//anse de la theiere
{ (-1.6,1.875,0),(-2.3,1.875,0),(-2.7,1.875,0),(-2.7,1.65,0)},
{ (-1.6,1.875,.3),(-2.3,1.875,.3),(-2.7,1.875,.3),(-2.7,1.65,.3)},
{ (-1.5,2.1,.3),(-2.5,2.1,.3),(-3,2.1,.3),(-3,1.65,.3)},
{ (-1.5,2.1,0),(-2.5,2.1,0),(-3,2.1,0),(-3,1.65,0)}
},{
{ (-1.5,2.1,0),(-2.5,2.1,0),(-3,2.1,0),(-3,1.65,0)},
{ (-1.5,2.1,-.3),(-2.5,2.1,-.3),(-3,2.1,-.3),(-3,1.65,-.3)},
{ (-1.6,1.875,-.3),(-2.3,1.875,-.3),(-2.7,1.875,-.3),(-2.7,1.65,-.3)},
{ (-1.6,1.875,0),(-2.3,1.875,0),(-2.7,1.875,0),(-2.7,1.65,0)}
},{
{ (-2.7,1.65,0),(-2.7,1.425,0),(-2.5,.975,0),(-2,.75,0)},
{ (-2.7,1.65,.3),(-2.7,1.425,.3),(-2.5,.975,.3),(-2,.75,.3)},
{ (-3,1.65,.3),(-3,1.2,.3),(-2.65,.7875,.3),(-1.9,.45,.3)},
{ (-3,1.65,0),(-3,1.2,0),(-2.65,.7875,0),(-1.9,.45,0)}
},{
{ (-3,1.65,0),(-3,1.2,0),(-2.65,.7875,0),(-1.9,.45,0)},
{ (-3,1.65,-.3),(-3,1.2,-.3),(-2.65,.7875,-.3),(-1.9,.45,-.3)},
{ (-2.7,1.65,-.3),(-2.7,1.425,-.3),(-2.5,.975,-.3),(-2,.75,-.3)},
{ (-2.7,1.65,0),(-2.7,1.425,0),(-2.5,.975,0),(-2,.75,0)}
},{ // bec de la theiere
{ (1.7,1.275,0),(2.6,1.275,0),(2.3,1.95,0),(2.7,2.25,0)},
{ (1.7,1.275,.66),(2.6,1.275,.66),(2.3,1.95,.25),(2.7,2.25,.25)},
{ (1.7,.45,.66),(3.1,.675,.66),(2.4,1.875,.25),(3.3,2.25,.25)},
{ (1.7,.45,0),(3.1,.675,0),(2.4,1.875,0),(3.3,2.25,0)}
},{
{ (1.7,.45,0),(3.1,.675,0),(2.4,1.875,0),(3.3,2.25,0)},
{ (1.7,.45,-.66),(3.1,.675,-.66),(2.4,1.875,-.25),(3.3,2.25,-.25)},
{ (1.7,1.275,-.66),(2.6,1.275,-.66),(2.3,1.95,-.25),(2.7,2.25,-.25)},
{ (1.7,1.275,0),(2.6,1.275,0),(2.3,1.95,0),(2.7,2.25,0)},
},{
{ (2.7,2.25,0),(2.8,2.325,0),(2.9,2.325,0),(2.8,2.25,0)},
{ (2.7,2.25,.25),(2.8,2.325,.25),(2.9,2.325,.15),(2.8,2.25,.15)},
{ (3.3,2.25,.25),(3.525,2.34375,.25),(3.45,2.3625,.15),(3.2,2.25,.15)},
{ (3.3,2.25,0),(3.525,2.34375,0),(3.45,2.3625,0),(3.2,2.25,0)}
},{
{ (3.3,2.25,0),(3.525,2.34375,0),(3.45,2.3625,0),(3.2,2.25,0)},
{ (3.3,2.25,-.25),(3.525,2.34375,-.25),(3.45,2.3625,-.15),(3.2,2.25,-.15)},
{ (2.7,2.25,-.25),(2.8,2.325,-.25),(2.9,2.325,-.15),(2.8,2.25,-.15)},
{ (2.7,2.25,0),(2.8,2.325,0),(2.9,2.325,0),(2.8,2.25,0)}
},{// % poignee du couvercle
{ (0,3,0),(.8,3,0),(0,2.7,0),(.2,2.55,0)},
{ (0,3,.002),(.8,3,.45),(0,2.7,0),(.2,2.55,.112)},
{ (.002,3,0),(.45,3,.8),(0,2.7,0),(.112,2.55,.2)},
{ (0,3,0),(0,3,.8),(0,2.7,0),(0,2.55,.2)}
},{
{ (0,3,0),(0,3,.8),(0,2.7,0),(0,2.55,.2)},
{ (-.002,3,0),(-.45,3,.8),(0,2.7,0),(-.112,2.55,.2)},
{ (0,3,.002),(-.8,3,.45),(0,2.7,0),(-.2,2.55,.112)},
{ (0,3,0),(-.8,3,0),(0,2.7,0),(-.2,2.55,0)}
},{
{ (0,3,0),(-.8,3,0),(0,2.7,0),(-.2,2.55,0)},
{ (0,3,-.002),(-.8,3,-.45),(0,2.7,0),(-.2,2.55,-.112)},
{ (-.002,3,0),(-.45,3,-.8),(0,2.7,0),(-.112,2.55,-.2)},
{ (0,3,0),(0,3,-.8),(0,2.7,0),(0,2.55,-.2)}
},{
{ (0,3,0),(0,3,-.8),(0,2.7,0),(0,2.55,-.2)},
{ (.002,3,0),(.45,3,-.8),(0,2.7,0),(.112,2.55,-.2)},
{ (0,3,-.002),(.8,3,-.45),(0,2.7,0),(.2,2.55,-.112)},
{ (0,3,0),(.8,3,0),(0,2.7,0),(.2,2.55,0)}
},{ // % couvercle
{ (.2,2.55,0),(.4,2.4,0),(1.3,2.4,0),(1.3,2.25,0)},
{ (.2,2.55,.112),(.4,2.4,.224),(1.3,2.4,.728),(1.3,2.25,.728)},
{ (.112,2.55,.2),(.224,2.4,.4),(.728,2.4,1.3),(.728,2.25,1.3)},
{ (0,2.55,.2),(0,2.4,.4),(0,2.4,1.3),(0,2.25,1.3)}
},{
{ (0,2.55,.2),(0,2.4,.4),(0,2.4,1.3),(0,2.25,1.3)},
{ (-.112,2.55,.2),(-.224,2.4,.4),(-.728,2.4,1.3),(-.728,2.25,1.3)},
{ (-.2,2.55,.112),(-.4,2.4,.224),(-1.3,2.4,.728),(-1.3,2.25,.728)},
{ (-.2,2.55,0),(-.4,2.4,0),(-1.3,2.4,0),(-1.3,2.25,0)}
},{
{ (-.2,2.55,0),(-.4,2.4,0),(-1.3,2.4,0),(-1.3,2.25,0)},
{ (-.2,2.55,-.112),(-.4,2.4,-.224),(-1.3,2.4,-.728),(-1.3,2.25,-.728)},
{ (-.112,2.55,-.2),(-.224,2.4,-.4),(-.728,2.4,-1.3),(-.728,2.25,-1.3)},
{ (0,2.55,-.2),(0,2.4,-.4),(0,2.4,-1.3),(0,2.25,-1.3)}
},{
{ (0,2.55,-.2),(0,2.4,-.4),(0,2.4,-1.3),(0,2.25,-1.3)},
{ (.112,2.55,-.2),(.224,2.4,-.4),(.728,2.4,-1.3),(.728,2.25,-1.3)},
{ (.2,2.55,-.112),(.4,2.4,-.224),(1.3,2.4,-.728),(1.3,2.25,-.728)},
{ (.2,2.55,0),(.4,2.4,0),(1.3,2.4,0),(1.3,2.25,0)}
}
};
currentprojection=orthographic((1,1,1),Y);
frame f;
for(int i=0; i < P.length; ++i) {
for(int j=0; j < P[i].length; ++j)
P[i][j] *= 10; // Temporary scaling.
draw(f,P[i],blue);
}
add3(f,10cm);