Tulip  5.1.0
Large graphs analysis and drawing
GlSphere.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 
20 #ifndef Tulip_GLSPHERE_H
21 #define Tulip_GLSPHERE_H
22 
23 #include <tulip/tulipconf.h>
24 
25 #include <tulip/Coord.h>
26 #include <tulip/Color.h>
27 
28 #include <tulip/GlSimpleEntity.h>
29 
30 namespace tlp {
31 
32 /**
33  * @ingroup OpenGL
34  * @brief Class to create a sphere with GlEntity system
35  */
36 class TLP_GL_SCOPE GlSphere : public GlSimpleEntity {
37 
38 public:
39 
40  /**
41  * @brief Constructor
42  *
43  * @warning Don't use this constructor
44  */
45  GlSphere() {}
46 
47  ~GlSphere();
48 
49  /**
50  * @brief Create a sphere with a position, a radius a fill color and multiple rotation (if you want)
51  */
52  GlSphere(const Coord &position,float radius,const Color &color=Color(0,0,0,255),float rotX=0,float rotY=0,float rotZ=0);
53 
54  /**
55  * @brief Create a sphere with a position, a radius, a texture, an alphe and multiple rotation (if you want)
56  */
57  GlSphere(const Coord &position,float radius,const std::string& textureFile,int alpha=255,float rotX=0,float rotY=0,float rotZ=0);
58 
59  /**
60  * @brief Draw the sphere
61  */
62  virtual void draw(float lod,Camera *camera);
63 
64  /**
65  * @brief Translate entity
66  */
67  virtual void translate(const Coord& mouvement);
68 
69  /**
70  * @brief Get absolute position
71  */
72  const Coord& getPosition() const {
73  return position;
74  }
75 
76  /**
77  * @brief Set absolute position
78  */
79  void setPosition(const Coord& pos) {
80  position = pos;
81  }
82 
83  /**
84  * @brief Set the texture name
85  */
86  virtual void setTexture(const std::string &texture) {
87  textureFile=texture;
88  }
89 
90  /**
91  * @brief Get the color
92  */
93  const Color& getColor() const {
94  return color;
95  }
96 
97  /**
98  * @brief Set the color
99  */
100  void setColor(const Color &newColor) {
101  color = newColor;
102  }
103 
104  /**
105  * @brief Function to export data in outString (in XML format)
106  */
107  virtual void getXML(std::string &outString);
108 
109  /**
110  * @brief Function to set data with inString (in XML format)
111  */
112  virtual void setWithXML(const std::string &inString, unsigned int &currentPosition);
113 
114 private:
115 
116  void generateBuffers(int space);
117 
118  Coord position;
119  float radius;
120  Color color;
121  std::string textureFile;
122  Coord rot;
123 
124  std::vector<unsigned int > buffers;
125  std::vector<float> vertices;
126  std::vector<float> texturesCoord;
127  std::vector<unsigned short> indices;
128  unsigned int verticesCount;
129 
130 };
131 
132 
133 }
134 
135 #endif // Tulip_GLSCENE_H
Base class for all Tulip OpenGL entities.
GlSphere()
Constructor.
Definition: GlSphere.h:45
void setColor(const Color &newColor)
Set the color.
Definition: GlSphere.h:100
virtual void setTexture(const std::string &texture)
Set the texture name.
Definition: GlSphere.h:86
void setPosition(const Coord &pos)
Set absolute position.
Definition: GlSphere.h:79
Tulip OpenGL camera object.
Definition: Camera.h:45
const Color & getColor() const
Get the color.
Definition: GlSphere.h:93
Class to create a sphere with GlEntity system.
Definition: GlSphere.h:36
const Coord & getPosition() const
Get absolute position.
Definition: GlSphere.h:72