|
setlocale( LC_ALL, "chs" );
//osgDB::writeNodeFile(*(mt.get()),"E:\\4\\111.osg");//strfile.GetBuffer(0));//
// TODO: 在此添加调度处理程序代码
//创建一个叶节点对象
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
//创建一个几何体对象
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry();
//创建顶点数组,注意顶点的添加顺序是逆时针的
osg::ref_ptr<osg::Vec3Array> v= new osg::Vec3Array();
//创建纹理坐标
osg::ref_ptr<osg::Vec2Array> vt= new osg::Vec2Array();
//创建颜色数组
osg::ref_ptr<osg::Vec4Array> vc = new osg::Vec4Array();
//创建法线数组
osg::ref_ptr<osg::Vec3Array> nc = new osg::Vec3Array();
for(double i=0;i<1000;i++)
{
v->push_back(osg::Vec3(i,0.0f,0.0f)) ;
v->push_back(osg::Vec3(i+1,0.0f,0.0f)) ;
v->push_back(osg::Vec3(i,1.0f,0.0f)) ;
v->push_back(osg::Vec3(i+1,0.0f,0.0f)) ;
v->push_back(osg::Vec3(i+1,1.0f,0.0f)) ;
v->push_back(osg::Vec3(i,1.0f,0.0f)) ;
vc->push_back(osg::Vec4(1.0f,0.0f,0.0f,1.0f));
vc->push_back(osg::Vec4(1.0f,0.0f,0.0f,1.0f));
nc->push_back(osg::Vec3(0.0f,0.0f,1.0f));
nc->push_back(osg::Vec3(0.0f,0.0f,1.0f));
}
//设置顶点数据
geom->setVertexArray(v.get());
//设置颜色数组
geom->setColorArray(vc.get());
//设置颜色的绑定方式为单个顶点
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
//设置法线数组
geom->setNormalArray(nc.get());
//设置法线的绑定方式为全部顶点
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
//添加图元,绘图基元为四边形
geom->addPrimitiveSet(new osg:: DrawArrays(osg:: PrimitiveSet::TRIANGLES,0,v->size()));
geode->addDrawable(geom.get());
osgDB::writeNodeFile(*(geode.get()),"F:\\11.osg");
上面代码在mfc sdi下运行并输出11.osg没有任何问题,但是到了在mfc dll下封装后c#调用 就出现问题,输不出11.osg.
这样的问题谁遇到过?如何解决? |
|