typedef unsigned char Byte; #include #include #include using namespace vcg; using namespace std; #include "CubeMapSamp.h" #include "OctaMapSamp.h" #include "Mol.h" #include "AO.h" const float infty=1000; vector tmpbool(32*32,false); void AO::PrintBuffer(){ int target=32; int k=0; for (int y=0; y0) { tmp=sqrt(tmp)+cz; int i=index(x+cxi,y+cyi); if (buf[i]>tmp) buf[i]=tmp; //buf[i]=0; } } } void AO::CheckAtom(QAtom &a){ int n=a.s.nsamp(); for (int i=0; i0) { int bx=(int) (a.trp[0]+f[0]); int by=(int) (a.trp[1]+f[1]); tmpbool[index(bx,by)]=true;; if (buf[index(bx,by)] == infty ) { a.s.sum[i]+=f[2]; }; a.s.div[i]+=f[2]; } } } AO::AO( Point3f _dir, Mol &m) { dir=_dir.Normalize(); // orthonormal basis Point3f ax,ay,az=dir; ax=az^Point3f(1,0,0); if (ax.SquaredNorm()<0.1) ax=az^Point3f(0,1,0); ax=ax.Normalize(); ay=(az^ax).Normalize(); // project... m.Transform(ax,ay,az); int target=32; // bufx=bufy=target; float bufscalex=target/(m.tx1-m.tx0); float bufscaley=target/(m.ty1-m.ty0); bufscale=(bufscalex