|
已成功编译osg for android 3.1.3,并且加上了官网链接的第三方库。
跑osgandroidGLES1那个例子,打开cow.osg都能正常读取tga格式的纹理图片,但是我参照 例子 osgsimulation 的代码,创建了一个earth,只显示一个灰色的球,无法加载图片,readImageFile报错,信息为:
Could not find plugin to read objects from file "sdcard/xuhy/osgdata/Images/land_shallow_topo_2048.jpg".
图片路径是没有问题的。
创建earth的代码如下:
osg::Node* OsgMainApp::createEarth()
{
osg::TessellationHints* hints = new osg::TessellationHints;
hints->setDetailRatio(5.0f);
osg::ShapeDrawable* sd = new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0.0,0.0,0.0), osg::WGS_84_RADIUS_POLAR), hints);
osg::Geode* geode = new osg::Geode;
geode->addDrawable(sd);
osg::Image* image = osgDB::readImageFile("sdcard/xuhy/osgdata/Images/land_shallow_topo_2048.jpg");
osg::notify(osg::ALWAYS)<<"read end"<<std::endl;
if (image)
{
geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, new osg::Texture2D(image));
}
osg::CoordinateSystemNode* csn = new osg::CoordinateSystemNode;
csn->setEllipsoidModel(new osg::EllipsoidModel());
csn->addChild(geode);
return csn;
}
我在android.mk中有相关的引用
LOCAL_LDFLAGS := -L $(LIBDIR) \
-losgdb_dds \
-losgdb_openflight \
-losgdb_tga \
-losgdb_jpeg \
-losgdb_gdal \
-losgdb_rgb \
-losgdb_osgterrain \
-losgdb_osg \
-losgdb_ive \
……
不知道怎么搞?
另外,求一个osg场景编辑器 |
|