Computational Embodied Neuroscience Simulator  1.1
3D simulation library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
cens_engine.h
Go to the documentation of this file.
1 // Computational Embodied Neuroscience Simulator (CENS) Library
2 // Copyright (c) 2010 Francesco Mannella
3 //
4 // cens_engine.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_ENGINE_H
23 #define CENS_ENGINE_H
24 
25 #include <iostream>
26 
27 #include "cens_physics.h"
28 #include "cens_graphics.h"
29 #include "cens_types.h"
30 
31 
32 
36 namespace cens
37 {
38 
40 
42  // Eigen - bt convertions ///////////////////////
44 
46  Eigen::Vector3f btVec2eigen(const btVector3& v);
47 
49  btVector3 eigen2btVec(const Eigen::Vector3f& v);
50 
52  btMatrix3x3 eigen2btMat(const Eigen::Matrix3f& v);
53 
55  Eigen::Matrix3f btMat2eigen(const btMatrix3x3& v);
56 
57 
59  typedef std::map< btCollisionObject *, CENSGraphicsShape * > CENSShapes;
60 
63 
104  class CENSEngine: public CENSPhysics, public CENSGraphics
105  {
106  public:
107 
108  CENSEngine();
109 
110  virtual ~CENSEngine();
111 
113  virtual void init(
114  int argc,
115  char **argv );
116 
117  virtual void initObjects() {};
118 
119  virtual void display();
120 
121  virtual void step(int value );
122 
124  virtual void run();
125 
127  virtual void stepRun();
128 
145  btRigidBody* localCreateRigidBody(
146  float mass,
147  const btTransform& startTransform,
148  btCollisionShape* shape,
149  const btVector3 &color = eigen2btVec(CENS_NULL_COLOR),
150  const TexCoords &texCoords = CENS_NULL_TEXCOORDS,
151  CENSPixelMap &pixmap = CENS_NULL_PIXMAP );
152 
163  btRigidBody* localImportRigidBody(
164  btRigidBody* body,
165  const btVector3 &color = eigen2btVec(CENS_NULL_COLOR),
166  const TexCoords &texCoords = CENS_NULL_TEXCOORDS,
167  CENSPixelMap &pixmap = CENS_NULL_PIXMAP );
168 
183  btSoftBody* localCreateSoftBody(
184  float mass,
185  btCollisionShape* shape,
186  const btVector3 &color = eigen2btVec(CENS_NULL_COLOR),
187  const TexCoords &texCoords = CENS_NULL_TEXCOORDS,
188  CENSPixelMap &pixmap = CENS_NULL_PIXMAP );
189 
200  btSoftBody* localLinkSoftBody(
201  btSoftBody* body,
202  const btVector3 &color = eigen2btVec(CENS_NULL_COLOR),
203  const TexCoords &texCoords = CENS_NULL_TEXCOORDS,
204  CENSPixelMap &pixmap = CENS_NULL_PIXMAP );
205 
206 
208  virtual int attachCamera(
209  btRigidBody *body,
210  btTransform local_transform,
211  std::string screenTitle,
212  int screenWidth,
213  int screenHeight,
214  int screenXGap,
215  int screenYGap,
216  btVector3 up,
217  float target,
218  float foV=70.0,
219  float near=1.0,
220  float far=10000
221  );
222  protected:
223 
231  {
232 
234  int m_bcIdx;
236  btRigidBody *m_bcBody;
238  btTransform m_bcLocal_transform;
240  btVector3 m_bcOrigin;
242  btVector3 m_bcTarget;
244  btVector3 m_bcUp;
245  };
246 
248  CENSShapes m_eShapes;
249 
251  std::vector<CENSBodyCameraData> m_eAttachedCameras;
252 
254  virtual void syncAttachedCamera(
255  int index
256  );
257 
258  };
259 
260 }
261 
262 #endif // CENS_ENGINE_H
263 
Initializing and manipulating physics objects.
Definition: cens_engine.h:104
btMatrix3x3 eigen2btMat(const Eigen::Matrix3f &v)
Computational Embodied Neuroscience Simulator library.
Definition: cens_engine.cpp:29
btSoftBody * localCreateSoftBody(float mass, btCollisionShape *shape, const btVector3 &color=eigen2btVec(CENS_NULL_COLOR), const TexCoords &texCoords=CENS_NULL_TEXCOORDS, CENSPixelMap &pixmap=CENS_NULL_PIXMAP)
A C++ wrapper for OpenGL.
Definition: cens_graphics.h:77
btRigidBody * localImportRigidBody(btRigidBody *body, const btVector3 &color=eigen2btVec(CENS_NULL_COLOR), const TexCoords &texCoords=CENS_NULL_TEXCOORDS, CENSPixelMap &pixmap=CENS_NULL_PIXMAP)
CENSPixelMap CENS_NULL_PIXMAP
Definition: cens_types.cpp:29
std::map< btCollisionObject *, CENSGraphicsShape * > CENSShapes
Definition: cens_engine.h:59
An interface to the bullet physics library.
Definition: cens_physics.h:203
std::vector< Vector2f > TexCoords
Definition: cens_types.h:44
virtual void syncAttachedCamera(int index)
btSoftBody * localLinkSoftBody(btSoftBody *body, const btVector3 &color=eigen2btVec(CENS_NULL_COLOR), const TexCoords &texCoords=CENS_NULL_TEXCOORDS, CENSPixelMap &pixmap=CENS_NULL_PIXMAP)
virtual void stepRun()
Definition: cens_engine.cpp:83
Eigen::Matrix3f btMat2eigen(const btMatrix3x3 &v)
virtual void run()
Definition: cens_engine.cpp:76
btVector3 eigen2btVec(const Eigen::Vector3f &v)
virtual void step(int value)
Definition: cens_engine.cpp:63
virtual void init(int argc, char **argv)
Definition: cens_engine.cpp:43
Use a byte vector as a matrix.
Definition: cens_pixelmap.h:40
virtual void initObjects()
Definition: cens_engine.h:117
btRigidBody * localCreateRigidBody(float mass, const btTransform &startTransform, btCollisionShape *shape, const btVector3 &color=eigen2btVec(CENS_NULL_COLOR), const TexCoords &texCoords=CENS_NULL_TEXCOORDS, CENSPixelMap &pixmap=CENS_NULL_PIXMAP)
Parameters for the body-camera link.
Definition: cens_engine.h:230
virtual ~CENSEngine()
Definition: cens_engine.cpp:57
Eigen::Vector3f btVec2eigen(const btVector3 &v)
std::vector< CENSBodyCameraData > m_eAttachedCameras
Definition: cens_engine.h:251
CENSShapes m_eShapes
Definition: cens_engine.h:248
virtual void display()
Definition: cens_engine.cpp:91
Vector3f CENS_NULL_COLOR
Definition: cens_types.cpp:26
TexCoords CENS_NULL_TEXCOORDS
Definition: cens_types.cpp:28
virtual int attachCamera(btRigidBody *body, btTransform local_transform, std::string screenTitle, int screenWidth, int screenHeight, int screenXGap, int screenYGap, btVector3 up, float target, float foV=70.0, float near=1.0, float far=10000)