dart
RenderInterface.hpp
1 /*
2  * Copyright (c) 2011-2021, 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 <Eigen/Dense>
38 #include <assimp/scene.h>
39 
40 #include "dart/math/MathTypes.hpp"
41 
42 namespace dart {
43 namespace gui {
44 
45 enum DecoBufferType
46 {
47  BT_Front,
48  BT_Back
49 };
50 
51 enum DecoColorChannel
52 {
53  CC_R,
54  CC_G,
55  CC_B,
56  CC_A,
57  CC_RGB,
58  CC_RGBA
59 };
60 
61 enum DecoDrawType
62 {
63  DT_WireFrame,
64  DT_SolidPolygon,
65  DT_FrontPolygon,
66  DT_BackPolygon,
67  DT_Max
68 };
69 
71 {
72 public:
74  {
75  }
76  virtual ~RenderInterface()
77  {
78  }
79 
80  virtual void initialize();
81  virtual void destroy();
82 
83  virtual void setViewport(int _x, int _y, int _width, int _height);
84  virtual void getViewport(int& _x, int& _y, int& _width, int& _height) const;
85 
86  virtual void clear(const Eigen::Vector3d& _color);
87 
88  virtual void setMaterial(
89  const Eigen::Vector3d& _diffuse,
90  const Eigen::Vector3d& _specular,
91  double _cosinePow);
92  virtual void getMaterial(
93  Eigen::Vector3d& _diffuse,
94  Eigen::Vector3d& _specular,
95  double& _cosinePow) const;
96  virtual void setDefaultMaterial();
97 
98  virtual void pushMatrix();
99  virtual void popMatrix();
100  virtual void pushName(int _id);
101  virtual void popName();
102 
103  virtual void translate(const Eigen::Vector3d& _offset); // glTranslate
104  virtual void rotate(const Eigen::Vector3d& _axis, double _rad); // glRotate
105  virtual void transform(const Eigen::Isometry3d& _transform); // glMultMatrix
106  virtual void scale(const Eigen::Vector3d& _scale); // glScale
107 
108  virtual void drawSphere(double radius, int slices = 16, int stacks = 16);
109  virtual void drawMultiSphere(
110  const std::vector<std::pair<double, Eigen::Vector3d>>& spheres,
111  int slices = 16,
112  int stacks = 16);
113  virtual void drawEllipsoid(const Eigen::Vector3d& _size);
114  virtual void drawCube(const Eigen::Vector3d& _size);
115  virtual void drawOpenCylinder(
116  double baseRadius,
117  double topRadius,
118  double height,
119  int slices = 16,
120  int stacks = 16);
121  virtual void drawCylinder(
122  double _radius, double _height, int slices = 16, int stacks = 16);
123  virtual void drawCapsule(double _radius, double _height);
124  virtual void drawCone(double _radius, double _height);
125  virtual void drawPyramid(double baseWidth, double baseDepth, double height);
126  virtual void drawMesh(const Eigen::Vector3d& _scale, const aiScene* _mesh);
127  virtual void drawSoftMesh(const aiMesh* mesh);
128  virtual void drawList(unsigned int index);
129  virtual void drawLineSegments(
130  const std::vector<Eigen::Vector3d>& _vertices,
131  const common::aligned_vector<Eigen::Vector2i>& _connections);
132 
133  virtual unsigned int compileDisplayList(
134  const Eigen::Vector3d& _size, const aiScene* _mesh);
135 
136  virtual void setPenColor(const Eigen::Vector4d& _col);
137  virtual void setPenColor(const Eigen::Vector3d& _col);
138 
139  virtual void setLineWidth(float _width);
140 
141  virtual void saveToImage(
142  const char* _filename, DecoBufferType _buffType = BT_Back);
143  virtual void readFrameBuffer(
144  DecoBufferType _buffType, DecoColorChannel _ch, void* _pixels);
145 };
146 
147 } // namespace gui
148 } // namespace dart
149 
150 #endif // #ifndef DART_GUI_RENDERINTERFACE_HPP_
Definition: RenderInterface.hpp:70
Definition: Aspect.cpp:40