@@ -578,6 +578,36 @@ class WindowSceneImpl : public WindowScene
578
578
node.setPosition (t);
579
579
}
580
580
581
+ void getEntityPose (const String& name ,OutputArray R, OutputArray tvec, bool invert) CV_OVERRIDE
582
+ {
583
+ SceneNode* node = sceneMgr->getEntity (name)->getParentSceneNode ();
584
+ Matrix3 _R;
585
+ // toOGRE.Inverse() == toOGRE
586
+ (node->getOrientation ()*toOGRE).ToRotationMatrix (_R);
587
+
588
+ if (invert)
589
+ {
590
+ _R = _R.Transpose ();
591
+ }
592
+
593
+ if (tvec.needed ())
594
+ {
595
+ Vector3 _tvec = node->getPosition ();
596
+
597
+ if (invert)
598
+ {
599
+ _tvec = _R * -_tvec;
600
+ }
601
+
602
+ Mat_<Real>(3 , 1 , _tvec.ptr ()).copyTo (tvec);
603
+ }
604
+
605
+ if (R.needed ())
606
+ {
607
+ Mat_<Real>(3 , 3 , _R[0 ]).copyTo (R);
608
+ }
609
+ }
610
+
581
611
void getEntityAnimations (const String& name, std::vector<String>& out) CV_OVERRIDE
582
612
{
583
613
SceneNode& node = _getSceneNode (sceneMgr, name);
@@ -659,7 +689,7 @@ class WindowSceneImpl : public WindowScene
659
689
Entity* ent = dynamic_cast <Entity*>(node.getAttachedObject (name));
660
690
CV_Assert (ent && " invalid entity" );
661
691
662
- ent->getSkeleton ()->setBlendMode (static_cast <Ogre::SkeletonAnimationBlendMode>(value[0 ]));
692
+ ent->getSkeleton ()->setBlendMode (static_cast <Ogre::SkeletonAnimationBlendMode>(int ( value[0 ]) ));
663
693
break ;
664
694
}
665
695
default :
@@ -847,6 +877,26 @@ class WindowSceneImpl : public WindowScene
847
877
848
878
camNode->lookAt (tgt->_getDerivedPosition () + _offset, Ogre::Node::TS_WORLD);
849
879
}
880
+
881
+ void setEntityLookAt (const String& origin, const String& target, InputArray offset) CV_OVERRIDE
882
+ {
883
+ SceneNode* orig = sceneMgr->getEntity (origin)->getParentSceneNode ();
884
+
885
+ Vector3 _offset = Vector3::ZERO;
886
+
887
+ if (!offset.empty ())
888
+ {
889
+ offset.copyTo (Mat_<Real>(3 , 1 , _offset.ptr ()));
890
+ }
891
+
892
+ if (target.compare (" " ) != 0 ){
893
+ SceneNode* tgt = sceneMgr->getEntity (target)->getParentSceneNode ();
894
+ orig->lookAt (tgt->_getDerivedPosition () + _offset, Ogre::Node::TS_WORLD, Ogre::Vector3::UNIT_Z);
895
+ }else {
896
+ orig->lookAt (_offset, Ogre::Node::TS_WORLD, Ogre::Vector3::UNIT_Z);
897
+ }
898
+ }
899
+
850
900
};
851
901
852
902
CV_EXPORTS_W void addResourceLocation (const String& path)
0 commit comments