OpenIG  2.0.4
cross-platform open-source OpenSceneGraph Image Generator
ImageGenerator.h
1 //#******************************************************************************
2 //#*
3 //#* Copyright (C) 2015 Compro Computer Services
4 //#* http://openig.compro.net
5 //#*
6 //#* Source available at: https://github.com/CCSI-CSSI/MuseOpenIG
7 //#*
8 //#* This software is released under the LGPL.
9 //#*
10 //#* This software is free software; you can redistribute it and/or modify
11 //#* it under the terms of the GNU Lesser General Public License as published
12 //#* by the Free Software Foundation; either version 2.1 of the License, or
13 //#* (at your option) any later version.
14 //#*
15 //#* This software is distributed in the hope that it will be useful,
16 //#* but WITHOUT ANY WARRANTY; without even the implied warranty of
17 //#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
18 //#* the GNU Lesser General Public License for more details.
19 //#*
20 //#* You should have received a copy of the GNU Lesser General Public License
21 //#* along with this library; if not, write to the Free Software
22 //#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 //#*
24 //#* Please direct any questions or comments to the OpenIG Forums
25 //#* Email address: openig@compro.net
26 //#*
27 //#*
28 //#* Please direct any questions or comments to the OpenIG Forums
29 //#* Email address: openig@compro.net
30 //#*
31 //#*
32 //#*****************************************************************************
33 
34 #ifndef IMAGEGENERATOR_H
35 #define IMAGEGENERATOR_H
36 
37 #if defined(OPENIG_SDK)
38  #include <OpenIG-Base/Export.h>
39  #include <OpenIG-Base/Types.h>
40  #include <OpenIG-Base/StringUtils.h>
41 #else
42  #include <Core-Base/Export.h>
43  #include <Core-Base/Types.h>
44  #include <Core-Base/StringUtils.h>
45 #endif
46 
47 #include <osg/ref_ptr>
48 #include <osg/MatrixTransform>
49 #include <osg/Group>
50 #include <osg/Matrixd>
51 #include <osg/Fog>
52 #include <osg/LightSource>
53 #include <osg/Program>
54 
55 #include <osgDB/ReadFile>
56 
57 #include <osgViewer/CompositeViewer>
58 
59 #include <map>
60 #include <string>
61 
62 namespace OpenIG {
63  namespace Base {
64 
72  class RefAnimationSequenceCallbacks;
73 
74  class IGCORE_EXPORT ImageGenerator
75  {
76  public:
84 
91  virtual ~ImageGenerator();
92 
100  virtual std::string version() = 0;
101 
111  typedef std::vector<unsigned int> ViewIdentifiers;
112 
131  virtual void init(osgViewer::CompositeViewer* viewer, const std::string& xmlFileName = "openig.xml", const ViewIdentifiers& ids = ViewIdentifiers()) = 0;
132 
139  virtual void cleanup() = 0;
140 
156  struct ReadNodeImplementationCallback : osg::Referenced
157  {
158  virtual osg::Node* readNode(const std::string& fileName, const osgDB::Options* options = 0) = 0;
159  };
160 
170  virtual void setReadNodeImplementationCallback(ReadNodeImplementationCallback* cb) = 0;
171 
179  virtual ReadNodeImplementationCallback* getReadNodeImplementationCallback() = 0;
189  virtual void setReadFileCallback(osgDB::Registry::ReadFileCallback* cb) = 0;
190 
198  virtual osgDB::Registry::ReadFileCallback* getReadFileCallback() = 0;
199 
200 
238  virtual void frame(bool usePlugins = true) = 0;
239 
240  // Scene management
259  virtual void addEntity(unsigned int id, const std::string& fileName, const osg::Matrixd& mx, const osgDB::Options* options = 0) = 0;
260 
275  virtual void addEntity(unsigned int id, const osg::Node* node, const osg::Matrixd& mx, const osgDB::Options* options = 0) = 0;
276 
285  virtual void removeEntity(unsigned int id) = 0;
286 
297  virtual void updateEntity(unsigned int id, const osg::Matrixd& mx) = 0;
298 
308  virtual void showEntity(unsigned int id, bool show) = 0;
309 
321  virtual void bindToEntity(unsigned int id, unsigned int toEntityId) = 0;
322 
333  virtual void unbindFromEntity(unsigned int id) = 0;
334 
344  virtual void reloadEntity(unsigned int id, const std::string& fileName, const osgDB::Options* options = 0) = 0;
345 
355  virtual void setEntityName(unsigned int id, const std::string& name) = 0;
356 
365  virtual std::string getEntityName(unsigned int id) = 0;
366 
376  virtual unsigned int getEntityId(unsigned int parentEntityId, const std::string& subEntityName) = 0;
377 
378  // Effects
390  virtual void addEffect(unsigned int id, const std::string& name, const osg::Matrixd& mx, const std::string& attributes) = 0;
391 
399  virtual void removeEffect(unsigned int id) = 0;
400 
410  virtual void bindEffect(unsigned int id, unsigned int entityID, const osg::Matrixd& mx) = 0;
411 
419  virtual void unbindEffect(unsigned int id) = 0;
420 
429  virtual void updateEffect(unsigned int id, const osg::Matrixd& mx) = 0;
430 
440  virtual void setEffectImplementationCallback(GenericImplementationCallback* cb) = 0;
441 
442  // Camera manipulation
453  virtual void setCameraPosition(const osg::Matrixd& mx, bool viewMatrix = false, unsigned int cameraID = 0) = 0;
454 
464  virtual void bindCameraToEntity(unsigned int id, const osg::Matrixd& mx, unsigned int cameraID = 0) = 0;
465 
475  virtual void bindCameraUpdate(const osg::Matrixd& mx, unsigned int cameraID = 0) = 0;
476 
483  virtual void unbindCameraFromEntity(unsigned int cameraID = 0) = 0;
484 
494  virtual void bindEntityToCamera(unsigned int id, const osg::Matrixd& mx, unsigned int cameraID = 0) = 0;
495 
506  virtual void bindEntityToCameraUpdate(unsigned int id, const osg::Matrixd& mx) = 0;
507 
514  virtual void unbindEntityFromCamera(unsigned int id) = 0;
515 
523  virtual bool isCameraBoundToEntity(unsigned int cameraID = 0) = 0;
524 
537  virtual void bindCameraSetFixedUp(bool fixedUp, bool freezeOrientation = false, unsigned int cameraID = 0) = 0;
538 
539  // Animation
558  virtual void playAnimation(unsigned int entityId, const std::string& animationName) = 0;
559 
570  virtual void playAnimation(unsigned int entityId, const StringUtils::StringList& animations) = 0;
571 
588  virtual void playAnimation(unsigned int entityId, const std::string& animationName, RefAnimationSequenceCallbacks* cbs) = 0;
589 
598  virtual void stopAnimation(unsigned int entityId, const std::string& animationName) = 0;
599 
608  virtual void stopAnimation(unsigned int entityId, const StringUtils::StringList& animations) = 0;
609 
619  virtual void resetAnimation(unsigned int entityId, const std::string& animationName) = 0;
620 
630  virtual void resetAnimation(unsigned int entityId, const StringUtils::StringList& animations) = 0;
631 
642  {
643  Play,
644  Stop,
645  Reset,
646  Pause,
647  Restore
648  };
649  virtual void changeAnimationStatus(unsigned int entityId, AnimationStatus status, const StringUtils::StringList& animations) = 0;
650 
651  // Environment
662  virtual void setFog(double visibility) = 0;
663 
675  virtual void setDate(unsigned int month,int day, int year) = 0;
676 
687  virtual void setTimeOfDay(unsigned int hour, unsigned int minutes) = 0;
688 
699  virtual void setRain(double factor) = 0;
700 
711  virtual void setSnow(double factor) = 0;
712 
725  virtual void setWind(float speed, float direction = 0.f) = 0;
726 
727  // Atmosphere
745  virtual void addCloudLayer(unsigned int id, int type, double altitude, double thickness = 0, double density = 0.3, bool enable = true) = 0;
746 
757  virtual void enableCloudLayer(unsigned int id, bool enableIn = true) = 0;
758 
768  virtual void removeCloudLayer(unsigned int id) = 0;
769 
784  virtual void updateCloudLayer(unsigned int id, double altitude, double thickness, double density) = 0;
785 
794  virtual void removeAllCloudlayers() = 0;
795 
817  virtual void createCloudLayerFile(unsigned int id, int type, double altitude, double thickness=0, double density=0.3, bool enable=true, std::string filename="") = 0;
818 
829  virtual void removeCloudLayerFile(unsigned int id) = 0;
830 
843  virtual void loadCloudLayerFile(unsigned int id, int type, std::string filename) = 0;
844 
845  // Lights
856  virtual void setLightImplementationCallback(LightImplementationCallback* cb) = 0;
857 
874  virtual void addLight(unsigned int id, const LightAttributes& lightAttributes, const osg::Matrixd& mx) = 0;
875 
883  virtual void removeLight(unsigned int id) = 0;
884 
895  virtual void updateLight(unsigned int id, const osg::Matrixd& mx) = 0;
896 
905  virtual void setLightUserData(unsigned int id, osg::Referenced* data) = 0;
906 
916  virtual void bindLightToEntity(unsigned int id, unsigned int entityId) = 0;
917 
926  virtual void unbindLightFromEntity(unsigned int id) = 0;
927 
939  virtual void enableLight(unsigned int id, bool enable, bool hard = true) = 0;
940 
953  virtual void bindLightToCamera(unsigned int id, const osg::Matrixd& offset = osg::Matrixd::identity()) = 0;
954 
962  virtual void unbindLightFromcamera(unsigned int id) = 0;
963 
973  virtual bool isLightEnabled(unsigned int id) = 0;
974 
975  typedef std::map< unsigned int, LightAttributes > LightAttributesMap;
976 
985  virtual LightAttributesMap& getLightAttributesMap() = 0;
986 
996  virtual LightAttributes getLightAttributes(unsigned int id) = 0;
997 
1009  virtual void updateLightAttributes(unsigned int id, const LightAttributes& attribs) = 0;
1010 
1020  virtual osgViewer::CompositeViewer* getViewer() = 0;
1021 
1032  virtual osg::Node* getScene() = 0;
1033 
1040  typedef osg::ref_ptr<osg::MatrixTransform> Entity;
1041  typedef std::map< unsigned int, Entity > EntityMap;
1042  typedef std::map< unsigned int, Entity >::iterator EntityMapIterator;
1043  typedef std::map< unsigned int, Entity >::const_iterator EntityMapConstIterator;
1044 
1054  virtual EntityMap& getEntityMap() = 0;
1055 
1063  virtual float getTerrainHeight( const osg::Vec3& position ) = 0;
1064 
1075  virtual float getIntersect( const osg::Vec3& pos, const osg::Vec3& angles, float angle ) = 0;
1076 
1087  virtual osg::Vec3 getIntersectPos( const osg::Vec3& pos, const osg::Vec3& angles,float angle, float height=100000 ) = 0;
1088 
1089 
1097  virtual osg::LightSource* getSunOrMoonLight() = 0;
1098 
1106  virtual osg::Fog* getFog() = 0;
1107 
1114  virtual void preRender() = 0;
1115 
1122  virtual void postRender() = 0;
1123  };
1124  } // namespace
1125 } // namespace
1126 
1127 #endif // IMAGEGENERATOR_H
Definition: ImageGenerator.h:62
Performs cleanup.
Definition: ImageGenerator.h:156
The Image Generator abstract interface. This is base class for openig::OpenIG.
Definition: ImageGenerator.h:74
std::vector< unsigned int > ViewIdentifiers
One might want to have the Image Generator only in some views, so this typedef holds the IDs of the v...
Definition: ImageGenerator.h:111
osg::ref_ptr< osg::MatrixTransform > Entity
This is our Entity, a base for models in the scene.
Definition: ImageGenerator.h:1040
AnimationStatus
Changes the animation status.
Definition: ImageGenerator.h:641