DART  6.7.3
RenderInterface.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2019, The DART development contributors
3  * All rights reserved.
4  *
5  * The list of contributors can be found at:
6  * https://github.com/dartsim/dart/blob/master/LICENSE
7  *
8  * This file is provided under the following "BSD-style" License:
9  * Redistribution and use in source and binary forms, with or
10  * without modification, are permitted provided that the following
11  * conditions are met:
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef DART_GUI_RENDERINTERFACE_HPP_
34 #define DART_GUI_RENDERINTERFACE_HPP_
35 
36 #include <vector>
37 #include <assimp/scene.h>
38 #include <Eigen/Dense>
39 
40 #include "dart/math/MathTypes.hpp"
41 
42 namespace dart {
43 namespace gui {
44 
47  BT_Back
48 };
49 
56  CC_RGBA
57 };
58 
64  DT_Max
65 };
66 
68 public:
70  virtual ~RenderInterface(){}
71 
72  virtual void initialize();
73  virtual void destroy();
74 
75  virtual void setViewport(int _x,int _y,int _width,int _height);
76  virtual void getViewport(int& _x, int& _y,int& _width,int& _height) const;
77 
78  virtual void clear(const Eigen::Vector3d& _color);
79 
80  virtual void setMaterial(const Eigen::Vector3d& _diffuse, const Eigen::Vector3d& _specular, double _cosinePow);
81  virtual void getMaterial(Eigen::Vector3d& _diffuse, Eigen::Vector3d& _specular, double& _cosinePow) const;
82  virtual void setDefaultMaterial();
83 
84  virtual void pushMatrix();
85  virtual void popMatrix();
86  virtual void pushName(int _id);
87  virtual void popName();
88 
89  virtual void translate(const Eigen::Vector3d& _offset); //glTranslate
90  virtual void rotate(const Eigen::Vector3d& _axis, double _rad); //glRotate
91  virtual void transform(const Eigen::Isometry3d& _transform); //glMultMatrix
92  virtual void scale(const Eigen::Vector3d& _scale); //glScale
93 
94  virtual void drawSphere(double radius, int slices = 16, int stacks = 16);
95  virtual void drawMultiSphere(const std::vector<std::pair<double, Eigen::Vector3d>>& spheres, int slices = 16, int stacks = 16);
96  virtual void drawEllipsoid(const Eigen::Vector3d& _size);
97  virtual void drawCube(const Eigen::Vector3d& _size);
98  virtual void drawOpenCylinder(double baseRadius, double topRadius, double height, int slices = 16, int stacks = 16);
99  virtual void drawCylinder(double _radius, double _height, int slices = 16, int stacks = 16);
100  virtual void drawCapsule(double _radius, double _height);
101  virtual void drawCone(double _radius, double _height);
102  virtual void drawMesh(const Eigen::Vector3d& _scale, const aiScene* _mesh);
103  virtual void drawSoftMesh(const aiMesh* mesh);
104  virtual void drawList(unsigned int index);
105  virtual void drawLineSegments(const std::vector<Eigen::Vector3d>& _vertices,
106  const common::aligned_vector<Eigen::Vector2i>& _connections);
107 
108  virtual unsigned int compileDisplayList(const Eigen::Vector3d& _size, const aiScene* _mesh);
109 
110  virtual void setPenColor(const Eigen::Vector4d& _col);
111  virtual void setPenColor(const Eigen::Vector3d& _col);
112 
113  virtual void setLineWidth(float _width);
114 
115  virtual void saveToImage(const char* _filename, DecoBufferType _buffType = BT_Back);
116  virtual void readFrameBuffer(DecoBufferType _buffType, DecoColorChannel _ch, void* _pixels);
117 };
118 
119 } // namespace gui
120 } // namespace dart
121 
122 #endif // #ifndef DART_GUI_RENDERINTERFACE_HPP_
std::size_t index
Definition: SkelParser.cpp:1617
Definition: RenderInterface.hpp:67
virtual void clear(const Eigen::Vector3d &_color)
Definition: RenderInterface.cpp:54
virtual void pushName(int _id)
Definition: RenderInterface.cpp:81
virtual void pushMatrix()
Definition: RenderInterface.cpp:73
virtual void setLineWidth(float _width)
Definition: RenderInterface.cpp:169
virtual void drawSphere(double radius, int slices=16, int stacks=16)
Definition: RenderInterface.cpp:105
virtual void drawCylinder(double _radius, double _height, int slices=16, int stacks=16)
Definition: RenderInterface.cpp:149
virtual void drawOpenCylinder(double baseRadius, double topRadius, double height, int slices=16, int stacks=16)
Definition: RenderInterface.cpp:145
virtual void getViewport(int &_x, int &_y, int &_width, int &_height) const
Definition: RenderInterface.cpp:50
virtual void initialize()
Definition: RenderInterface.cpp:38
RenderInterface()
Definition: RenderInterface.hpp:69
virtual void drawEllipsoid(const Eigen::Vector3d &_size)
Definition: RenderInterface.cpp:114
virtual void drawList(unsigned int index)
Definition: RenderInterface.cpp:127
virtual void drawCapsule(double _radius, double _height)
Definition: RenderInterface.cpp:153
virtual void drawSoftMesh(const aiMesh *mesh)
Definition: RenderInterface.cpp:122
virtual void translate(const Eigen::Vector3d &_offset)
Definition: RenderInterface.cpp:89
virtual void popName()
Definition: RenderInterface.cpp:85
virtual void drawCone(double _radius, double _height)
Definition: RenderInterface.cpp:157
virtual void drawMultiSphere(const std::vector< std::pair< double, Eigen::Vector3d >> &spheres, int slices=16, int stacks=16)
Definition: RenderInterface.cpp:109
virtual void setPenColor(const Eigen::Vector4d &_col)
Definition: RenderInterface.cpp:161
virtual void setDefaultMaterial()
Definition: RenderInterface.cpp:68
virtual void drawMesh(const Eigen::Vector3d &_scale, const aiScene *_mesh)
Definition: RenderInterface.cpp:118
virtual void drawCube(const Eigen::Vector3d &_size)
Definition: RenderInterface.cpp:141
virtual void popMatrix()
Definition: RenderInterface.cpp:77
virtual void setViewport(int _x, int _y, int _width, int _height)
Definition: RenderInterface.cpp:46
virtual void getMaterial(Eigen::Vector3d &_diffuse, Eigen::Vector3d &_specular, double &_cosinePow) const
Definition: RenderInterface.cpp:63
virtual void saveToImage(const char *_filename, DecoBufferType _buffType=BT_Back)
Definition: RenderInterface.cpp:174
virtual unsigned int compileDisplayList(const Eigen::Vector3d &_size, const aiScene *_mesh)
Definition: RenderInterface.cpp:136
virtual void setMaterial(const Eigen::Vector3d &_diffuse, const Eigen::Vector3d &_specular, double _cosinePow)
Definition: RenderInterface.cpp:58
virtual void scale(const Eigen::Vector3d &_scale)
Definition: RenderInterface.cpp:101
virtual void rotate(const Eigen::Vector3d &_axis, double _rad)
Definition: RenderInterface.cpp:93
virtual void readFrameBuffer(DecoBufferType _buffType, DecoColorChannel _ch, void *_pixels)
Definition: RenderInterface.cpp:179
virtual void transform(const Eigen::Isometry3d &_transform)
Definition: RenderInterface.cpp:97
virtual void drawLineSegments(const std::vector< Eigen::Vector3d > &_vertices, const common::aligned_vector< Eigen::Vector2i > &_connections)
Definition: RenderInterface.cpp:131
virtual void destroy()
Definition: RenderInterface.cpp:42
virtual ~RenderInterface()
Definition: RenderInterface.hpp:70
std::vector< _Tp, Eigen::aligned_allocator< _Tp > > aligned_vector
Definition: Memory.hpp:66
DecoBufferType
Definition: RenderInterface.hpp:45
@ BT_Front
Definition: RenderInterface.hpp:46
@ BT_Back
Definition: RenderInterface.hpp:47
DecoDrawType
Definition: RenderInterface.hpp:59
@ DT_SolidPolygon
Definition: RenderInterface.hpp:61
@ DT_FrontPolygon
Definition: RenderInterface.hpp:62
@ DT_BackPolygon
Definition: RenderInterface.hpp:63
@ DT_WireFrame
Definition: RenderInterface.hpp:60
@ DT_Max
Definition: RenderInterface.hpp:64
DecoColorChannel
Definition: RenderInterface.hpp:50
@ CC_B
Definition: RenderInterface.hpp:53
@ CC_R
Definition: RenderInterface.hpp:51
@ CC_RGBA
Definition: RenderInterface.hpp:56
@ CC_A
Definition: RenderInterface.hpp:54
@ CC_G
Definition: RenderInterface.hpp:52
@ CC_RGB
Definition: RenderInterface.hpp:55
Definition: BulletCollisionDetector.cpp:63