Je suis en train d'essayer de faire une animation où je fais l'intersection d'un plan et d'un pavé droit. Si je ne fais qu'une image tout va bien. Mais si je fais une animation, il n'y a que l'intersection que je rajoute à la main qui est dessinée :
Code : Tout sélectionner
import bsp;
import animate;
settings.tex="pdflatex";
settings.outformat="pdf";
currentprojection=obliqueX;
settings.render=0;
settings.prc=false;
currentlight = nolight;
typedef path3[] shape;
shape operator *(transform3 T, shape p){
shape os;
for(path3 g:p) os.push(T*g);
return os;
}
path3 path(triple[] T){
path3 P;
for(triple i:T) P=P--i;
return P;
}
void addshapes(face[] F, shape[] shp, pen drawpen=currentpen, pen fillpen=white)
{
for(int i=0; i < shp.length; ++i)
for(int j=0; j < shp[i].length; ++j) {
path3 g=shp[i][j];
picture pic=F.push(g);
if(fillpen != nullpen) filldraw(pic,project(g),fillpen, drawpen);
else draw(pic,project(g),drawpen);
// filldraw(pic,g,currentlight.intensity(F[F.length-1].point)*fillpen, drawpen);
}
}
real long=2,larg=2,haut=4;
real marge=1;
shape face1,face2,face3,face4,face6,plan;
//dessous
face1=(0,0,0)--(long,0,0)--(long,0,haut)--(0,0,haut)--cycle;
face2=(0,larg,0)--(long,larg,0)--(long,larg,haut)--(0,larg,haut)--cycle;
face3=(0,0,0)--(0,larg,0)--(0,larg,haut)--(0,0,haut)--cycle;
face4=(long,0,0)--(long,larg,0)--(long,larg,haut)--(long,0,haut)--cycle;
//face5=(0,0,0)--(long,0,0)--(long,larg,0)--(0,larg,0)--cycle;
face6=(0,0,haut)--(long,0,haut)--(long,larg,haut)--(0,larg,haut)--cycle;
real h2;
animation Anim;
for(real h1=6;h1>-1;h1-=1)
{
write("on passe a h="+(string)h1);
h2=h1-marge;
plan=(-marge,-marge,h1)--(long+marge,-marge,h1)--(long+marge,larg+marge,h2)--(-marge,larg+marge,h2)--cycle;
triple[] A1;
A1=intersectionpoints((0,0,0)--(0,larg,0)--(0,larg,haut)--(0,0,haut)--cycle,surface(plan));
face[] hidden,visible;
shape[] Shapes;
Shapes.push(face1);
Shapes.push(face2);
Shapes.push(face3);
Shapes.push(face4);
Shapes.push(plan);
Shapes.push(face6);
addshapes(hidden, Shapes, drawpen=linewidth(bp));
addshapes(visible, Shapes, drawpen=dashed, fillpen=nullpen);
picture pic;
size(pic,10cm,0);
if (A1.length >1){
draw(pic,surface((long,0,0)+A1[1]--(long,0,0)+A1[0]--A1[0]--A1[1]--cycle),lightgreen+opacity(0.2));
draw(pic,(long,0,0)+A1[1]--(long,0,0)+A1[0]--A1[0]);
draw(pic,A1[0]--A1[1],dashed);
pen pdernier=linewidth(bp);
if (A1[1].z<haut){
pdernier=dashed;
}
draw(pic,A1[1]--(long,0,0)+A1[1],pdernier);
}
add(pic,hidden);
add(pic,visible);
add(pic.fit(),bbox(xmargin=3mm,invisible));
Anim.add(pic);
//restore();
erase();
};
Anim.movie();
Je ne comprends plus rien...