]> git.mxchange.org Git - simgear.git/blob - simgear/scene/material/EffectGeode.cxx
Effects in models working for transparent materials and chrome animation
[simgear.git] / simgear / scene / material / EffectGeode.cxx
1 // Copyright (C) 2008  Timothy Moore timoore@redhat.com
2 //
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License as
5 // published by the Free Software Foundation; either version 2 of the
6 // License, or (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful, but
9 // WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16
17 #ifdef HAVE_CONFIG_H
18 #  include <simgear_config.h>
19 #endif
20
21 #include "EffectGeode.hxx"
22 #include "Effect.hxx"
23 #include "Technique.hxx"
24
25 #include <osgUtil/CullVisitor>
26
27 #include <osgDB/Registry>
28 #include <osgDB/Input>
29 #include <osgDB/ParameterOutput>
30
31 namespace simgear
32 {
33
34 using namespace osg;
35 using namespace osgUtil;
36
37 EffectGeode::EffectGeode()
38 {
39 }
40
41 EffectGeode::EffectGeode(const EffectGeode& rhs, const osg::CopyOp& copyop) :
42     Geode(rhs, copyop),
43     _effect(static_cast<Effect*>(copyop(rhs._effect.get())))
44 {
45 }
46
47 void EffectGeode::setEffect(Effect* effect)
48 {
49     _effect = effect;
50     if (!_effect)
51         return;
52     addUpdateCallback(new Effect::InitializeCallback);
53 }
54
55 void EffectGeode::resizeGLObjectBuffers(unsigned int maxSize)
56 {
57     if (_effect.valid())
58         _effect->resizeGLObjectBuffers(maxSize);
59     Geode::resizeGLObjectBuffers(maxSize);
60 }
61
62 void EffectGeode::releaseGLObjects(osg::State* state) const
63 {
64     if (_effect.valid())
65         _effect->releaseGLObjects(state);
66     Geode::releaseGLObjects(state);
67 }
68
69 bool EffectGeode_writeLocalData(const Object& obj, osgDB::Output& fw)
70 {
71     const EffectGeode& eg = static_cast<const EffectGeode&>(obj);
72
73     fw.indent() << "effect\n";
74     fw.writeObject(*eg.getEffect());
75     return true;
76 }
77
78 namespace
79 {
80 osgDB::RegisterDotOsgWrapperProxy effectGeodeProxy
81 (
82     new EffectGeode,
83     "simgear::EffectGeode",
84     "Object Node Geode simgear::EffectGeode",
85     0,
86     &EffectGeode_writeLocalData
87     );
88 }
89 }