【小數位數】、【小數精度】
小數位的顯示長度控制需要兩步設置,其實比較簡單,比如:
#include <sstream>
osgText::Text* text = dynamic_cast<osgText::Text*>(textNode->getDrawable(0));
std::wstringstream ss;
osg::Vec3d pos = _osgView->getCursorPickPoint();
//設置小數位數只保留3位,整數部分不限制
ss.setf(std::ios::fixed, std::ios::floatfield);
ss.precision(3);
ss << L"X:" << pos.x() << L", Y:" << pos.y() << L", Z:" << pos.z() ;
text->setText(ss.str().c_str());