Added support for setting texture units in the new TexGenNode.
This commit is contained in:
@@ -16,14 +16,15 @@ using namespace osg;
|
||||
|
||||
TexGenNode::TexGenNode()
|
||||
{
|
||||
_textureUnit = 0;
|
||||
_value = StateAttribute::ON;
|
||||
_stateset = new StateSet;
|
||||
_texgen = new TexGen;
|
||||
setLocalStateSetModes(_value);
|
||||
}
|
||||
|
||||
TexGenNode::TexGenNode(const TexGenNode& cn, const CopyOp& copyop):
|
||||
Group(cn,copyop),
|
||||
_textureUnit(cn._textureUnit),
|
||||
_value(cn._value),
|
||||
_texgen(static_cast<TexGen*>(copyop(cn._texgen.get())))
|
||||
{
|
||||
@@ -36,19 +37,4 @@ TexGenNode::~TexGenNode()
|
||||
void TexGenNode::setTexGen(TexGen* texgen)
|
||||
{
|
||||
_texgen = texgen;
|
||||
setLocalStateSetModes(_value);
|
||||
}
|
||||
|
||||
// Set the GLModes on StateSet associated with the TexGen.
|
||||
void TexGenNode::setStateSetModes(StateSet& stateset,const StateAttribute::GLModeValue value) const
|
||||
{
|
||||
if (_texgen.valid())
|
||||
stateset.setAssociatedModes(_texgen.get(),value);
|
||||
}
|
||||
|
||||
void TexGenNode::setLocalStateSetModes(const StateAttribute::GLModeValue value)
|
||||
{
|
||||
if (!_stateset) _stateset = new StateSet;
|
||||
_stateset->setAllToInherit();
|
||||
setStateSetModes(*_stateset,value);
|
||||
}
|
||||
|
||||
@@ -883,7 +883,7 @@ void CullVisitor::apply(TexGenNode& node)
|
||||
|
||||
RefMatrix& matrix = getModelViewMatrix();
|
||||
|
||||
addPositionedAttribute(&matrix,node.getTexGen());
|
||||
addPositionedTextureAttribute(node.getTextureUnit(), &matrix,node.getTexGen());
|
||||
|
||||
handle_cull_callbacks_and_traverse(node);
|
||||
|
||||
|
||||
@@ -56,4 +56,27 @@ void RenderStageLighting::draw(osg::State& state,RenderLeaf*& previous)
|
||||
|
||||
}
|
||||
|
||||
for(TexUnitAttrMatrixListMap::iterator titr=_texAttrListMap.begin();
|
||||
titr!=_texAttrListMap.end();
|
||||
++titr)
|
||||
{
|
||||
state.setActiveTextureUnit(titr->first);
|
||||
|
||||
AttrMatrixList attrList = titr->second;
|
||||
|
||||
for(AttrMatrixList::iterator litr=attrList.begin();
|
||||
litr!=attrList.end();
|
||||
++litr)
|
||||
{
|
||||
state.applyModelViewMatrix((*litr).second.get());
|
||||
|
||||
// apply the light source.
|
||||
litr->first->apply(state);
|
||||
|
||||
// tell state about.
|
||||
state.haveAppliedTextureAttribute(titr->first, litr->first);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user