DART 6.11.1
Loading...
Searching...
No Matches
OpenGLRenderInterface.hpp
Go to the documentation of this file.
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_OPENGLRENDERINTERFACE_HPP_
34#define DART_GUI_OPENGLRENDERINTERFACE_HPP_
35
36#include <list>
37#include <vector>
40
41namespace dart {
42
43namespace dynamics {
44class Skeleton;
45class BodyNode;
46class Shape;
47class ShapeFrame;
48} // namespace dynamics
49
50namespace gui {
52{
53
54public:
56 : mViewportX(0.0),
57 mViewportY(0.0),
58 mViewportWidth(0.0),
60 {
61 }
63 {
64 }
65
66 void initialize() override;
67 void destroy() override;
68
69 void setViewport(int _x, int _y, int _width, int _height) override;
70 void getViewport(int& _x, int& _y, int& _width, int& _height) const override;
71
72 void clear(const Eigen::Vector3d& _color) override;
73
74 void setMaterial(
75 const Eigen::Vector3d& _diffuse,
76 const Eigen::Vector3d& _specular,
77 double _cosinePow) override;
78 void getMaterial(
79 Eigen::Vector3d& _diffuse,
80 Eigen::Vector3d& _specular,
81 double& _cosinePow) const override;
82 void setDefaultMaterial() override;
83
84 void pushMatrix() override;
85 void popMatrix() override;
86 void pushName(int _id) override;
87 void popName() override;
88
89 void translate(const Eigen::Vector3d& _offset) override; // glTranslate
90 void rotate(const Eigen::Vector3d& _axis, double _rad) override; // glRotate
91 void transform(const Eigen::Isometry3d& _transform) override; // glMultMatrix
92 void scale(const Eigen::Vector3d& _scale) override; // glScale
93
96 void compileList(dynamics::Shape* _shape);
97 GLuint compileList(const Eigen::Vector3d& _scale, const aiScene* _mesh);
98
99 void drawSphere(double radius, int slices = 16, int stacks = 16) override;
100 void drawMultiSphere(
101 const std::vector<std::pair<double, Eigen::Vector3d>>& spheres,
102 int slices = 16,
103 int stacks = 16) override;
105 const std::vector<std::pair<double, Eigen::Vector3d>>& spheres,
106 std::size_t subdivisions) override;
107 void drawEllipsoid(const Eigen::Vector3d& _diameters) override;
108 void drawCube(const Eigen::Vector3d& _size) override;
109 void drawOpenCylinder(
110 double baseRadius,
111 double topRadius,
112 double height,
113 int slices = 16,
114 int stacks = 16) override;
115 void drawCylinder(
116 double _radius,
117 double _height,
118 int slices = 16,
119 int stacks = 16) override;
120 void drawCapsule(double radius, double height) override;
121 void drawCone(double radius, double height) override;
122 void drawPyramid(double baseWidth, double baseDepth, double height) override;
123 void drawMesh(const Eigen::Vector3d& _scale, const aiScene* _mesh) override;
124 void drawSoftMesh(const aiMesh* mesh) override;
125 void drawList(GLuint index) override;
126 void drawLineSegments(
127 const std::vector<Eigen::Vector3d>& _vertices,
128 const common::aligned_vector<Eigen::Vector2i>& _connections) override;
129
130 void setPenColor(const Eigen::Vector4d& _col) override;
131 void setPenColor(const Eigen::Vector3d& _col) override;
132
133 void setLineWidth(float _width) override;
134
135 void saveToImage(
136 const char* _filename, DecoBufferType _buffType = BT_Back) override;
137 void readFrameBuffer(
138 DecoBufferType _buffType, DecoColorChannel _ch, void* _pixels) override;
139
140private:
141 void color4_to_float4(const aiColor4D* c, float f[4]);
142 void set_float4(float f[4], float a, float b, float c, float d);
143 void applyMaterial(const struct aiMaterial* mtl);
144 void recursiveRender(const struct aiScene* sc, const struct aiNode* nd);
145
147
148public:
149 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
150};
151
152} // namespace gui
153} // namespace dart
154
155#endif // #ifndef DART_GUI_OPENGLRENDERINTERFACE_HPP_
std::size_t index
Definition SkelParser.cpp:1672
BodyNode class represents a single node of the skeleton.
Definition BodyNode.hpp:79
Definition Shape.hpp:54
class Skeleton
Definition Skeleton.hpp:59
Definition OpenGLRenderInterface.hpp:52
void scale(const Eigen::Vector3d &_scale) override
Definition OpenGLRenderInterface.cpp:166
void transform(const Eigen::Isometry3d &_transform) override
Definition OpenGLRenderInterface.cpp:161
void drawCapsule(double radius, double height) override
Definition OpenGLRenderInterface.cpp:447
void drawMultiSphere(const std::vector< std::pair< double, Eigen::Vector3d > > &spheres, int slices=16, int stacks=16) override
Definition OpenGLRenderInterface.cpp:226
void drawEllipsoid(const Eigen::Vector3d &_diameters) override
Definition OpenGLRenderInterface.cpp:283
void drawList(GLuint index) override
Definition OpenGLRenderInterface.cpp:767
void compileList(dynamics::Skeleton *_skel)
Definition OpenGLRenderInterface.cpp:788
void drawCube(const Eigen::Vector3d &_size) override
Definition OpenGLRenderInterface.cpp:290
void translate(const Eigen::Vector3d &_offset) override
Definition OpenGLRenderInterface.cpp:151
void clear(const Eigen::Vector3d &_color) override
Definition OpenGLRenderInterface.cpp:107
void rotate(const Eigen::Vector3d &_axis, double _rad) override
Definition OpenGLRenderInterface.cpp:156
void popName() override
Definition OpenGLRenderInterface.cpp:146
void destroy() override
Definition OpenGLRenderInterface.cpp:85
int mViewportX
Definition OpenGLRenderInterface.hpp:146
OpenGLRenderInterface()
Definition OpenGLRenderInterface.hpp:55
virtual ~OpenGLRenderInterface()
Definition OpenGLRenderInterface.hpp:62
void getMaterial(Eigen::Vector3d &_diffuse, Eigen::Vector3d &_specular, double &_cosinePow) const override
Definition OpenGLRenderInterface.cpp:120
void saveToImage(const char *_filename, DecoBufferType _buffType=BT_Back) override
Definition OpenGLRenderInterface.cpp:876
void setDefaultMaterial() override
Definition OpenGLRenderInterface.cpp:127
void set_float4(float f[4], float a, float b, float c, float d)
Definition OpenGLRenderInterface.cpp:563
void drawSoftMesh(const aiMesh *mesh) override
Definition OpenGLRenderInterface.cpp:743
void popMatrix() override
Definition OpenGLRenderInterface.cpp:136
void getViewport(int &_x, int &_y, int &_width, int &_height) const override
Definition OpenGLRenderInterface.cpp:98
void drawMultiSphereConvexHull(const std::vector< std::pair< double, Eigen::Vector3d > > &spheres, std::size_t subdivisions) override
Definition OpenGLRenderInterface.cpp:243
void readFrameBuffer(DecoBufferType _buffType, DecoColorChannel _ch, void *_pixels) override
Definition OpenGLRenderInterface.cpp:871
int mViewportY
Definition OpenGLRenderInterface.hpp:146
int mViewportWidth
Definition OpenGLRenderInterface.hpp:146
void applyMaterial(const struct aiMaterial *mtl)
Definition OpenGLRenderInterface.cpp:573
void drawOpenCylinder(double baseRadius, double topRadius, double height, int slices=16, int stacks=16) override
Definition OpenGLRenderInterface.cpp:332
int mViewportHeight
Definition OpenGLRenderInterface.hpp:146
void initialize() override
Definition OpenGLRenderInterface.cpp:71
void setPenColor(const Eigen::Vector4d &_col) override
Definition OpenGLRenderInterface.cpp:856
void setMaterial(const Eigen::Vector3d &_diffuse, const Eigen::Vector3d &_specular, double _cosinePow) override
Definition OpenGLRenderInterface.cpp:113
void setLineWidth(float _width) override
Definition OpenGLRenderInterface.cpp:866
void drawCylinder(double _radius, double _height, int slices=16, int stacks=16) override
Definition OpenGLRenderInterface.cpp:354
void drawSphere(double radius, int slices=16, int stacks=16) override
Definition OpenGLRenderInterface.cpp:171
void drawLineSegments(const std::vector< Eigen::Vector3d > &_vertices, const common::aligned_vector< Eigen::Vector2i > &_connections) override
Definition OpenGLRenderInterface.cpp:772
void drawMesh(const Eigen::Vector3d &_scale, const aiScene *_mesh) override
Definition OpenGLRenderInterface.cpp:728
void color4_to_float4(const aiColor4D *c, float f[4])
Definition OpenGLRenderInterface.cpp:555
void recursiveRender(const struct aiScene *sc, const struct aiNode *nd)
Definition OpenGLRenderInterface.cpp:648
void drawPyramid(double baseWidth, double baseDepth, double height) override
Definition OpenGLRenderInterface.cpp:509
void setViewport(int _x, int _y, int _width, int _height) override
Definition OpenGLRenderInterface.cpp:89
void drawCone(double radius, double height) override
Definition OpenGLRenderInterface.cpp:480
void pushMatrix() override
Definition OpenGLRenderInterface.cpp:131
void pushName(int _id) override
Definition OpenGLRenderInterface.cpp:141
Definition RenderInterface.hpp:71
std::vector< _Tp, Eigen::aligned_allocator< _Tp > > aligned_vector
Definition Memory.hpp:71
DecoBufferType
Definition RenderInterface.hpp:46
@ BT_Back
Definition RenderInterface.hpp:48
DecoColorChannel
Definition RenderInterface.hpp:52
Definition BulletCollisionDetector.cpp:65