|
楼主 |
发表于 2014-5-19 17:32:37
|
显示全部楼层
谢谢,各种试验后木有成功!!求教啊详细代码啊
XXX类的成员变量
//map容器用于保存创建好的三角扇区
Std::map<int, osg::ref_ptr<osg::Node> > pies;
Osg::ref _ptr <osg::Group> _root ;
Osg::ref_ptr<osg::Group> pieGroup ;
OSG::Vec3d SCANER_POSITION[] ={
osg::Vec3d (Lng1, Lat1,Heig),
osg::Vec3d (Lng2, Lat2,Heig),
osg::Vec3d (Lng3, Lat3,Heig),
osg::Vec3d (Lng4, Lat4,Heig),
osg::Vec3d (Lng5, Lat5,Heig),
osg::Vec3d (Lng6, Lat6,Heig)
}
//构造中
有执行:
_root = new osg::Group()
viewerWidget = new osg::Earth:tGui::ViewerWidget(_root);
viewerWidget->getView(_views);
pieGroup = new osg::Group();
_root->addChile(pieGroup.get());
//创建三角波束
Void XXX::createPie()
{
for(int i = 0; i < 6; i++)
{
//扇区的3个顶点
double x1 =0, y1 =0, z1=0;
double x2=0, y2=0, z2=0;
double x3=0, y3=0, z3=0;
//将大地坐标转为地心坐标
VrUtil::CoordinateCentralEarthLonLatH2xyz(
SCANER_POSITION.x() + 0.0013* sin(30*M_PI/180),
SCANER_POSITION.y () + 0.0013* cos(30*M_PI/180),
SCANER_POSITION.z (),
x1, y1, z1);
VrUtil::CoordinateCentralEarthLonLatH2xyz(
SCANER_POSITION.x()
SCANER_POSITION.y ()
SCANER_POSITION.z (),
X2, y2, z2);
VrUtil::CoordinateCentralEarthLonLatH2xyz(
SCANER_POSITION.x() + 0.0013* sin(45*M_PI/180),
SCANER_POSITION.y () + 0.0013* cos(45*M_PI/180),
SCANER_POSITION.z (),
X3, y3, z3);
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
osg::ref_ptr<osg::Vec3Array> vPoint = new osg::Vec3Array;
geom->setVertexArray(vPoint.get());
vPoint ->push_back(osg::Vec3d(x1, y1, z1));
vPoint ->push_back(osg::Vec3d(x2, y2, z2));
vPoint ->push_back(osg::Vec3d(x3, y3, z3));
osg::ref_ptr<osg::Vec4Array> vColor = new osg::Vec4Array;
geom->setColorArray(vColor.get());
geom.->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
vColor->push_back(osg::Vec4(1.0f, 0.1f,0.3f,0,3f));
vColor->push_back(osg::Vec4(1.0f, 0.1f,0.3f,0,3f));
vColor->push_back(osg::Vec4(1.0f, 0.1f,0.3f,0,3f));
geom->addPrimitiveSet(new osg:rawArrays(osg:rimitivSet::TRIANGLE_FAN,0,3));
//设置透明度
osg::ref_ptr<osg::StateSet> stateSet = new osg::StateSet;
stateSet->setModel(GL_BLEND, osg::StateAttribute::OFF);
stateSet->setModel(GL_DEPTH_TEST, osg::StateAttribute::OFF);
stateSet->setModel(GL_LIGHTING, osg::StateAttribute::PROTECTED);
stateSet->setRenderingHintl( osg::StateSet::Attribute::TRANSPARENT_BIN);
osg::ref_ptr<osg::Geode> geodPie = new osg::Geode;
geodePie->addDrawable(geom..get());
pies.insert(std::map<int, osg::ref_ptr<osg::Node> >::value_type(i+1, geodePie));
}
//旋转:
Void XXX::movePies()
{
Std::map<int , osg::ref_ptr<osg::Node> >::ieerator itNode = pies.begin();
While(itNode != pies.end())
{
Osg::ref_ptr<osg::MatrixTransform> trans = new osg::MatrixTransfrom();
trans ->addChild(itNode->second.get());
pieGroup ->addChild(trans.get())
//如何设置旋转???
代码????
itNode++;
}
}
|
|