DART 6.12.2
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>
38
41
42namespace dart {
43
44namespace dynamics {
45class Skeleton;
46class BodyNode;
47class Shape;
48class ShapeFrame;
49} // namespace dynamics
50
51namespace gui {
53{
54public:
56 : mViewportX(0.0),
57 mViewportY(0.0),
58 mViewportWidth(0.0),
60 {
61 }
63
64 void initialize() override;
65 void destroy() override;
66
67 void setViewport(int _x, int _y, int _width, int _height) override;
68 void getViewport(int& _x, int& _y, int& _width, int& _height) const override;
69
70 void clear(const Eigen::Vector3d& _color) override;
71
72 void setMaterial(
73 const Eigen::Vector3d& _diffuse,
74 const Eigen::Vector3d& _specular,
75 double _cosinePow) override;
76 void getMaterial(
77 Eigen::Vector3d& _diffuse,
78 Eigen::Vector3d& _specular,
79 double& _cosinePow) const override;
80 void setDefaultMaterial() override;
81
82 void pushMatrix() override;
83 void popMatrix() override;
84 void pushName(int _id) override;
85 void popName() override;
86
87 void translate(const Eigen::Vector3d& _offset) override; // glTranslate
88 void rotate(const Eigen::Vector3d& _axis, double _rad) override; // glRotate
89 void transform(const Eigen::Isometry3d& _transform) override; // glMultMatrix
90 void scale(const Eigen::Vector3d& _scale) override; // glScale
91
94 void compileList(dynamics::Shape* _shape);
95 GLuint compileList(const Eigen::Vector3d& _scale, const aiScene* _mesh);
96
97 void drawSphere(double radius, int slices = 16, int stacks = 16) override;
98 void drawMultiSphere(
99 const std::vector<std::pair<double, Eigen::Vector3d>>& spheres,
100 int slices = 16,
101 int stacks = 16) override;
103 const std::vector<std::pair<double, Eigen::Vector3d>>& spheres,
104 std::size_t subdivisions) override;
105 void drawEllipsoid(const Eigen::Vector3d& _diameters) override;
106 void drawCube(const Eigen::Vector3d& _size) override;
107 void drawOpenCylinder(
108 double baseRadius,
109 double topRadius,
110 double height,
111 int slices = 16,
112 int stacks = 16) override;
113 void drawCylinder(
114 double _radius,
115 double _height,
116 int slices = 16,
117 int stacks = 16) override;
118 void drawCapsule(double radius, double height) override;
119 void drawCone(double radius, double height) override;
120 void drawPyramid(double baseWidth, double baseDepth, double height) override;
121 void drawMesh(const Eigen::Vector3d& _scale, const aiScene* _mesh) override;
122 void drawSoftMesh(const aiMesh* mesh) override;
123 void drawList(GLuint index) override;
124 void drawLineSegments(
125 const std::vector<Eigen::Vector3d>& _vertices,
126 const common::aligned_vector<Eigen::Vector2i>& _connections) override;
127
128 void setPenColor(const Eigen::Vector4d& _col) override;
129 void setPenColor(const Eigen::Vector3d& _col) override;
130
131 void setLineWidth(float _width) override;
132
133 void saveToImage(
134 const char* _filename, DecoBufferType _buffType = BT_Back) override;
135 void readFrameBuffer(
136 DecoBufferType _buffType, DecoColorChannel _ch, void* _pixels) override;
137
138private:
139 void color4_to_float4(const aiColor4D* c, float f[4]);
140 void set_float4(float f[4], float a, float b, float c, float d);
141 void applyMaterial(const struct aiMaterial* mtl);
142 void recursiveRender(const struct aiScene* sc, const struct aiNode* nd);
143
145
146public:
147 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
148};
149
150} // namespace gui
151} // namespace dart
152
153#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:60
Definition OpenGLRenderInterface.hpp:53
void scale(const Eigen::Vector3d &_scale) override
Definition OpenGLRenderInterface.cpp:164
void transform(const Eigen::Isometry3d &_transform) override
Definition OpenGLRenderInterface.cpp:159
void drawCapsule(double radius, double height) override
Definition OpenGLRenderInterface.cpp:445
void drawMultiSphere(const std::vector< std::pair< double, Eigen::Vector3d > > &spheres, int slices=16, int stacks=16) override
Definition OpenGLRenderInterface.cpp:224
void drawEllipsoid(const Eigen::Vector3d &_diameters) override
Definition OpenGLRenderInterface.cpp:281
void drawList(GLuint index) override
Definition OpenGLRenderInterface.cpp:765
void compileList(dynamics::Skeleton *_skel)
Definition OpenGLRenderInterface.cpp:786
void drawCube(const Eigen::Vector3d &_size) override
Definition OpenGLRenderInterface.cpp:288
void translate(const Eigen::Vector3d &_offset) override
Definition OpenGLRenderInterface.cpp:149
void clear(const Eigen::Vector3d &_color) override
Definition OpenGLRenderInterface.cpp:107
void rotate(const Eigen::Vector3d &_axis, double _rad) override
Definition OpenGLRenderInterface.cpp:154
void popName() override
Definition OpenGLRenderInterface.cpp:144
void destroy() override
Definition OpenGLRenderInterface.cpp:87
int mViewportX
Definition OpenGLRenderInterface.hpp:144
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:874
void setDefaultMaterial() override
Definition OpenGLRenderInterface.cpp:127
void set_float4(float f[4], float a, float b, float c, float d)
Definition OpenGLRenderInterface.cpp:561
void drawSoftMesh(const aiMesh *mesh) override
Definition OpenGLRenderInterface.cpp:741
void popMatrix() override
Definition OpenGLRenderInterface.cpp:134
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:241
void readFrameBuffer(DecoBufferType _buffType, DecoColorChannel _ch, void *_pixels) override
Definition OpenGLRenderInterface.cpp:869
int mViewportY
Definition OpenGLRenderInterface.hpp:144
int mViewportWidth
Definition OpenGLRenderInterface.hpp:144
void applyMaterial(const struct aiMaterial *mtl)
Definition OpenGLRenderInterface.cpp:571
void drawOpenCylinder(double baseRadius, double topRadius, double height, int slices=16, int stacks=16) override
Definition OpenGLRenderInterface.cpp:330
int mViewportHeight
Definition OpenGLRenderInterface.hpp:144
void initialize() override
Definition OpenGLRenderInterface.cpp:73
void setPenColor(const Eigen::Vector4d &_col) override
Definition OpenGLRenderInterface.cpp:854
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:864
void drawCylinder(double _radius, double _height, int slices=16, int stacks=16) override
Definition OpenGLRenderInterface.cpp:352
void drawSphere(double radius, int slices=16, int stacks=16) override
Definition OpenGLRenderInterface.cpp:169
void drawLineSegments(const std::vector< Eigen::Vector3d > &_vertices, const common::aligned_vector< Eigen::Vector2i > &_connections) override
Definition OpenGLRenderInterface.cpp:770
void drawMesh(const Eigen::Vector3d &_scale, const aiScene *_mesh) override
Definition OpenGLRenderInterface.cpp:726
void color4_to_float4(const aiColor4D *c, float f[4])
Definition OpenGLRenderInterface.cpp:553
void recursiveRender(const struct aiScene *sc, const struct aiNode *nd)
Definition OpenGLRenderInterface.cpp:646
void drawPyramid(double baseWidth, double baseDepth, double height) override
Definition OpenGLRenderInterface.cpp:507
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:478
void pushMatrix() override
Definition OpenGLRenderInterface.cpp:129
void pushName(int _id) override
Definition OpenGLRenderInterface.cpp:139
Definition RenderInterface.hpp:72
std::vector< _Tp, Eigen::aligned_allocator< _Tp > > aligned_vector
Definition Memory.hpp:71
DecoBufferType
Definition RenderInterface.hpp:47
@ BT_Back
Definition RenderInterface.hpp:49
DecoColorChannel
Definition RenderInterface.hpp:53
Definition BulletCollisionDetector.cpp:60