summaryrefslogtreecommitdiff
path: root/cad/plugins/QuteMol/qutemol/src/Sampling.cpp
blob: 2fddc16259b26c48c021e5626b43a9291964052a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
typedef unsigned char Byte;

#include <GL/glew.h>
#include "CgUtil.h"

//#include <GL/gl.h>
#include <math.h>
//#include <GL/glu.h>

#include <vector>

#include <vcg/space/point3.h>
#include <vcg/space/color4.h>

using namespace vcg;
using namespace std;

#include "CubeMapSamp.h"
#include "OctaMapSamp.h"

int CubeMapSamp::size;
int OctaMapSamp::size;

vector<Point3f> CubeMapSamp::dir;
vector<Point3f> CubeMapSamp::dirrot;
vector<int> CubeMapSamp::map;   // mappa 2d di indici a dir
//vector<float> CubeMapSamp::weight;

vector<Point3f> OctaMapSamp::dir;
vector<Point3f> OctaMapSamp::dirrot;
vector<float> OctaMapSamp::weight;

void OctaMapSamp::FillTexture(vector<Byte> &texture, const vector<int> &sumtable, 
                   int texsize, float div, int tx, int ty )
{
    for (int y=0,k=0; y<size; y++) 
    for (int x=0; x<size; x++,k++) 
    {
      int h=(x+tx+(y+ty)*texsize);
      
      int res= (int) ( sumtable[h] * div /** weight[k]*/ );
      if (res>255) res=255;
      texture[h*3+0]= res;
      texture[h*3+1]= res;
      texture[h*3+2]= res; 
     /* if (res<512-275)  {
        texture[h*3+0]= 0;
        texture[h*3+1]= res;
        texture[h*3+2]= res; 
      } else if (res<254) {
        texture[h*3+0]= 0;
        texture[h*3+1]= 255;
        texture[h*3+2]= 0; 
      } else
      if (res>275)  {
      texture[h*3+0]= 255;
      texture[h*3+1]= res-255;
      texture[h*3+2]= res/2-255; } else {
        texture[h*3+0]= res;
       if (res>255) res=255;
       texture[h*3+1]= res;
      texture[h*3+2]= res; 
      }*/
    }
    
}