root/OpenSceneGraph/trunk/include/osgFX/Cartoon @ 13041

Revision 13041, 3.6 kB (checked in by robert, 2 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//osgFX - Copyright (C) 2003 Marco Jez
14
15#ifndef OSGFX_CARTOON_
16#define OSGFX_CARTOON_
17
18#include <osgFX/Export>
19#include <osgFX/Effect>
20
21#include <osg/Material>
22#include <osg/LineWidth>
23
24namespace osgFX
25{
26
27     /**
28     This effect implements a technique called 'Cel-Shading' to produce a
29     cartoon-style (non photorealistic) rendering. Two passes are required:
30     the first one draws solid surfaces, the second one draws the outlines.
31     A vertex program is used to setup texture coordinates for a sharp lighting
32     texture on unit 0 which is generated on-the-fly.
33     This effect requires the ARB_vertex_program extension.
34     */
35    class OSGFX_EXPORT Cartoon: public Effect {
36    public:
37        Cartoon();
38        Cartoon(const Cartoon& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
39
40        // effect class informations
41        META_Effect(
42            osgFX,
43            Cartoon,
44
45            "Cartoon",
46
47            "This effect implements a technique called 'Cel-Shading' to produce a "
48            "cartoon-style (non photorealistic) rendering. Two passes are required: "
49            "the first one draws solid surfaces, the second one draws the outlines. "
50            "A vertex program is used to setup texture coordinates for a sharp lighting "
51            "texture on unit 0 which is generated on-the-fly.\n"
52            "This effect requires the ARB_vertex_program extension "
53            "or OpenGL Shading Language.",
54
55            "Marco Jez; OGLSL port by Mike Weiblen");
56
57        /** get the outline color */
58        inline const osg::Vec4& getOutlineColor() const;
59
60        /** set the outline color */
61        inline void setOutlineColor(const osg::Vec4& color);
62
63        /** get the outline line width */
64        inline float getOutlineLineWidth() const;
65
66        /** set the outline line width */
67        inline void setOutlineLineWidth(float w);
68
69        /** get the OpenGL light number */
70        inline int getLightNumber() const;
71
72        /** set the OpenGL light number that will be used in lighting computations */
73        inline void setLightNumber(int n);
74
75    protected:
76        virtual ~Cartoon() {}
77        Cartoon& operator=(const Cartoon&) { return *this; }
78
79        bool define_techniques();
80
81    private:
82        osg::ref_ptr<osg::Material> _wf_mat;
83        osg::ref_ptr<osg::LineWidth> _wf_lw;
84        int _lightnum;
85    };
86
87    // INLINE METHODS
88
89    inline const osg::Vec4& Cartoon::getOutlineColor() const
90    {
91        return _wf_mat->getEmission(osg::Material::FRONT_AND_BACK);
92    }
93
94    inline void Cartoon::setOutlineColor(const osg::Vec4& color)
95    {
96        _wf_mat->setEmission(osg::Material::FRONT_AND_BACK, color);
97    }
98
99    inline float Cartoon::getOutlineLineWidth() const
100    {
101        return _wf_lw->getWidth();
102    }
103
104    inline void Cartoon::setOutlineLineWidth(float w)
105    {
106        _wf_lw->setWidth(w);
107    }
108
109    inline int Cartoon::getLightNumber() const
110    {
111        return _lightnum;
112    }
113
114    inline void Cartoon::setLightNumber(int n)
115    {
116        _lightnum = n;
117        dirtyTechniques();
118    }
119
120}
121
122#endif
Note: See TracBrowser for help on using the browser.