root/OpenSceneGraph/trunk/src/osgShadow/ShadowedScene.cpp @ 13041

Revision 13041, 3.1 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
14#include <osg/Texture2D>
15#include <osg/CoordinateSystemNode>
16#include <osg/TexEnv>
17#include <osg/io_utils>
18
19#include <osgUtil/CullVisitor>
20#include <osgShadow/ShadowedScene>
21
22using namespace osgShadow;
23
24ShadowedScene::ShadowedScene(ShadowTechnique* st):
25    _receivesShadowTraversalMask(0xffffffff),
26    _castsShadowTraversalMask(0xffffffff)
27{
28    setNumChildrenRequiringUpdateTraversal(1);
29
30    setShadowSettings(new ShadowSettings);
31
32    if (st) setShadowTechnique(st);
33}
34
35ShadowedScene::ShadowedScene(const ShadowedScene& ss, const osg::CopyOp& copyop):
36    osg::Group(ss,copyop),
37    _receivesShadowTraversalMask(ss._receivesShadowTraversalMask),
38    _castsShadowTraversalMask(ss._castsShadowTraversalMask)
39{
40    setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1);
41
42    if (ss._shadowTechnique.valid())
43    {
44        setShadowTechnique( dynamic_cast<osgShadow::ShadowTechnique*>(ss._shadowTechnique->clone(copyop)) );
45    }
46
47    if (ss._shadowSettings)
48    {
49        setShadowSettings(ss._shadowSettings.get());
50    }
51    else
52    {
53        setShadowSettings(new ShadowSettings);
54    }
55
56}
57
58ShadowedScene::~ShadowedScene()
59{
60    setShadowTechnique(0);
61}
62
63void ShadowedScene::traverse(osg::NodeVisitor& nv)
64{
65    if (_shadowTechnique.valid())
66    {
67        _shadowTechnique->traverse(nv);
68    }
69    else
70    {
71        osg::Group::traverse(nv);
72    }
73}
74
75void ShadowedScene::setShadowSettings(ShadowSettings* ss)
76{
77    _shadowSettings = ss;
78}
79
80void ShadowedScene::setShadowTechnique(ShadowTechnique* technique)
81{
82    if (_shadowTechnique == technique) return;
83
84    if (_shadowTechnique.valid())
85    {
86        _shadowTechnique->cleanSceneGraph();
87        _shadowTechnique->_shadowedScene = 0;
88    }
89
90    _shadowTechnique = technique;
91
92    if (_shadowTechnique.valid())
93    {
94        _shadowTechnique->_shadowedScene = this;
95        _shadowTechnique->dirty();
96    }
97}
98
99void ShadowedScene::cleanSceneGraph()
100{
101    if (_shadowTechnique.valid())
102    {
103        _shadowTechnique->cleanSceneGraph();
104    }
105}
106
107
108void ShadowedScene::dirty()
109{
110    if (_shadowTechnique.valid())
111    {
112        _shadowTechnique->dirty();
113    }
114}
115
116void ShadowedScene::resizeGLObjectBuffers(unsigned int maxSize)
117{
118    if (_shadowTechnique.valid()) _shadowTechnique->resizeGLObjectBuffers(maxSize);
119    Group::resizeGLObjectBuffers(maxSize);
120}
121
122void ShadowedScene::releaseGLObjects(osg::State* state) const
123{
124    if (_shadowTechnique.valid()) _shadowTechnique->releaseGLObjects(state);
125    Group::releaseGLObjects(state);
126}
Note: See TracBrowser for help on using the browser.