Debian Codegraph @

src/CubeMapSamp.h

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1
2 class CubeMapSampcxx . . $ CubeMapSamp#{
3 public:
4
5 static int sizecxx . . $ CubeMapSamp#size.; // dim lato
6
7 static vectorcxx . . $ std/vector#<int> mapcxx . . $ CubeMapSamp#map.; // mappa 2d di indici a dir
8 static vectorcxx . . $ std/vector#<Point3fcxx . . $ vcg/Point3f#> dircxx . . $ CubeMapSamp#dir.; // direzioni (uniche!)
9 static vectorcxx . . $ std/vector#<Point3fcxx . . $ vcg/Point3f#> dirrotcxx . . $ CubeMapSamp#dirrot.; // direzioni ruotate (uniche!)
10
11 vectorcxx . . $ std/vector#<float> sumcxx . . $ CubeMapSamp#sum.; // somme (uniche!)
12 vectorcxx . . $ std/vector#<float> divcxx . . $ CubeMapSamp#div.; // divisioni (uniche!)
13
14
15
16 static void Transformcxx . . $ CubeMapSamp#Transform(d1992f7955acee33).(Point3fcxx . . $ vcg/Point3f# ax, Point3fcxx . . $ vcg/Point3f# ay, Point3fcxx . . $ vcg/Point3f# az){
•17 for (int i=0; i < (int)dircxx . . $ CubeMapSamp#dir..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); i++) {
18 dirrotcxx . . $ CubeMapSamp#dirrot.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i][cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).0]=dircxx . . $ CubeMapSamp#dir.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]*cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61).ax;
19 dirrotcxx . . $ CubeMapSamp#dirrot.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i][cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).1]=dircxx . . $ CubeMapSamp#dir.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]*cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61).ay;
20 dirrotcxx . . $ CubeMapSamp#dirrot.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i][cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).2]=dircxx . . $ CubeMapSamp#dir.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]*cxx . . $ vcg/Point3#`operator*`(4a489cdb697f6e61).az;
21 }
22 }
23
24
25 static int TotTexSizeXcxx . . $ CubeMapSamp#TotTexSizeX(b126dc7c1de90089).(){
26 return sizecxx . . $ CubeMapSamp#size.*3;
27 }
28
29 static int TotTexSizeYcxx . . $ CubeMapSamp#TotTexSizeY(b126dc7c1de90089).(){
30 return sizecxx . . $ CubeMapSamp#size.*2;
31 }
32
33 static inline int nsampcxx . . $ CubeMapSamp#nsamp(b126dc7c1de90089).(){
34 return dircxx . . $ CubeMapSamp#dir..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).();
35 }
36
37
38 // duplicates those texels that are already douplicated
39 void DuplicateTexelscxx . . $ CubeMapSamp#DuplicateTexels(54e11277e2b28f45).(vectorcxx . . $ std/vector#<Bytecxx . . $ Byte#> &t, int s, int tx, int ty){
40 int nUnique=mapcxx . . $ CubeMapSamp#map..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).();
41 vectorcxx . . $ std/vector#<int> dupicxx . . $ std/vector#vector(229e4d6bd205de31).(nUnique, -1);
42 for (int y=0; y<sizecxx . . $ CubeMapSamp#size.*2; y++)
43 for (int x=0; x<sizecxx . . $ CubeMapSamp#size.*3; x++)
44 {
45 int k=(x+tx+(y+ty)*s)*3;
46 int i= mapcxx . . $ CubeMapSamp#map.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).Indexcxx . . $ CubeMapSamp#Index(9b79fb6aee4c0440).( x , y )];
47 if (dupi[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]<0) {
48 dupi[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]=k;
49 } else {
50 int a=dupi[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i];
51 t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).a+0]=t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).k+0];
52 t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).a+1]=t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).k+1];
53 t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).a+2]=t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).k+2];
54 }
55 }
56 }
57
58 void FillTexturecxx . . $ CubeMapSamp#FillTexture(75de56d795bd0575).(vectorcxx . . $ std/vector#<Bytecxx . . $ Byte#> &t, int s, int tx, int ty,
59 float cr,float cg,float cb){
60 for (int y=0; y<sizecxx . . $ CubeMapSamp#size.*2; y++) {
61 for (int x=0; x<sizecxx . . $ CubeMapSamp#size.*3; x++)
62 {
63 int k=(x+tx+(y+ty)*s)*3;
•64 //int i= map[Index( x , y )];
65 /*Byte col=0, colr=255;
66 if (div[i]>0) { col=(Byte)(sum[i]/div[i]*255); colr=128; }
67 t[k++]= colr;
68 t[k++]= col;
69 t[k++]= col;*/
70
71 /*
72 Byte shade=(int)(dir[map[ Index( x , y ) ] ][2] * 255.0);
73 t[k++]= shade;
74 t[k++]= shade;
75 t[k++]= shade;
76 */
77
78 //t[k++]= t[k++]= t[k++]= 200;
79
80 Point3fcxx . . $ vcg/Point3f# p=dircxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).mapcxx . . $ CubeMapSamp#map.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce). Indexcxx . . $ CubeMapSamp#Index(9b79fb6aee4c0440).( x , y ) ] ];
81 Point3fcxx . . $ vcg/Point3f# q=(p+cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c).Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(1,1,1))/cxx . . $ vcg/Point3#`operator/`(19a42edf8b0c4f9d).2.0*cxx . . $ vcg/Point3#`operator*`(19a42edf8b0c4f9d).255.0;
82 t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).k++]= (Bytecxx . . $ Byte#)(q[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).0]*cr);
83 t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).k++]= (Bytecxx . . $ Byte#)(q[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).1]*cg);
84 t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).k++]= (Bytecxx . . $ Byte#)(q[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).2]*cb);
85
86
87 /*int shade=(int)(p*Point3d(0.8,0.6,0)*255.0);
88 if (shade<0) shade=-shade/2;
89 if (shade>255) shade=255;
90 t[k++]= shade;
91 t[k++]= shade;
92 t[k++]= shade;*/
93
94
95 /* float i=255.0*float(map[Index( x , y )])/(size*size*size);
96 t[k++]= (int)i;
97 t[k++]= (int)i;
98 t[k++]= (int)i;
99
100
101 int r=0, g=0, b=0;
102 if (y<size) r=255;
103 if (x<size) b=255; if (x>=size*2) g=255;
104 k=(x+(y)*s)*3;
105 t[k++]= t[k++]/2+r/2;
106 t[k++]= t[k++]/2+g/2;
107 t[k++]= t[k++]/2+b/2;
108 */
109
110 /*
111 int r=0, g=0, b=0;
112 if (y<size) r=255;
113 if (x<size) b=255; if (x>=size*2) g=255;
114 t[k++]= r;
115 t[k++]= g;
116 t[k++]= b;*/
117 // printf("%4d ",map[Index( x , y )]);
118 //printf("%3d ",shade);
119
120 }
121 //printf("\n");
122 }
123
124 }
125
126
127 static inline int Indexcxx . . $ CubeMapSamp#Index(9b79fb6aee4c0440).(int x, int y){
128 return x+y*sizecxx . . $ CubeMapSamp#size.*3;
129 }
130
131 static inline int Index3cxx . . $ CubeMapSamp#Index3(2326284602b0bb2d).(int x, int y, int z){
132 return x+y*sizecxx . . $ CubeMapSamp#size.+z*sizecxx . . $ CubeMapSamp#size.*sizecxx . . $ CubeMapSamp#size.;
133 }
134
135 static inline int Icxx . . $ CubeMapSamp#I(7864480464b09eea).(int x){
136 return sizecxx . . $ CubeMapSamp#size.-1-x;
137 }
138
139 void Zerocxx . . $ CubeMapSamp#Zero(49f6e7a06ebc5aa8).(){
140 int n=dircxx . . $ CubeMapSamp#dir..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).();
141 sumcxx . . $ CubeMapSamp#sum..resizecxx . . $ std/vector#resize(3804226c8c0acbc3).(n,0);
142 divcxx . . $ CubeMapSamp#div..resizecxx . . $ std/vector#resize(3804226c8c0acbc3).(n,0);
143 }
144
145 static void initMapcxx . . $ CubeMapSamp#initMap(49f6e7a06ebc5aa8).(){
146 mapcxx . . $ CubeMapSamp#map..resizecxx . . $ std/vector#resize(2c44cd906ae4e829).(sizecxx . . $ CubeMapSamp#size.*sizecxx . . $ CubeMapSamp#size.*6);
147 int dx=0;
148
149 int nsampl=sizecxx . . $ CubeMapSamp#size.*sizecxx . . $ CubeMapSamp#size.*sizecxx . . $ CubeMapSamp#size. - (sizecxx . . $ CubeMapSamp#size.-2)*(sizecxx . . $ CubeMapSamp#size.-2)*(sizecxx . . $ CubeMapSamp#size.-2);
150 dircxx . . $ CubeMapSamp#dir..resizecxx . . $ std/vector#resize(2c44cd906ae4e829).(nsampl);
151 dirrotcxx . . $ CubeMapSamp#dirrot..resizecxx . . $ std/vector#resize(2c44cd906ae4e829).(nsampl);
152
153 vectorcxx . . $ std/vector#<int> tmpmapcxx . . $ std/vector#vector(83fdeebbe0501a83).(sizecxx . . $ CubeMapSamp#size.*sizecxx . . $ CubeMapSamp#size.*sizecxx . . $ CubeMapSamp#size.);
154 int k=0;
155 for (int z=0; z<sizecxx . . $ CubeMapSamp#size.; z++)
156 for (int y=0; y<sizecxx . . $ CubeMapSamp#size.; y++)
157 for (int x=0; x<sizecxx . . $ CubeMapSamp#size.; x++) {
158 if ((x==0) || (y==0) || (z==0) ||
159 (x==sizecxx . . $ CubeMapSamp#size.-1) || (y==sizecxx . . $ CubeMapSamp#size.-1) || (z==sizecxx . . $ CubeMapSamp#size.-1) ) {
160
161 tmpmap[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce). Index3cxx . . $ CubeMapSamp#Index3(2326284602b0bb2d).(x,y,z) ] = k;
162 float h=(sizecxx . . $ CubeMapSamp#size.-1)*0.5;
163 dircxx . . $ CubeMapSamp#dir.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).k]=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(x-h,y-h,z-h);
164 dircxx . . $ CubeMapSamp#dir.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).k].Normalizecxx . . $ vcg/Point3#Normalize(f55c2490dff4ff58).();
165 k++;
166 }
167 }
168 dx=sizecxx . . $ CubeMapSamp#size.;
169 for (int x=0; x<sizecxx . . $ CubeMapSamp#size.; x++)
170 for (int y=0; y<sizecxx . . $ CubeMapSamp#size.; y++) {
171 mapcxx . . $ CubeMapSamp#map.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce). Indexcxx . . $ CubeMapSamp#Index(9b79fb6aee4c0440).( x +dx, y ) ] = tmpmap[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce). Index3cxx . . $ CubeMapSamp#Index3(2326284602b0bb2d).( x, y, sizecxx . . $ CubeMapSamp#size.-1) ];
172 mapcxx . . $ CubeMapSamp#map.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce). Indexcxx . . $ CubeMapSamp#Index(9b79fb6aee4c0440).( Icxx . . $ CubeMapSamp#I(7864480464b09eea).(x) +dx, Icxx . . $ CubeMapSamp#I(7864480464b09eea).(y)+sizecxx . . $ CubeMapSamp#size. ) ] = tmpmap[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce). Index3cxx . . $ CubeMapSamp#Index3(2326284602b0bb2d).( x, y, 0) ];
173 }
174
175 dx=0;
176 for (int y=0; y<sizecxx . . $ CubeMapSamp#size.; y++)
177 for (int z=0; z<sizecxx . . $ CubeMapSamp#size.; z++) {
178 mapcxx . . $ CubeMapSamp#map.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce). Indexcxx . . $ CubeMapSamp#Index(9b79fb6aee4c0440).( y+dx, z ) ] = tmpmap[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce). Index3cxx . . $ CubeMapSamp#Index3(2326284602b0bb2d).( sizecxx . . $ CubeMapSamp#size.-1, y, z) ];
179 mapcxx . . $ CubeMapSamp#map.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce). Indexcxx . . $ CubeMapSamp#Index(9b79fb6aee4c0440).( Icxx . . $ CubeMapSamp#I(7864480464b09eea).(y)+dx, Icxx . . $ CubeMapSamp#I(7864480464b09eea).(z)+sizecxx . . $ CubeMapSamp#size. ) ] = tmpmap[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce). Index3cxx . . $ CubeMapSamp#Index3(2326284602b0bb2d).( 0, y, z) ];
180 }
181
182 dx=sizecxx . . $ CubeMapSamp#size.*2;
183 for (int x=0; x<sizecxx . . $ CubeMapSamp#size.; x++)
184 for (int z=0; z<sizecxx . . $ CubeMapSamp#size.; z++) {
185 mapcxx . . $ CubeMapSamp#map.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce). Indexcxx . . $ CubeMapSamp#Index(9b79fb6aee4c0440).( z+dx, x ) ] = tmpmap[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce). Index3cxx . . $ CubeMapSamp#Index3(2326284602b0bb2d).( x, sizecxx . . $ CubeMapSamp#size.-1, z) ];
186 mapcxx . . $ CubeMapSamp#map.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce). Indexcxx . . $ CubeMapSamp#Index(9b79fb6aee4c0440).( Icxx . . $ CubeMapSamp#I(7864480464b09eea).(z)+dx, Icxx . . $ CubeMapSamp#I(7864480464b09eea).(x)+sizecxx . . $ CubeMapSamp#size.) ] = tmpmap[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce). Index3cxx . . $ CubeMapSamp#Index3(2326284602b0bb2d).( x, 0, z) ];
187 }
188
189 }
190
191 void Smoothcxx . . $ CubeMapSamp#Smooth(54e11277e2b28f45).(vectorcxx . . $ std/vector#<Bytecxx . . $ Byte#> &t, int s, int tx, int ty){
192 vectorcxx . . $ std/vector#<int> oldvaluecxx . . $ std/vector#vector(83fdeebbe0501a83).(sizecxx . . $ CubeMapSamp#size.*sizecxx . . $ CubeMapSamp#size.*6);
193 // copy old values
194 for (int y=0; y<sizecxx . . $ CubeMapSamp#size.*2; y++)
195 for (int x=0; x<sizecxx . . $ CubeMapSamp#size.*3; x++)
196 {
197 int k=(x+tx+(y+ty)*s)*3;
198 int i= Indexcxx . . $ CubeMapSamp#Index(9b79fb6aee4c0440).( x , y );
199 oldvalue[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]=t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).k];
200 }
201
202 int dy=sizecxx . . $ CubeMapSamp#size.*3, dx=1;
203 const int TH=-1;
204 // smooth old values
205 for (int y=0; y<sizecxx . . $ CubeMapSamp#size.*2; y++)
206 for (int x=0; x<sizecxx . . $ CubeMapSamp#size.*3; x++)
207 {
208 int i= Indexcxx . . $ CubeMapSamp#Index(9b79fb6aee4c0440).( x , y );
209 int sum=oldvalue[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i], div=1;
210 if ((y%sizecxx . . $ CubeMapSamp#size.)!=0) if (oldvalue[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i-dy]>TH) {
211 sum+=oldvalue[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i-dy];
212 div++;
213 }
214 if ((x%sizecxx . . $ CubeMapSamp#size.)!=0) if (oldvalue[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i-dx]>TH){
215 sum+=oldvalue[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i-dx];
216 div++;
217 }
218 if (((y+1)%sizecxx . . $ CubeMapSamp#size.)!=0) if (oldvalue[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i+dy]>TH){
219 sum+=oldvalue[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i+dy];
220 div++;
221 }
222 if (((x+1)%sizecxx . . $ CubeMapSamp#size.)!=0) if (oldvalue[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i+dy]>TH){
223 sum+=oldvalue[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i+dx];
224 div++;
225 }
226 sum/=div;
227 int k=(x+tx+(y+ty)*s)*3;
228 t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).k]=t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).k+1]=t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).k+2]=sum;
229 }
230
231 // merge texels
232 int nUnique=mapcxx . . $ CubeMapSamp#map..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).();
233 vectorcxx . . $ std/vector#<int> dupicxx . . $ std/vector#vector(229e4d6bd205de31).(nUnique, -1);
234 for (int y=0; y<sizecxx . . $ CubeMapSamp#size.*2; y++)
235 for (int x=0; x<sizecxx . . $ CubeMapSamp#size.*3; x++)
236 {
237 int k=(x+tx+(y+ty)*s)*3;
238 int i= mapcxx . . $ CubeMapSamp#map.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).Indexcxx . . $ CubeMapSamp#Index(9b79fb6aee4c0440).( x , y )];
239 if (dupi[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]<0) {
240 dupi[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]=k;
241 } else {
242 int a=dupi[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i];
243 t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).a+0]=t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).k+0]=(t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).a+0]+t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).k+0])/2;
244 t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).a+1]=t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).k+1]=(t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).a+0]+t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).k+0])/2;
245 t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).a+2]=t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).k+2]=(t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).a+0]+t[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).k+0])/2;
246 }
247 }
248
249 }
250
251 static void SetSizecxx . . $ CubeMapSamp#SetSize(d4f767463ce0a6b3).(int _size){
252 sizecxx . . $ CubeMapSamp#size.=_size;
253 initMapcxx . . $ CubeMapSamp#initMap(49f6e7a06ebc5aa8).();
254 }
255
256 CubeMapSampcxx . . $ CubeMapSamp#CubeMapSamp(49f6e7a06ebc5aa8).(){
257 }
258
259 };
260
261
262