Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / libs / osgearth / osgQtQuick / OSGBillboardNode.cpp
blobf5a27efba01525f85628cc8a7ebc2646f191308f
1 /**
2 ******************************************************************************
4 * @file OSGBillboardNode.cpp
5 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
6 * @addtogroup
7 * @{
8 * @addtogroup
9 * @{
10 * @brief
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "OSGBillboardNode.hpp"
30 #include <osg/Depth>
31 #include <osg/Texture2D>
32 #include <osg/ImageSequence>
34 #include <osgDB/ReadFile>
36 #include <QDebug>
38 namespace osgQtQuick {
39 // NOTE : these flags should not overlap with OSGGroup flags!!!
40 // TODO : find a better way...
41 enum DirtyFlag {};
43 struct OSGBillboardNode::Hidden : public QObject {
44 Q_OBJECT
46 private:
47 OSGBillboardNode * const self;
49 osg::ref_ptr<osg::Camera> camera;
51 public:
52 Hidden(OSGBillboardNode *self) : QObject(self), self(self)
55 osg::Node *createNode()
57 camera = new osg::Camera;
58 camera->setClearMask(0);
59 camera->setCullingActive(false);
60 camera->setAllowEventFocus(false);
61 camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
62 camera->setRenderOrder(osg::Camera::POST_RENDER);
63 camera->setProjectionMatrix(osg::Matrix::ortho2D(0.0, 1.0, 0.0, 1.0));
65 osg::StateSet *ss = camera->getOrCreateStateSet();
66 ss->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
67 ss->setAttributeAndModes(new osg::Depth(osg::Depth::LEQUAL, 1.0, 1.0));
69 return camera;
73 /* class OSGBillboardNode */
75 OSGBillboardNode::OSGBillboardNode(QObject *parent) : Inherited(parent), h(new Hidden(this))
78 OSGBillboardNode::~OSGBillboardNode()
80 delete h;
83 osg::Node *OSGBillboardNode::createNode()
85 return h->createNode();
88 void OSGBillboardNode::updateNode()
90 Inherited::updateNode();
92 } // namespace osgQtQuick
94 #include "OSGBillboardNode.moc"