X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscene%2Ftgdb%2Fpt_lights.hxx;h=863328dc60bffafcd90500e4aca615bcc8e854e7;hb=3b5665fe92802d3d36d6304cb2c184dc03e91de4;hp=7e5aa5ed760d503773e1cee23d0556057094a790;hpb=efac53b1212d3dd3456b7cada4262287c700ce34;p=simgear.git diff --git a/simgear/scene/tgdb/pt_lights.hxx b/simgear/scene/tgdb/pt_lights.hxx index 7e5aa5ed..863328dc 100644 --- a/simgear/scene/tgdb/pt_lights.hxx +++ b/simgear/scene/tgdb/pt_lights.hxx @@ -29,66 +29,76 @@ # error This library requires C++ #endif - #include -#include STL_STRING +#include #include // STL -#include -#include // plib include +#include +#include +#include #include #include +#include +#include -SG_USING_STD(string); -SG_USING_STD(vector); - +#include "SGLightBin.hxx" +#include "SGDirectionalLightBin.hxx" -typedef vector < int > int_list; -typedef int_list::iterator int_list_iterator; -typedef int_list::const_iterator int_point_list_iterator; +namespace simgear +{ +class Effect; +} +// Specify the way we want to draw directional point lights (assuming the +// appropriate extensions are available.) -// Generate a directional light. This routines creates a -// 'directional' light that can only be viewed from within 90 degrees -// of the specified dir vector. +inline void SGConfigureDirectionalLights( bool use_point_sprites, + bool enhanced_lighting, + bool distance_attenuation ) { + static SGSceneFeatures* sceneFeatures = SGSceneFeatures::instance(); + sceneFeatures->setEnablePointSpriteLights(use_point_sprites); + sceneFeatures->setEnableDistanceAttenuationLights(distance_attenuation); +} -// To accomplish this, he routine creates a triangle with the 1st -// point coincident with the specified pt and the 2nd and 3rd points -// extending upward. The 1st point is created with an 'alpha' value -// of 1 while the 2nd and 3rd points are created with an 'alpha' of -// 0.0. +class SGLightFactory { +public: -// If the triangle is drawn in glPolygonMode(GL_FRONT, GL_POINT) mode, -// then two important things happen: + static osg::Drawable* + getLightDrawable(const SGLightBin::Light& light); -// 1) Only the 3 vertex points are drawn, the 2nd two with an alpha of -// 0 so actually only the desired point is rendered. + static osg::Drawable* + getLightDrawable(const SGDirectionalLightBin::Light& light); -// 2) since we are drawing a triangle, back face culling takes care of -// eliminating this poing when the view angle relative to dir is -// greater than 90 degrees. + /** + * Return a drawable for a very simple point light that isn't + * distance scaled. + */ + static osg::Drawable* + getLights(const SGLightBin& lights, unsigned inc = 1, float alphaOff = 0); -// The final piece of this puzzle is that if we now use environment -// mapping on this point, via an appropriate texture we can then -// control the intensity and color of the point based on the view -// angle relative to 'dir' the optimal view direction of the light -// (i.e. the direction the light is pointing.) + static osg::Drawable* + getLights(const SGDirectionalLightBin& lights); -// Yes this get's to be long and convoluted. If you can suggest a -// simpler way, please do! :-) + static osg::Drawable* + getVasi(const SGVec3f& up, const SGDirectionalLightBin& lights, + const SGVec4f& red, const SGVec4f& white); -ssgLeaf *sgMakeDirectionalLight( sgVec3 pt, sgVec3 dir, sgVec3 up ); + static osg::Node* + getSequenced(const SGDirectionalLightBin& lights, const simgear::SGReaderWriterOptions* options); + static osg::Node* + getOdal(const SGLightBin& lights, const simgear::SGReaderWriterOptions* options); -ssgBranch *sgMakeDirectionalLights( const point_list &nodes, - const point_list &normals, - const int_list &pnt_i, - const int_list &nml_i, - SGMaterialLib *matlib, - const string &material, - sgdVec3 dup ); + static osg::Node* + getHoldShort(const SGDirectionalLightBin& lights, const simgear::SGReaderWriterOptions* options); + static osg::Node* + getGuard(const SGDirectionalLightBin& lights, const simgear::SGReaderWriterOptions* options); +}; +simgear::Effect* getLightEffect(float size, const osg::Vec3& attenuation, + float minSize, float maxSize, bool directional, + const simgear::SGReaderWriterOptions* options); #endif // _SG_PT_LIGHTS_HXX