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 #include <simgear/math/SGMath.hxx> 27 28 #include <osg/Drawable> 29 #include <osg/Version> 30 31 class SGVasiDrawable : public osg::Drawable { 32 struct LightData; 33 public: 34 META_Object(SimGear, SGVasiDrawable); 35 SGVasiDrawable(const SGVasiDrawable&, const osg::CopyOp&); 36 SGVasiDrawable(const SGVec4f& red = SGVec4f(1, 0, 0, 1), 37 const SGVec4f& white = SGVec4f(1, 1, 1, 1)); 38 39 /// Add a red/white switching light pointing into the direction that 40 /// is computed to point in about the given normal with the given 41 /// azimut angle upwards. The up direction is the world up direction 42 /// that defines the horizontal plane. 43 void addLight(const SGVec3f& position, const SGVec3f& normal, 44 const SGVec3f& up, float azimutDeg); 45 46 /// add a red/white switching light pointing towards normal 47 /// at the given position with the given up vector. The up direction 48 /// is the world up direction that defines the horizontal plane. 49 void addLight(const SGVec3f& position, const SGVec3f& normal, 50 const SGVec3f& up); 51 52 virtual void drawImplementation(osg::RenderInfo& renderInfo) const; 53 virtual osg::BoundingBox 54 #if OSG_VERSION_LESS_THAN(3,3,2) 55 computeBound() 56 #else 57 computeBoundingBox() 58 #endif 59 const; 60 61 private: 62 SGVec4f getColor(float angleDeg) const; 63 void draw(const SGVec3f& eyePoint, const LightData& light) const; 64 65 std::vector<LightData> _lights; 66 SGVec4f _red; 67 SGVec4f _white; 68 }; 69 70 #endif // _SG_VASI_LIGHT_HXX 71