15 #include "pandabase.h"
19 #include "datagramIterator.h"
20 #include "bamReader.h"
21 #include "bamWriter.h"
33 Namable::operator = (copy);
34 _ambient = copy._ambient;
35 _diffuse = copy._diffuse;
36 _specular = copy._specular;
37 _emission = copy._emission;
38 _shininess = copy._shininess;
39 _flags = copy._flags & (~F_attrib_lock);
56 if (enforce_attrib_lock) {
57 if ((_flags & F_ambient)==0) {
58 nassertv(!is_attrib_locked());
81 if (enforce_attrib_lock) {
82 if ((_flags & F_diffuse)==0) {
83 nassertv(!is_attrib_locked());
105 if (enforce_attrib_lock) {
106 if ((_flags & F_specular)==0) {
107 nassertv(!is_attrib_locked());
111 _flags |= F_specular;
130 if (enforce_attrib_lock) {
131 if ((_flags & F_emission)==0) {
132 nassertv(!is_attrib_locked());
136 _flags |= F_emission;
150 if (_flags != other._flags) {
151 return _flags - other._flags;
169 return strcmp(get_name().c_str(), other.get_name().c_str());
178 output(ostream &out)
const {
179 out <<
"Material " << get_name();
203 write(ostream &out,
int indent_level)
const {
204 indent(out, indent_level) <<
"Material " << get_name() <<
"\n";
206 indent(out, indent_level + 2) <<
"ambient = " <<
get_ambient() <<
"\n";
209 indent(out, indent_level + 2) <<
"diffuse = " <<
get_diffuse() <<
"\n";
212 indent(out, indent_level + 2) <<
"specular = " <<
get_specular() <<
"\n";
215 indent(out, indent_level + 2) <<
"emission = " <<
get_emission() <<
"\n";
217 indent(out, indent_level + 2) <<
"shininess = " <<
get_shininess() <<
"\n";
218 indent(out, indent_level + 2) <<
"local = " <<
get_local() <<
"\n";
219 indent(out, indent_level + 2) <<
"twoside = " <<
get_twoside() <<
"\n";
262 parse_params(params, scan, manager);
263 me->fillin(scan, manager);
int compare_to(const LVecBase4f &other) const
This flavor of compare_to uses a default threshold value based on the numeric type.
const LColor & get_ambient() const
Returns the ambient color setting, if it has been set.
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
void set_diffuse(const LColor &color)
Specifies the diffuse color setting of the material.
void add_string(const string &str)
Adds a variable-length string to the datagram.
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
bool has_ambient() const
Returns true if the ambient color has been explicitly set for this material, false otherwise...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
bool has_specular() const
Returns true if the specular color has been explicitly set for this material, false otherwise...
bool get_twoside() const
Returns the state of the two-sided lighting flag.
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_shininess() const
Returns the shininess exponent of the material.
PN_int32 get_int32()
Extracts a signed 32-bit integer.
bool has_emission() const
Returns true if the emission color has been explicitly set for this material, false otherwise...
const LColor & get_emission() const
Returns the emission color setting, if it has been set.
string get_string()
Extracts a variable-length string.
void set_emission(const LColor &color)
Specifies the emission color setting of the material.
void set_specular(const LColor &color)
Specifies the diffuse color setting of the material.
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void read_datagram(DatagramIterator &source)
Reads the vector from the Datagram using get_stdfloat().
const LColor & get_specular() const
Returns the specular color setting, if it has been set.
Defines the way an object appears in the presence of lighting.
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
This is the base class for all three-component vectors and points.
void write_datagram(Datagram &destination) const
Writes the vector to the Datagram using add_stdfloat().
bool has_diffuse() const
Returns true if the diffuse color has been explicitly set for this material, false otherwise...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
void add_int32(PN_int32 value)
Adds a signed 32-bit integer to the datagram.
A class to retrieve the individual data elements previously stored in a Datagram. ...
bool get_local() const
Returns the local viewer flag.
TypeHandle is the identifier used to differentiate C++ class types.
int compare_to(const Material &other) const
Returns a number less than zero if this material sorts before the other one, greater than zero if it ...
void set_ambient(const LColor &color)
Specifies the ambient color setting of the material.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
const LColor & get_diffuse() const
Returns the diffuse color setting, if it has been set.
static void register_with_read_factory()
Factory method to generate a Material object.