Added a fast function to obtain the default material

This commit is contained in:
Josh Yelon 2008-01-25 03:28:17 +00:00
parent a9ade97ed0
commit 7625c2cfa2
3 changed files with 18 additions and 0 deletions

View File

@ -51,6 +51,19 @@ INLINE Material::
~Material() { ~Material() {
} }
////////////////////////////////////////////////////////////////////
// Function: Material::get_default
// Access: Published, Static
// Description: Returns the default material.
////////////////////////////////////////////////////////////////////
INLINE Material *Material::
get_default() {
if (_default == 0) {
_default = new Material("default");
}
return _default;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: Material::has_ambient // Function: Material::has_ambient
// Access: Published // Access: Published

View File

@ -25,6 +25,7 @@
#include "bamWriter.h" #include "bamWriter.h"
TypeHandle Material::_type_handle; TypeHandle Material::_type_handle;
PT(Material) Material::_default;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: Material::Copy Assignment Operator // Function: Material::Copy Assignment Operator

View File

@ -40,6 +40,8 @@ PUBLISHED:
void operator = (const Material &copy); void operator = (const Material &copy);
INLINE ~Material(); INLINE ~Material();
INLINE static Material *get_default();
INLINE bool has_ambient() const; INLINE bool has_ambient() const;
INLINE const Colorf &get_ambient() const; INLINE const Colorf &get_ambient() const;
void set_ambient(const Colorf &color); void set_ambient(const Colorf &color);
@ -84,6 +86,8 @@ private:
Colorf _emission; Colorf _emission;
float _shininess; float _shininess;
static PT(Material) _default;
enum Flags { enum Flags {
F_ambient = 0x001, F_ambient = 0x001,
F_diffuse = 0x002, F_diffuse = 0x002,