]> git.mxchange.org Git - simgear.git/blob - simgear/scene/tgdb/SGVasiDrawable.hxx
Merge branch 'maint' into next
[simgear.git] / simgear / scene / tgdb / SGVasiDrawable.hxx
1 /* -*-c++-*-
2  *
3  * Copyright (C) 2006-2007 Mathias Froehlich 
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18  * MA 02110-1301, USA.
19  *
20  */
21
22 #ifndef _SG_VASI_DRAWABLE_HXX
23 #define _SG_VASI_DRAWABLE_HXX
24
25 #include <simgear/compiler.h>
26
27 #include <osg/Drawable>
28 #include <simgear/math/SGMath.hxx>
29
30 class SGVasiDrawable : public osg::Drawable {
31   struct LightData;
32 public:
33   META_Object(SimGear, SGVasiDrawable);
34   SGVasiDrawable(const SGVasiDrawable&, const osg::CopyOp&);
35   SGVasiDrawable(const SGVec4f& red = SGVec4f(1, 0, 0, 1),
36                  const SGVec4f& white = SGVec4f(1, 1, 1, 1));
37
38   /// Add a red/white switching light pointing into the direction that
39   /// is computed to point in about the given normal with the given
40   /// azimut angle upwards. The up direction is the world up direction
41   /// that defines the horizontal plane.
42   void addLight(const SGVec3f& position, const SGVec3f& normal,
43                 const SGVec3f& up, float azimutDeg);
44
45   /// add a red/white switching light pointing towards normal
46   /// at the given position with the given up vector. The up direction
47   /// is the world up direction that defines the horizontal plane.
48   void addLight(const SGVec3f& position, const SGVec3f& normal,
49                 const SGVec3f& up);
50
51   virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
52   virtual osg::BoundingBox computeBound() const;
53
54 private:
55   SGVec4f getColor(float angleDeg) const;
56   void draw(const SGVec3f& eyePoint, const LightData& light) const;
57   
58   std::vector<LightData> _lights;
59   SGVec4f _red;
60   SGVec4f _white;
61 };
62
63 #endif // _SG_VASI_LIGHT_HXX