33 #ifndef DART_GUI_OSG_VIEWER_HPP_
34 #define DART_GUI_OSG_VIEWER_HPP_
37 #include <unordered_set>
40 #include <osgViewer/Viewer>
41 #include <osgShadow/ShadowTechnique>
49 namespace simulation {
64 class DefaultEventHandler;
67 class SimpleFrameShapeDnD;
68 class InteractiveFrame;
69 class InteractiveFrameDnD;
120 Viewer(const ::osg::Vec4& clearColor = ::osg::Vec4(0.9,0.9,0.9,1.0));
145 void record(
const std::string& directory,
const std::string& prefix =
"image",
146 bool restart =
false, std::size_t digits=6);
177 void removeWorldNode(std::shared_ptr<dart::simulation::World> _oldWorld);
182 std::shared_ptr<dart::simulation::World> _world)
const;
192 const std::unordered_set<ViewerAttachment*>&
getAttachments()
const;
256 bool _useExternalIK =
true,
257 bool _useWholeBody =
false);
294 const ::osg::ref_ptr<::osg::Group>&
getRootGroup()
const;
std::size_t index
Definition: SkelParser.cpp:1617
The Subject class is a base class for any object that wants to report when it gets destroyed.
Definition: Subject.hpp:58
BodyNode class represents a single node of the skeleton.
Definition: BodyNode.hpp:78
Entity class is a base class for any objects that exist in the kinematic tree structure of DART.
Definition: Entity.hpp:60
The SimpleFrame class offers a user-friendly way of creating arbitrary Frames within the kinematic tr...
Definition: SimpleFrame.hpp:52
Definition: DragAndDrop.hpp:272
Definition: DefaultEventHandler.hpp:101
DragAndDrop is a class that facilitates enabling various kinds of dart Entities to be dragged and dro...
Definition: DragAndDrop.hpp:61
Definition: DragAndDrop.hpp:240
Definition: InteractiveFrame.hpp:112
Definition: Viewer.cpp:56
SimpleFrameDnD is a DragAndDrop implementation for SimpleFrame objects.
Definition: DragAndDrop.hpp:180
SimpleFrameShapeDnD is a version of SimpleFrameDnD that allows a specific Shape within the SimpleFram...
Definition: DragAndDrop.hpp:212
Definition: Viewer.hpp:75
ViewerAttachment()
Default constructor.
Definition: Viewer.cpp:151
Viewer * getViewer()
Definition: Viewer.cpp:165
virtual void attach(Viewer *newViewer)
This function will get called when the visual is attached to a new Viewer.
Definition: Viewer.cpp:183
Viewer * mViewer
Definition: Viewer.hpp:111
virtual ~ViewerAttachment()
Virtual destructor.
Definition: Viewer.cpp:158
virtual void customAttach(Viewer *newViewer)
This function will be called by attach(Viewer*) so you can do customized setup when the Viewer change...
Definition: Viewer.cpp:177
virtual void refresh()=0
This function will get called each time the Viewer is refreshed.
Definition: Viewer.hpp:116
void setUpwardsDirection(const ::osg::Vec3 &_up)
Set the direction that this Viewer should consider to be upwards (default is <0,0,...
Definition: Viewer.cpp:510
Viewer(const ::osg::Vec4 &clearColor=::osg::Vec4(0.9, 0.9, 0.9, 1.0))
Constructor for dart::gui::osg::Viewer.
Definition: Viewer.cpp:193
bool isSimulating() const
Return true iff this Viewer is currently set to simulate.
Definition: Viewer.cpp:569
void removeWorldNode(WorldNode *_oldWorldNode)
Remove a WorldNode from this Viewer.
Definition: Viewer.cpp:389
void simulate(bool _on)
Set all currently active WorldNodes to simulate _on.
Definition: Viewer.cpp:553
void addWorldNode(WorldNode *_newWorldNode, bool _active=true)
Add a WorldNode to this Viewer.
Definition: Viewer.cpp:372
virtual void switchHeadlights(bool _on)
Pass in true to turn headlights on, false to turn headlights off.
Definition: Viewer.cpp:313
bool mSimulating
True iff this Viewer is currently simulating.
Definition: Viewer.hpp:358
WorldNode * getWorldNode(std::shared_ptr< dart::simulation::World > _world) const
Get the WorldNode associated with the given _world.
Definition: Viewer.cpp:412
std::string mImageDirectory
Directory for saving images.
Definition: Viewer.hpp:322
DragAndDrop * enableDragAndDrop(dart::dynamics::Entity *_entity)
Returns a nullptr if _entity is not a type that can support the built-in drag and drop features,...
Definition: Viewer.cpp:590
const std::string & getInstructions() const
Get a string containing the user interface constructions for this Viewer.
Definition: Viewer.cpp:795
void addAttachment(ViewerAttachment *_attachment)
Add an attachment to this Viewer.
Definition: Viewer.cpp:432
void record(const std::string &directory, const std::string &prefix="image", bool restart=false, std::size_t digits=6)
As the screen refreshes, save screen capture images to the specified directory.
Definition: Viewer.cpp:255
std::multimap< dart::dynamics::Shape *, SimpleFrameShapeDnD * > mSimpleFrameShapeDnDMap
Multimap from Shape ptrs to SimpleFrameShapeDnD ptrs.
Definition: Viewer.hpp:384
bool isAllowingSimulation() const
Return true iff this Viewer is currently allowing simulation to happen.
Definition: Viewer.cpp:584
std::string mInstructions
string of instructions for this Viewer
Definition: Viewer.hpp:373
std::string mScreenCapName
Name for the next screen capture.
Definition: Viewer.hpp:328
::osg::ref_ptr< DefaultEventHandler > mDefaultEventHandler
Default WorldNodeEventHandler for this dart::gui::osg::Viewer.
Definition: Viewer.hpp:331
const ::osg::ref_ptr<::osg::LightSource > & getLightSource(std::size_t index=0) const
Get one of the LightSources of this Viewer index either 0 or 1 Useful for shadowing techniques.
Definition: Viewer.cpp:475
::osg::ref_ptr<::osg::Light > mLight2
Non-headlights Light #2.
Definition: Viewer.hpp:346
void setVerticalFieldOfView(double fov)
Sets the vertical field of view of the master camera of the view.
Definition: Viewer.cpp:847
void allowSimulation(bool _allow)
Prevent simulation from starting, even if simulate(true) is called.
Definition: Viewer.cpp:575
virtual void updateViewer()
Called automatically at the beginning of each render cycle.
Definition: Viewer.cpp:807
std::size_t mImageSequenceNum
Current number of the image sequence for screen recording.
Definition: Viewer.hpp:310
::osg::Vec3 mOver
Vector pointing to the side.
Definition: Viewer.hpp:355
::osg::Vec3 mUpwards
Vector pointing upwards.
Definition: Viewer.hpp:352
void updateDragAndDrops()
Called automatically by updateViewer()
Definition: Viewer.cpp:813
::osg::ref_ptr<::osg::Light > mLight1
Non-headlights Light #1.
Definition: Viewer.hpp:340
bool disableDragAndDrop(DragAndDrop *_dnd)
Delete a DragAndDrop object.
Definition: Viewer.cpp:706
void setupDefaultLights()
Set up the default lighting scheme.
Definition: Viewer.cpp:484
bool mHeadlights
True iff headlights were last set to be on.
Definition: Viewer.hpp:364
::osg::Group * getLightGroup()
Get the Group node that contains the LightSources for this Viewer.
Definition: Viewer.cpp:463
::osg::ref_ptr<::osg::LightSource > mLightSource2
Non-headlights LightSource #2.
Definition: Viewer.hpp:349
void captureScreen(const std::string &filename)
Capture the current screen in a png file.
Definition: Viewer.cpp:238
void addInstructionText(const std::string &_instruction)
Add something to the instructions for this Viewer.
Definition: Viewer.cpp:801
::osg::ref_ptr<::osg::Group > mLightGroup
The Group Node containing light sources.
Definition: Viewer.hpp:337
virtual ~Viewer()
Destructor.
Definition: Viewer.cpp:227
void pauseRecording()
If the Viewer is recording, then pause the recording.
Definition: Viewer.cpp:282
void setWorldNodeActive(WorldNode *_node, bool _active=true)
Set the given WorldNode to active.
Definition: Viewer.cpp:536
std::unordered_set< ViewerAttachment * > mAttachments
Definition: Viewer.hpp:370
double getVerticalFieldOfView() const
Returns the vertical field of view of the master camera of the view.
Definition: Viewer.cpp:878
::osg::ref_ptr<::osg::Group > mRootGroup
The root node of this Viewer.
Definition: Viewer.hpp:334
virtual void switchDefaultEventHandler(bool _on)
Creates the default event handler for this dart::gui::osg::Viewer.
Definition: Viewer.cpp:299
std::string mImagePrefix
Prefix to apply to images.
Definition: Viewer.hpp:325
std::map< WorldNode *, bool > mWorldNodes
Map of WorldNodes in this dart::gui::osg::Viewer.
Definition: Viewer.hpp:368
const ::osg::ref_ptr<::osg::Group > & getRootGroup() const
Get the root ::osg::Group of this Viewer.
Definition: Viewer.cpp:841
bool isRecording() const
Returns true if the Viewer is currently recording.
Definition: Viewer.cpp:293
::osg::ref_ptr<::osg::LightSource > mLightSource1
Non-headlights LightSource #1.
Definition: Viewer.hpp:343
std::map< dart::dynamics::SimpleFrame *, SimpleFrameDnD * > mSimpleFrameDnDMap
Map from SimpleFrame ptrs to SimpleFrameDnD ptrs.
Definition: Viewer.hpp:379
DefaultEventHandler * getDefaultEventHandler() const
Return a pointer to the default event handler.
Definition: Viewer.cpp:307
void removeAttachment(ViewerAttachment *_attachment)
Remove the attachment from this Viewer.
Definition: Viewer.cpp:444
std::size_t mImageDigits
Number of digits to use when saving an image sequence.
Definition: Viewer.hpp:313
std::map< InteractiveFrame *, InteractiveFrameDnD * > mInteractiveFrameDnDMap
Map from InteractiveFrame ptrs to InteractiveFrameDnD ptrs.
Definition: Viewer.hpp:387
bool mAllowSimulation
True iff this Viewer is allowing simulation.
Definition: Viewer.hpp:361
std::map< dart::dynamics::BodyNode *, BodyNodeDnD * > mBodyNodeDnDMap
Map from BodyNode ptrs to BodyNodeDnD ptrs.
Definition: Viewer.hpp:390
bool mScreenCapture
Whether or not the Viewer is staged for a screen capture.
Definition: Viewer.hpp:319
bool mRecording
Whether or not the Viewer is currently recording.
Definition: Viewer.hpp:316
const std::unordered_set< ViewerAttachment * > & getAttachments() const
Get the set of attachments in this Viewer.
Definition: Viewer.cpp:457
bool checkHeadlights() const
True iff headlights are currently set to true.
Definition: Viewer.cpp:366
WorldNode class encapsulates a World to be displayed in OpenSceneGraph.
Definition: WorldNode.hpp:65
class World
Definition: World.hpp:83
Definition: BulletCollisionDetector.cpp:63