34#include <NDEVR/DesignObject.h>
35#include <NDEVR/Table.h>
36#include <NDEVR/Pointer.h>
37#include <NDEVR/BaseValues.h>
38#include <NDEVR/VectorFunctions.h>
131 return object->m_base->material_properties[eint01(property)];
140 return object->m_design_index;
381 template<
class t_type>
393 template<
class t_type>
406 template<
class t_type>
421 template<
class t_type>
426 WLock lock(lock_ptr);
437 template<
class t_type>
448 template<
class t_type>
595 static const bool Enum =
false;
606 template class NDEVR_DESIGN_API StringStream<Material::GridLineMode>;
607 template class NDEVR_DESIGN_API StringStream<Material::TextureCoordMode>;
608 template class NDEVR_DESIGN_API StringStream<Material::TileTextureMode>;
609 template class NDEVR_DESIGN_API StringStream<Material::UVMode>;
610 template class NDEVR_DESIGN_API StringStream<Material::ShadingModel>;
611 template class NDEVR_DESIGN_API StringStream<NDPM>;
622 struct hash<Material>
629 std::size_t operator()(
const Material& d)
const noexcept
632 std::size_t value = 0;
633 for (
uint01 i = 0; i < 8; i++)
634 value = value * 256 + (s[i + 0U] ^ s[i + 8U]);
The equivelent of std::vector but with a bit more control.
Base information class for all design objects in the NDEVR property database.
uint04 m_design_index
Index of the parent design that owns this object.
DesignObjectBase * m_base
Pointer to the owning DesignObjectBase property database.
Provides the underlying data storage for the NDEVR Scene Model hierarchy.
DesignObject()=default
Creates an "invalid" design object.
uint04 index() const
Returns the primary row index of this object within the DesignObjectBase property table.
Searches a model hierarchy and pulls all parameter data based on the AccumationMode settings.
The core class for reading/writing and storing images in an optimized way.
Container responsible for storing and setting the appearance of a Model or Geometry within the NDEVR ...
void setUVLayer(UVType uv_index, const t_type &type)
Sets the layer index for the specified UV channel.
bool hasPerVertexColoring(UVType type=UVType::e_KD) const
Checks whether per-vertex coloring is active for the specified UV type.
void setTileTextureMode(const Vector< 3, TileTextureMode > &modes)
Sets the texture tiling mode for each of the three axes.
bool hasUVLayer(UVType index) const
Checks whether the specified UV channel has a layer index assigned.
void colorBy(const DesignParameterAccumulator &accumulator)
Applies color-by-property rendering using the given parameter accumulator.
bool hasModelDependentColor(UVType type) const
Checks whether the color for the specified UV type depends on the owning model.
RGBColor convertValueToColor(fltp08 value) const
Converts a scalar value to an RGBColor using this material's color palette and range.
uint04 getUVLayer(UVType uv_index) const
Retrieves the layer index for the specified UV channel.
TranslatedString displayName() const
Returns a user-facing display name for this material.
bool hasModelDependentColor() const
Checks whether any UV type has model-dependent coloring.
fltp04 getUVIntensity(UVType uv_index) const
Retrieves the intensity value for the specified UV channel.
void ensureImageDataLoaded(ImageFactory &factory)
Ensures that any referenced image data is loaded into memory using the provided factory.
PrimitiveProperty defaultRenderProperty() const
Returns the default primitive render property for this material.
Buffer< RGBColor > palette() const
Retrieves the color palette used for value-based coloring.
void setUVColor(const t_type &type)
Sets the color for all UV channels to the same value.
ShadingModel
Enumerates the available shading models for material rendering.
@ e_number_of_shading_models
Sentinel value indicating the total number of shading models.
@ e_cook_torrance
Cook-Torrance shading model. Special shader for metallic surfaces.
@ e_flat
Flat shading. Shading is done on per-face base, diffuse only. Also known as 'faceted shading'.
@ e_background_gradiant
Background gradient shading.
@ e_skybox
Skybox cubemap shading.
@ e_ibl
Image-based lighting model.
@ e_no_shading
No shading applied. Constant light influence of 1.0.
@ e_phong
Phong shading with per-pixel lighting.
@ e_fresnel
Fresnel-based shading model.
@ e_gouraud
Simple Gouraud shading with per-vertex color interpolation.
@ e_pbr
Physically-based rendering model.
@ e_minnaert
Minnaert shading per pixel. Extension to Lambertian shading accounting for material "darkness".
@ e_water
Specialized water surface shading.
@ e_oren_nayar
Oren-Nayar shading per pixel. Extension to Lambertian shading accounting for surface roughness.
@ e_phong_blinn
Phong-Blinn shading model.
@ e_toon
Toon shading per pixel. Also known as 'comic' shader.
RGBColor constantColor(Model model, RGBColor background_color=RGBColor(255, 255, 255), UVType type=UVType::e_KD) const
Computes a constant representative color for this material given a model and background.
bool hasUVColor(UVType index) const
Checks whether the specified UV channel has a color assigned.
StringView getUVImage(UVType uv_index) const
Retrieves the image file path or identifier for the specified UV channel.
TextureCoordMode getTextureCoordinateMode() const
Retrieves the current texture coordinate generation mode.
void cleanupMaterial()
Cleans up and resets material properties to a minimal valid state.
TranslatedString appearanceName() const
Returns the appearance-specific name for this material.
Vector< 3, TileTextureMode > getTileTextureMode() const
Retrieves the texture tiling mode for each of the three axes.
void updateModifiedTime(const Time &time=Time::SystemTime())
Updates the material's modification timestamp.
bool hasActiveImage() const
Checks whether this material has an active (non-empty, in-use) image texture.
bool validate() const
Validates that this material's properties are in a consistent and usable state.
void combineFrom(const Material &mesh)
Combines material properties from another Material into this one.
void copyFrom(const Material &mesh)
Copies all material properties from another Material, replacing current values.
UVMode getUVMode(UVType uv_index) const
Retrieves the UV mapping mode for the specified UV channel.
void setPalette(const Buffer< RGBColor > &palette)
Sets the color palette used for value-based coloring.
GridLineMode
Defines modes for gridline rendering on material surfaces.
@ e_global_linework
Gridlines rendered in global/world coordinate space.
@ e_invalid
Invalid/unset gridline mode.
@ e_modelspace_linework
Gridlines rendered in model-local coordinate space.
@ e_no_linework
No gridlines rendered.
void setupAsDefault()
Initializes this material with default property values.
void setUVImage(UVType uv_index, const StringView &type)
Sets the image file path or identifier for the specified UV channel.
bool hasOpacity() const
Checks whether this material has a non-default opacity value set.
UVMode
Defines UV mapping modes that control how texture colors are determined for surfaces.
@ e_scaled_channel
Color channel values are scaled by a property range.
@ e_color_channel
Color is taken from the per-vertex color channel.
@ e_none
No UV mapping applied.
@ e_background_contrast_plus_solid
Combines background contrast with a solid color.
@ e_solid_color
A single solid color is used.
@ e_background_contrast
Uses a color that contrasts with the background.
@ e_highlight
Uses the highlight/selection color.
@ e_color_by_layer
Color is determined by the layer assignment.
@ e_background
Uses the background color.
@ e_color_by_model
Color is determined by the owning model.
@ e_image
Color is sampled from a texture image.
void updateUVColor(const t_type &type, const void *lock_ptr=nullptr)
Updates the color for all UV channels, only writing if the value has changed.
bool hasImageData() const
Checks whether this material has any image data loaded or referenced.
TextureCoordMode
Defines how texture coordinates are generated or interpreted for a material.
@ e_project_box
Generate texture coordinates via box/cube projection.
@ e_project_sphere
Generate texture coordinates via spherical projection.
@ e_use_mat_coordinates
Use the material's own texture coordinate definitions.
@ e_project_plane
Generate texture coordinates via planar projection.
@ e_tex_coord_undefined
Texture coordinate mode is undefined/unset.
@ e_project_cylinder
Generate texture coordinates via cylindrical projection.
bool hasUVIntensity(UVType index) const
Checks whether the specified UV channel has a non-default intensity value.
void setUVMode(UVType uv_index, const UVMode &type)
Sets the UV mapping mode for the specified UV channel.
Material(DesignObjectBase *property_table)
Constructs a new Material and allocates a row in the given property table.
bool hasActiveUVImage(UVType index) const
Checks whether the specified UV channel has an active image texture assigned.
Material(uint04 index, DesignObjectBase *property_table)
Constructs a Material referencing a specific row in the given property table.
void updateUVColor(UVType uv_index, const t_type &value, const void *lock_ptr=nullptr)
Updates the color for a specific UV channel, only writing if the value has changed.
void setUVColor(UVType uv_index, const t_type &type)
Sets the color for a specific UV channel.
RGBColor getUVColor(UVType uv_index) const
Retrieves the color assigned to the specified UV channel.
void setUVIntensity(UVType uv_index, const t_type &type)
Sets the intensity value for the specified UV channel.
Material(const DesignObject &obj)
Constructs a Material from a generic DesignObject reference.
ShadingModel getShadingModel() const
Retrieves the current shading model for this material.
bool isSupportedByShadingModel(UVType type) const
Checks whether the given UV type is supported by the current shading model.
TileTextureMode
Defines how texture coordinates outside the [0,1] range are handled per axis.
@ e_tile_texture_wrap
Texture coordinate wraps: u|v is translated to u%1|v%1.
@ e_tile_tex_undefined
Tiling mode is undefined/unset.
@ e_tile_texture_mirror
Texture coordinate mirrors: u%1|v%1 if (u-(u%1))%2 is zero, otherwise 1-(u%1)|1-(v%1).
@ e_tile_texture_decal
Texture is not applied to pixels with coordinates outside [0,1].
@ e_tile_texture_clamp
Texture coordinates outside [0,1] are clamped to the nearest valid value.
A core class that represents a node on model hierarchy.
static constexpr TableColumn * column(const DesignInfo *object, NDPM property)
Retrieves the TableColumn pointer for the given material property.
static constexpr uint04 index(const DesignInfo *object, NDPM)
Retrieves the row index for a material property lookup.
Provides access to the TableColumn and row index for a given property enum value.
Represents a color in the RGB space with optional alpha transparency.
The core String View class for the NDEVR API.
A virtual storage type that is used with Table class to store data where the actual mechanism for sto...
Represents a timestamp with utilities for manipulation and conversion.
static Time SystemTime()
Retrieves the current system time which is a combination of std::chrono::steady_clock to ensure smoot...
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Used to lock a particular variable for writing.
The primary namespace for the NDEVR SDK.
NDPM
NDPM - NDEVR Design Property Material: Values stored in the material database.
@ color_value_palette
Color palette used for value-based coloring.
@ smooth_normals
Whether vertex normals are smoothed across faces.
@ pixel_thickness
Thickness in pixels for line and point rendering.
@ extra_property_value_max
Maximum value for the extra property color mapping range.
@ wireframe
Whether the material is rendered in wireframe mode.
@ ignore_color_channel_lighting
Whether lighting is ignored for the color channel.
@ reflectivity
Reflectivity coefficient of the material surface.
@ override_camera_material
Whether this material overrides the camera's material settings.
@ shading_model
The shading model index used for rendering (see Material::ShadingModel).
@ write_to_depth
Whether rendering writes to the depth buffer.
@ override_parent_material
Whether this material overrides the parent model's material.
@ shininess
Specular shininess exponent for the material surface.
@ fade_render_distance
Distance at which the material begins to fade out.
@ gridline_spacing_mode
Mode controlling how gridline spacing is interpreted.
@ extra_property_value_mid
Midpoint value for the extra property color mapping range.
@ draw_by_property_channel
Name of the property channel used for color-by-property rendering.
@ max_render_distance
Maximum distance beyond which the material is not rendered.
@ bump_scale
Scale factor applied to bump/normal mapping.
@ grid_line_spacing
Spacing values for gridline rendering (4-component vector).
@ opacity
The overall opacity of the material (0.0 = fully transparent, 1.0 = fully opaque).
@ use_normal_for_tex_coord
Whether surface normals are used to generate texture coordinates.
@ material_property_size
Sentinel value representing the total number of material properties.
@ extra_property_value_min
Minimum value for the extra property color mapping range.
@ tile_texture_mode
Texture tiling mode per axis (wrap, clamp, decal, mirror).
@ model_space_material
Whether the material is defined in model space rather than screen space.
@ depth_bias
Bias applied to depth values to prevent z-fighting.
@ two_sided
Whether the material is rendered on both sides of a face.
@ ignore_depth
Whether to skip depth testing when rendering this material.
@ texture_coord_mode
Mode for generating or interpreting texture coordinates.
@ type
The type identifier string for this model node.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
@ guid
A 128-bit globally unique identifier for the object.
PrimitiveProperty
Describes which rendering property a primitive index buffer corresponds to.
UVType
Channels that describe how an object should interact with light.
@ e_KD
Diffuse texture/color channel.
@ e_uv_size
The number of UV types. Used for sizing arrays.
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.
static const bool Float
Whether this is a floating-point type.
static const bool Color
Whether this is a color type.
static const bool Number
Whether this is a numeric type.
static const bool Enum
Whether this is an enum type.
static constexpr ObjectInfo< Material, false, false > VectorSub()
Returns the ObjectInfo for the vector sub-element type (identity for scalar types).
static const uint01 Dimensions
Number of dimensions (0 for scalar types).
static const bool String
Whether this is a string type.
static const bool Boolean
Whether this is a boolean type.
static const bool Integer
Whether this is an integer type.
static const bool Primitive
Whether this is a primitive type.
static const bool Pointer
Whether this is a pointer type.
static const bool Vector
Whether this is a vector type.
static const bool Unsigned
Whether this is an unsigned numeric type.
static const bool Buffer
Whether this is a buffer type.
Information about the object.
Maps a compile-time property enum value to its corresponding C++ storage type.