Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/py color support osg viewer #1398

Merged
merged 8 commits into from
Aug 17, 2019
5 changes: 5 additions & 0 deletions python/dartpy/gui/osg/ImGuiViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ void ImGuiViewer(py::module& m)
dart::gui::osg::Viewer,
osg::ref_ptr<dart::gui::osg::ImGuiViewer>>(m, "ImGuiViewer")
.def(::py::init<>())
.def(
::py::init([](const Eigen::Vector4d& clearColor) {
return new ::dart::gui::osg::ImGuiViewer(eigToOsgVec4f(clearColor));
}),
::py::arg("clearColor"))
.def(::py::init<const osg::Vec4&>(), ::py::arg("clearColor"))
.def(
"getImGuiHandler",
Expand Down
5 changes: 5 additions & 0 deletions python/dartpy/gui/osg/Viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ void Viewer(py::module& m)
dart::common::Subject,
::osg::ref_ptr<dart::gui::osg::Viewer>>(m, "Viewer")
.def(::py::init<>())
.def(
::py::init([](const Eigen::Vector4f& clearColor) {
return new ::dart::gui::osg::Viewer(eigToOsgVec4d(clearColor));
}),
::py::arg("clearColor"))
.def(::py::init<const osg::Vec4&>(), ::py::arg("clearColor"))
.def(
"captureScreen",
Expand Down
51 changes: 26 additions & 25 deletions python/examples/hello_world_gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@


class HelloWorldNode(dart.gui.osg.RealTimeWorldNode):
# Use this function to execute custom code before each time that the
# window is rendered. This function can be deleted if it does not need
# to be used.
def customPreRefresh(self):
pass

# Use this function to execute custom code after each time that the
# window is rendered. This function can be deleted if it does not need
# to be used.
def customPostRefresh(self):
pass

# Use this function to execute custom code before each simulation time
# step is performed. This function can be deleted if it does not need
# to be used.
def customPreStep(self):
pass

# Use this function to execute custom code after each simulation time
# step is performed. This function can be deleted if it does not need
# to be used.
def customPostStep(self):
pass
# Use this function to execute custom code before each time that the
# window is rendered. This function can be deleted if it does not need
# to be used.
def customPreRefresh(self):
pass

# Use this function to execute custom code after each time that the
# window is rendered. This function can be deleted if it does not need
# to be used.
def customPostRefresh(self):
pass

# Use this function to execute custom code before each simulation time
# step is performed. This function can be deleted if it does not need
# to be used.
def customPreStep(self):
pass

# Use this function to execute custom code after each simulation time
# step is performed. This function can be deleted if it does not need
# to be used.
def customPostStep(self):
pass


def main():
Expand All @@ -37,10 +37,11 @@ def main():
world.addSkeleton(ground)
world.setGravity([0, -9.81, 0])

# Create world node and add it to viewer
node = HelloWorldNode(world)

# Create world node and add it to viewer
viewer = dart.gui.osg.Viewer()
# create a viewer with background color (red, green, blue, alpha), here: white
viewer = dart.gui.osg.Viewer([1.0, 1.0, 1.0, 1.0])
viewer.addWorldNode(node)

# Grid settings
Expand Down