Computational Embodied Neuroscience Simulator  1.1
3D simulation library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
cens_graphics_shape.h
Go to the documentation of this file.
1 // Computational Embodied Neuroscience Simulator (CENS) Library
2 // Copyright (c) 2010 Francesco Mannella
3 //
4 // cens_graphics_shape.h
5 // Copyright (c) 2010 Francesco Mannella
6 //
7 // This file is part of CENS library.
8 //
9 // CENS library is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 3 of the License, or
12 // (at your option) any later version.
13 //
14 // CENS library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with CENS library. If not, see <http://www.gnu.org/licenses/>.
21 
22 #ifndef CENS_GRAPHICS_SHAPE_H
23 #define CENS_GRAPHICS_SHAPE_H
24 
25 #include <vector>
26 
27 // linear algebra
28 #include <Eigen/Core>
29 #include <Eigen/Geometry>
30 
31 
32 using namespace Eigen;
33 
34 // OpenGL
35 #include <GL/glut.h>
36 #include <GL/freeglut.h>
37 
38 #include "cens_pixelmap.h"
39 #include "cens_types.h"
40 
41 
42 namespace cens {
43 
51  {
52 
53  public:
54 
56  {
57  m_gsType = GS_NULL;
58  m_gsColor = Vector3f(0,0,0);
59  m_gsTexture = 0;
60  m_gsTextureImage = 0;
61  m_gsTextureWidth = 0;
62  m_gsTextureHeight = 0;
63  };
64 
66  {
67  m_gsType = copy.m_gsType;
68  m_gsColor = copy.m_gsColor;
69  m_gsVertices = copy.m_gsVertices;
70  m_gsTexture = copy.m_gsTexture;
71  m_gsTextureWidth = copy.m_gsTextureWidth;
72  m_gsTextureHeight = copy.m_gsTextureHeight;
73  copyimage(copy.m_gsTextureImage);
74  }
75 
77 
87  void buildAsPlane(
88  const Vector3f &orig,
89  const Vector3f &v1,
90  const Vector3f &v2,
91  const Vector3f &color = CENS_NULL_COLOR,
92  CENSPixelMap pixmap = CENS_NULL_PIXMAP );
100  void buildAsBox(
101  const Vector3f &halfExtents,
102  const Vector3f &color = CENS_NULL_COLOR,
103  CENSPixelMap pixmap = CENS_NULL_PIXMAP );
111  void buildAsSphere(
112  float radius,
113  const Vector3f &color = CENS_NULL_COLOR,
114  CENSPixelMap pixmap = CENS_NULL_PIXMAP);
131  void buildAsConvex(
132  const Vertices &vertices,
133  const unsigned int *idx,
134  int nvtxs,
135  int nidxs,
136  int ntrns,
137  const TexCoords &texCoords = CENS_NULL_TEXCOORDS,
138  const Vector3f &color = CENS_NULL_COLOR,
139  CENSPixelMap pixmap = CENS_NULL_PIXMAP );
149  void buildAsSoft(
150  int numTriangles,
151  const TexCoords &texCoords = CENS_NULL_TEXCOORDS,
152  const Vector3f &color = CENS_NULL_COLOR,
153  CENSPixelMap pixmap = CENS_NULL_PIXMAP );
160  void draw(
161  const Vector3f &org,
162  const Matrix3f &rot);
166  void drawSoft();
173  void copyimage(const GLubyte *source);
177  void setTexture();
181  void initTexture();
187  int getType();
191  const Vector3f &getColor();
195  Vertices & getVertices();
200  Vector3f &getVertex(int vertex_index);
204  Vertices & getNormals();
209  Vector3f &getNormal(int normal_index);
214  TexCoords & getTexCoords();
220  Vector2f &getTexCoord(int texCoord_index);
227  void setType(int type);
231  void setColor(const Vector3f &color);
235  void setVertices(const Vertices &vertices);
239  void addVertex(const Vector3f &vertex);
243  void setNormals(const Vertices &normals);
244  void addNormal(const Vector3f &normal);
249  void setTexCoords(const TexCoords &texCoords);
254  void addTexCoord(const Vector2f &texCoord);
255 
256  private:
257 
258  int m_gsType;
259  Vector3f m_gsColor;
263  GLuint m_gsTexture;
267 
268  };
269 
270 }
271 
272 
273 #endif //CENS_GRAPHICS_SHAPE_H
CENSGraphicsShape(const CENSGraphicsShape &copy)
Computational Embodied Neuroscience Simulator library.
Definition: cens_engine.cpp:29
std::vector< Vector3f > Vertices
Definition: cens_types.h:43
CENSPixelMap CENS_NULL_PIXMAP
Definition: cens_types.cpp:29
Graphic processing of an object.
std::vector< Vector2f > TexCoords
Definition: cens_types.h:44
Use a byte vector as a matrix.
Definition: cens_pixelmap.h:40
Vector3f CENS_NULL_COLOR
Definition: cens_types.cpp:26
TexCoords CENS_NULL_TEXCOORDS
Definition: cens_types.cpp:28