Go to the documentation of this file.
25 int AudioVolumeAttrib::_attrib_slot;
31 AudioVolumeAttrib(
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;
59 make(PN_stdfloat volume) {
61 return return_new(attrib);
73 return return_new(attrib);
90 set_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);
101 void AudioVolumeAttrib::
102 output(std::ostream &out)
const {
103 out << get_type() <<
":";
127 int 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;
148 size_t AudioVolumeAttrib::
149 get_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);
201 void AudioVolumeAttrib::
202 register_with_read_factory() {
233 attrib->fillin(scan, manager);
242 void AudioVolumeAttrib::
244 RenderAttrib::fillin(scan, manager);
248 nassertv(_volume >= 0.f);
249 _has_volume = !IS_NEARLY_EQUAL(_volume, 1.0f);
bool is_off() const
Returns true if the AudioVolumeAttrib will ignore any color scales inherited from above,...
CPT(RenderAttrib) AudioVolumeAttrib
Constructs an identity audio volume attrib.
A class to retrieve the individual data elements previously stored in a Datagram.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
This is the base class for a number of render attributes (other than transform) that may be set on sc...
This hash_compare class hashes a float or a double.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Base class for objects that can be written to and read from Bam files.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
TypeHandle is the identifier used to differentiate C++ class types.
bool get_bool()
Extracts a boolean value.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
static size_t add_hash(size_t start, const Key &key)
Adds the indicated key into a running hash.
size_t add_hash(size_t start, const Key &key) const
Adds the indicated key into a running hash.
void add_bool(bool value)
Adds a boolean value to the datagram.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Applies a scale to audio volume for positional sounds in the scene graph.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_volume
Returns the volume to be applied to sounds.
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,...
has_volume
Returns true if the AudioVolumeAttrib has a non-identity volume, false otherwise (in which case it mi...