Skip to content

Commit

Permalink
Merge pull request #588 from dartsim/package_reorganizing_osgKido_rename
Browse files Browse the repository at this point in the history
Change namespace and directory of osgKido
  • Loading branch information
jslee02 committed Jan 21, 2016
2 parents 24ff5c4 + 69ea914 commit 1bb64a7
Show file tree
Hide file tree
Showing 59 changed files with 798 additions and 696 deletions.
31 changes: 26 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if(MSVC)
else()
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
endif()
option(KIDO_BUILD_OSGKIDO "Build osgKido library" ON)
option(KIDO_BUILD_OSGKIDO "Build osgKido library" ON) # TODO(JS): Rename the option name to more relevant name to osg GUI and add more options for other extensions (#590).
option(KIDO_BUILD_EXAMPLES "Build examples" ON)
option(KIDO_BUILD_TUTORIALS "Build tutorials" ON)
option(KIDO_BUILD_UNITTESTS "Build unit tests" ON)
Expand Down Expand Up @@ -255,6 +255,31 @@ else()
endif()
endif()

# OpenSceneGraph
find_package(OpenSceneGraph 3.0 QUIET
COMPONENTS osg osgViewer osgManipulator osgGA osgDB)
if(OPENSCENEGRAPH_FOUND)
message(STATUS "Looking for OpenSceneGraph -- ${OPENSCENEGRAPH_VERSION} found")
set(HAVE_OPENSCENEGRAPH TRUE)
else(OPENSCENEGRAPH_FOUND)
# kido-gui-osg requires both OSG and OpenThreads. This section attempts to
# identify which of those are missing from the building machine and offer
# advice to the user for getting osgKido to build.
find_package(OpenThreads QUIET)
if(OPENTHREADS_FOUND)
set(warning_msg "Could NOT find OpenSceneGraph")
else(OPENTHREADS_FOUND)
if(OSG_LIBRARY)
set(warning_msg "Could NOT find OpenThreads")
else(OSG_LIBRARY)
set(warning_msg "Could NOT find OpenSceneGraph nor OpenThreads")
endif(OSG_LIBRARY)
endif(OPENTHREADS_FOUND)
message(WARNING "${warning_msg} -- we will skip kido-gui-osg\n"
"If you believe you do have both OSG and OpenThreads installed, try setting OSG_DIR")
set(HAVE_OPENSCENEGRAPH FALSE)
endif(OPENSCENEGRAPH_FOUND)

# FLANN
find_package(FLANN 1.8.4 QUIET)
if(FLANN_FOUND)
Expand Down Expand Up @@ -567,10 +592,6 @@ install(FILES package.xml DESTINATION share/${PROJECT_NAME})
#===============================================================================
add_subdirectory(kido)

if(KIDO_BUILD_OSGKIDO)
add_subdirectory(osgKido)
endif(KIDO_BUILD_OSGKIDO)

# Unit tests
if(KIDO_BUILD_UNITTESTS)
enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion ci/before_install_osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ipopt
ros/deps/urdfdom
ros/deps/urdfdom_headers
ros/deps/console_bridge
ros/deps/gtest
open-scene-graph
'

brew install $PACKAGES | grep -v '%$'
32 changes: 15 additions & 17 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,15 @@ Description: Kinematics Dynamics and Optimization Library for Animation and Robo
Multibody dynamic simulation in KIDO is an extension of RTQL8, an open source
software created by the Georgia Tech Graphics Lab.

Package: libkido-optimizer-nlopt0-dev
Package: libkido-gui-osg0-dev
Section: libdevel
Architecture: any
Pre-Depends: ${misc:Pre-Depends}
Depends: ${misc:Depends},
libkido0-dev,
libkido-optimizer-nlopt0.1 (= ${binary:Version}),
libnlopt-dev
libkido-gui0-dev,
libkido-gui-osg0.1 (= ${binary:Version}),
libopenthreads-dev,
libopenscenegraph-dev
Description: Kinematics Dynamics and Optimization Library for Animation and Robotics, development component files
KIDO is a collaborative, cross-platform, open source library created by the
Georgia Tech Graphics Lab and Humanoid Robotics Lab. The library provides data
Expand All @@ -315,7 +316,7 @@ Description: Kinematics Dynamics and Optimization Library for Animation and Robo
Multibody dynamic simulation in KIDO is an extension of RTQL8, an open source
software created by the Georgia Tech Graphics Lab.

Package: libkido-optimizer-nlopt0.1
Package: libkido-gui-osg0.1
Section: libs
Architecture: any
Pre-Depends: ${misc:Pre-Depends}
Expand Down Expand Up @@ -345,14 +346,14 @@ Description: Kinematics Dynamics and Optimization Library for Animation and Robo
Multibody dynamic simulation in KIDO is an extension of RTQL8, an open source
software created by the Georgia Tech Graphics Lab.

Package: libkido-optimizer-ipopt0-dev
Package: libkido-optimizer-nlopt0-dev
Section: libdevel
Architecture: any
Pre-Depends: ${misc:Pre-Depends}
Depends: ${misc:Depends},
libkido0-dev,
libkido-optimizer-ipopt0.1 (= ${binary:Version}),
coinor-libipopt-dev
libkido-optimizer-nlopt0.1 (= ${binary:Version}),
libnlopt-dev
Description: Kinematics Dynamics and Optimization Library for Animation and Robotics, development component files
KIDO is a collaborative, cross-platform, open source library created by the
Georgia Tech Graphics Lab and Humanoid Robotics Lab. The library provides data
Expand All @@ -377,7 +378,7 @@ Description: Kinematics Dynamics and Optimization Library for Animation and Robo
Multibody dynamic simulation in KIDO is an extension of RTQL8, an open source
software created by the Georgia Tech Graphics Lab.

Package: libkido-optimizer-ipopt0.1
Package: libkido-optimizer-nlopt0.1
Section: libs
Architecture: any
Pre-Depends: ${misc:Pre-Depends}
Expand Down Expand Up @@ -407,17 +408,14 @@ Description: Kinematics Dynamics and Optimization Library for Animation and Robo
Multibody dynamic simulation in KIDO is an extension of RTQL8, an open source
software created by the Georgia Tech Graphics Lab.

Package: libosgKido0-dev
Package: libkido-optimizer-ipopt0-dev
Section: libdevel
Architecture: any
Pre-Depends: ${misc:Pre-Depends}
Depends: ${misc:Depends},
libkido0-dev,
libkido-planning0-dev,
libkido-utils0-dev,
libosgKido0.1 (= ${binary:Version}),
libopenthreads-dev,
libopenscenegraph-dev
libkido-optimizer-ipopt0.1 (= ${binary:Version}),
coinor-libipopt-dev
Description: Kinematics Dynamics and Optimization Library for Animation and Robotics, development component files
KIDO is a collaborative, cross-platform, open source library created by the
Georgia Tech Graphics Lab and Humanoid Robotics Lab. The library provides data
Expand All @@ -442,7 +440,7 @@ Description: Kinematics Dynamics and Optimization Library for Animation and Robo
Multibody dynamic simulation in KIDO is an extension of RTQL8, an open source
software created by the Georgia Tech Graphics Lab.

Package: libosgKido0.1
Package: libkido-optimizer-ipopt0.1
Section: libs
Architecture: any
Pre-Depends: ${misc:Pre-Depends}
Expand Down Expand Up @@ -470,4 +468,4 @@ Description: Kinematics Dynamics and Optimization Library for Animation and Robo
KIDO has applications in robotics and computer animation because it features a
multibody dynamic simulator and tools for control and motion planning.
Multibody dynamic simulation in KIDO is an extension of RTQL8, an open source
software created by the Georgia Tech Graphics Lab.
software created by the Georgia Tech Graphics Lab.
2 changes: 2 additions & 0 deletions debian/libkido-gui-osg0-dev.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
usr/include/kido/gui/osg/*
usr/lib/libkido-gui-osg.so
1 change: 1 addition & 0 deletions debian/libkido-gui-osg0.1.install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
usr/lib/libkido-gui-osg.so.*
2 changes: 0 additions & 2 deletions debian/libosgKido0-dev.install

This file was deleted.

1 change: 0 additions & 1 deletion debian/libosgKido0.1.install

This file was deleted.

1 change: 1 addition & 0 deletions kido/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#cmakedefine HAVE_IPOPT 1
#cmakedefine HAVE_SNOPT 1
#cmakedefine HAVE_BULLET_COLLISION 1
#cmakedefine HAVE_OPENSCENEGRAPH 1

#define KIDO_ROOT_PATH "@CMAKE_SOURCE_DIR@/"
#define KIDO_DATA_PATH "@CMAKE_SOURCE_DIR@/data/"
Expand Down
6 changes: 6 additions & 0 deletions kido/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ file(GLOB hdrs "*.hpp")

include_directories(SYSTEM ${GLUT_INCLUDE_DIR})

# Add subdirectories
if(HAVE_OPENSCENEGRAPH)
add_subdirectory(osg)
endif(HAVE_OPENSCENEGRAPH)

# Library
kido_add_library(kido-gui ${srcs} ${hdrs})
target_link_libraries(kido-gui kido kido-utils ${GLUT_LIBRARY})

# Generate header for this namespace
kido_get_filename_components(header_names "gui headers" ${hdrs})
list(APPEND header_names "osg/osg.hpp")
kido_generate_include_header_list(
gui_headers
"kido/gui/"
Expand Down
40 changes: 40 additions & 0 deletions kido/gui/osg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
include_directories(SYSTEM ${OPENSCENEGRAPH_INCLUDE_DIRS})

# Search all header and source files
file(GLOB srcs "*.cpp")
file(GLOB hdrs "*.hpp")

set(kido_gui_osg_srcs ${srcs})
set(kido_gui_osg_hdrs ${hdrs})

add_subdirectory(render)

# Library
kido_add_library(kido-gui-osg ${kido_gui_osg_srcs} ${kido_gui_osg_hdrs})
target_link_libraries(kido-gui-osg kido kido-utils ${OPENSCENEGRAPH_LIBRARIES})

# Generate header for this namespace
kido_get_filename_components(header_names "gui osg headers" ${hdrs})
list(APPEND header_names "render/render.hpp")
kido_generate_include_header_list(
gui_osg_headers
"kido/gui/osg/"
"gui osg headers"
${header_names}
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/osg.hpp.in
${CMAKE_CURRENT_BINARY_DIR}/osg.hpp
)

if(${KIDO_BUILD_EXAMPLES})
add_subdirectory(examples)
endif(${KIDO_BUILD_EXAMPLES})

# Install
install(
FILES ${hdrs} ${CMAKE_CURRENT_BINARY_DIR}/osg.hpp
DESTINATION include/kido/gui/osg
COMPONENT headers
)
install(TARGETS kido-gui-osg EXPORT KIDOTargets DESTINATION lib)
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,21 @@

#include <osgGA/GUIEventAdapter>

#include "osgKido/DefaultEventHandler.hpp"
#include "osgKido/MouseEventHandler.hpp"
#include "osgKido/Viewer.hpp"
#include "osgKido/render/ShapeNode.hpp"
#include "osgKido/EntityNode.hpp"
#include "osgKido/Utils.hpp"
#include "kido/gui/osg/DefaultEventHandler.hpp"
#include "kido/gui/osg/MouseEventHandler.hpp"
#include "kido/gui/osg/Viewer.hpp"
#include "kido/gui/osg/render/ShapeNode.hpp"
#include "kido/gui/osg/EntityNode.hpp"
#include "kido/gui/osg/Utils.hpp"

#include "kido/dynamics/Entity.hpp"


#include <iostream>

namespace osgKido
{
namespace kido {
namespace gui {
namespace osg {

DefaultEventHandler::DefaultEventHandler(Viewer* _viewer)
: mViewer(_viewer),
Expand Down Expand Up @@ -103,7 +104,7 @@ Eigen::Vector3d DefaultEventHandler::getDeltaCursor(
ConstraintType _constraint,
const Eigen::Vector3d& _constraintVector) const
{
osg::Vec3d eye, center, up;
::osg::Vec3d eye, center, up;
mViewer->getCamera()->getViewMatrixAsLookAt(eye, center, up);

Eigen::Vector3d near, far;
Expand Down Expand Up @@ -150,15 +151,15 @@ void DefaultEventHandler::getNearAndFarPointUnderCursor(Eigen::Vector3d& near,
Eigen::Vector3d& far,
double distance) const
{
osg::Camera* C = mViewer->getCamera();
osg::Matrix VPW = C->getViewMatrix() * C->getProjectionMatrix()
::osg::Camera* C = mViewer->getCamera();
::osg::Matrix VPW = C->getViewMatrix() * C->getProjectionMatrix()
* C->getViewport()->computeWindowMatrix();
osg::Matrix invVPW;
::osg::Matrix invVPW;
invVPW.invert(VPW);

double x = getWindowCursorX(), y = getWindowCursorY();
osg::Vec3 osgNear = osg::Vec3(x,y,0.0) * invVPW;
osg::Vec3 osgFar = osg::Vec3(x,y,distance) * invVPW;
::osg::Vec3 osgNear = ::osg::Vec3(x,y,0.0) * invVPW;
::osg::Vec3 osgFar = ::osg::Vec3(x,y,distance) * invVPW;

near = osgToEigVec3(osgNear);
far = osgToEigVec3(osgFar);
Expand Down Expand Up @@ -224,7 +225,7 @@ void DefaultEventHandler::pick(std::vector<PickInfo>& infoVector,
infoVector.reserve(hlist.size());
for(const osgUtil::LineSegmentIntersector::Intersection& intersect : hlist)
{
osg::Drawable* drawable = intersect.drawable;
::osg::Drawable* drawable = intersect.drawable;
render::ShapeNode* shape =
dynamic_cast<render::ShapeNode*>(drawable->getParent(0));
if(shape)
Expand Down Expand Up @@ -442,4 +443,6 @@ void DefaultEventHandler::handleDestructionNotification(
mMouseEventHandlers.erase(it);
}

} // namespace osgKido
} // namespace osg
} // namespace gui
} // namespace kido
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef OSGKIDO_DEFAULTEVENTHANDLER_HPP
#define OSGKIDO_DEFAULTEVENTHANDLER_HPP
#ifndef KIDO_GUI_OSG_DEFAULTEVENTHANDLER_HPP
#define KIDO_GUI_OSG_DEFAULTEVENTHANDLER_HPP

#include <vector>
#include <array>
Expand All @@ -49,14 +49,14 @@
#include "kido/common/Observer.hpp"

namespace kido {

namespace dynamics {
class Entity;
class Shape;
} // dynamics
} // kido

namespace osgKido
{
namespace gui {
namespace osg {

struct PickInfo
{
Expand Down Expand Up @@ -198,7 +198,7 @@ class DefaultEventHandler : public osgGA::GUIEventHandler,
virtual void handleDestructionNotification(
const kido::common::Subject* _subject) override;

/// osgKido::Viewer that this event handler is tied to
/// kido::gui::osg::Viewer that this event handler is tied to
Viewer* mViewer;

/// Set of MouseEventHandlers that are tied to this DefaultEventHandler
Expand Down Expand Up @@ -231,6 +231,8 @@ class DefaultEventHandler : public osgGA::GUIEventHandler,

};

} // namespace osgKido
} // namespace osg
} // namespace gui
} // namespace kido

#endif // OSGKIDO_DEFAULTEVENTHANDLER_HPP
#endif // KIDO_GUI_OSG_DEFAULTEVENTHANDLER_HPP
Loading

0 comments on commit 1bb64a7

Please sign in to comment.