|
请教array等高手:
我应用MFC框架,导入一个my.earth和一个卫星模型。现在卫星模型显示不了材质,估计是光照的原因。
代码如下:
LPTSTR cmd = ::GetCommandLine();
int argc = 0; WCHAR **argv;
argv = ::CommandLineToArgvW(cmd, &argc);
size_t len = wcslen(argv[0]) + 1;size_t converted = 0;
char *CStr;CStr=(char*)malloc(len*sizeof(char));
wcstombs_s(&converted, CStr, len, argv[0], _TRUNCATE);
size_t len1 = wcslen(argv[1]) + 1;size_t converted1 = 0;
char *CStr1;CStr1=(char*)malloc(len1*sizeof(char));
wcstombs_s(&converted1, CStr1, len1, argv[1], _TRUNCATE);
char* f1=NULL; char *f2=NULL; char *f3=NULL;f1 = CStr;f2 = CStr1;
char *f123[2];f123[0] = f1;f123[1] = f2;char **temp = f123;
mViewer = new osgViewer::Viewer();
mRoot = new osg::Group;//场景根元素
osg::Node *m_Satellite = osgDB::readNodeFile("c:/OSG/data/500/500.flt");
osg::MatrixTransform *mt = new osg::MatrixTransform();
osg::StateSet* stateset = mt->getOrCreateStateSet();
stateset->setMode(osg::StateAttribute::MATERIAL,osg::StateAttribute::ON);
stateset->setMode(GL_LIGHTING,osg::StateAttribute::ON);
stateset->setRenderBinMode(osg::StateSet::OVERRIDE_RENDERBIN_DETAILS);
//const osg::BoundingSphere &bs = mModel->getBound();
//osg::Vec3d centers = bs.center();
//double st = bs._radius;
osg::Matrixd md = osg::Matrixd::translate(osg::Vec3d(0,-12427322-100,0));
mt->setMatrix(osg::Matrixd::scale(690000,690000,690000) * md);
mt->addChild(m_Satellite);
//构造arguments,以便建立MapNodeHelper对象,显示.earth文件中所有元素
osg::ArgumentParser arguments(&argc,temp);
osg::Node * mModel = MapNodeHelper().load( arguments, mViewer );//读取gdal_tiff.earth
osgEarth::MapNode* mapNode = MapNode::findMapNode( mModel );
//加入太空环境
double hours = mapNode->externalConfig().child("sky").value( "hours", 18.0 );
SkyNode* sky = new SkyNode(mapNode->getMap());
sky->setDateTime( 2013, 2, 5, 17.0);
sky->attach(mViewer);
mRoot->addChild(sky);
mRoot->addChild(mModel);
osg::StateSet* statesets = mModel->getOrCreateStateSet();
osg::StateSet::ModeList &stsss = statesets->getModeList();
mRoot->addChild(mt);
最终的结果如下:
需要对光照或者什么进行怎样的设置?
|
|