Panda3D
|
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, PN_stdfloat volume); 00033 INLINE AudioVolumeAttrib(const AudioVolumeAttrib ©); 00034 00035 PUBLISHED: 00036 static CPT(RenderAttrib) make_identity(); 00037 static CPT(RenderAttrib) make(PN_stdfloat 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 PN_stdfloat get_volume() const; 00044 CPT(RenderAttrib) set_volume(PN_stdfloat 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 size_t get_hash_impl() const; 00052 virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const; 00053 virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const; 00054 00055 private: 00056 bool _off; 00057 bool _has_volume; 00058 PN_stdfloat _volume; 00059 static CPT(RenderAttrib) _identity_attrib; 00060 00061 PUBLISHED: 00062 static int get_class_slot() { 00063 return _attrib_slot; 00064 } 00065 virtual int get_slot() const { 00066 return get_class_slot(); 00067 } 00068 00069 public: 00070 static void register_with_read_factory(); 00071 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00072 00073 protected: 00074 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00075 void fillin(DatagramIterator &scan, BamReader *manager); 00076 00077 public: 00078 static TypeHandle get_class_type() { 00079 return _type_handle; 00080 } 00081 static void init_type() { 00082 RenderAttrib::init_type(); 00083 register_type(_type_handle, "AudioVolumeAttrib", 00084 RenderAttrib::get_class_type()); 00085 _attrib_slot = register_slot(_type_handle, 100, make_default); 00086 } 00087 virtual TypeHandle get_type() const { 00088 return get_class_type(); 00089 } 00090 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00091 00092 private: 00093 static TypeHandle _type_handle; 00094 static int _attrib_slot; 00095 }; 00096 00097 #include "audioVolumeAttrib.I" 00098 00099 #endif 00100