Computational Embodied Neuroscience Simulator  1.1
3D simulation library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
cens_engine.cpp
Go to the documentation of this file.
1 // Computational Embodied Neuroscience Simulator (CENS) Library
2 // Copyright (c) 2010 Francesco Mannella
3 //
4 // cens_engine.cpp
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 #include "cens_utils.h"
23 #include "cens_engine.h"
24 #include <vector>
25 #include <map>
26 #include <string>
27 #include <sstream>
28 
29 namespace cens
30 {
31 
34 
36  {
37  cens_graphics = this;
38  }
39 
42 
43  void CENSEngine::init( int argc, char **argv )
44  {
45 
46  initCENSGraphics(argc, argv );
47  initObjects();
48  for(unsigned int x=0; x<m_grCameras.size(); x++) {
49  focusCamera(x);
50  initTextures();
51  }
52 
53  }
54 
56 
58  {
59  }
60 
62 
63  void CENSEngine::step( int value )
64  {
65 
66  if(m_grSimEnabled)
68 
69  CENSGraphics::step( value );
70 
71  }
72 
73 
75 
77  {
78  loop();
79  }
80 
82 
84  {
86  }
87 
88 
90 
92  {
93 
95  // RENDER OBJECTS ///////////////////////////////////////
96 
97  btScalar m[16];
98  btVector3 aabbMin,aabbMax;
99  btMatrix3x3 rot;
100  btVector3 orig;
101  rot.setIdentity();
102  btQuaternion qRot;
103  const btTransform *mainTransform;
104  btRigidBody* rbody = 0;
105  btSoftBody* sbody = 0;
106 
107  // loop through all bodies in the cens_physics world
108  for (int i = 0; i < m_phDynamicsWorld->getNumCollisionObjects(); i++ )
109  {
110 
111  btCollisionObject* colObj=m_phDynamicsWorld->getCollisionObjectArray()[i];
112  if( colObj->getInternalType() == btCollisionObject::CO_RIGID_BODY ) {
113 
114  rbody = btRigidBody::upcast(colObj);
115 
117  // get the body current transform //
118 
119  mainTransform = &(colObj->getWorldTransform());
120 
121  mainTransform->getOpenGLMatrix( m );
122  qRot = mainTransform->getRotation();
123  rot = mainTransform->getBasis();
124  orig = mainTransform->getOrigin();
125 
126 
127  Vector3f glorg = btVec2eigen(orig);
128  Matrix3f glrot = btMat2eigen(rot);
129 
130  m_eShapes[colObj]->draw( glorg, glrot );
131 
132  }
133  else if ( colObj->getInternalType() == btCollisionObject::CO_SOFT_BODY )
134  {
135 
136  sbody = btSoftBody::upcast(colObj);
137 
139  // get the body current transform //
140 
141  mainTransform = &(getTransformFromBody(sbody));
142 
143  mainTransform->getOpenGLMatrix( m );
144  qRot = mainTransform->getRotation();
145  rot = mainTransform->getBasis();
146  orig = mainTransform->getOrigin();
147 
148  for(int n=0; n<sbody->m_faces.size(); n++)
149  {
150 
151  btSoftBody::Node* node_0=sbody->m_faces[n].m_n[0];
152  btSoftBody::Node* node_1=sbody->m_faces[n].m_n[1];
153  btSoftBody::Node* node_2=sbody->m_faces[n].m_n[2];
154 
155  m_grShapes[i]->getVertices()[n*3 +0] = btVec2eigen(node_0->m_x);
156  m_grShapes[i]->getVertices()[n*3 +1] = btVec2eigen(node_1->m_x);
157  m_grShapes[i]->getVertices()[n*3 +2] = btVec2eigen(node_2->m_x);
158  m_grShapes[i]->getNormals()[n] = btVec2eigen(node_2->m_n);
159 
160  }
161 
162  m_eShapes[colObj]->drawSoft();
163 
164  }
165 
167  // draw object axes ////////////////
169  drawAxis( btVec2eigen(orig), btMat2eigen(rot), 40 );
170 
171  }
172 
174  // draw axis ///////////////////////
175 
176  if(m_grAxisEnabled)
177  {
178 
179  Matrix3f id = Matrix3f::Identity();
180  drawAxis(Vector3f(0,0,0), id, 80);
181 
182  }
183 
185  // draw camera axis ////////////////
186 
187  for(unsigned int index=0; index<m_eAttachedCameras.size(); index++)
188  {
189 
190  if(m_grCameraAxisEnabled) {
191 
192  CENSBodyCameraData &data =m_eAttachedCameras[index];
193  CENSCamera &camera = *m_grEyeCameras[data.m_bcIdx];
194  btTransform &cameraTransform = getTransformFromBody(data.m_bcBody);
195 
196  drawLine(
197  camera.m_cOrigin,
198  btVec2eigen(
199  cameraTransform*(
200  data.m_bcLocal_transform.getOrigin() +
201  data.m_bcLocal_transform.getBasis() * (data.m_bcUp*camera.m_cDistance))),
202  Vector3f(1,1,1) );
203  drawLine( camera.m_cOrigin,
204  camera.m_cTarget,
205  Vector3f(.6,0,0) );
206 
207  }
208 
209  syncAttachedCamera(index);
210 
211  }
212 
213 
215  // draw joint pivot axis ///////////
217  {
218 
219  for (int i = 0; i < m_phDynamicsWorld->getNumConstraints(); i++ )
220  {
221 
222  btTypedConstraint *joint = m_phDynamicsWorld->getConstraint(i);
223  btTransform pivot1;
224  btTransform pivot2;
225  btTransform &t1=joint->getRigidBodyA().getWorldTransform();
226  btTransform &t2=joint->getRigidBodyB().getWorldTransform();
227 
228  if( joint->getConstraintType() == HINGE_CONSTRAINT_TYPE )
229  {
230  pivot1 = t1 * ((CENSHingeConstraint *)joint)->getAFrame();
231  drawAxis( btVec2eigen(pivot1.getOrigin()), btMat2eigen(pivot1.getBasis()), 3 );
232  pivot2 = t2 * ((CENSHingeConstraint *)joint)->getBFrame();
233  drawAxis( btVec2eigen(pivot2.getOrigin()), btMat2eigen(pivot2.getBasis()), 3 );
234  }
235  else if( joint->getConstraintType() == CONETWIST_CONSTRAINT_TYPE )
236  {
237  pivot1 = t1 * ((btConeTwistConstraint *)joint)->getAFrame();
238  drawAxis( btVec2eigen(pivot1.getOrigin()), btMat2eigen(pivot1.getBasis()), 3 );
239  pivot2 = t2 * ((btConeTwistConstraint *)joint)->getBFrame();
240  drawAxis( btVec2eigen(pivot2.getOrigin()), btMat2eigen(pivot2.getBasis()), 3 );
241  }
242  else if( joint->getConstraintType() == SLIDER_CONSTRAINT_TYPE )
243  {
244  pivot1 = t1 * ((btSliderConstraint *)joint)->getFrameOffsetA();
245  drawAxis( btVec2eigen(pivot1.getOrigin()), btMat2eigen(pivot1.getBasis()), 3 );
246  pivot2 = t2 * ((btSliderConstraint *)joint)->getFrameOffsetB();
247  drawAxis( btVec2eigen(pivot2.getOrigin()), btMat2eigen(pivot2.getBasis()), 3 );
248  }
249  else if( joint->getConstraintType() == D6_CONSTRAINT_TYPE )
250  {
251  pivot1 = t1 * ((btGeneric6DofConstraint *)joint)->getFrameOffsetA();
252  drawAxis( btVec2eigen(pivot1.getOrigin()), btMat2eigen(pivot1.getBasis()), 3 );
253  pivot2 = t2 * ((btGeneric6DofConstraint *)joint)->getFrameOffsetB();
254  drawAxis( btVec2eigen(pivot2.getOrigin()), btMat2eigen(pivot2.getBasis()), 3 );
255  }
256  }
257 
258  }
259 
261 
262  }
263 
265  // BODY BUILDING OVERRIDES ////////////////////////////////////////////////////////////////////
267 
269  float mass,
270  const btTransform& startTransform,
271  btCollisionShape* shape,
272  const btVector3 &color_,
273  const TexCoords &texCoords,
274  CENSPixelMap &pixmap )
275  {
276 
277  btRigidBody *body = CENSPhysics::localCreateRigidBody(mass, startTransform, shape);
278 
279  Vector3f color = btVec2eigen(color_);
280 
281  bool is_empty_pixmap = pixmap.getData()==0;
282  bool is_empty_color = color == CENS_NULL_COLOR;
283 
284  switch( shape->getShapeType() )
285  {
286 
287  case STATIC_PLANE_PROXYTYPE:
288  {
289  const btStaticPlaneShape* staticPlaneShape =
290  static_cast<const btStaticPlaneShape*>(shape);
291  btScalar planeConst =
292  staticPlaneShape->getPlaneConstant();
293  const btVector3& planeNormal =
294  staticPlaneShape->getPlaneNormal();
295  btVector3 planeOrigin =
296  planeNormal * planeConst;
297  btVector3 vec0,vec1;
298  btPlaneSpace1(planeNormal,vec0,vec1);
299 
300  Vector3f org = btVec2eigen(planeOrigin);
301  Vector3f v0 = btVec2eigen(vec0);
302  Vector3f v1 = btVec2eigen(vec1);
303 
304  CENSGraphicsShape *gsshape = new CENSGraphicsShape();
305 
306  gsshape->buildAsPlane(org,v0,v1,
307  is_empty_color?m_grBoxColor:color,
308  is_empty_pixmap?CENSPixelMap():pixmap);
309  m_grShapes.push_back(gsshape);
310 
311  m_eShapes[body] = gsshape;
312  }
313  break;
314  case BOX_SHAPE_PROXYTYPE:
315  {
316  const btBoxShape* boxShape =
317  static_cast<const btBoxShape*>(shape);
318  btVector3 halfExtent =
319  boxShape->getHalfExtentsWithMargin();
320  Vector3f glHalfExtent =
321  btVec2eigen(halfExtent);
322 
323  CENSGraphicsShape *gsshape = new CENSGraphicsShape();
324  gsshape->buildAsBox(glHalfExtent,
325  is_empty_color?m_grBoxColor:color,
326  is_empty_pixmap?CENSPixelMap():pixmap);
327  m_grShapes.push_back(gsshape);
328 
329  m_eShapes[body] = gsshape;
330  }
331  break;
332  case SPHERE_SHAPE_PROXYTYPE:
333  {
334  const btSphereShape* sphereShape =
335  static_cast<const btSphereShape*>(shape);
336  float radius = sphereShape->getMargin();
337 
338  CENSGraphicsShape *gsshape = new CENSGraphicsShape();
339  gsshape->buildAsSphere(radius,
340  is_empty_color?m_grSphereColor:color,
341  is_empty_pixmap?CENSPixelMap():pixmap);
342  m_grShapes.push_back(gsshape);
343 
344  m_eShapes[body] = gsshape;
345  }
346  break;
347  default:
348  if( shape->isConvex())
349  {
350  const btConvexShape* convexShape =
351  static_cast<const btConvexShape*>(shape);
352 
353  btShapeHull hull(convexShape);
354 
355  if(hull.buildHull(convexShape->getMargin()))
356  {
357 
358  const btVector3* btvtx = hull.getVertexPointer();
359  const unsigned int* idx = hull.getIndexPointer();
360  std::vector<Vector3f> vtx(hull.numVertices());
361 
362  for(int x=0; x< hull.numVertices(); x++)
363  {
364  Vector3f v=btVec2eigen(btvtx[x]);
365  vtx[x]=v;
366  }
367 
368  CENSGraphicsShape *gsshape = new CENSGraphicsShape();
369  gsshape->buildAsConvex( vtx, idx,
370  hull.numVertices(),
371  hull.numIndices(),
372  hull.numTriangles(),
373  texCoords,
374  is_empty_color?m_grCapsuleColor:color,
375  is_empty_pixmap?CENS_NULL_PIXMAP:pixmap);
376 
377  m_grShapes.push_back(gsshape);
378 
379  m_eShapes[body] = gsshape;
380  }
381  }
382  break;
383  }
384 
385  return body;
386 
387  }
388 
390 
392  btRigidBody* body,
393  const btVector3 &color_,
394  const TexCoords &texCoords,
395  CENSPixelMap &pixmap )
396  {
397 
398  float mass = (body->getInvMass() >0 ) ? 1.0/(body->getInvMass()): 0;
399 
400  const btTransform& startTransform = body->getCenterOfMassTransform();
401 
402  btCollisionShape* shape = body->getCollisionShape();
403 
404  Vector3f color = btVec2eigen(color_);
405 
406  bool is_empty_pixmap = pixmap.getData()==0;
407  bool is_empty_color = color == CENS_NULL_COLOR;
408 
409  switch( shape->getShapeType() )
410  {
411 
412  case STATIC_PLANE_PROXYTYPE:
413  {
414  const btStaticPlaneShape* staticPlaneShape =
415  static_cast<const btStaticPlaneShape*>(shape);
416  btScalar planeConst =
417  staticPlaneShape->getPlaneConstant();
418  const btVector3& planeNormal =
419  staticPlaneShape->getPlaneNormal();
420  btVector3 planeOrigin =
421  planeNormal * planeConst;
422  btVector3 vec0,vec1;
423  btPlaneSpace1(planeNormal,vec0,vec1);
424 
425  Vector3f org = btVec2eigen(planeOrigin);
426  Vector3f v0 = btVec2eigen(vec0);
427  Vector3f v1 = btVec2eigen(vec1);
428 
429  CENSGraphicsShape *gsshape = new CENSGraphicsShape();
430 
431  gsshape->buildAsPlane(org,v0,v1,
432  is_empty_color?m_grBoxColor:color,
433  is_empty_pixmap?CENSPixelMap():pixmap);
434  m_grShapes.push_back(gsshape);
435 
436  m_eShapes[body] = gsshape;
437  }
438  break;
439  case BOX_SHAPE_PROXYTYPE:
440  {
441  const btBoxShape* boxShape =
442  static_cast<const btBoxShape*>(shape);
443  btVector3 halfExtent =
444  boxShape->getHalfExtentsWithMargin();
445  Vector3f glHalfExtent =
446  btVec2eigen(halfExtent);
447 
448  CENSGraphicsShape *gsshape = new CENSGraphicsShape();
449  gsshape->buildAsBox(glHalfExtent,
450  is_empty_color?m_grBoxColor:color,
451  is_empty_pixmap?CENSPixelMap():pixmap);
452  m_grShapes.push_back(gsshape);
453 
454  m_eShapes[body] = gsshape;
455  }
456  break;
457  case SPHERE_SHAPE_PROXYTYPE:
458  {
459  const btSphereShape* sphereShape =
460  static_cast<const btSphereShape*>(shape);
461  float radius = sphereShape->getMargin();
462 
463  CENSGraphicsShape *gsshape = new CENSGraphicsShape();
464  gsshape->buildAsSphere(radius,
465  is_empty_color?m_grSphereColor:color,
466  is_empty_pixmap?CENSPixelMap():pixmap);
467  m_grShapes.push_back(gsshape);
468 
469  m_eShapes[body] = gsshape;
470  }
471  break;
472  default:
473  if( shape->isConvex())
474  {
475  const btConvexShape* convexShape =
476  static_cast<const btConvexShape*>(shape);
477 
478  btShapeHull hull(convexShape);
479 
480  if(hull.buildHull(convexShape->getMargin()))
481  {
482 
483  const btVector3* btvtx = hull.getVertexPointer();
484  const unsigned int* idx = hull.getIndexPointer();
485  std::vector<Vector3f> vtx(hull.numVertices());
486 
487  for(int x=0; x< hull.numVertices(); x++)
488  {
489  Vector3f v=btVec2eigen(btvtx[x]);
490  vtx[x]=v;
491  }
492 
493  CENSGraphicsShape *gsshape = new CENSGraphicsShape();
494  gsshape->buildAsConvex( vtx, idx,
495  hull.numVertices(),
496  hull.numIndices(),
497  hull.numTriangles(),
498  texCoords,
499  is_empty_color?m_grCapsuleColor:color,
500  is_empty_pixmap?CENS_NULL_PIXMAP:pixmap);
501 
502  m_grShapes.push_back(gsshape);
503 
504 
505  m_eShapes[body] = gsshape;
506  }
507  }
508  break;
509  }
510 
511  return body;
512 
513  }
514 
515 
516 
518 
520  float mass,
521  btCollisionShape* shape,
522  const btVector3 &color_,
523  const TexCoords &texCoords,
524  CENSPixelMap &pixmap )
525  {
526 
527  btSoftBody * body = CENSPhysics::localCreateSoftBody(mass,shape);
528 
529  Vector3f color = btVec2eigen(color_);
530 
531  bool is_empty_pixmap = pixmap.getData()==0;
532  bool is_empty_color = color == CENS_NULL_COLOR;
533 
534  CENSGraphicsShape *gsshape = new CENSGraphicsShape();
535  gsshape->buildAsSoft(body->m_faces.size(),
536  texCoords,
537  is_empty_color?m_grSoftColor:color,
538  is_empty_pixmap?CENS_NULL_PIXMAP:pixmap);
539  m_grShapes.push_back(gsshape);
540 
541  m_eShapes[body] = gsshape;
542 
543  return body;
544  }
547  btSoftBody* body,
548  const btVector3 &color_,
549  const TexCoords &texCoords,
550  CENSPixelMap &pixmap )
551  {
552 
553  Vector3f color = btVec2eigen(color_);
554 
555  bool is_empty_pixmap = pixmap.getData()==0;
556  bool is_empty_color = color == CENS_NULL_COLOR;
557 
558  CENSGraphicsShape *gsshape = new CENSGraphicsShape();
559  gsshape->buildAsSoft(body->m_faces.size(),
560  texCoords,
561  is_empty_color?m_grSoftColor:color,
562  is_empty_pixmap?CENS_NULL_PIXMAP:pixmap);
563  m_grShapes.push_back(gsshape);
564 
565  m_eShapes[body] = gsshape;
566 
567  return body;
568  }
569 
571  // CAMERAS ////////////////////////////////////////////////////////////////////////////////////
573 
575  btRigidBody *body,
576  btTransform local_transform,
577  std::string screenTitle,
578  int screenWidth,
579  int screenHeight,
580  int screenXGap,
581  int screenYGap,
582  btVector3 up,
583  float target,
584  float foV,
585  float near,
586  float far
587  )
588  {
589 
590 
591  CENSCamera *pCam = new CENSCamera(m_grViewCamera);
592 
593  pCam->m_cHeight=0;
594  pCam->m_cScreenTitle=screenTitle.c_str();
595  pCam->m_cScreenWidth=screenWidth;
596  pCam->m_cScreenHeight=screenHeight;
597  pCam->m_cScreenXGap=screenXGap;
598  pCam->m_cScreenYGap=screenYGap;
599  pCam->m_cDistance=1;
600  pCam->m_cFoV=foV;
601  pCam->m_cNear=near;
602  pCam->m_cFar=far;
603  initCamera(*pCam,m_grLight);
604 
605 
606  CENSCamera &camera= *pCam;
607  m_grEyeCameras.push_back(&camera);
608 
609  int idx = m_grEyeCameras.size()-1;
610  CENSBodyCameraData data;
611  data.m_bcIdx = idx;
612  data.m_bcBody = body;
613  data.m_bcOrigin = local_transform.getOrigin();
614  data.m_bcTarget =
615  local_transform.getOrigin() +
616  local_transform.getBasis() * btVector3(target,0,0);
617  data.m_bcUp = local_transform.getBasis() * up;
618 
619 
620  data.m_bcLocal_transform = local_transform;
621  m_eAttachedCameras.push_back( data );
622 
623  syncAttachedCamera(idx);
624 
625  return idx;
626  }
627 
628 
630 
632  {
633 
635  btRigidBody *body = data.m_bcBody;
636  CENSCamera &camera = *m_grEyeCameras[data.m_bcIdx];
637 
638  btTransform &mainTransform = getTransformFromBody(body);
639 
640  camera.m_cOrigin =
641  btVec2eigen(
642  mainTransform * data.m_bcOrigin );
643 
644  camera.m_cTarget =
645  btVec2eigen(
646  mainTransform * data.m_bcTarget );
647 
648  camera.m_cUp = btVec2eigen(
649  mainTransform.getBasis() * data.m_bcUp );
650 
651  }
652 
654 
655 
657  // Eigen - bt convertions ///////////////////////
659 
660  Eigen::Vector3f btVec2eigen(const btVector3& v)
661  {
662  return Eigen::Vector3f(v.x(), v.y(), v.z());
663  }
664 
665  btVector3 eigen2btVec(const Eigen::Vector3f& v)
666  {
667  return btVector3(v.x(), v.y(), v.z());
668  }
669 
670  btMatrix3x3 eigen2btMat(const Eigen::Matrix3f& v)
671  {
672  btMatrix3x3 bv;
673  for(int x=0;x<3;x++)
674  for(int y=0;y<3;y++)
675  bv[x][y]=v(x,y);
676  return bv;
677  }
678 
679  Eigen::Matrix3f btMat2eigen(const btMatrix3x3& v)
680  {
681  Eigen::Matrix3f bv;
682  for(int x=0;x<3;x++)
683  for(int y=0;y<3;y++)
684  bv(x,y)=v[x][y];
685  return bv;
686  }
687 
688 }
A custom HingeConstraint Class.
Definition: cens_physics.h:374
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)
void drawLine(const Vector3f &v1, const Vector3f &v2, const Vector3f color)
btSoftRigidDynamicsWorld * m_phDynamicsWorld
Definition: cens_physics.h:322
void drawAxis(const Vector3f &origin, const Matrix3f &rotation, float length)
std::vector< CENSCamera * > m_grCameras
btRigidBody * localImportRigidBody(btRigidBody *body, const btVector3 &color=eigen2btVec(CENS_NULL_COLOR), const TexCoords &texCoords=CENS_NULL_TEXCOORDS, CENSPixelMap &pixmap=CENS_NULL_PIXMAP)
CENSGraphics * cens_graphics
CENSPixelMap CENS_NULL_PIXMAP
Definition: cens_types.cpp:29
Graphic processing of an object.
virtual void loop()
void buildAsConvex(const Vertices &vertices, const unsigned int *idx, int nvtxs, int nidxs, int ntrns, const TexCoords &texCoords=CENS_NULL_TEXCOORDS, const Vector3f &color=CENS_NULL_COLOR, CENSPixelMap pixmap=CENS_NULL_PIXMAP)
void buildAsSphere(float radius, const Vector3f &color=CENS_NULL_COLOR, CENSPixelMap pixmap=CENS_NULL_PIXMAP)
virtual void stepToStepLoop()
CENSCamera m_grViewCamera
std::vector< Vector2f > TexCoords
Definition: cens_types.h:44
virtual void syncAttachedCamera(int index)
std::vector< CENSGraphicsShape * > m_grShapes
btSoftBody * localLinkSoftBody(btSoftBody *body, const btVector3 &color=eigen2btVec(CENS_NULL_COLOR), const TexCoords &texCoords=CENS_NULL_TEXCOORDS, CENSPixelMap &pixmap=CENS_NULL_PIXMAP)
void focusCamera(int camera_index)
virtual void stepRun()
Definition: cens_engine.cpp:83
Vector3f m_grSphereColor
Eigen::Matrix3f btMat2eigen(const btMatrix3x3 &v)
virtual void initCENSGraphics(int argc, char **argv)
virtual void cens_physics_step()
virtual btSoftBody * localCreateSoftBody(float mass, btCollisionShape *shape)
Vector3f m_grCapsuleColor
virtual void run()
Definition: cens_engine.cpp:76
btVector3 eigen2btVec(const Eigen::Vector3f &v)
void initCamera(CENSCamera &camera, CENSLight light)
virtual void step(int value)
Definition: cens_engine.cpp:63
void buildAsPlane(const Vector3f &orig, const Vector3f &v1, const Vector3f &v2, const Vector3f &color=CENS_NULL_COLOR, CENSPixelMap pixmap=CENS_NULL_PIXMAP)
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 btRigidBody * localCreateRigidBody(float mass, const btTransform &startTransform, btCollisionShape *shape)
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 of a camera
std::vector< CENSCamera * > m_grEyeCameras
const GLubyte * getData() const
Definition: cens_pixelmap.h:95
Parameters for the body-camera link.
Definition: cens_engine.h:230
virtual ~CENSEngine()
Definition: cens_engine.cpp:57
Eigen::Vector3f btVec2eigen(const btVector3 &v)
void buildAsSoft(int numTriangles, const TexCoords &texCoords=CENS_NULL_TEXCOORDS, const Vector3f &color=CENS_NULL_COLOR, CENSPixelMap pixmap=CENS_NULL_PIXMAP)
std::vector< CENSBodyCameraData > m_eAttachedCameras
Definition: cens_engine.h:251
btTransform & getTransformFromBody(btRigidBody *body)
virtual void step(int ts)
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
void buildAsBox(const Vector3f &halfExtents, const Vector3f &color=CENS_NULL_COLOR, CENSPixelMap pixmap=CENS_NULL_PIXMAP)
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)