|
#include <QStringList>
#include <osg/Texture>
#include <osg/StateSet>
#include <osg/Geode>
#include "drawable.h"
#include "videotexture.h"
Drawable::Drawable(QObject *parent, QString Dir, QDomElement node) :
OSGControlLayout(parent, Dir, node)
{
for(unsigned int i=0; i < node.childNodes().count(); i++)
{
QDomElement tempElement = node.childNodes().item(i).toElement();
QString type = tempElement.nodeName();
QStringList list = type.split(".");
if(list.length() == 2)
{
if(list[0] == Type)
{
if(list[1] == "Textures")
setTextures(tempElement);
}
}
}
}
void Drawable::setTextures(osg::Geometry *geomnode)
{
for(unsigned int i=0; i <_textures.count(); i++)
{
geomnode->getOrCreateStateSet()->setTextureAttributeAndModes(i, _textures.at(i)->getTexture());
}
}
void Drawable::setTextures(QDomElement node)
{
for(unsigned int i=0; i < node.childNodes().count(); i++)
{
QDomElement tempElement = node.childNodes().item(i).toElement();
QString type = tempElement.nodeName();
if(type == "VideoTexture")
setVideoTexture(tempElement);
if(type == "Texture2D")
setTexture2D(tempElement);
}
}
void Drawable::setVideoTexture(QDomElement node)
{
VideoTexture *_videoTexture = new VideoTexture(this, _Dir, node);
_textures.append(_videoTexture);
}
void Drawable::setTexture2D(QDomElement node)
{
Texture2D *_texture = new Texture2D(this, _Dir, node);
_textures.append(_texture);
}
|
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.