CAD导入——文字读取(文字内容、位置、角度)

 1 //文字节点
 2 std::vector<GeometricPrimitives*> GP = _dwgData["Axis"];
 3 osg::ref_ptr<osg::Geode> currentLabel = GP->getCurrentLabel();
 4 osg::ref_ptr<osg::Node> currNode = currentLabel->getChild(i);
 5 std::string tempStr = "";//存储
 6 if (!(currNode->getUserValue("GMTextContent", tempStr)))//读取到的文字内容存在tempStr里面
 7   return;
 8 osg::ref_ptr<osgText::Text> currTest = dynamic_cast<osgText::Text*>(currNode.get());
 9 osg::Vec3f strCenter = currTest->getPosition();//文字位置
1 osg::Quat q = keyText->getRotation();
2 float siny_cosp = 2 * (q.w() * q.z() + q.x() * q.y());
3 float cosy_cosp = 1 - 2 * (q.y() * q.y() + q.z() * q.z());
4 float rotateRad = std::atan2(siny_cosp, cosy_cosp); //文字角度

 


更新:2022年10月8日
>文字角度-参考:[轴角、四元数转换 - Edith6 - 博客园]https://www.cnblogs.com/FormerWhite/p/15211131.html

posted @ 2022-09-22 17:32  jessicaland  阅读(213)  评论(0)    收藏  举报