|
osg::ref_ptr<osg::Node> node1 = new osg::Node();
std::string strPath = "http://osgservice.yutuxinxi.com/Mod/kazhumi.IVE";
osgDB::ReaderWriter::ReadResult rr = osgDB::Registry::instance()->readNode(strPath,osgDB::Registry::instance()->getOptions() );
if ( rr.validNode() )
node1 = rr.takeNode();
if (!node1 )
{
m_GetTileObj->m_SystempObj->_Msg("读取模型失败!");
return 0;
}
else
{
node1->setName("我的模型");
}
/de1->setDataVariance( osg::Object:YNAMIC );
//int CastsShadowTraversalMask=0x2;
/de1->setNodeMask(CastsShadowTraversalMask);
////控制建筑物的位置 比例高度
osg::ref_ptr<osg::MatrixTransform> mthouseSelf;
osg::ref_ptr<osg::MatrixTransform> mthouse;
mthouseSelf = new osg::MatrixTransform;
mthouseSelf->getOrCreateStateSet()->setMode(GL_RESCALE_NORMAL, osg::StateAttribute::ON);
bool yes=mthouseSelf->addChild(node1);
if (!yes)
{
m_GetTileObj->m_SystempObj->_Msg("mthouseSelf添加失败了!");
return 0;
}
mthouse = new osg::MatrixTransform;
yes=mthouse->addChild(mthouseSelf);
if (!yes)
{
m_GetTileObj->m_SystempObj->_Msg("mthouse添加失败了!");
return 0;
}
osg::Matrixd mtTemp;
osg::ref_ptr<osg::CoordinateSystemNode> csn = new osg::CoordinateSystemNode;
csn->setEllipsoidModel(new osg::EllipsoidModel());
csn->getEllipsoidModel()->computeLocalToWorldTransformFromLatLongHeight(osg::DegreesToRadians(34.74769),osg::DegreesToRadians(113.61961),0.0, mtTemp);
mthouse->setMatrix(mtTemp);
osg::Vec3d center;
mapNode->getMapSRS()->transformToWorld(osg::Vec3(113.61961,34.74769,0), center);
//////读取center和dist
osg::ref_ptr<osg:agedLOD> plod = new osg::PagedLOD;
float m_minRange=0,m_MaxRange=0;
plod->setCenter(center);
//plod->setRange(0, 0,500000.0);
plod->setCenterMode(osg:OD::USER_DEFINED_CENTER);
yes=plod->addChild(mthouse);
if (!yes)
{
m_GetTileObj->m_SystempObj->_Msg("plod添加失败了!");
return 0;
}
yes=earthPageIveLod->addChild(plod);
if (!yes)
{
m_GetTileObj->m_SystempObj->_Msg("earthPageIveLod添加失败了!");
return 0;
}
|
|