Debian Codegraph @

src/CgUtil.h

raw symbols SCIP
1
2 class GeoSettings {
3 public:
4 typedef enum{ SPACE_FILL, BALL_N_STICKS, LICORICE } GeoMode;
5
6 GeoMode mode;
7
8 float stickRadius;
9 float licoRadius;
10
11 bool stick_smooth_color;
12 bool use_stick_const_color;
13 float stick_const_color_R,stick_const_color_G,stick_const_color_B;
14
15 bool showHetatm;
16
17 void SetDefaults(){
18 mode=SPACE_FILL;
19 //stickRadius=0.2;
20 SetLicoRadiusPercentage(50);
21 SetStickRadiusPercentage(100);
22 //licoRadius=0.6;
23
24 stick_smooth_color = false;
25 use_stick_const_color = false;
26 stick_const_color_R=0.75;
27 stick_const_color_G=0.50;
28 stick_const_color_B=0.50;
29
30 showHetatm = false;
31
32 }
33
34 void Rotate(){
35 mode=(GeoMode)((((int)mode)+1)%3);
36 }
37
38 GeoSettings() {
39 SetDefaults();
40 }
41
42 void Apply();
43 void ApplyColor();
44
45 void SetLicoRadiusPercentage(int percentage){
46 licoRadius = 0.3 + percentage/100.0*0.65;
47 }
48
49 int GetLicoRadiusPercentage(){
50 return int(100.0*((licoRadius - 0.3)/0.65));
51 }
52
53 void SetStickRadiusPercentage(int percentage){
54 const float tmp=0.32 * 0.85-0.16;
55 stickRadius = 0.16 + percentage/100.0*tmp;
56 }
57
58 int GetStickRadiusPercentage(){
59 const float tmp=0.32 * 0.85-0.16;
60 return int(100.0*((stickRadius - 0.16)/tmp));
61 }
62
63 };
64
65 // drawing settings
66 class CgUtil {
67 public:
68
69
70 // RENDERING PARAMETERS:
71 // Settarli a piacere e poi chiamare setShaders...
72 /////////////////////////////////////////////
73
74 /* SERIALIZE_BEGIN */
75
76 float P_light_base; // from 0 (dark) to 1 (bright)
77 float P_lighting; // from 0 (no lighting) to 1 (full lighting)
78 float P_phong; // from 0 (no phong lighting) to 1 (full lighting)
79 float P_phong_size; // from 0 (POW=100) to 1 (POW=1)
80
81 float P_col_atoms_sat; // base color: saturation
82 float P_col_atoms_bri; // base color: brightness
83
84 float P_texture; // FOR AO! from 0 (no AO) to 1 full AO
85 float P_border_inside; // size of antialiased borders inside, in % of atom
86 float P_border_outside; // borders outside (pure black), full size
87 float P_depth_full; // size of depth step for a full border
88
89 bool P_sem_effect;
90
91 float P_halo_size;
92 float P_halo_col;
93 float P_halo_str;
94 float P_halo_aware;
95
96 float P_fog;
97
98 bool P_capping; // capping
99 float P_shadowstrenght; // how much light
100
101 float P_bg_color_R;
102 float P_bg_color_G;
103 float P_bg_color_B;
104
105 bool auto_normalize;
106
107 bool P_double_shadows;
108
109 bool P_border_fixed;
110
111 /* SERIALIZE_END */
112
113 bool do_use_doubleshadow();
114 bool can_use_doubleshadow();
115 bool P_use_shadowmap() {return P_shadowstrenght>0; };
116
117 // Save and load the above
118 bool Load(const char* filename);
119 bool Save(const char* filename);
120
121 // Set
122 void Set();
123
124 // coming from GeoSettings
125 bool P_cyl_smooth_color;
126 bool P_cyl_const_color;
127 float P_cyl_const_color_R,P_cyl_const_color_G,P_cyl_const_color_B;
128
129 void setGeoSettings(const GeoSettings &gs);
130
131 // Error messages
132 static char lasterr[255];
133
134 enum { USE_OCTA, USE_CUBE } textmode; // textmode
135 enum { PERSPECTIVE, ORTHO } projmode; // projmode
136 bool proj_figa;
137
138 void SetDefaults(); // set defoult params
139 void SetForOffLine(); // set defoult params for an offscreen rendering
140 void SetForShadowMap(bool accurate);// set defoult params for an offscreen rendering
141 void MakeShaders(); // activates params
142 void UpdateShaders() {shadersMade=false;}; // activates params
143 void BindShaders(); // binds, loads if necessary
144
145 void MakeStickShaders();
146 void BindStickShaders();
147
148 bool BindDrawAOShader();
149 bool MakeDrawAOShader();
150
151 bool BindDrawAOShaderSticks();
152 bool MakeDrawAOShaderSticks();
153
154 bool UseHalo();
155
156 bool BindHaloShader(int powres); // 1^pow = size of halo texture
157 bool MakeHaloShader(int powres);
158
159 // questi sono settati automaticamente
160 /////////////////////////////////////
161 float gap; // gap, % of border texels to be skipped
162 int textureSideX,textureSideY;
163 bool writeAlpha; // true during probe rendering only
164 bool writeCol; // write a color at all?
165
166 static bool init();
167 static void ShowShaderInfo(int i);
168 static bool checkError();
169 static bool checkProgramError(char *st);
170 static bool shaderHasChanged;
171
172 float cyl_radius;
173
174 bool doingAlphaSnapshot; // lots of things change when doing an alpha snapshot
175
176 CgUtil();
177
178 void ResetHalo();
179
180 private:
181
182 enum {MAXPOW=15};
183
184 bool shadersMade;
185
186 float norm;
187 void Normalize();
188 void UndoNormalize();
189
190 bool setBallVertexProgram();
191 bool setBallFragmentProgram();
192
193 bool setStickVertexProgram();
194 bool setStickFragmentProgram();
195
196 /*static int loadVertexProgram(const char *str);
197 static int loadFragmentProgram(const char *str);*/
198
199 static char *readFile(const char *file);
200
201 bool loaded, loadedStick, loadedVertexHalo;
202 GLuint idf, idv, idfStick, idvStick;
203
204 bool loadedHalo[MAXPOW];
205 GLuint idfHalo[MAXPOW];
206 GLuint idvHalo;
207
208 void LoadVertexHaloShader();
209
210 void addDirectLightingSnippet(char* fp);
211 void addTexturingSnippet(char* fp);
212 void addShadowMapComputationFP(char* fp);
213 void addDepthAdjustSnippet(char* fp);
214
215 float _border_outside();
216 float _border_inside();
217
218 bool shadowmapBuilding;
219 bool accurateShadowmapBuilding;
220
221
222
223 };
224