30 _face_color.set(1.0, 1.0, 1.0, 1.0);
31 _specular_color.set(0.0, 0.0, 0.0);
32 _emissive_color.set(0.0, 0.0, 0.0);
35 _has_material =
false;
52 if (egg_prim->has_color()) {
61 if (egg_mat->has_diff()) {
64 if (egg_mat->has_spec()) {
65 const LColor &spec = egg_mat->
get_spec();
66 _specular_color.set(spec[0], spec[1], spec[2]);
68 if (egg_mat->has_emit()) {
69 const LColor &emit = egg_mat->
get_emit();
70 _emissive_color.set(emit[0], emit[1], emit[2]);
72 if (egg_mat->has_shininess()) {
73 _power = egg_mat->get_shininess();
100 bool got_spec = (_specular_color != LRGBColor::zero());
101 bool got_emit = (_emissive_color != LRGBColor::zero());
102 if (got_spec || got_emit) {
104 temp.set_diff(_face_color);
106 temp.set_shininess(_power);
107 temp.set_spec(LColor(_specular_color[0], _specular_color[1],
108 _specular_color[2], 1.0));
111 temp.set_emit(LColor(_emissive_color[0], _emissive_color[1],
112 _emissive_color[2], 1.0));
119 egg_prim->set_color(_face_color);
128 ct = _face_color.compare_to(other._face_color);
130 ct = (_power == other._power) ? 0 : ((_power < other._power) ? -1 : 1);
133 ct = _specular_color.compare_to(other._specular_color);
136 ct = _emissive_color.compare_to(other._emissive_color);
139 ct = strcmp(_texture.c_str(), other._texture.c_str());
150 return _has_material;
169 _specular_color, _emissive_color);
184 _face_color = LCAST(PN_stdfloat, (*obj)[
"faceColor"].vec4());
185 _power = (*obj)[
"power"].d();
186 _specular_color = LCAST(PN_stdfloat, (*obj)[
"specularColor"].vec3());
187 _emissive_color = LCAST(PN_stdfloat, (*obj)[
"emissiveColor"].vec3());
188 _has_material =
true;
193 for (
int i = 0; i < num_objects; i++) {
200 if (xfile_cat.is_debug()) {
202 <<
"Ignoring material object of unknown type: " A base class for any of a number of kinds of geometry primitives: polygons, point lights,...
get_material
Returns a pointer to the applied material, or NULL if there is no material applied.
const Filename & get_filename() const
Returns a nonmodifiable reference to the filename.
bool has_texture() const
Returns true if this material includes a texture map, false otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Defines a texture map that may be applied to geometry.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
XFileDataNode * make_x_material(XFileNode *x_meshMaterials, const std::string &suffix)
Creates a Material object for the material list.
void set_texture(EggTexture *texture)
Replaces the current list of textures with the indicated texture.
XFileDataNode * add_Material(const std::string &name, const LColor &face_color, double power, const LRGBColor &specular_color, const LRGBColor &emissive_color)
Creates a new Material instance, as a child of this node.
void apply_to_egg(EggPrimitive *egg_prim, XFileToEggConverter *converter)
Applies the properties in the material to the indicated egg primitive.
XFileDataNode * add_TextureFilename(const std::string &name, const Filename &filename)
Creates a new TextureFilename instance, as a child of this node.
set_material
Applies the indicated material to the primitive.
LColor get_color() const
Returns the color set on this particular attribute.
void set_from_egg(EggPrimitive *egg_prim)
Sets the structure up from the indicated egg data.
EggMaterial * create_unique_material(const EggMaterial ©)
Returns an EggMaterial pointer whose properties match that of the the given EggMaterial,...
bool has_material() const
Returns true if this material represents something meaningful, or false if the default material is su...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_num_objects() const
Returns the list of child objects of this node.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A single node of an X file.
The name of a file, such as a texture file or an Egg file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool has_texture() const
Returns true if the primitive has any textures specified, false otherwise.
get_spec
It is legal to call this even if has_spec() returns false.
const std::string & get_template_name() const
A convenience function to return the name of the template used to define this data object.
This represents an X file "material", which consists of a color, lighting, and/or texture specificati...
This is an abstract base class for an XFileNode which is also an XFileDataObject.
get_emit
It is legal to call this even if has_emit() returns false.
get_texture
Returns the first texture on the primitive, if any, or NULL if there are no textures on the primitive...
EggTexture * create_unique_texture(const EggTexture ©)
Returns an EggTexture pointer whose properties match that of the the given EggTexture,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool fill_material(XFileDataNode *obj)
Fills the structure based on the raw data from the X file's Material object.
XFileDataNode * get_object(int n) const
Returns the nth child object of this node.
virtual bool is_standard_object(const std::string &template_name) const
Returns true if this node represents an instance of the standard template with the indicated name,...
get_diff
It is legal to call this even if has_diff() returns false.
static Filename from_os_specific(const std::string &os_specific, Type type=T_general)
This named constructor returns a Panda-style filename (that is, using forward slashes,...
Filename convert_model_path(const Filename &orig_filename)
Converts the indicated model filename to a relative or absolute or whatever filename,...
has_material
Returns true if the primitive is materiald (and get_material() will return a real pointer),...