需求描述:需要实现在三维场景中添加图片的功能,可以实现图片的定位和位置更新。
解决思路:准备采用超图底层的广告牌UGGeoBillboard来实现,已经在Extensions4Qt工程下的layer3d.cpp中写了一个AddPicture的接口,也在GettingStarted的mainwindow.cpp中的CreateModel中调用了。
当前状态:代码编译没有问题,但是三维场景中只显示了广告牌的名称,设置的图片没有显示。
Feature3D *Layer3D::AddPicture(QString &pictureFile,OgdcPoint3D &position,QString &strID)
{
//!新建图片对象
UGGeoPicture* pPicture = new UGGeoPicture();
QImage* pImage = new QImage(pictureFile);
UGImageData* pImageData = new UGImageData();
pImageData->nHeight = pImage->height();
pImageData->nWidth = pImage->width();
pImageData->nWidthBytes = pImage->bytesPerLine();
pImageData->btBitsPixel = 32;
pImageData->pBits = new UGbyte[pImage->byteCount()];
memcpy(pImageData->pBits,pImage->bits(),pImage->byteCount());
UGArray<UGImageData*> arrImageData;
arrImageData.Add(pImageData);
UGPoint2D pntCenter(position.x,position.y);
UGSize2D szSize(1,1);
bool bIsOk = pPicture->Make(arrImageData,pntCenter,szSize);
//! 新建布告板对象
UGGeoBillboard *pUGGeoBillboard = new UGGeoBillboard();
pUGGeoBillboard->MakeWithGeometry(pPicture);
pUGGeoBillboard->SetHeight(72);
pUGGeoBillboard->SetWidth(48);
if(bIsOk)
{
pUGGeoBillboard->SetPosition(position);
return this->AddFeature(pUGGeoBillboard,strID);
}
else
return NULL;
}