DART 6.13.2
Loading...
Searching...
No Matches
Utils.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2022, 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_OSG_UTILS_HPP_
34#define DART_GUI_OSG_UTILS_HPP_
35
36#include <Eigen/Geometry>
37#include <osg/Camera>
38#include <osg/Matrix>
39
40namespace dart::gui::osg {
41
44template <typename T = double>
45constexpr T getAlphaThreshold();
46
48template <typename Scalar>
49::osg::Matrix eigToOsgMatrix(
50 const Eigen::Transform<Scalar, 3, Eigen::Isometry>& tf);
51
53template <typename Derived>
54::osg::Matrix eigToOsgMatrix(const Eigen::DenseBase<Derived>& M);
55
57template <typename Derived>
58::osg::Vec3f eigToOsgVec3f(const Eigen::MatrixBase<Derived>& vec);
59
61template <typename Derived>
62::osg::Vec3d eigToOsgVec3d(const Eigen::MatrixBase<Derived>& vec);
63
66template <typename Derived>
67typename std::conditional<
68 std::is_same<typename Derived::Scalar, float>::value,
69 ::osg::Vec3f,
70 ::osg::Vec3d>::type
71eigToOsgVec3(const Eigen::MatrixBase<Derived>& vec);
72
74Eigen::Vector3f osgToEigVec3(const ::osg::Vec3f& vec);
75
77Eigen::Vector3d osgToEigVec3(const ::osg::Vec3d& vec);
78
80template <typename Derived>
81::osg::Vec4f eigToOsgVec4f(const Eigen::MatrixBase<Derived>& vec);
82
84template <typename Derived>
85::osg::Vec4d eigToOsgVec4d(const Eigen::MatrixBase<Derived>& vec);
86
89template <typename Derived>
90std::conditional<
91 std::is_same<typename Derived::Scalar, float>::value,
92 ::osg::Vec4f,
93 ::osg::Vec4d>
94eigToOsgVec4(const Eigen::MatrixBase<Derived>& vec);
95
97Eigen::Vector4f osgToEigVec4(const ::osg::Vec4f& vec);
98
100Eigen::Vector4d osgToEigVec4(const ::osg::Vec4d& vec);
101
103::osg::Camera* createRttCamera(
104 ::osg::Camera::BufferComponent buffer,
105 ::osg::Texture* tex,
106 bool isAbsolute = false);
107
110::osg::Camera* createHudCamera(
111 double left = 0, double right = 1, double bottom = 0, double top = 1);
112
114::osg::Geode* createScreenQuad(float width, float height, float scale = 1.0f);
115
116} // namespace dart::gui::osg
117
119
120#endif // DART_GUI_OSG_UTILS_HPP_
std::string type
Definition SdfParser.cpp:82
Definition DefaultEventHandler.cpp:49
::osg::Vec3f eigToOsgVec3f(const Eigen::MatrixBase< Derived > &vec)
Converts Eigen::MatrixBase to osg::Vec3f.
Definition Utils-impl.hpp:107
::osg::Vec4f eigToOsgVec4f(const Eigen::MatrixBase< Derived > &vec)
Converts Eigen::MatrixBase to osg::Vec4f.
Definition Utils-impl.hpp:137
::osg::Camera * createHudCamera(double left, double right, double bottom, double top)
Creates a head-up display (HUD) camera that renders on the top after the main scene is drawn,...
Definition Utils.cpp:96
constexpr T getAlphaThreshold()
Returns the alpha threshold for demining if the object is a transparent object or not.
Definition Utils-impl.hpp:42
::osg::Matrix eigToOsgMatrix(const Eigen::Transform< Scalar, 3, Eigen::Isometry > &tf)
Converts Eigen::Isometry to osg::Matrix.
Definition Utils-impl.hpp:60
::osg::Camera * createRttCamera(::osg::Camera::BufferComponent buffer, ::osg::Texture *tex, bool isAbsolute)
Create a Render-To-Texture (RTT) camera.
Definition Utils.cpp:67
std::conditional< std::is_same< typename Derived::Scalar, float >::value, ::osg::Vec4f, ::osg::Vec4d > eigToOsgVec4(const Eigen::MatrixBase< Derived > &vec)
Converts Eigen::MatrixBase to osg::Vec4f or osg::Vec4d based on the scalar type.
Definition Utils-impl.hpp:155
Eigen::Vector3f osgToEigVec3(const ::osg::Vec3f &vec)
Converts osg::Vec3f to Eigen::Vector3f.
Definition Utils.cpp:43
::osg::Vec3d eigToOsgVec3d(const Eigen::MatrixBase< Derived > &vec)
Converts Eigen::MatrixBase to osg::Vec3d.
Definition Utils-impl.hpp:114
::osg::Vec4d eigToOsgVec4d(const Eigen::MatrixBase< Derived > &vec)
Converts Eigen::MatrixBase to osg::Vec4d.
Definition Utils-impl.hpp:144
::osg::Geode * createScreenQuad(float width, float height, float scale)
Creates a osg::Geode of quad shape.
Definition Utils.cpp:113
std::conditional< std::is_same< typenameDerived::Scalar, float >::value,::osg::Vec3f,::osg::Vec3d >::type eigToOsgVec3(const Eigen::MatrixBase< Derived > &vec)
Converts Eigen::MatrixBase to osg::Vec3f or osg::Vec3d based on the scalar type.
Definition Utils-impl.hpp:125
Eigen::Vector4f osgToEigVec4(const ::osg::Vec4f &vec)
Converts osg::Vec4f to Eigen::Vector4f.
Definition Utils.cpp:55