1 // Copyright (C) 2009 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Library General Public
5 // License as published by the Free Software Foundation; either
6 // version 2 of the License, or (at your option) any later version.
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 GNU
11 // Library General Public License for more details.
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.
18 #ifndef HLASceneObject_hxx
19 #define HLASceneObject_hxx
22 #include <osg/PagedLOD>
23 #include <osg/ref_ptr>
25 #include <simgear/hla/HLAObjectClass.hxx>
26 #include <simgear/hla/HLALocation.hxx>
28 #include "HLAObjectReferenceData.hxx"
32 class HLASceneObjectClass;
34 class HLASceneObject : public simgear::HLAObjectInstance {
36 HLASceneObject(HLASceneObjectClass* objectClass, const SGWeakPtr<simgear::HLAFederate>& federate);
37 virtual ~HLASceneObject();
39 virtual void createAttributeDataElements();
41 virtual void discoverInstance(const simgear::RTIData& tag);
42 virtual void removeInstance(const simgear::RTIData& tag);
44 virtual void registerInstance(simgear::HLAObjectClass* objectClass);
45 virtual void deleteInstance(const simgear::RTIData& tag);
47 const HLASceneObject* getSceneObject() const;
48 HLASceneObject* getSceneObject();
49 void setSceneObject(HLASceneObject* sceneObject);
51 virtual SGLocationd getLocation(const SGTimeStamp& timeStamp) const;
53 simgear::HLADataElement* getModelDataElement();
58 SGLocationd _getRelativeLocation(const SGTimeStamp& timeStamp) const;
59 // Return the velocities of this current object without taking the referenced velocities into account
60 SGVec3d _getRelativeAngularVelocity() const;
61 SGVec3d _getRelativeLinearVelocity() const;
63 void _setModelFileName(const std::string& fileName);
66 class _ModelDataElement;
69 // Add the transform node to the scenegraph
70 void _addToSceneGraph();
71 // Remove the transform node from the scenegraph
72 void _removeFromSceneGraph();
74 // The location of this object
75 SGSharedPtr<simgear::HLAAbstractLocation> _location;
76 // If this object is living relative to an other one, this one is non zero
77 simgear::HLAObjectReferenceData<HLASceneObject> _sceneObject;
79 // The top level transform node for this scene object
80 osg::ref_ptr<_Transform> _transform;
81 osg::ref_ptr<osg::PagedLOD> _pagedLOD;
84 } // namespace fgviewer