Panda3D

lensFlareNode.h

00001 // Filename: lensFlareNode.h
00002 // Created by:  jason (18Jul00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #if 0  // temporarily disabled until we can port to new scene graph.
00016 
00017 #ifndef LENSFLARENODE_H
00018 #define LENSFLARENODE_H
00019 
00020 #include "pandabase.h"
00021 
00022 #include "namedNode.h"
00023 #include "texture.h"
00024 #include "luse.h"
00025 #include "pta_Colorf.h"
00026 #include "pta_float.h"
00027 #include "renderRelation.h"
00028 #include "pmap.h"
00029 
00030 class GraphicsStateGuardian;
00031 class ClockObject;
00032 
00033 class EXPCL_PANDAFX LensFlareNode : public Node
00034 {
00035 PUBLISHED:
00036   INLINE LensFlareNode();
00037 
00038   void add_flare(PT(Texture) flare, PTA_float scales, PTA_float offsets,
00039                  PTA_float angle_scales, PTA_Colorf colors);
00040   void add_blind(PT(Texture) blind);
00041 
00042   INLINE void set_texel_scale(float texel_to_world);
00043   INLINE void set_global_scale(float scale);
00044 
00045   INLINE void set_blind_falloff(float fall_off);
00046   INLINE void set_flare_falloff(float fall_off);
00047 
00048   INLINE void set_light_source(PT_Node source);
00049 
00050 public:
00051   virtual bool sub_render(const AllTransitionsWrapper &input_trans,
00052                           AllTransitionsWrapper &modify_trans,
00053                           RenderTraverser *trav);
00054   virtual bool has_sub_render() const;
00055 
00056 private:
00057   typedef pvector<PTA_float> vector_Vfloat;
00058   typedef pvector<PTA_Colorf> vector_Vcolorf;
00059   typedef pvector< PT(RenderRelation) > vector_relation;
00060   typedef pvector< PT(Texture) > vector_texture;
00061 
00062   vector_texture _flares;
00063   PT(Texture) _blind;
00064 
00065   vector_relation _flare_arcs;
00066   PT(RenderRelation) _blind_arc;
00067 
00068   vector_Vfloat _flare_scales;
00069   vector_Vfloat _flare_angle_scales;
00070   vector_Vfloat _flare_offsets;
00071   vector_Vcolorf _flare_colors;
00072 
00073   float _global_scale;
00074   float _texel_scale;
00075 
00076   float _blind_fall_off;
00077   float _flare_fall_off;
00078 
00079   PT_Node _light_node;
00080 
00081   /****Internal functions*****/
00082 
00083   //Sub-routines that are defined only for code cleanliness
00084   void prepare_flares(const LVector3f &delta, const LPoint3f &light, const float &angle);
00085   void prepare_blind(const float &angle, const float &tnear);
00086 
00087   //All of the geometry for halos and blooms is created the same way.
00088   //Sparkle geometry is created differently because we cycle through
00089   //the set of Sparkle textures to create an animation
00090 
00091   void set_geometry(GeomSprite *sprite, const PTA_float &geom_scales,
00092                     const PTA_float &geom_offsets, const PTA_float &geom_angle_scales,
00093                     const PTA_Colorf &geom_colors, const LVector3f &delta,
00094                     const LPoint3f &light, const float &angle);
00095 
00096 
00097   void render_child(RenderRelation *arc,
00098                     const AllTransitionsWrapper &trans,
00099                     GraphicsStateGuardian *gsg);
00100   void render_children(const vector_relation &arcs,
00101                        const AllTransitionsWrapper &trans,
00102                        GraphicsStateGuardian *gsg);
00103 
00104 public:
00105   static void register_with_read_factory();
00106   virtual void write_datagram(BamWriter *manager, Datagram &me);
00107   virtual int complete_pointers(TypedWritable **plist,
00108                                 BamReader *manager);
00109 
00110   static TypedWritable *make_LensFlareNode(const FactoryParams &params);
00111 
00112 protected:
00113   void fillin(DatagramIterator &scan, BamReader *manager);
00114 
00115 private:
00116   int _num_flares, _num_arcs;
00117 
00118 public:
00119   static TypeHandle get_class_type( void ) {
00120       return _type_handle;
00121   }
00122   static void init_type( void ) {
00123     NamedNode::init_type();
00124     register_type( _type_handle, "LensFlareNode",
00125                 NamedNode::get_class_type() );
00126   }
00127   virtual TypeHandle get_type( void ) const {
00128     return get_class_type();
00129   }
00130   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00131 
00132 private:
00133   static TypeHandle             _type_handle;
00134 };
00135 
00136 #include "lensFlareNode.I"
00137 
00138 #endif
00139 
00140 /***********OLD SPARKLE CODE.  LEFT IN CASE
00141 public:
00142   void add_sparkle(PT_Node source, PT(Texture) sparkle);
00143   void set_sparkles_attributes(PT_Node source, float angle_scale, vector_float scales,
00144                                vector_float offsets, vector_Colorf colors);
00145   void set_sparkle_fps(float fps);
00146 
00147 private:
00148   //Sparkle animation variables
00149   ClockObject* _global_clock;
00150   float _next_switch;
00151   float _sparkle_fps;
00152   float _inv_sparkle_fps;
00153 
00154   typedef pmap<PT_Node, vector_float> Sparkle_Scales;
00155   typedef pmap<PT_Node, vector_float> Sparkle_Offsets;
00156   typedef pmap<PT_Node, vector_Colorf> Sparkle_Colors;
00157 
00158   Textures _sparkles;
00159   Relations _sparkle_arcs;
00160 
00161   Sparkle_Scales _sparkle_scales;
00162   Sparkle_Offsets _sparkle_offsets;
00163   Sparkle_Colors _sparkle_colors;
00164 
00165   int _num_sparkles_on;
00166   pmap<PT_Node, int> _current_sparkles;
00167 
00168   void prepare_sparkles(vector_relation &arcs, const vector_texture &sparkles,
00169                         const vector_float &scales, const vector_float &offsets,
00170                         const vector_Colorf &colors, const LVector3f &delta,
00171                         const LPoint3f &light, const BoundingVolume &bound, int &old_sparkle);
00172 
00173   //Timing function to control sparkle animation
00174   int compute_current(int &current_sparkle, vector_texture sparkles);
00175 
00176 ******************/
00177 
00178 #endif  // temporarily disabled until we can port to new scene graph.
 All Classes Functions Variables Enumerations