Panda3D

audioVolumeAttrib.h

00001 // Filename: audioVolumeAttrib.h
00002 // Created by:  darren (15Dec06)
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 #ifndef AUDIOVOLUMEATTRIB_H
00016 #define AUDIOVOLUMEATTRIB_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "renderAttrib.h"
00021 #include "luse.h"
00022 
00023 class FactoryParams;
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //       Class : AudioVolumeAttrib
00027 // Description : Applies a scale to audio volume for positional sounds
00028 //               in the scene graph.
00029 ////////////////////////////////////////////////////////////////////
00030 class EXPCL_PANDA_PGRAPH AudioVolumeAttrib : public RenderAttrib {
00031 protected:
00032   AudioVolumeAttrib(bool off, float volume);
00033   INLINE AudioVolumeAttrib(const AudioVolumeAttrib &copy);
00034 
00035 PUBLISHED:
00036   static CPT(RenderAttrib) make_identity();
00037   static CPT(RenderAttrib) make(float volume);
00038   static CPT(RenderAttrib) make_off();
00039   static CPT(RenderAttrib) make_default();
00040 
00041   INLINE bool is_off() const;
00042   INLINE bool has_volume() const;
00043   INLINE float get_volume() const;
00044   CPT(RenderAttrib) set_volume(float volume) const;
00045 
00046 public:
00047   virtual void output(ostream &out) const;
00048 
00049 protected:
00050   virtual int compare_to_impl(const RenderAttrib *other) const;
00051   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
00052   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
00053 
00054 private:
00055   bool _off;
00056   bool _has_volume;
00057   float _volume;
00058   static CPT(RenderAttrib) _identity_attrib;
00059 
00060 PUBLISHED:
00061   static int get_class_slot() {
00062     return _attrib_slot;
00063   }
00064   virtual int get_slot() const {
00065     return get_class_slot();
00066   }
00067 
00068 public:
00069   static void register_with_read_factory();
00070   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00071 
00072 protected:
00073   static TypedWritable *make_from_bam(const FactoryParams &params);
00074   void fillin(DatagramIterator &scan, BamReader *manager);
00075   
00076 public:
00077   static TypeHandle get_class_type() {
00078     return _type_handle;
00079   }
00080   static void init_type() {
00081     RenderAttrib::init_type();
00082     register_type(_type_handle, "AudioVolumeAttrib",
00083                   RenderAttrib::get_class_type());
00084     _attrib_slot = register_slot(_type_handle, 100, make_default);
00085   }
00086   virtual TypeHandle get_type() const {
00087     return get_class_type();
00088   }
00089   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00090 
00091 private:
00092   static TypeHandle _type_handle;
00093   static int _attrib_slot;
00094 };
00095 
00096 #include "audioVolumeAttrib.I"
00097 
00098 #endif
00099 
 All Classes Functions Variables Enumerations