1 #ifndef __SceneOpenSceneGraph_hh__
2 #define __SceneOpenSceneGraph_hh__
4 #include <bias_config.h>
6 #include <GLviewer/Scenes/SceneBase.hh>
7 #include <Gui/biasgl.h>
12 #include <osg/ShapeDrawable>
13 #include <osgViewer/Viewer>
14 #include <osgDB/ReadFile>
15 #include <Base/Math/Vector3.hh>
16 #include <GLviewer/Scenes/NodeInfo.hh>
19 #include <osgAnimation/BasicAnimationManager>
20 #include <osgAnimation/Animation>
36 if (nv && nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)
61 void playAnimation(osgAnimation::Animation* pAnimation,
int priority = 0,
float weight = 1.0)
65 osgAnimation::BasicAnimationManager::playAnimation(pAnimation,priority,weight);
112 int AppendSubTreeFromFile(
const std::string& fileName,
114 bool optimize =
false);
118 return AppendSubTreeFromFile(fileName, dummy); }
121 int AppendSubTreeFromImageFile(
const std::string& fileName,
122 const double& width_mm,
126 bool SaveSubTree(osg::Node *node,
const std::string &fileName);
130 void RemoveSubTreeAndParents(osg::Node* Node);
133 void RemoveSubTree(osg::Node* childNode);
142 void HeadlightSwitch(
bool on=
true);
145 { lightRepresentationVisible_ = !lightRepresentationVisible_;
146 UpdateLightRepresentation_(); };
159 void MakeTransparent(
const double transparency);
163 bool RightMouseDoubleClicked(
int x,
int y);
166 void SetAnimate(
const bool animate);
172 void SetAnimationTime(
const double current_time,
bool CallDraw=
true);
189 void SetNodeVisible(osg::Node* node,
const bool visible);
190 void SetNodeOccluder(osg::Node* node,
const bool state);
191 void SetNodeMarkerID(osg::Node* node,
const unsigned long long &
id);
193 {
return NodeInfoMap_;}
195 bool Save(std::string filename);
196 bool Load(std::string filename);
198 bool IsEditableNode(osg::Node* node);
215 const std::string &mirrortexture,
bool cutUpperHalf=
false);
217 osg::Node* createMirroredScene(osg::Node* model,
222 const std::string &mirrortexture,
bool cutUpperHalf);
225 clearMask_ = clearMask;
226 sceneView_->getCamera()->setClearMask(clearMask_);
230 sceneView_->updateTraversal();
231 sceneView_->renderingTraversals();
232 if (sceneView_.valid()) sceneView_->frame();
236 if(hasOpenSceneGraphAnimation_){
237 osgAnimation::AnimationList animlst = animationManager_.getAnimationList();
238 std::cout << animlst[0]->getStartTime() << std::endl;
239 animationManager_.playAnimation(animlst[0]);
240 std::cout <<
"after: " << animlst[0]->getStartTime() << std::endl;
245 if(hasOpenSceneGraphAnimation_){
246 osgAnimation::AnimationList animlst = animationManager_.getAnimationList();
247 animationManager_.stopAnimation(animlst[0]);
252 osgAnimation::AnimationList animlst = animationManager_.getAnimationList();
253 return animationManager_.isPlaying(animlst[0]);
257 animationManager_.NextFrame();
286 void UpdateLightRepresentation_();
287 void DisableZWriteForTransparentNodes_();
288 void CreateStandardNodes_();
290 std::string NodePtr2IDString_(osg::Node* node);
308 if (node.getUpdateCallback()) {
309 osgAnimation::AnimationManagerBase* b =
dynamic_cast<osgAnimation::AnimationManagerBase*
>(node.getUpdateCallback());
311 _am =
new osgAnimation::BasicAnimationManager(*b);
325 #endif // __SceneOpenSceneGraph_hh__
void operator()(osg::Node *node, osg::NodeVisitor *nv)
osg::ref_ptr< osg::Group > rootTree_
double lastPauseTime_
Time when the animation was paused for the last time.
container for scene root and ptr to nodeinfomap
const NodeInfoMap & GetNodeInfoMapRef()
osg::ref_ptr< osgViewer::Viewer > sceneView_
bool hasOpenSceneGraphAnimation_
void OpenSceneGraphAnimationNextFrame()
double timeOffset_
Time offset because of time "pauses".
MyBasicAnimationManager animationManager_
bool lightRepresentationVisible_
Implements narrow access to OpenSceneGraph.
~MyBasicAnimationManager()
osg::ref_ptr< osgAnimation::BasicAnimationManager > _am
osg::ref_ptr< osg::Light > light_
bool OpenSceneGraphAnimationIsPlaying()
Base class for all scenes.
void StartOpenSceneGraphAnimation()
osg::ref_ptr< osg::MatrixTransform > lightTransform_
MyBasicAnimationManager()
void StopOpenSceneGraphAnimation()
osg::observer_ptr< osgViewer::GraphicsWindow > embedWindow_
void playAnimation(osgAnimation::Animation *pAnimation, int priority=0, float weight=1.0)
osg::ref_ptr< osg::Switch > lightRepresentationSwitch_
void SetClearMask(int clearMask)
osg::ref_ptr< osg::FrameStamp > frameStamp_
int AppendSubTreeFromFile(const std::string &fileName)
osg::ref_ptr< osg::Geode > lightRepresentationGeode_
void apply(osg::Node &node)
void LightRepresentationVisibleSwitch()
Toggle the light visible switch.