#include <opennurbs_material.h>

Inheritance diagram for ON_Material:
ON_ModelComponent ON_Object

Public Member Functions

 ON_Material () ON_NOEXCEPT
 
 ON_Material (const ON_Material &src)
 
 ~ON_Material ()=default
 
int AddTexture (const ON_Texture &tx)
 If there is already a texture with the same file name and type, then that texture is modified, otherwise a new texture is added. If tx has user data, the user data is copied to the m_textures[] element. More...
 
int AddTexture (const wchar_t *filename, ON_Texture::TYPE type)
 If there is a texture with a matching type, that texture's filename is modified, otherwise a new texture is added. More...
 
ON_Color Ambient () const
 Interface. More...
 
int DeleteTexture (const wchar_t *filename, ON_Texture::TYPE type)
 Deletes all texures with matching filenames and types. More...
 
ON_Color Diffuse () const
 
bool DisableLighting () const
 
void Dump (ON_TextLog &text_log) const override
 Creates a text dump of the object. More...
 
ON_Color Emission () const
 
int FindTexture (ON_UUID texture_id) const
 Searches for a texure with matching texture_id. If more than one texture matches, the first match is returned. More...
 
int FindTexture (const wchar_t *filename, ON_Texture::TYPE type, int i0=-1) const
 Searches for a texure with matching filename and type. If more than one texture matches, the first match is returned. More...
 
double FresnelReflectionCoefficient (ON_3dVector N, ON_3dVector R) const
 
bool FresnelReflections () const
 
bool IsValid (class ON_TextLog *text_log=nullptr) const override
 ON_Object overrides. More...
 
ON_UUID MaterialPlugInId () const
 ID of the last plug-in to modify this material. More...
 
ON::object_type ObjectType () const override
 Useful for switch statements that need to differentiate between basic object types like points, curves, surfaces, and so on. More...
 
ON_Materialoperator= (const ON_Material &src)=default
 
ON_UUID RdkMaterialInstanceId () const
 Get the RDK material id. More...
 
bool RdkMaterialInstanceIdIsNil () const
 
bool RdkMaterialInstanceIdIsNotNil () const
 
bool Read (ON_BinaryArchive &archive) override
 Low level archive writing tool used by ON_BinaryArchive::ReadObject(). More...
 
double Reflectivity () const
 Transparency values are in range 0.0 = opaque to 1.0 = transparent. More...
 
void SetAmbient (ON_Color)
 
void SetDiffuse (ON_Color)
 
void SetDisableLighting (bool bDisableLighting)
 
void SetEmission (ON_Color)
 
void SetFresnelReflections (bool bFresnelReflections)
 
void SetMaterialPlugInId (ON_UUID plugin_id)
 
void SetRdkMaterialInstanceId (ON_UUID rdk_material_instance_id)
 Set this material's RDK material id. More...
 
void SetReflectivity (double)
 
void SetShareable (bool bShareable)
 
void SetShine (double)
 
void SetSpecular (ON_Color)
 
void SetTransparency (double)
 
void SetUseDiffuseTextureAlphaForObjectTransparencyTexture (bool bUseDiffuseTextureAlphaForObjectTransparencyTexture)
 
bool Shareable () const
 
double Shine () const
 Shine values are in range 0.0 to ON_Material::MaxShine. More...
 
ON_Color Specular () const
 
double Transparency () const
 Transparency values are in range 0.0 = opaque to 1.0 = transparent. More...
 
bool UseDiffuseTextureAlphaForObjectTransparencyTexture () const
 
bool Write (ON_BinaryArchive &archive) const override
 Low level archive writing tool used by ON_BinaryArchive::WriteObject(). More...
 
- Public Member Functions inherited from ON_ModelComponent
 ON_ModelComponent () ON_NOEXCEPT
 
 ON_ModelComponent (const ON_ModelComponent &source)
 
 ON_ModelComponent (ON_ModelComponent::Type component_type) ON_NOEXCEPT
 Sets and locks the component type attribute. More...
 
 ON_ModelComponent (ON_ModelComponent::Type component_type, const ON_ModelComponent &source) ON_NOEXCEPT
 Locked status of source attributes is not copied to permit copy and modify operations. More...
 
 ~ON_ModelComponent ()=default
 
bool ChangeName (const wchar_t *new_name, class ON_ComponentManifest *manifest)
 Change the name of a component and optionally update a manifest. More...
 
bool ClearComponentType ()
 Set the model serial number value to the ON_ModelComponent::Unset.Type() and change the state so TypeIsSet() returns false. More...
 
bool ClearId ()
 Set the component id value to the ON_ModelComponent::Unset.ModelComponentId() and change the state so ModelComponentIdIsSet() returns false. More...
 
bool ClearIndex ()
 Set the component index value to the ON_ModelComponent::Unset.ModelComponentIndex() and change the state so ModelComponentIndexIsSet() returns false. More...
 
unsigned int ClearModelComponentAttributes (unsigned int attributes_filter)
 Writes the attributes identified by the component_filter parameter. More...
 
bool ClearModelComponentStatus ()
 
bool ClearModelSerialNumber ()
 Sets the model serial number, reference model serial number and instance definition model serial number values to 0 and flags these values as unset. More...
 
bool ClearName ()
 Set the component name value to the ON_ModelComponent::Unset.Name() and change the state so NameIsSet() and DeletedNameIsSet() both return false. More...
 
bool ClearParentId ()
 
int CompareName (const ON_UUID &other_parent_id, const wchar_t *other_name) const
 
int CompareName (const wchar_t *other_name) const
 
int CompareNameExact (const ON_UUID &other_parent_id, const wchar_t *other_name) const
 
int CompareNameExact (const wchar_t *other_name) const
 
ON_ModelComponent::Type ComponentType () const
 
bool ComponentTypeIsLocked () const
 
bool ComponentTypeIsSet () const
 
ON__UINT64 ContentVersionNumber () const
 Whenever an attribute is changed, the content version number is incremented. The ContentVersionNumber() is commonly used by consumers of the model component attributes to trigger updates when needed. More...
 
unsigned int CopyFrom (const ON_ModelComponent &src, unsigned int attributes_filter)
 
ON__UINT32 DataCRC (ON__UINT32 current_remainder) const override
 Returns a CRC calculated from the information that defines the object. This CRC can be used as a quick way to see if two objects are not identical. More...
 
const ON_wString DeletedName () const
 
const ON_NameHashDeletedNameHash () const
 
bool DeletedNameIsSet () const
 
bool DeleteName ()
 If NameIsSet() is true, then the name is deleted in a waty that can be undone by calling UndeleteName() and the DeletedNameIsSet() property is changed to true. More...
 
void Dump (ON_TextLog &) const override
 Creates a text dump of the object. More...
 
bool EraseIdentification (bool bIgnoreLocks)
 
const wchar_tGetName (ON_wString &component_name) const
 
const ON_UUIDId () const
 
bool IdIsLocked () const
 
bool IdIsNil () const
 
bool IdIsNotNil () const
 
bool IdIsSet () const
 
const ON_UUIDIfIdIsNilSetId ()
 If the it is nil, call SetId(). More...
 
int Index () const
 
int Index (int unset_index_value) const
 
bool IndexIsLocked () const
 
bool IndexIsSet () const
 
unsigned int InstanceDefinitionModelSerialNumber () const
 
bool IsDeleted () const
 
bool IsHidden () const
 
bool IsLocked () const
 
bool IsReferenceComponent () const
 
bool IsSystemComponent () const
 
bool IsValid (class ON_TextLog *text_log=nullptr) const override
 Tests an object to see if its data members are correctly initialized. More...
 
void LockAllSettingsExceptName ()
 
void LockComponentType ()
 Calling LockType() will prhibit future changes to the Type attribute. More...
 
void LockId ()
 Calling LockModelComponentId() will prhibit future changes to the ModelComponentId attribute. More...
 
void LockIndex ()
 Calling LockModelComponentIndex() will prhibit future changes to the ModelComponentIndex attribute. More...
 
void LockModelComponentStatus ()
 
void LockModelSerialNumber ()
 Calling LockModelSerialNumber() will prohibit future changes to the ModelSerialNumber(), ReferenceModelSerialNumber(), and InstanceDefinitionModelSerialNumber() attributes. More...
 
void LockName ()
 Calling LockName() will prohibit future changes to the Name attribute. More...
 
void LockParentId ()
 
ON_ComponentStatus ModelComponentStatus () const
 
bool ModelComponentStatusIsLocked () const
 
bool ModelComponentStatusIsSet () const
 
ON_UUID ModelObjectId () const override
 All objects in an opennurbs model have an id ( ON_Layer.m_layer_id, ON_Font.m_font_id, ON_Material.m_material_id, ON_3dmObjectAttributes.m_uuid ). More...
 
unsigned int ModelSerialNumber () const
 
bool ModelSerialNumberIsLocked () const
 
bool ModelSerialNumberIsSet () const
 
const ON_wString Name () const
 
const wchar_tNameAsPointer () const
 Expert user function that gets a pointer to the name. More...
 
const ON_NameHashNameHash () const
 Get a platform independent hash of the name suitable for equality testing and binary searching. When testing for equality or doing binary searches, using ON_NameHash values is faster than using the CompareName or ON_wString::CompareAttributeName. More...
 
bool NameIsEmpty () const
 
bool NameIsLocked () const
 
bool NameIsNotEmpty () const
 
bool NameIsSet () const
 
const ON_NameHash NewNameHash (const wchar_t *new_name) const
 
ON_ModelComponentoperator= (const ON_ModelComponent &source)
 
const ON_UUIDParentId () const
 
bool ParentIdIsLocked () const
 
bool ParentIdIsNil () const
 
bool ParentIdIsNotNil () const
 
bool ParentIdIsSet () const
 
bool ReadModelComponentAttributes (class ON_BinaryArchive &archive)
 
unsigned int ReferenceModelSerialNumber () const
 
ON__UINT64 RuntimeSerialNumber () const
 
const ON_UUIDSetAndLockId ()
 Sets the id to a new value created by ON_CreateUuid() and locks the id attribute so it cannot be changed. More...
 
bool SetAsSystemComponent ()
 
bool SetAsUnsetSystemComponent ()
 
bool SetComponentType (ON_ModelComponent::Type component_component_type)
 
bool SetDeletedModelComponentState (bool bDeleted, class ON_ComponentManifest *manifest)
 
void SetHiddenModelComponentState (bool bHidden)
 
bool SetId (const ON_UUID &component_id)
 
const ON_UUIDSetId ()
 Sets the id to a new value created by ON_CreateUuid(). More...
 
bool SetIdentification (const class ON_ComponentManifestItem &manifest_item, const wchar_t *manifest_name, bool bSetId, bool bParentId, bool bSetName, bool bSetIndex)
 Set a component's id, name and index to the manifest_item values. More...
 
bool SetIndex (int component_index)
 
bool SetLocalizedSystemComponentName (const wchar_t *system_component_localized_name)
 
void SetLockedModelComponentState (bool bLocked)
 
bool SetModelComponentStatus (ON_ComponentStatus component_status)
 
bool SetModelSerialNumber (unsigned int model_serial_number)
 Specify the model that is managing this component. More...
 
bool SetModelSerialNumber (unsigned int model_serial_number, unsigned int reference_model_serial_number, unsigned int instance_definition_model_serial_number)
 Specify the model that is managing this component. More...
 
bool SetName (const wchar_t *component_name)
 
bool SetParentId (const ON_UUID &parent_id)
 
unsigned int SizeOf () const override
 
bool UndeleteName ()
 
bool WriteModelComponentAttributes (class ON_BinaryArchive &archive, unsigned int attributes_filter) const
 
- Public Member Functions inherited from ON_Object
 ON_Object () ON_NOEXCEPT
 
 ON_Object (const ON_Object &)
 
virtual ~ON_Object ()
 
virtual ON_AggregateComponentStatus AggregateComponentStatus () const
 Call whenever a component status setting is modifed by directly changing it on a component in a way that will result in any saved information about the parent object's aggretate component status becoming invalid. More...
 
bool AttachUserData (class ON_UserData *pUserData)
 Attach user data to an object. More...
 
unsigned int ClearAllComponentStates () const
 Set all active level component states to ON_ComponentStatus::NoneSet. More...
 
virtual unsigned int ClearComponentStates (ON_ComponentStatus states_to_clear) const
 Clear the specified states on every component. More...
 
virtual unsigned int ClearComponentStates (ON_COMPONENT_INDEX component_index, ON_ComponentStatus states_to_clear) const
 Clear states on an individual component. More...
 
unsigned int CopyUserData (const ON_Object &source_object, ON_UUID source_userdata_item_id, ON_Object::UserDataConflictResolution userdata_conflict_resolution)
 Expert user tool that copies user data items with positive values of ON_UserData.m_userdata_copycount from source_object to "this. More...
 
void CopyUserData (const ON_Object &source_object)
 Calls CopyUserData(source_object,ON_Object::UserDataConflictResolution::source_object). More...
 
virtual bool DeleteComponents (const ON_COMPONENT_INDEX *ci_list, size_t ci_count)
 Delete the portions of the object identified in ci_list[]. More...
 
virtual void DestroyRuntimeCache (bool bDelete=true)
 Expert user function. If you are using openNURBS in its default configuration to read and write 3dm archives, you never need to call this function. Many objects employ lazy creation of (runtime) caches that save information to help speed geometric calculations. This function will destroy all runtime information. More...
 
bool DetachUserData (class ON_UserData *pUserData)
 Remove user data from an object. More...
 
void EmergencyDestroy ()
 Sets m_user_data_list = 0. More...
 
class ON_UserDataFirstUserData () const
 User data is stored as a linked list of ON_UserData classes. FirstUserData gets the first item in the linked list. This is the most recent item attached using AttachUserData(). Remark: To iterate through all the user data on an object, call FirstUserData() and then use ON_UserData::Next() to traverse the list. More...
 
virtual unsigned int GetComponentsWithSetStates (ON_ComponentStatus states_filter, bool bAllEqualStates, ON_SimpleArray< ON_COMPONENT_INDEX > &components) const
 
class ON_UserDataGetUserData (const ON_UUID &userdata_uuid) const
 Get a pointer to user data. More...
 
bool GetUserString (const wchar_t *key, ON_wString &string_value) const
 Get user string from the object. More...
 
int GetUserStringKeys (ON_ClassArray< ON_wString > &user_string_keys) const
 Get a list of all user string keys on the object. More...
 
int GetUserStrings (ON_ClassArray< ON_UserString > &user_strings) const
 Get a list of all user strings on the object. More...
 
bool IsKindOf (const ON_ClassId *pClassId) const
 Low level tool to test if an object is derived from a specified class. More...
 
virtual void MarkAggregateComponentStatusAsNotCurrent () const
 Call whenever a component status setting is modifed by directly changing it on a component in a way that will result in any saved information about the parent object's aggretate component status becoming invalid. More...
 
virtual void MemoryRelocate ()
 The MemoryRelocate() function is called when an object's location in memory is changed. For example, if an object resides in a chunk of memory that is grown by calling a realloc that has to allocate a new chunk and copy the contents of the old chunk to the new chunk, then the location of the object's memory changes. In practice this happens when classes derived from ON_Object are stored in dynamic arrays, like the default implementation of ON_ObjectArray<>'s that use realloc to grow the dynamic array. More...
 
unsigned int MoveUserData (ON_Object &source_object, ON_UUID source_userdata_item_id, ON_Object::UserDataConflictResolution userdata_conflict_resolution, bool bDeleteAllSourceItems)
 Expert user tool that moves user data items from source_object to "this. More...
 
void MoveUserData (ON_Object &source_object)
 Calls MoveUserData(source_object,ON_Object::UserDataConflictResolution::source_object,true). More...
 
ON_Objectoperator= (const ON_Object &)
 
void PurgeUserData ()
 PurgeUserData() removes all user data from object. More...
 
virtual unsigned int SetComponentStates (ON_COMPONENT_INDEX component_index, ON_ComponentStatus states_to_set) const
 Set states on an individual component. More...
 
virtual unsigned int SetComponentStatus (ON_COMPONENT_INDEX component_index, ON_ComponentStatus status_to_copy) const
 Copy status settings to an individual component. More...
 
bool SetUserString (const wchar_t *key, const wchar_t *string_value)
 Attach a user string to the object. This information will perisist through copy construction, operator=, and file IO. More...
 
int SetUserStrings (int count, const ON_UserString *user_strings, bool bReplace)
 Append entries to the user string list More...
 
void TransformUserData (const class ON_Xform &xform)
 Objects derived from ON_Geometry must call TransformUserData() in their Transform() member function. More...
 
virtual bool UpdateReferencedComponents (const class ON_ComponentManifest &source_manifest, const class ON_ComponentManifest &destination_manifest, const class ON_ManifestMap &manifest_map)
 Uses the destination_manifest to update references to other components. This is typically done when a component's references came from a "source" context and are being updated to the "destination" context. For example, inserting one model into another when index, id, and name conflicts need to be resolved at the time of insertion. More...
 
int UserStringCount () const
 

Static Public Member Functions

static int Compare (const ON_Material &a, const ON_Material &b)
 compare everything except Index() value. More...
 
static int CompareAppearance (const ON_Material &a, const ON_Material &b)
 
static int CompareColorAttributes (const ON_Material &a, const ON_Material &b)
 
static int CompareNameAndIds (const ON_Material &a, const ON_Material &b)
 compare Id(), Name(), m_rdk_material_instance_id More...
 
static int CompareReflectionAttributes (const ON_Material &a, const ON_Material &b)
 
static int CompareTextureAttributes (const ON_Material &a, const ON_Material &b)
 
static double FresnelReflectionCoefficient (double fresnel_index_of_refraction, const double N[3], const double R[3])
 
static const ON_MaterialFromModelComponentRef (const class ON_ModelComponentReference &model_component_reference, const ON_Material *none_return_value)
 
- Static Public Member Functions inherited from ON_ModelComponent
static int CompareId (const ON_ModelComponent &a, const ON_ModelComponent &b)
 
static int CompareIdAndName (const ON_ModelComponent &a, const ON_ModelComponent &b)
 
static int CompareName (const ON_ModelComponent &a, const ON_ModelComponent &b)
 
static int CompareNameAndId (const ON_ModelComponent &a, const ON_ModelComponent &b)
 
static int CompareNameExact (const ON_ModelComponent &a, const ON_ModelComponent &b)
 
static ON_ModelComponent::Type ComponentTypeFromUnsigned (unsigned int component_type_as_unsigned)
 
static bool ComponentTypeIsValid (ON_ModelComponent::Type component_type)
 
static bool ComponentTypeIsValidAndNotMixed (ON_ModelComponent::Type component_type)
 
static const ON_wString ComponentTypeToString (ON_ModelComponent::Type)
 
static bool IndexRequired (ON_ModelComponent::Type component_type)
 
static unsigned int Internal_SystemComponentHelper ()
 For internal use. Never call this function. More...
 
static const wchar_tIsNamePathSeparator (const wchar_t *s)
 Test a string to see if its beginning matches the string returned by ON_ModelComponent::NamePathSeparator. More...
 
*</code > *</example > *static const wchar_tIsReferencePrefixDelimiter (const wchar_t *s)
 Test a string to see if its beginning matches the string returned by ON_ModelComponent::NameReferenceDelimiter. More...
 
static const wchar_tIsReferencePrefixSeparator (const wchar_t *s)
 Test a string to see if its beginning matches the string returned by ON_ModelComponent::NameReferenceSeparator. More...
 
static bool IsValidComponentName (const wchar_t *candidate_component_name)
 
static bool IsValidComponentName (const ON_wString &candidate_component_name)
 
static bool IsValidComponentName (size_t length, const wchar_t *candidate_component_name)
 
static bool IsValidComponentName (const class ON_ComponentManifest &model_manfest, const ON_ModelComponent &model_component, bool bPermitReferencePrefix, ON_wString &valid_name)
 
static bool IsValidComponentNameFirstCodePoint (ON__UINT32 unicode_code_point)
 
static bool IsValidComponentNameFirstCodePoint (int length, const wchar_t *candidate_component_name)
 
static const ON_wString NameLeaf (const wchar_t *name)
 
static const ON_wString NameParent (const wchar_t *name, bool bIncludeReference)
 
static const ON_wString NameReferencePrefix (const wchar_t *name)
 
static const ON_wString RemoveAllReferencePrefixDelimiters (const wchar_t *name)
 Remove all occurances of ON::NameReferenceDelimiter() from name. More...
 
static const ON_wString RemoveReferencePrefix (const wchar_t *name)
 
static const ON_wString RemoveTrailingNamePathSeparator (const wchar_t *name)
 Remove any trailing occurance of ON_ModelComponent::NamePathSeparator from name. More...
 
static const ON_wString RemoveTrailingReferencePrefixDelimiter (const wchar_t *name)
 Remove any trailing occurance of ON_ModelComponent::NameReferenceDelimiter from name. More...
 
static const ON_wString RemoveTrailingReferencePrefixSeparator (const wchar_t *name)
 Remove any trailing occurance of ON_ModelComponent::NameReferenceSeparator from name. More...
 
static void SplitName (const wchar_t *name, ON_wString &reference_prefix, ON_wString &name_parent, ON_wString &name_leaf)
 
static bool UniqueNameIgnoresCase (ON_ModelComponent::Type component_type)
 
static bool UniqueNameIncludesParent (ON_ModelComponent::Type component_type)
 
static bool UniqueNameRequired (ON_ModelComponent::Type component_type)
 

Public Attributes

ON_Color m_ambient = ON_Color::Black
 
ON_Color m_diffuse = ON_Color::Gray126
 
ON_Color m_emission = ON_Color::Black
 
double m_fresnel_index_of_refraction = 1.56
 
double m_index_of_refraction = 1.0
 
ON_SimpleArray< ON_UuidIndex > m_material_channel
 Used to provide per face material support. The parent object reference a basic material. When a brep face or mesh facet wants to use a material besides the base material, it specifies a channelSupports material channel. The default material channel is 0 and that indicates the base material. A channel of n > 0 means that face used the material with id m_material_channel[n-1]. If (n-1) >= m_material_channel.Count(), then the base material is used. The value of m_material_channel[n].m_id is persistent. The value of m_material_channel[n].m_i is a runtime index in the CRhinoDoc::m_material_table[]. If CRhinoDoc::m_material_table[m_i].m_uuid != m_id, then m_id is assumed to be correct. More...
 
ON_Color m_reflection = ON_Color::White
 
double m_reflection_glossiness = 0.0
 
double m_reflectivity = 0.0
 
double m_refraction_glossiness = 0.0
 
double m_shine = 0.0
 
ON_Color m_specular = ON_Color::White
 
ON_ObjectArray< ON_Texturem_textures
 
double m_transparency = 0.0
 
ON_Color m_transparent = ON_Color::White
 

Static Public Attributes

static const ON_Material Default
 
static const double MaxShine
 
static const ON_Material Unset
 
- Static Public Attributes inherited from ON_ModelComponent
static const ON_wString NamePathSeparator
 Returns the string "::". This is the string Rhino uses in layer full path names to separate the names of individual layers. More...
 
static const ON_wString ReferencePrefixDelimiter
 Returns the string " : ". This is the string Rhino uses to separate the reference file names from and model component names read from those files. More...
 
static const ON_wString ReferencePrefixSeparator
 Returns the string ">". This is the string Rhino uses to separate the block definition name and linked file name in grandparent layers. More...
 
static const ON_ModelComponent Unset
 
*static const ON_wString WorksessionReferencePrefix *const wchar_t
 

Additional Inherited Members

- Public Types inherited from ON_ModelComponent
enum  Attributes : unsigned int {
  NoAttributes = 0U, ComponentSerialNumberAttribute = 0x0001U, TypeAttribute = 0x0002U, ModelSerialNumberAttribute = 0x0004U,
  IdAttribute = 0x0008U, IndexAttribute = 0x0010U, NameAttribute = 0x0020U, ParentIdAttribute = 0x0040U,
  DeletedNameAttribute = 0x0080U, ComponentStatusAttribute = 0x0100U, BinaryArchiveAttributes = 0x78U, AllAttributes = 0x1FFU,
  SystemComponentAttribute = 0x8000U
}
 
enum  Type : unsigned char {
  Type::Unset = 0, Type::Image = 1, Type::TextureMapping = 2, Type::RenderMaterial = 3,
  Type::LinePattern = 4, Type::Layer = 5, Type::Group = 6, Type::TextStyle = 7,
  Type::DimStyle = 8, Type::RenderLight = 9, Type::HatchPattern = 10, Type::InstanceDefinition = 11,
  Type::ModelGeometry = 12, Type::HistoryRecord = 13, Type::Mixed = 0xFE
}
 The ON_ModelComponent::Type enum has a value for each explicit component type and two special values, Unset and Mixed. Use an ON_ModelComponentTypeIterator instance to iterate over the ON_ModelComponent::Type values. More...
 
- Public Types inherited from ON_Object
enum  UserDataConflictResolution : unsigned char {
  UserDataConflictResolution::destination_object = 0, UserDataConflictResolution::source_object = 1, UserDataConflictResolution::source_copycount_gt = 2, UserDataConflictResolution::source_copycount_ge = 3,
  UserDataConflictResolution::destination_copycount_gt = 4, UserDataConflictResolution::destination_copycount_ge = 5, UserDataConflictResolution::delete_item = 6
}
 When a userdata item is copied or moved from a source object to a destination object, the ON_Object::UserDataConflictResolution enum values specify how conficts are resolved. Remark: A userdata item "conflict" occurs when both the destination and source object have a user data item with the same value of ON_UserData::m_userdata_uuid. More...
 
- Protected Member Functions inherited from ON_ModelComponent
void IncrementContentVersionNumber () const
 

Constructor & Destructor Documentation

◆ ON_Material() [1/2]

ON_Material::ON_Material ( )

◆ ON_Material() [2/2]

ON_Material::ON_Material ( const ON_Material src)

◆ ~ON_Material()

ON_Material::~ON_Material ( )
default

Member Function Documentation

◆ AddTexture() [1/2]

int ON_Material::AddTexture ( const ON_Texture tx)

If there is already a texture with the same file name and type, then that texture is modified, otherwise a new texture is added. If tx has user data, the user data is copied to the m_textures[] element.

Parameters
tx[in]
Returns
Index of the added texture in the m_textures[] array.

This is intended to be a quick and simple way to add textures to the material. If you need to do something different, then just work on the m_textures[] array.

◆ AddTexture() [2/2]

int ON_Material::AddTexture ( const wchar_t filename,
ON_Texture::TYPE  type 
)

If there is a texture with a matching type, that texture's filename is modified, otherwise a new texture is added.

Parameters
filename[in] new filename
type[in]
Returns
Index of the added texture in the m_textures[] array.

This is intended to be a quick and simple way to add textures to the material. If you need to do something different, then just work on the m_textures[] array.

◆ Ambient()

ON_Color ON_Material::Ambient ( ) const

Interface.

◆ Compare()

static int ON_Material::Compare ( const ON_Material a,
const ON_Material b 
)
static

compare everything except Index() value.

◆ CompareAppearance()

static int ON_Material::CompareAppearance ( const ON_Material a,
const ON_Material b 
)
static

◆ CompareColorAttributes()

static int ON_Material::CompareColorAttributes ( const ON_Material a,
const ON_Material b 
)
static

◆ CompareNameAndIds()

static int ON_Material::CompareNameAndIds ( const ON_Material a,
const ON_Material b 
)
static

compare Id(), Name(), m_rdk_material_instance_id

◆ CompareReflectionAttributes()

static int ON_Material::CompareReflectionAttributes ( const ON_Material a,
const ON_Material b 
)
static

◆ CompareTextureAttributes()

static int ON_Material::CompareTextureAttributes ( const ON_Material a,
const ON_Material b 
)
static

◆ DeleteTexture()

int ON_Material::DeleteTexture ( const wchar_t filename,
ON_Texture::TYPE  type 
)

Deletes all texures with matching filenames and types.

Parameters
filename[in] If nullptr, then any filename matches.
type[in] If ON_Texture::no_texture_type, then any texture type matches.
Returns
Number of textures deleted.

◆ Diffuse()

ON_Color ON_Material::Diffuse ( ) const

◆ DisableLighting()

bool ON_Material::DisableLighting ( ) const
Returns
True if lighting is disabled.

True means render this object without applying any modulation based on lights. Basically, the diffuse, ambient, specular and emissive channels get combined additively, clamped, and then get treated as an emissive channel. Another way to think about it is when m_bDisableLighting is true, render the same way OpenGL does when ::glDisable( GL_LIGHTING ) is called.

◆ Dump()

void ON_Material::Dump ( ON_TextLog ) const
overridevirtual

Creates a text dump of the object.

Dump() is intended for debugging and is not suitable for creating high quality text descriptions of an object.

The default implementations of this virtual function prints the class's name.

Reimplemented from ON_Object.

◆ Emission()

ON_Color ON_Material::Emission ( ) const

◆ FindTexture() [1/2]

int ON_Material::FindTexture ( ON_UUID  texture_id) const

Searches for a texure with matching texture_id. If more than one texture matches, the first match is returned.

Parameters
texture_id[in]
Returns
>=0 m_textures[] index of matching texture -1 if no match is found.

◆ FindTexture() [2/2]

int ON_Material::FindTexture ( const wchar_t filename,
ON_Texture::TYPE  type,
int  i0 = -1 
) const

Searches for a texure with matching filename and type. If more than one texture matches, the first match is returned.

Parameters
filename[in] If nullptr, then any filename matches.
type[in] If ON_Texture::no_texture_type, then any texture type matches.
i0[in] If i0 is < 0, the search begins at m_textures[0], if i0 >= m_textures.Count(), -1 is returnd, otherwise, the search begins at m_textures[i0+1].
Returns
>=0 m_textures[] index of matching texture -1 if no match is found.
Iterate through all the the bitmap textures on
a material.
@verbatim
ON_Material& mat = ...;
int ti = -1;
int bitmap_texture_count = 0;
for(;;)
{
ti = mat.FindTexture(
nullptr,
ti );
if ( ti < 0 )
{
// no more bitmap textures
break;
}
// we have a bitmap texture
bitmap_texture_count++;
const ON_Texture& bitmap_texture = mat.m_textures[ti];
...
}
@endverbatim

◆ FresnelReflectionCoefficient() [1/2]

static double ON_Material::FresnelReflectionCoefficient ( double  fresnel_index_of_refraction,
const double  N[3],
const double  R[3] 
)
static
Parameters
fresnel_index_of_refraction[in] ON_Material::Material::Default.m_fresnel_index_of_refraction is a good default
N[in] 3d surface normal
R[in] 3d reflection direction
Returns
1.0: The input values were not valid or the calculation failed due to a divide by zero or some other numerical arithmetic failure. fresnel reflection coefficient 1/2 * ((g-c)/(g+c))^2 * (1 + ( (c*(g+c) -1)/(c*(g+c) + 1) )^2) where c = N o (N-R); // c = 3d vector dot product of N and (N-R) and g = sqrt(fresnel_index_of_refraction*fresnel_index_of_refraction + c*c - 1.0).

◆ FresnelReflectionCoefficient() [2/2]

double ON_Material::FresnelReflectionCoefficient ( ON_3dVector  N,
ON_3dVector  R 
) const
Parameters
N[in] 3d surface normal
R[in] 3d reflection direction
Returns
If m_bFresnelReflections is false, then 1.0 is returned. If m_bFresnelReflections is true, then the value of the fresnel reflection coefficient is returned. In typical rendering applications, the reflection term is multiplied by the fresnel reflection coefficient before it is added to the diffuse color. If any input is not valid or the calculation fails, then 1.0 is returned.

When m_bFresnelReflections is true, the calculation is performed by calling ON_FresnelReflectionCoefficient() with m_fresnel_index_of_refraction as the fresnel index of refraction.

◆ FresnelReflections()

bool ON_Material::FresnelReflections ( ) const

◆ FromModelComponentRef()

static const ON_Material* ON_Material::FromModelComponentRef ( const class ON_ModelComponentReference model_component_reference,
const ON_Material none_return_value 
)
static
Parameters
model_component_reference[in]
none_return_value[in] value to return if ON_Material::Cast(model_component_ref.ModelComponent()) is nullptr
Returns
If ON_Material::Cast(model_component_ref.ModelComponent()) is not nullptr, that pointer is returned. Otherwise, none_return_value is returned.

◆ IsValid()

bool ON_Material::IsValid ( class ON_TextLog text_log = nullptr) const
overridevirtual

ON_Object overrides.

Reimplemented from ON_Object.

◆ MaterialPlugInId()

ON_UUID ON_Material::MaterialPlugInId ( ) const

ID of the last plug-in to modify this material.

◆ ObjectType()

ON::object_type ON_Material::ObjectType ( ) const
overridevirtual

Useful for switch statements that need to differentiate between basic object types like points, curves, surfaces, and so on.

Returns

ON::object_type enum value.

The default implementation of this virtual function returns ON::unknown_object_type

Reimplemented from ON_Object.

◆ operator=()

ON_Material& ON_Material::operator= ( const ON_Material src)
default

◆ RdkMaterialInstanceId()

ON_UUID ON_Material::RdkMaterialInstanceId ( ) const

Get the RDK material id.

Returns
The RDK material id for this material.

The RDK material id identifies a material definition managed by the RDK (rendering development kit). Multiple materials in a Rhino or opennurbs model can reference the same RDK material.

◆ RdkMaterialInstanceIdIsNil()

bool ON_Material::RdkMaterialInstanceIdIsNil ( ) const

◆ RdkMaterialInstanceIdIsNotNil()

bool ON_Material::RdkMaterialInstanceIdIsNotNil ( ) const

◆ Read()

bool ON_Material::Read ( ON_BinaryArchive binary_archive)
overridevirtual

Low level archive writing tool used by ON_BinaryArchive::ReadObject().

Parameters
binary_archivearchive to read from
Returns
Returns true if the read is successful.

Use ON_BinaryArchive::ReadObject() to read objects. This Read() function should read the objects definition back into its data members.

The default implementation of this virtual function returns false and does nothing.

Reimplemented from ON_Object.

◆ Reflectivity()

double ON_Material::Reflectivity ( ) const

Transparency values are in range 0.0 = opaque to 1.0 = transparent.

◆ SetAmbient()

void ON_Material::SetAmbient ( ON_Color  )

◆ SetDiffuse()

void ON_Material::SetDiffuse ( ON_Color  )

◆ SetDisableLighting()

void ON_Material::SetDisableLighting ( bool  bDisableLighting)

◆ SetEmission()

void ON_Material::SetEmission ( ON_Color  )

◆ SetFresnelReflections()

void ON_Material::SetFresnelReflections ( bool  bFresnelReflections)

◆ SetMaterialPlugInId()

void ON_Material::SetMaterialPlugInId ( ON_UUID  plugin_id)

◆ SetRdkMaterialInstanceId()

void ON_Material::SetRdkMaterialInstanceId ( ON_UUID  rdk_material_instance_id)

Set this material's RDK material id.

Parameters
rdk_material_id[in] RDK material id value.

The RDK material id identifies a material definition managed by the RDK (rendering development kit). Multiple materials in a Rhino or opennurbs model can reference the same RDK material.

◆ SetReflectivity()

void ON_Material::SetReflectivity ( double  )

◆ SetShareable()

void ON_Material::SetShareable ( bool  bShareable)

◆ SetShine()

void ON_Material::SetShine ( double  )

◆ SetSpecular()

void ON_Material::SetSpecular ( ON_Color  )

◆ SetTransparency()

void ON_Material::SetTransparency ( double  )

◆ SetUseDiffuseTextureAlphaForObjectTransparencyTexture()

void ON_Material::SetUseDiffuseTextureAlphaForObjectTransparencyTexture ( bool  bUseDiffuseTextureAlphaForObjectTransparencyTexture)

◆ Shareable()

bool ON_Material::Shareable ( ) const
Returns
True if the material can be shared.

If true, when an object using this material is copied, the copy references the same material.

◆ Shine()

double ON_Material::Shine ( ) const

Shine values are in range 0.0 to ON_Material::MaxShine.

◆ Specular()

ON_Color ON_Material::Specular ( ) const

◆ Transparency()

double ON_Material::Transparency ( ) const

Transparency values are in range 0.0 = opaque to 1.0 = transparent.

◆ UseDiffuseTextureAlphaForObjectTransparencyTexture()

bool ON_Material::UseDiffuseTextureAlphaForObjectTransparencyTexture ( ) const

◆ Write()

bool ON_Material::Write ( ON_BinaryArchive binary_archive) const
overridevirtual

Low level archive writing tool used by ON_BinaryArchive::WriteObject().

Parameters
binary_archivearchive to write to
Returns
Returns true if the write is successful.

Use ON_BinaryArchive::WriteObject() to write objects. This Write() function should just write the specific definition of this object. It should not write and any chunk typecode or length information.

The default implementation of this virtual function returns false and does nothing.

Reimplemented from ON_Object.

Member Data Documentation

◆ Default

const ON_Material ON_Material::Default
static

◆ m_ambient

ON_Color ON_Material::m_ambient = ON_Color::Black

◆ m_diffuse

ON_Color ON_Material::m_diffuse = ON_Color::Gray126

◆ m_emission

ON_Color ON_Material::m_emission = ON_Color::Black

◆ m_fresnel_index_of_refraction

double ON_Material::m_fresnel_index_of_refraction = 1.56

◆ m_index_of_refraction

double ON_Material::m_index_of_refraction = 1.0

◆ m_material_channel

ON_SimpleArray<ON_UuidIndex> ON_Material::m_material_channel

Used to provide per face material support. The parent object reference a basic material. When a brep face or mesh facet wants to use a material besides the base material, it specifies a channelSupports material channel. The default material channel is 0 and that indicates the base material. A channel of n > 0 means that face used the material with id m_material_channel[n-1]. If (n-1) >= m_material_channel.Count(), then the base material is used. The value of m_material_channel[n].m_id is persistent. The value of m_material_channel[n].m_i is a runtime index in the CRhinoDoc::m_material_table[]. If CRhinoDoc::m_material_table[m_i].m_uuid != m_id, then m_id is assumed to be correct.

◆ m_reflection

ON_Color ON_Material::m_reflection = ON_Color::White

◆ m_reflection_glossiness

double ON_Material::m_reflection_glossiness = 0.0

◆ m_reflectivity

double ON_Material::m_reflectivity = 0.0

◆ m_refraction_glossiness

double ON_Material::m_refraction_glossiness = 0.0

◆ m_shine

double ON_Material::m_shine = 0.0

◆ m_specular

ON_Color ON_Material::m_specular = ON_Color::White

◆ m_textures

ON_ObjectArray<ON_Texture> ON_Material::m_textures

◆ m_transparency

double ON_Material::m_transparency = 0.0

◆ m_transparent

ON_Color ON_Material::m_transparent = ON_Color::White

◆ MaxShine

const double ON_Material::MaxShine
static

◆ Unset

const ON_Material ON_Material::Unset
static