25int AudioVolumeAttrib::_attrib_slot;
31AudioVolumeAttrib(
bool off, PN_stdfloat volume) :
35 nassertv(_volume >= 0.f);
36 _has_volume = !IS_NEARLY_EQUAL(_volume, 1.0f);
46 if (_identity_attrib ==
nullptr) {
47 AudioVolumeAttrib *attrib =
new AudioVolumeAttrib(
false, 1.0f);;
48 _identity_attrib = return_new(attrib);
51 return _identity_attrib;
59make(PN_stdfloat volume) {
60 AudioVolumeAttrib *attrib =
new AudioVolumeAttrib(
false, volume);
61 return return_new(attrib);
71 AudioVolumeAttrib *attrib =
72 new AudioVolumeAttrib(
true, 1.0f);
73 return return_new(attrib);
82 return return_new(
new AudioVolumeAttrib(
false, 1.0f));
91 AudioVolumeAttrib *attrib =
new AudioVolumeAttrib(*
this);
92 assert(volume >= 0.f);
93 attrib->_volume = volume;
94 attrib->_has_volume = !IS_NEARLY_EQUAL(volume, 1.0f);
95 return return_new(attrib);
101void AudioVolumeAttrib::
102output(std::ostream &out)
const {
103 out << get_type() <<
":";
127int AudioVolumeAttrib::
129 const AudioVolumeAttrib *ta = (
const AudioVolumeAttrib *)other;
131 if (_off != ta->_off) {
132 return (
int)_off - (int)ta->_off;
135 if (_volume != ta->_volume) {
136 return _volume < ta->_volume ? -1 : 1;
148size_t AudioVolumeAttrib::
149get_hash_impl()
const {
152 hash = float_hash().
add_hash(hash, _volume);
169 const AudioVolumeAttrib *ta = (
const AudioVolumeAttrib *)other;
175 AudioVolumeAttrib *attrib =
new AudioVolumeAttrib(
is_off(), ta->_volume * _volume);
176 return return_new(attrib);
190 const AudioVolumeAttrib *ta = (
const AudioVolumeAttrib *)other;
192 PN_stdfloat new_volume = _volume == 0.0f ? 1.0f : ta->_volume / _volume;
194 AudioVolumeAttrib *attrib =
new AudioVolumeAttrib(
false, new_volume);
195 return return_new(attrib);
233 attrib->fillin(scan, manager);
242void AudioVolumeAttrib::
244 RenderAttrib::fillin(scan, manager);
248 nassertv(_volume >= 0.f);
249 _has_volume = !IS_NEARLY_EQUAL(_volume, 1.0f);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Applies a scale to audio volume for positional sounds in the scene graph.
static ConstPointerTo< RenderAttrib > make_default()
Returns a RenderAttrib that corresponds to whatever the standard default properties for render attrib...
static void register_with_read_factory()
Tells the BamReader how to create objects of type AudioVolumeAttrib.
ConstPointerTo< RenderAttrib > set_volume(PN_stdfloat volume) const
Returns a new AudioVolumeAttrib, just like this one, but with the volume changed to the indicated val...
bool is_off() const
Returns true if the AudioVolumeAttrib will ignore any color scales inherited from above,...
static ConstPointerTo< RenderAttrib > make_identity()
Constructs an identity audio volume attrib.
has_volume
Returns true if the AudioVolumeAttrib has a non-identity volume, false otherwise (in which case it mi...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
static ConstPointerTo< RenderAttrib > make(PN_stdfloat volume)
Constructs a new AudioVolumeAttrib object that indicates audio volume should be scaled by the indicat...
static ConstPointerTo< RenderAttrib > make_off()
Constructs a new AudioVolumeAttrib object that ignores any AudioVolumeAttrib inherited from above.
get_volume
Returns the volume to be applied to sounds.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
A class to retrieve the individual data elements previously stored in a Datagram.
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
bool get_bool()
Extracts a boolean value.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
void add_bool(bool value)
Adds a boolean value to the datagram.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
This is the base class for a number of render attributes (other than transform) that may be set on sc...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
TypeHandle is the identifier used to differentiate C++ class types.
Base class for objects that can be written to and read from Bam files.
size_t add_hash(size_t start, const Key &key) const
Adds the indicated key into a running hash.
static size_t add_hash(size_t start, const int &key)
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.