12 #ifndef PROJECT_DRAWLIST_H 13 #define PROJECT_DRAWLIST_H 44 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
58 size_t addMiniCheetah(
Vec4<float> color,
bool useOld);
62 size_t addDebugSphere(
float radius);
66 void addMesh(
double grid_size,
const Vec3<double> &left_corner,
72 void resize(
size_t nUniqueObject,
size_t nTotalObjects) {
73 _nUnique = nUniqueObject;
74 _nTotal = nTotalObjects;
75 _vertexData.resize(nUniqueObject);
76 _normalData.resize(nUniqueObject);
77 _colorData.resize(nUniqueObject);
78 _offsetXforms.resize(nUniqueObject);
79 _objectMap.resize(nTotalObjects);
94 return _glArrayOffsets.at(_objectMap.at(i));
101 return _glArraySizes.at(_objectMap.at(i));
135 return _kinematicXform[i];
144 _glColorData.size() + _glNormalData.size() + _glVertexData.size();
145 bytes = bytes *
sizeof(float);
146 return (
float)bytes / float(1 << 20);
155 _reloadNeeded =
false;
169 template <
typename T>
171 bool updateOrigin =
false) {
172 for (
size_t modelID = 5, graphicsID =
id; modelID < model.
getNumBodies();
173 modelID++, graphicsID++) {
174 _kinematicXform.at(graphicsID) =
179 _cameraOrigin = model.
getState().bodyPosition.template cast<T>();
190 template <
typename T>
192 if (_additionalInfoFirstVisit) {
194 _cp_touch.resize(_nTotalGC,
false);
195 _cp_pos.resize(_nTotalGC);
196 _cp_force.resize(_nTotalGC);
197 std::vector<double> tmp(3);
198 for (
size_t i(0); i < _nTotalGC; ++i) {
202 _additionalInfoFirstVisit =
false;
205 for (
size_t i(0); i < _nTotalGC; ++i) {
208 for (
size_t j(0); j < 3; ++j) {
209 _cp_pos[i][j] = model.
getModel()._pGC[i][j];
221 template <
typename T>
228 template <
typename T>
232 H.translate(0., 0., height);
233 _kinematicXform.at(
id) = H;
236 template <
typename T>
240 H.translate(position[0], position[1], position[2]);
241 _kinematicXform.at(
id) = H;
252 if ((size % 3) != 0) {
253 throw std::runtime_error(
"setSolidColor invalid size");
256 for (
size_t i = 0; i < size / 3; i++) {
265 const std::vector<double> &
getGCPos(
size_t idx) {
return _cp_pos[idx]; }
266 const std::vector<double> &
getGCForce(
size_t idx) {
return _cp_force[idx]; }
271 return _height_map_left_corner;
282 size_t _nUnique = 0, _nTotal = 0;
288 std::string _baseFileName =
"../resources/";
301 bool _reloadNeeded =
false;
302 bool _additionalInfoFirstVisit =
true;
304 size_t _nTotalGC = 0;
317 size_t _cheetah3LoadIndex = 0, _miniCheetahLoadIndex = 0,
318 _sphereLoadIndex = 0, _cubeLoadIndex = 0;
321 #endif // PROJECT_DRAWLIST_H VisualizationData * _visualizationData
std::vector< size_t > _glArrayOffsets
Utility functions that exist only in the simulator.
std::vector< std::vector< float > > _normalData
std::vector< std::vector< float > > _colorData
typename Eigen::Matrix< T, 3, 3 > Mat3
typename Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > DMat
std::vector< bool > _cp_touch
std::vector< size_t > _glArraySizes
static void setSolidColor(std::vector< float > &data, size_t size, float r, float g, float b)
typename Eigen::Matrix< T, 3, 1 > Vec3
const Vec3< double > & getCameraOrigin()
const Vec3< T > & getContactForce(size_t idx)
void updateRobotFromModel(DynamicsSimulator< T > &model, size_t id, bool updateOrigin=false)
std::vector< std::vector< double > > _cp_force
const std::vector< double > & getGCPos(size_t idx)
vectorAligned< SolidColor > _instanceColor
const Vec3< double > & getHeightMapLeftCorner()
const size_t & getTotalNumGC()
std::vector< BoxInfo > _box_list
std::vector< QMatrix4x4 > _kinematicXform
void resize(size_t nUniqueObject, size_t nTotalObjects)
Vec3< double > _height_map_left_corner
Collision logic for an infinite plane.
size_t getSizeOfAllData()
std::vector< float > _glColorData
size_t getNumObjectsToDraw()
Vec3< double > _cameraOrigin
QMatrix4x4 & getModelKinematicTransform(size_t i)
const double & getHeightMapMax()
const size_t & getTotalNumGC()
vectorAligned< Mat4< float > > _offsetXforms
typename Eigen::Matrix< T, 4, 1 > Vec4
DMat< double > _height_map
const FBModelState< T > & getState() const
void updateCheckerboard(T height, size_t id)
std::vector< float > _glNormalData
size_t getGLDrawArraySize(size_t i)
typename std::vector< T, Eigen::aligned_allocator< T >> vectorAligned
std::vector< size_t > _objectMap
Utility to load .obj files, containing 3D models of robots.
void updateDebugSphereLocation(Vec3< T > &position, size_t id)
const std::vector< BoxInfo > & getBoxInfoList()
size_t getGLDrawArrayOffset(size_t i)
Rigid Body Dynamics Simulator with Collisions.
const double & getGridSize()
void updateAdditionalInfo(DynamicsSimulator< T > &model)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Vec4< float > rgba
std::vector< float > _glVertexData
std::vector< std::vector< double > > _cp_pos
QMatrix4x4 & getModelBaseTransform(size_t i)
const FloatingBaseModel< T > & getModel()
Some colors commonly used in the simulator.
Implementation of Rigid Body Floating Base model data structure.
void updateCheckerboardFromCollisionPlane(CollisionPlane< T > &model, size_t id)
const std::vector< double > & getGCForce(size_t idx)
const DMat< double > & getHeightMap()
const double & getHeightMapMin()
Utility functions for manipulating spatial quantities.
std::vector< QMatrix4x4 > _modelOffsets
QMatrix4x4 spatialTransformToQT(const Eigen::MatrixBase< T > &X)
std::vector< std::vector< float > > _vertexData