root/OpenSceneGraph/trunk/src/osgUtil/RenderLeaf.cpp
@
13041
| Revision 13041, 2.9 kB (checked in by robert, 14 months ago) | |
|---|---|
|
|
| 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/RenderLeaf> |
| 14 | #include <osgUtil/StateGraph> |
| 15 | #include <osg/Notify> |
| 16 | |
| 17 | using namespace osg; |
| 18 | using namespace osgUtil; |
| 19 | |
| 20 | void RenderLeaf::render(osg::RenderInfo& renderInfo,RenderLeaf* previous) |
| 21 | { |
| 22 | osg::State& state = *renderInfo.getState(); |
| 23 | |
| 24 | // don't draw this leaf if the abort rendering flag has been set. |
| 25 | if (state.getAbortRendering()) |
| 26 | { |
| 27 | //cout << "early abort"<<endl; |
| 28 | return; |
| 29 | } |
| 30 | |
| 31 | if (previous) |
| 32 | { |
| 33 | |
| 34 | // apply matrices if required. |
| 35 | state.applyProjectionMatrix(_projection.get()); |
| 36 | state.applyModelViewMatrix(_modelview.get()); |
| 37 | |
| 38 | // apply state if required. |
| 39 | StateGraph* prev_rg = previous->_parent; |
| 40 | StateGraph* prev_rg_parent = prev_rg->_parent; |
| 41 | StateGraph* rg = _parent; |
| 42 | if (prev_rg_parent!=rg->_parent) |
| 43 | { |
| 44 | StateGraph::moveStateGraph(state,prev_rg_parent,rg->_parent); |
| 45 | |
| 46 | // send state changes and matrix changes to OpenGL. |
| 47 | state.apply(rg->getStateSet()); |
| 48 | |
| 49 | } |
| 50 | else if (rg!=prev_rg) |
| 51 | { |
| 52 | |
| 53 | // send state changes and matrix changes to OpenGL. |
| 54 | state.apply(rg->getStateSet()); |
| 55 | |
| 56 | } |
| 57 | |
| 58 | // if we are using osg::Program which requires OSG's generated uniforms to track |
| 59 | // modelview and projection matrices then apply them now. |
| 60 | if (state.getUseModelViewAndProjectionUniforms()) state.applyModelViewAndProjectionUniformsIfRequired(); |
| 61 | |
| 62 | // draw the drawable |
| 63 | _drawable->draw(renderInfo); |
| 64 | } |
| 65 | else |
| 66 | { |
| 67 | // apply matrices if required. |
| 68 | state.applyProjectionMatrix(_projection.get()); |
| 69 | state.applyModelViewMatrix(_modelview.get()); |
| 70 | |
| 71 | // apply state if required. |
| 72 | StateGraph::moveStateGraph(state,NULL,_parent->_parent); |
| 73 | |
| 74 | state.apply(_parent->getStateSet()); |
| 75 | |
| 76 | // if we are using osg::Program which requires OSG's generated uniforms to track |
| 77 | // modelview and projection matrices then apply them now. |
| 78 | if (state.getUseModelViewAndProjectionUniforms()) state.applyModelViewAndProjectionUniformsIfRequired(); |
| 79 | |
| 80 | // draw the drawable |
| 81 | _drawable->draw(renderInfo); |
| 82 | } |
| 83 | |
| 84 | if (_dynamic) |
| 85 | { |
| 86 | state.decrementDynamicObjectCount(); |
| 87 | } |
| 88 | |
| 89 | // OSG_NOTICE<<"RenderLeaf "<<_drawable->getName()<<" "<<_depth<<std::endl; |
| 90 | } |
Note: See TracBrowser
for help on using the browser.
