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