|
本帖最后由 Hadse 于 2011-8-11 08:26 编辑
子弹模型在添加光照效果后,原来的效果就不见了,
有什么办法可以解决这个问题吗?
OSG新手,稍微详细点。
代码如下:
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osg/Node>
#include <osg/Geode>
#include <osg/Group>
#include <osgFX/SpecularHighlights>
#include <osgUtil/Optimizer>
void main()
{
osg::ref_ptr<osgViewer::Viewer> v = new osgViewer::Viewer();
osg::ref_ptr<osg::Group> r = new osg::Group();
osg::ref_ptr<osg::Node> n = osgDB::readNodeFile("zidan.osg");
osg::ref_ptr<osgFX::SpecularHighlights> s = new osgFX::SpecularHighlights();
s->setTextureUnit(0);
s->setLightNumber(2);
s->setSpecularColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
s->setSpecularExponent(16.0f);
s->addChild(n.get());
r->addChild(s.get());
osgUtil::Optimizer o;o.optimize(r.get());
v->setSceneData(r.get());
v->realize();
v->run();
} |
|