@@ -277,6 +277,7 @@ class WindowSceneImpl : public WindowScene
277
277
RenderWindow* rWin;
278
278
Ptr<OgreBites::CameraMan> camman;
279
279
Ptr<Rectangle2D> bgplane;
280
+ std::unordered_map<String, Controller<Real>*> frameCtrlrs;
280
281
281
282
Ogre::RenderTarget* depthRTT;
282
283
int flags;
@@ -495,7 +496,8 @@ class WindowSceneImpl : public WindowScene
495
496
node->attachObject (ent);
496
497
}
497
498
498
- void removeEntity (const String& name) CV_OVERRIDE {
499
+ void removeEntity (const String& name) CV_OVERRIDE
500
+ {
499
501
SceneNode& node = _getSceneNode (sceneMgr, name);
500
502
node.getAttachedObject (name)->detachFromParent ();
501
503
@@ -576,6 +578,52 @@ class WindowSceneImpl : public WindowScene
576
578
node.setPosition (t);
577
579
}
578
580
581
+ void getEntityAnimations (const String& name, std::vector<String>& out) CV_OVERRIDE
582
+ {
583
+ SceneNode& node = _getSceneNode (sceneMgr, name);
584
+ Entity* ent = dynamic_cast <Entity*>(node.getAttachedObject (name));
585
+ CV_Assert (ent && " invalid entity" );
586
+ for (auto const & anim : ent->getAllAnimationStates ()->getAnimationStates ())
587
+ {
588
+ out.push_back (anim.first );
589
+ }
590
+ }
591
+
592
+ void playEntityAnimation (const String& name, const String& animname, bool loop = true ) CV_OVERRIDE
593
+ {
594
+ SceneNode& node = _getSceneNode (sceneMgr, name);
595
+ Entity* ent = dynamic_cast <Entity*>(node.getAttachedObject (name));
596
+ CV_Assert (ent && " invalid entity" );
597
+ AnimationState* animstate = ent->getAnimationState (animname);
598
+
599
+ animstate->setTimePosition (0 );
600
+ animstate->setEnabled (true );
601
+ animstate->setLoop (loop);
602
+
603
+ if (frameCtrlrs.find (animname) != frameCtrlrs.end ()) return ;
604
+ frameCtrlrs.insert ({
605
+ animname,
606
+ Ogre::ControllerManager::getSingleton ().createFrameTimePassthroughController (
607
+ Ogre::AnimationStateControllerValue::create (animstate, true )
608
+ )
609
+ });
610
+ }
611
+
612
+ void stopEntityAnimation (const String& name, const String& animname) CV_OVERRIDE
613
+ {
614
+ SceneNode& node = _getSceneNode (sceneMgr, name);
615
+ Entity* ent = dynamic_cast <Entity*>(node.getAttachedObject (name));
616
+ CV_Assert (ent && " invalid entity" );
617
+ AnimationState* animstate = ent->getAnimationState (animname);
618
+
619
+ if (!animstate->getEnabled ()) return ;
620
+
621
+ animstate->setEnabled (false );
622
+ animstate->setTimePosition (0 );
623
+ Ogre::ControllerManager::getSingleton ().destroyController (frameCtrlrs[animname]);
624
+ frameCtrlrs.erase (animname);
625
+ }
626
+
579
627
void setEntityProperty (const String& name, int prop, const String& value) CV_OVERRIDE
580
628
{
581
629
CV_Assert (prop == ENTITY_MATERIAL);
@@ -598,9 +646,25 @@ class WindowSceneImpl : public WindowScene
598
646
599
647
void setEntityProperty (const String& name, int prop, const Scalar& value) CV_OVERRIDE
600
648
{
601
- CV_Assert (prop == ENTITY_SCALE);
602
649
SceneNode& node = _getSceneNode (sceneMgr, name);
603
- node.setScale (value[0 ], value[1 ], value[2 ]);
650
+ switch (prop)
651
+ {
652
+ case ENTITY_SCALE:
653
+ {
654
+ node.setScale (value[0 ], value[1 ], value[2 ]);
655
+ break ;
656
+ }
657
+ case ENTITY_ANIMBLEND_MODE:
658
+ {
659
+ Entity* ent = dynamic_cast <Entity*>(node.getAttachedObject (name));
660
+ CV_Assert (ent && " invalid entity" );
661
+
662
+ ent->getSkeleton ()->setBlendMode (static_cast <Ogre::SkeletonAnimationBlendMode>(value[0 ]));
663
+ break ;
664
+ }
665
+ default :
666
+ CV_Error (Error::StsBadArg, " unsupported property" );
667
+ }
604
668
}
605
669
606
670
void getEntityProperty (const String& name, int prop, OutputArray value) CV_OVERRIDE
0 commit comments