root/OpenSceneGraph/trunk/src/osgUtil/PositionalStateContainer.cpp @ 13041

Revision 13041, 3.2 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13#include <osgUtil/PositionalStateContainer>
14
15using namespace osg;
16using namespace osgUtil;
17
18// register a PositionalStateContainer prototype with the RenderBin prototype list.
19//RegisterRenderBinProxy<PositionalStateContainer> s_registerPositionalStateContainerProxy;
20
21PositionalStateContainer::PositionalStateContainer()
22{
23}
24
25PositionalStateContainer::~PositionalStateContainer()
26{
27}
28
29void PositionalStateContainer::reset()
30{
31    _attrList.clear();
32    _texAttrListMap.clear();
33}
34
35void PositionalStateContainer::draw(osg::State& state,RenderLeaf*& previous, const osg::Matrix* postMultMatrix)
36{
37
38    if (previous)
39    {
40        StateGraph::moveToRootStateGraph(state,previous->_parent);
41        state.apply();
42        previous = NULL;
43    }
44
45    // apply the light list.
46    for(AttrMatrixList::iterator litr=_attrList.begin();
47        litr!=_attrList.end();
48        ++litr)
49    {
50        if (postMultMatrix)
51        {
52            if ((*litr).second.valid())
53                state.applyModelViewMatrix(new osg::RefMatrix( (*((*litr).second)) * (*postMultMatrix)));
54            else
55                state.applyModelViewMatrix(new osg::RefMatrix( *postMultMatrix));
56        }
57
58        else
59        {
60            state.applyModelViewMatrix((*litr).second.get());
61        }
62
63        // apply the light source.
64        litr->first->apply(state);
65
66        // tell state about.
67        state.haveAppliedAttribute(litr->first.get());
68
69        // set this state as a global default
70        state.setGlobalDefaultAttribute(litr->first.get());
71    }
72
73    for(TexUnitAttrMatrixListMap::iterator titr=_texAttrListMap.begin();
74        titr!=_texAttrListMap.end();
75        ++titr)
76    {
77        state.setActiveTextureUnit(titr->first);
78
79        AttrMatrixList attrList = titr->second;
80
81        for(AttrMatrixList::iterator litr=attrList.begin();
82            litr!=attrList.end();
83            ++litr)
84        {
85            if (postMultMatrix)
86            {
87                if ((*litr).second.valid())
88                    state.applyModelViewMatrix(new osg::RefMatrix( (*((*litr).second)) * (*postMultMatrix)));
89                else
90                    state.applyModelViewMatrix(new osg::RefMatrix( *postMultMatrix));
91            }
92            else
93            {
94                state.applyModelViewMatrix((*litr).second.get());
95            }
96
97            // apply the light source.
98            litr->first->apply(state);
99
100            // tell state about.
101            state.haveAppliedTextureAttribute(titr->first, litr->first.get());
102
103            // set this state as a global default
104            state.setGlobalDefaultTextureAttribute(titr->first, litr->first.get());
105        }
106
107    }
108}
Note: See TracBrowser for help on using the browser.