Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/effects/lensFlareNode.h

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

Generated on Fri May 2 00:37:22 2003 for Panda by doxygen1.3