|
#include "modelvisitor.h"
#include "texture.h"
ModelVisitor::ModelVisitor(QObject *parent, QVector<Texture *> textures) :
QObject(parent), _textures(textures)
{
setTraversalMode(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN);
}
void ModelVisitor::apply(osg::Geode &node)
{
for(unsigned int i = 0; i < node.getNumDrawables(); ++i)
{
osg::Drawable *drawable = node.getDrawable(i);
QString drawableName(drawable->getName().c_str());
int unit = 0;
for(int j = 0; j < _textures.count(); j++)
{
if(_textures.at(j)->getTargetMesh() == drawableName)
{
drawable->getOrCreateStateSet()->
setTextureAttributeAndModes(unit, _textures.at(j)->getTexture());
unit++;
}
}
// if(!_textures.isEmpty())
// OSG_NOTICE << "ModelVisitor " << drawable->getName() << '"' << std::endl;
// drawable->setUseDisplayList(false);
// drawable->setUseVertexBufferObjects(true);
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.