00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <osg/ShapeDrawable>
00024 #include <osgUtil/SceneView>
00025 #include <osgUtil/Optimizer>
00026 #include <osg/Geode>
00027 #include <osg/Fog>
00028 #include <osg/Geometry>
00029 #include <osg/Texture2D>
00030 #include <osg/Billboard>
00031 #include <osg/BlendFunc>
00032 #include <osg/AlphaFunc>
00033 #include <osgDB/Registry>
00034 #include <osgDB/ReadFile>
00035 #include <osgProducer/Viewer>
00036
00037
00042
00043 #include "lightManager.h"
00044 #include "soundManager.h"
00045
00046
00047 class Scene3D{
00048 public:
00049 Scene3D();
00050 ~Scene3D();
00051
00052 void attach(osgProducer::Viewer* );
00053 void update();
00054 void createScene();
00055 void initSound();
00056
00057 void optimize(osg::Node* root);
00058 void setSky();
00059 void setVisibilityRange(float range);
00060 void setSkyDome(osg::Node* skyDome);
00061 void setClouds(osg::Node* node, float height);
00062 void setSkyLightColor(const osg::Vec4& color);
00063 void setSkyLightPosition(const osg::Vec2& headingAzimuth);
00064 void addTree (const std::string & strFile, float x,float y, float z);
00065 osg::Node* addObject(osg::Node* node,osg::Vec3d pos,osg::Vec3d scale);
00066 osg::ref_ptr<osgAL::SoundNode> addSound(const std::string& name);
00067 void addSoundSource (const std::string & strFile, float x,float y, float z,float factor, float dist);
00068 osg::ref_ptr<osg::Group> getRootNode();
00069 osg::ref_ptr<osg::MatrixTransform> getRoot();
00070 bool isSoundEnabled();
00071 osg::Node* createMovingModel(osg::Node* n,float scale,const std::string & strFile,const osg::Vec3& center, float radius,float speed);
00072 void creerChutesEtAnim(osg::Group* scene);
00073
00074 void setTrees(bool b){trees=b;};
00075 void setFogs(bool b){fogs=b;};
00076
00077 private:
00078 osgProducer::Viewer* viewer;
00079 osg::Drawable* createShrub(const float & scale, osg::StateSet* bbState);
00080 osg::ref_ptr<osgAL::SoundRoot> sound_root;
00081 osg::ref_ptr<osg::Group> rootNode;
00082 osg::ref_ptr<osg::MatrixTransform> root;
00083 osg::ref_ptr<osg::StateSet> rootStateSet;
00084 osg::ref_ptr<osg::MatrixTransform> sky;
00085 osg::ref_ptr<osg::MatrixTransform> skyDome;
00086 osg::ref_ptr<osg::LightSource> skyLight;
00087 osg::ref_ptr<osg::LightSource> backLight;
00088 osg::ref_ptr<osg::MatrixTransform> clouds;
00089 LightManager lightManager;
00090 SoundManager * soundMgr;
00091 bool sound;
00092 bool trees;
00093 bool fogs;
00094 };
00095