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) {
48 _identity_attrib = return_new(attrib);
51 return _identity_attrib;
59make(PN_stdfloat volume) {
61 return return_new(attrib);
73 return return_new(attrib);
90set_volume(PN_stdfloat volume)
const {
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::
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 {
176 return return_new(attrib);
192 PN_stdfloat new_volume = _volume == 0.0f ? 1.0f : ta->_volume / _volume;
195 return return_new(attrib);
201void AudioVolumeAttrib::
202register_with_read_factory() {
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.
bool is_off() const
Returns true if the AudioVolumeAttrib will ignore any color scales inherited from above,...
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.
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.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
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.
This hash_compare class hashes a float or a double.
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 Key &key)
Adds the indicated key into a running hash.
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.