Allink  v0.1
Draw.h
1 #ifndef DISEGNA_H
2 #define DISEGNA_H
3 
4 #include "../include/Matematica.h"
5 #ifdef USE_GL
6 
7 #include <GL/glut.h>
8 
9 
10 #if !defined(GLUT_WHEEL_UP)
11 # define GLUT_WHEEL_UP 3
12 # define GLUT_WHEEL_DOWN 4
13 #endif
14 
15 class Draw{
16  private:
18  int pr;//prospettiva
20  int IfShift;
22  void Expand(void);
24  void spinDisplay(void);
26  void Illuminazione(void);
28  void init (void);
30  void Spot(void);
32  void Nebbia(void);
34  void processEvent(int value);
36  void ChangeSize(GLsizei w,GLsizei h);
38  void Shout(const char *s, ... );
39  //Matematica *Mat;
41  int BlendSource;
43  int BlendDest;
44  public:
45  //Draw(int argc,char** argv);
46  Draw();
48  void Draw1(void);
50  void DMinimal(void);
52  void DrTriangles(int NPoint);
54  void ShowImage();
56  void Window(int argc,char **argv);
58  void DFigure(void);
60  void DTimer(int v);
62  void Dreshape(int w,int h);
64  int ApplyTexture();
66  int ShowTexture();
68  void Transform();
70  void DrCube();
72  void ChooseBlend(int Which);
74  void PutString(double *Pos,char *String);
76  void PutString(double Posx,double Posy,double Posz,char *String);
78  void Numera(double *Pos,int n);
79  //------------Definition.cpp-------------
81  void Lista(int NSquare);
83  int DefPoint();
85  int DefCube(int NSquare);
87  int DefQuad(int NSquare);
89  int DefCylinder(double Rad,double Height);
91  int DefMetalCylinder(double Rad,double Height);
93  int DefHexagon();
95  int DefGriglia();
97  int DefWall();
99  int DefArrow();
101  int DefArrowThin();
103  int DefTexture();
105  void InitConstant();
107  double Normal(double *v,double *u,double *w,double *n);
109  typedef void(Draw::*DEPTH_MAP)(double Val,GLfloat *Color);
113  void DepthMap(double Val,GLfloat *Color){(*this.*Depth_Map)(Val,Color);}
115  void DepthMap1(double Val,GLfloat *Color);
117  void ChooseDepthMap(int n);
119  int DefLegend();
120  //-------------Control.cpp
122  void Dmouse(int button, int state,int x,int y);
124  void DMouseMove(int x,int y);
126  void Dspecial(int k, int x, int y);
128  void keyboardDraw(unsigned char key);
130  void CameraQuat();
132  void ChangeSuGiu(GLfloat Movement);
134  void ChangeDxSx(GLfloat Movement);
135  //----------File.cpp-------------
137  void abort_(const char * s, ...);
139  int Picture();
141  int WritePixel();
143  int WritePng();
145  int WritePngwriter();
147  int OpenImage(const char *FileName);
149  void ReadScript();
151  void ReadConf();
153  int ImWidth,ImHeight;
155  GLfloat spin,angolo, dspin,
157  xa, ya, za,
159  xf, yf, zf,
161  xp, yp, zp, zw,
163  xi, yi, zi,
165  xLeg, yLeg, zLeg,
167  dxLeg, dyLeg,
169  xl0, yl0, zl0,
171  xl1, yl1, zl1,
173  scale, dscale,tscale,
175  Rback, Gback,Bback,Aback;
177  GLfloat IncrVisDxSx, IncrVisSuGiu;
179  GLfloat AngleDxSx, AngleSuGiu;
181  double InvScaleUn;
183  double GridStep;//Griglia
185  GLuint Hexagon;
187  GLuint DrLegend;
189  GLuint Griglia;
191  GLuint Quad;
193  GLuint Point;
195  GLuint Cylinder;
200  GLuint Particles;
202  GLuint ScriptList;
204  GLuint GlWall;
206  GLuint Arrow;
208  GLuint Cube;
210  GLuint Texture;
212  GLuint XCenter;
214  GLuint YCenter;
216  int la;
218  int gr;
220  int lu;
222  int sp;
224  int ne;
226  int MainWindow,SubWindow1,SubWindow2;
228  int Diap,tDiap,tDiapBase;
230  int IfPoint;//point or Sphere
232  int IfInfo;
234  int IfScript;
236  int IfImage;
238  int IfBlend;
242  int Values;
244  int Step;
246  int WinWidth;
250  int xRem;
252  int yRem;
256  int NLevel;
258  float Diameter,StepDiameter;
260  float NanoRad,ExtraDiam;
262  double Edge[3];
264  int GridEdge[3];
266  double ExtRad;
268  double ExtHeight;
270  GLubyte *pixel;
272  char *Number;
274  char *frame;
276  char *info;
277 };
278 
279 extern void keyboard(unsigned char key,int x, int y);
280 extern void MenuChoise(int option);
281 extern void MenuVisual(int option);
282 extern void ParticleList(void);
283 extern void ParticleRealTime();
284 extern void Figure();
285 extern void Figure1();
286 extern void Timer(int v);
287 extern void reshape(int w,int h);
288 extern void mouse(int button, int state,int x,int y);
289 extern void MouseMove(int x,int y);
290 extern void special(int k, int x, int y);
291 extern void DefCylinder(GLuint Cylinder,double CyEdge,double CyHeight,double InvScaleUn);
292 static const GLfloat DrAmbientWhite [] = {0.25, 0.25, 0.25, 1.00};
293 static const GLfloat DrAmbientRed [] = {0.25, 0.00, 0.00, 1.00};
294 static const GLfloat DrAmbientGreen [] = {0.00, 0.25, 0.00, 1.00};
295 static const GLfloat DrAmbientBlue [] = {0.00, 0.00, 0.25, 1.00};
296 static const GLfloat DrDiffuseWhite [] = {0.75, 0.75, 0.75, 1.00};
297 static const GLfloat DrDiffuseRed [] = {0.75, 0.00, 0.00, 1.00};
298 static const GLfloat DrDiffuseGreen [] = {0.00, 0.75, 0.00, 1.00};
299 static const GLfloat DrDiffuseBlue [] = {0.00, 0.00, 0.75, 1.00};
300 static const GLfloat DrSpecularWhite[] = {1.00, 1.00, 1.00, 1.00};
301 static const GLfloat DrSpecularRed [] = {1.00, 0.25, 0.25, 1.00};
302 static const GLfloat DrSpecularGreen[] = {0.25, 1.00, 0.25, 1.00};
303 static const GLfloat DrSpecularBlue [] = {0.25, 0.25, 1.00, 1.00};
304 #endif//USE_GL
305 #endif//DISEGNA_H
306 static float ColorType[12][4] =
307  { {0.,.7,0.,1.},
308  {0.,.0,.7,1.},
309  {.7,.0,.0,1.},
310  {.4,.1,.7,1.},
311  {.4,.5,.0,1.},
312  {.7,.3,.3,1.},
313  {0.,.4,.3,1.},
314  {0.,.0,.5,1.},
315  {.0,.2,.5,1.},
316  {.0,.4,.7,1.},
317  {.7,.1,.4,1.},
318  {.4,.7,.2,1.}};
void DepthMap1(double Val, GLfloat *Color)
Depth map.
GLfloat xp
Translation, wheel.
Definition: Draw.h:155
int GridEdge[3]
Number of lines per edge.
Definition: Draw.h:264
double InvScaleUn
Rescale the three orthogonal directions.
Definition: Draw.h:181
void DMouseMove(int x, int y)
How the scene rotate (Camera view should be implemented)
Definition: DrawControl.cpp:63
void ChangeDxSx(GLfloat Movement)
Movement right left.
Definition: DrawControl.cpp:15
int IfInfo
Removes the info line.
Definition: Draw.h:232
GLuint Hexagon
Refers to the list of a hexagon.
Definition: Draw.h:185
void Dreshape(int w, int h)
Principal reshape function.
Definition: Draw.cpp:237
int DefGriglia()
Griglia.
GLfloat IncrVisDxSx
Increment visual DxSx, SuGiu.
Definition: Draw.h:177
int DefMetalCylinder(double Rad, double Height)
Metallic cylinder.
Draw provides the basic configuration of the openGL libraries used in every derived program...
Definition: Draw.h:15
double Normal(double *v, double *u, double *w, double *n)
Calculate the normal.
void ReadScript()
Reads and draw a script file.
Definition: DrawFile.cpp:285
int ne
Enables/disables fog.
Definition: Draw.h:224
void DrTriangles(int NPoint)
Boh.
Definition: DrawScene.cpp:191
void DMinimal(void)
A empty scene (only the list)
Definition: DrawScene.cpp:15
int Diap
Number of frames.
Definition: Draw.h:228
void DFigure(void)
Definition of the scene on which the objects will be drawn.
Definition: DrawScene.cpp:35
int ApplyTexture()
Apply the texture to a square.
Definition: DrawScene.cpp:217
GLuint Arrow
Refers to the list of a arrow.
Definition: Draw.h:206
GLuint DrLegend
Refers to the list of the legend.
Definition: Draw.h:187
int DefCube(int NSquare)
Cube.
GLfloat Rback
Background color.
Definition: Draw.h:155
int WritePngwriter()
Write a png file of the data in pixel (uses libpngwriter)
Definition: DrawFile.cpp:277
GLuint XCenter
Center of the frame.
Definition: Draw.h:212
void Dspecial(int k, int x, int y)
Boh.
int sp
Enables/disables spot light.
Definition: Draw.h:222
void DepthMap(double Val, GLfloat *Color)
Pointer to a generic function.
Definition: Draw.h:113
GLfloat spin
Obsolete.
Definition: Draw.h:155
GLfloat xl1
Position of the light1.
Definition: Draw.h:155
char * frame
Boh.
Definition: Draw.h:274
int Picture()
Write a tiff file of the data in pixel.
Definition: DrawFile.cpp:183
int Values
Number of values to divide the edge in squares.
Definition: Draw.h:242
int WinHeight
Height of the window.
Definition: Draw.h:248
int gr
Puts/removes the grid.
Definition: Draw.h:218
int DefQuad(int NSquare)
Quad.
GLuint YCenter
Center of the frame.
Definition: Draw.h:214
void(Draw::* DEPTH_MAP)(double Val, GLfloat *Color)
Data type for distance/field functions.
Definition: Draw.h:109
int ChangeMouse
Boh.
Definition: Draw.h:254
void keyboardDraw(unsigned char key)
Combines the key with the functions.
int ImWidth
Width and height of the image.
Definition: Draw.h:153
GLuint GlWall
Refers to the list of a wall.
Definition: Draw.h:204
int MainWindow
Refers to optional different windows.
Definition: Draw.h:226
void DTimer(int v)
Not working.
Definition: Draw.cpp:144
void ChooseDepthMap(int n)
Choose Depth map.
int IfImage
Boh.
Definition: Draw.h:236
GLuint Point
Refers to the list of the point.
Definition: Draw.h:193
GLuint Quad
Refers to the list of the square.
Definition: Draw.h:191
int la
Puts/removes the box edges.
Definition: Draw.h:216
int DefCylinder(double Rad, double Height)
Cylinder.
void InitConstant()
Initializes all the view constants.
int OpenImage(const char *FileName)
Open a image to be store in pixel.
Definition: DrawFile.cpp:180
GLuint Griglia
Refers to the list of the grid.
Definition: Draw.h:189
DEPTH_MAP Depth_Map
Pointer to a distance/field function.
Definition: Draw.h:111
int IfMaterial
Activate the illumination for a specific material.
Definition: Draw.h:240
float NanoRad
Obsolete.
Definition: Draw.h:260
void CameraQuat()
Quaternion camera implementation.
Definition: DrawControl.cpp:4
GLuint Cube
Refers to the list of the texture.
Definition: Draw.h:208
void DrCube()
Line in a cube.
Definition: DrawScene.cpp:431
GLuint ScriptList
Refers to the list of the objects called by the script file.
Definition: Draw.h:202
int IfPoint
Decides to draw points or spheres.
Definition: Draw.h:230
int DefArrow()
Arrow.
GLfloat AngleDxSx
Angle DxSx, SuGiu.
Definition: Draw.h:179
int DefWall()
Wall.
GLuint Particles
Refers to the list of the total position of the particles which will be generated in another program...
Definition: Draw.h:200
int DefHexagon()
Hexagon.
int ShowTexture()
Call the texture in the scene.
Definition: DrawScene.cpp:232
void Draw1(void)
A scene for debugging.
Definition: DrawScene.cpp:122
void Transform()
Transform the system coordinates.
Definition: DrawScene.cpp:244
double ExtRad
Cylinder radius.
Definition: Draw.h:266
GLfloat xl0
Position of the light0.
Definition: Draw.h:155
int yRem
Old y position of the mouse.
Definition: Draw.h:252
void Lista(int NSquare)
Definition of the primitives.
GLfloat xLeg
Position of the legend.
Definition: Draw.h:155
int WritePng()
Write a png file of the data in pixel (not working)
Definition: DrawFile.cpp:280
GLfloat scale
Obsolete.
Definition: Draw.h:155
void abort_(const char *s,...)
Check.
GLuint MetalCylinder
Refers to the list of another cylinder (obsolete)
Definition: Draw.h:197
int Step
Current step for the picture&#39;s name.
Definition: Draw.h:244
int DefTexture()
Define a simple texture.
GLfloat xa
Angles.
Definition: Draw.h:155
int DefArrowThin()
Arrow.
GLfloat xf
Orientation of the light.
Definition: Draw.h:155
int IfScript
Ignores the script file.
Definition: Draw.h:234
int IfBlend
Activate the blending.
Definition: Draw.h:238
double ExtHeight
Cylinder height.
Definition: Draw.h:268
GLfloat dxLeg
Width of the legend.
Definition: Draw.h:155
GLfloat xi
Position of the info string.
Definition: Draw.h:155
double Edge[3]
Box size.
Definition: Draw.h:262
GLuint Texture
Refers to the list of the texture.
Definition: Draw.h:210
int xRem
Old x position of the mouse.
Definition: Draw.h:250
void ShowImage()
Displays the data stored in pixel.
Definition: DrawScene.cpp:211
int DefPoint()
Point.
void ChooseBlend(int Which)
Choose a different blending function.
char * info
Info line.
Definition: Draw.h:276
float Diameter
Obsolete.
Definition: Draw.h:258
void Window(int argc, char **argv)
Initial definition of the window.
Definition: Draw.cpp:108
int WritePixel()
Boh.
Definition: DrawFile.cpp:186
int WinWidth
Width of the window.
Definition: Draw.h:246
void PutString(double *Pos, char *String)
Put a string.
Definition: DrawScene.cpp:439
GLuint Cylinder
Refers to the list of the cylinder.
Definition: Draw.h:195
char * Number
Characters for the grid.
Definition: Draw.h:272
int NLevel
Levels of the images data (usually 4=RGBA)
Definition: Draw.h:256
void Numera(double *Pos, int n)
Print the.
Definition: Draw.cpp:304
int lu
Enables/disables illumination.
Definition: Draw.h:220
GLubyte * pixel
Principal image (always allocated)
Definition: Draw.h:270
void Dmouse(int button, int state, int x, int y)
To launch the menu.
Definition: DrawControl.cpp:86
int DefLegend()
Depth map.
void ReadConf()
Reads and applies external configurations.
Definition: DrawFile.cpp:6
void ChangeSuGiu(GLfloat Movement)
Movement up-down.
Definition: DrawControl.cpp:30
double GridStep
Finess of the grid.
Definition: Draw.h:183