class CubeMapSamp{ public: static int size; // dim lato static vector map; // mappa 2d di indici a dir static vector dir; // direzioni (uniche!) static vector dirrot; // direzioni ruotate (uniche!) vector sum; // somme (uniche!) vector div; // divisioni (uniche!) static void Transform(Point3f ax, Point3f ay, Point3f az){ for (int i=0; i &t, int s, int tx, int ty){ int nUnique=map.size(); vector dupi(nUnique, -1); for (int y=0; y &t, int s, int tx, int ty, float cr,float cg,float cb){ for (int y=0; y0) { col=(Byte)(sum[i]/div[i]*255); colr=128; } t[k++]= colr; t[k++]= col; t[k++]= col;*/ /* Byte shade=(int)(dir[map[ Index( x , y ) ] ][2] * 255.0); t[k++]= shade; t[k++]= shade; t[k++]= shade; */ //t[k++]= t[k++]= t[k++]= 200; Point3f p=dir[map[ Index( x , y ) ] ]; Point3f q=(p+Point3f(1,1,1))/2.0*255.0; t[k++]= (Byte)(q[0]*cr); t[k++]= (Byte)(q[1]*cg); t[k++]= (Byte)(q[2]*cb); /*int shade=(int)(p*Point3d(0.8,0.6,0)*255.0); if (shade<0) shade=-shade/2; if (shade>255) shade=255; t[k++]= shade; t[k++]= shade; t[k++]= shade;*/ /* float i=255.0*float(map[Index( x , y )])/(size*size*size); t[k++]= (int)i; t[k++]= (int)i; t[k++]= (int)i; int r=0, g=0, b=0; if (y=size*2) g=255; k=(x+(y)*s)*3; t[k++]= t[k++]/2+r/2; t[k++]= t[k++]/2+g/2; t[k++]= t[k++]/2+b/2; */ /* int r=0, g=0, b=0; if (y=size*2) g=255; t[k++]= r; t[k++]= g; t[k++]= b;*/ // printf("%4d ",map[Index( x , y )]); //printf("%3d ",shade); } //printf("\n"); } } static inline int Index(int x, int y){ return x+y*size*3; } static inline int Index3(int x, int y, int z){ return x+y*size+z*size*size; } static inline int I(int x){ return size-1-x; } void Zero(){ int n=dir.size(); sum.resize(n,0); div.resize(n,0); } static void initMap(){ map.resize(size*size*6); int dx=0; int nsampl=size*size*size - (size-2)*(size-2)*(size-2); dir.resize(nsampl); dirrot.resize(nsampl); vector tmpmap(size*size*size); int k=0; for (int z=0; z &t, int s, int tx, int ty){ vector oldvalue(size*size*6); // copy old values for (int y=0; yTH) { sum+=oldvalue[i-dy]; div++; } if ((x%size)!=0) if (oldvalue[i-dx]>TH){ sum+=oldvalue[i-dx]; div++; } if (((y+1)%size)!=0) if (oldvalue[i+dy]>TH){ sum+=oldvalue[i+dy]; div++; } if (((x+1)%size)!=0) if (oldvalue[i+dy]>TH){ sum+=oldvalue[i+dx]; div++; } sum/=div; int k=(x+tx+(y+ty)*s)*3; t[k]=t[k+1]=t[k+2]=sum; } // merge texels int nUnique=map.size(); vector dupi(nUnique, -1); for (int y=0; y