15 #include "audioVolumeAttrib.h"
16 #include "graphicsStateGuardianBase.h"
18 #include "bamReader.h"
19 #include "bamWriter.h"
21 #include "datagramIterator.h"
22 #include "config_pgraph.h"
39 nassertv(_volume >= 0.f);
40 _has_volume = !IS_NEARLY_EQUAL(_volume, 1.0f);
54 _identity_attrib = return_new(attrib);
57 return _identity_attrib;
67 make(PN_stdfloat volume) {
69 return return_new(attrib);
84 return return_new(attrib);
106 set_volume(PN_stdfloat volume)
const {
108 assert(volume >= 0.f);
109 attrib->_volume = volume;
110 attrib->_has_volume = !IS_NEARLY_EQUAL(volume, 1.0f);
111 return return_new(attrib);
119 void AudioVolumeAttrib::
120 output(ostream &out)
const {
121 out << get_type() <<
":";
148 int AudioVolumeAttrib::
151 DCAST_INTO_R(ta, other, 0);
153 if (_off != ta->_off) {
154 return (
int)_off - (int)ta->_off;
157 if (_volume != ta->_volume) {
158 return _volume < ta->_volume ? -1 : 1;
174 size_t AudioVolumeAttrib::
175 get_hash_impl()
const {
202 DCAST_INTO_R(ta, other, 0);
209 return return_new(attrib);
227 DCAST_INTO_R(ta, other, 0);
228 PN_stdfloat new_volume = _volume == 0.0f ? 1.0f : ta->_volume / _volume;
231 return return_new(attrib);
276 parse_params(params, scan, manager);
277 attrib->fillin(scan, manager);
289 void AudioVolumeAttrib::
291 RenderAttrib::fillin(scan, manager);
295 nassertv(_volume >= 0.f);
296 _has_volume = !IS_NEARLY_EQUAL(_volume, 1.0f);
bool get_bool()
Extracts a boolean value.
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
This is the base class for a number of render attributes (other than transform) that may be set on sc...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Base class for objects that can be written to and read from Bam files.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
PN_stdfloat get_volume() const
Returns the volume to be applied to sounds.
bool has_volume() const
Returns true if the AudioVolumeAttrib has a non-identity volume, false otherwise (in which case it mi...
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
static size_t add_hash(size_t start, const Key &key)
Adds the indicated key into a running hash.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
bool is_off() const
Returns true if the AudioVolumeAttrib will ignore any color scales inherited from above...
This hash_compare class hashes a float or a double.
void add_bool(bool value)
Adds a boolean value to the datagram.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
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)
Registers a new kind of thing the Factory will be able to create.
static void register_with_read_factory()
Tells the BamReader how to create objects of type AudioVolumeAttrib.
size_t add_hash(size_t start, const Key &key) const
Adds the indicated key into a running hash.
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. ...
TypeHandle is the identifier used to differentiate C++ class types.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Applies a scale to audio volume for positional sounds in the scene graph.