| 1 | typedef unsigned char Byte; |
| 2 | |
| 3 | #include <GL/glew.h> |
| 4 | #include "CgUtil.h" |
| 5 | |
| 6 | //#include <GL/gl.h> |
| 7 | #include <math.h> |
| 8 | //#include <GL/glu.h> |
| 9 | |
| 10 | #include <vector> |
| 11 | |
| 12 | #include <vcg/space/point3.h> |
| 13 | #include <vcg/space/color4.h> |
| 14 | |
| 15 | using namespace vcg; |
| 16 | using namespace std; |
| 17 | |
| 18 | #include "CubeMapSamp.h" |
| 19 | #include "OctaMapSamp.h" |
| 20 | |
| 21 | int CubeMapSamp::size; |
| 22 | int OctaMapSamp::size; |
| 23 | |
| 24 | vector<Point3f> CubeMapSamp::dir; |
| 25 | vector<Point3f> CubeMapSamp::dirrot; |
| 26 | vector<int> CubeMapSamp::map; // mappa 2d di indici a dir |
| 27 | //vector<float> CubeMapSamp::weight; |
| 28 | |
| 29 | vector<Point3f> OctaMapSamp::dir; |
| 30 | vector<Point3f> OctaMapSamp::dirrot; |
| 31 | vector<float> OctaMapSamp::weight; |
| 32 | |
| 33 | void OctaMapSamp::FillTexture(vector<Byte> &texture, const vector<int> &sumtable, |
| 34 | int texsize, float div, int tx, int ty ) |
| 35 | { |
| 36 | for (int y=0,k=0; y<size; y++) |
| 37 | for (int x=0; x<size; x++,k++) |
| 38 | { |
| 39 | int h=(x+tx+(y+ty)*texsize); |
| 40 | |
| 41 | int res= (int) ( sumtable[h] * div /** weight[k]*/ ); |
| 42 | if (res>255) res=255; |
| 43 | texture[h*3+0]= res; |
| 44 | texture[h*3+1]= res; |
| 45 | texture[h*3+2]= res; |
| 46 | /* if (res<512-275) { |
| 47 | texture[h*3+0]= 0; |
| 48 | texture[h*3+1]= res; |
| 49 | texture[h*3+2]= res; |
| 50 | } else if (res<254) { |
| 51 | texture[h*3+0]= 0; |
| 52 | texture[h*3+1]= 255; |
| 53 | texture[h*3+2]= 0; |
| 54 | } else |
| 55 | if (res>275) { |
| 56 | texture[h*3+0]= 255; |
| 57 | texture[h*3+1]= res-255; |
| 58 | texture[h*3+2]= res/2-255; } else { |
| 59 | texture[h*3+0]= res; |
| 60 | if (res>255) res=255; |
| 61 | texture[h*3+1]= res; |
| 62 | texture[h*3+2]= res; |
| 63 | }*/ |
| 64 | } |
| 65 | |
| 66 | } |