Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
|
A collection of key value pairs used to control the behaviour of the rendering system when rendering a single "object.". More...
#include <material.hpp>
Public Member Functions | |
virtual | ~Material () |
Destroys the material object. | |
Material () | |
Constructs a new Material object. | |
Material (const Material &other) | |
Material copy constructor. | |
Material (Material &&other) | |
Material move constructor. | |
Material & | operator= (const Material &other) |
Material copy constructor. | |
Material & | operator= (Material &&other) |
Material move constructor. | |
void | updateFloatProperty (const std::string &name, float value) |
Updates a float property. | |
float | getFloatProperty (const std::string &name) |
Gets a float property. | |
void | updateIntProperty (const std::string &name, int value) |
Updates an int property. | |
int | getIntProperty (const std::string &name) |
Gets an int property. | |
void | updateVec2Property (const std::string &name, const glm::vec2 &value) |
Updates a glm::vec2 property. | |
glm::vec2 | getVec2Property (const std::string &name) |
Gets a glm::vec2 property. | |
void | updateVec4Property (const std::string &name, const glm::vec4 &value) |
Updates a glm::vec4 property. | |
glm::vec4 | getVec4Property (const std::string &name) |
Gets a glm::vec4 property. | |
void | updateTextureProperty (const std::string &name, std::shared_ptr< Texture > value) |
Updates a texture property. | |
std::shared_ptr< Texture > | getTextureProperty (const std::string &name) |
Gets the texture property of an object. | |
![]() | |
std::string | getResourceTypeName_ () const override |
Get the resource type string for this resource. | |
![]() | |
virtual | ~IResource ()=default |
Destroy the IResource object. | |
Static Public Member Functions | |
static std::shared_ptr< Material > | ApplyOverrides (const nlohmann::json &materialOverrides, std::shared_ptr< Material > material=std::shared_ptr< Material >(new Material{})) |
Overrides various material related properties based on a JSON description of the overrides. | |
static void | RegisterFloatProperty (const std::string &name, float defaultValue) |
Registers a project-wide float property. | |
static void | RegisterIntProperty (const std::string &name, int defaultValue) |
Registers a project-wide int property. | |
static void | RegisterVec4Property (const std::string &name, const glm::vec4 &defaultValue) |
Registers a project-wide glm::vec4 property. | |
static void | RegisterVec2Property (const std::string &name, const glm::vec2 &defaultValue) |
Registers a project-wide glm::vec2 property. | |
static void | RegisterTextureHandleProperty (const std::string &name, std::shared_ptr< Texture > defaultValue) |
Registers a project-wide texture property. | |
static std::string | getResourceTypeName () |
Gets the resource type string for this object. | |
static void | Init () |
Initializes the material system, to be called at the start of the application before material properties are registered. | |
static void | Clear () |
Clears all of this project's material system properties, to be called prior to application shutdown. | |
Private Attributes | |
std::map< std::string, float > | mFloatProperties {} |
All float property overrides used in this Material instance. | |
std::map< std::string, int > | mIntProperties {} |
All int property overrides used in this Material instance. | |
std::map< std::string, glm::vec4 > | mVec4Properties {} |
All glm::vec4 property overrides used in this Material instance. | |
std::map< std::string, glm::vec2 > | mVec2Properties {} |
All glm::vec2 property overrides used in this Material instance. | |
std::map< std::string, std::shared_ptr< Texture > > | mTextureProperties {} |
Static Private Attributes | |
static Material * | defaultMaterial { nullptr } |
A material instantiated at the start of the application, intended to hold all of the material properties and their default values. | |
Additional Inherited Members | |
![]() | |
Resource (int explicitlyInitializeMe) | |
Construct a new resource object. | |
![]() | |
IResource ()=default | |
Construct a new IResource object. | |
![]() | |
template<typename TResource> | |
static void | RegisterResource () |
Registers this resource as a Resource type with the ResourceDatabase. | |
A collection of key value pairs used to control the behaviour of the rendering system when rendering a single "object.".
Each key-value pair is a string-type pair declared by the rendering system or its submodules at the start of the application.
While different engines implement materials differently, some common uses for them are:
Material::Material | ( | const Material & | other | ) |
Material::Material | ( | Material && | other | ) |
|
static |
Overrides various material related properties based on a JSON description of the overrides.
Here is an example of material overrides for a model resource defined in a scene file:
materialOverrides | The material property overrides for an object in JSON. |
material | A reference to the material on which the overrides are applied. |
float Material::getFloatProperty | ( | const std::string & | name | ) |
Gets a float property.
name | The name of the property. |
int Material::getIntProperty | ( | const std::string & | name | ) |
Gets an int property.
name | The name of the property. |
|
inlinestatic |
Gets the resource type string for this object.
std::shared_ptr< Texture > Material::getTextureProperty | ( | const std::string & | name | ) |
Gets the texture property of an object.
name | The name of the property. |
glm::vec2 Material::getVec2Property | ( | const std::string & | name | ) |
Gets a glm::vec2 property.
name | The name of the property. |
glm::vec4 Material::getVec4Property | ( | const std::string & | name | ) |
Gets a glm::vec4 property.
name | The name of the property. |
|
static |
Registers a project-wide float property.
name | The name of the property. |
defaultValue | Its initial value. |
|
static |
Registers a project-wide int property.
name | The name of the property. |
defaultValue | Its initial value. |
|
static |
Registers a project-wide texture property.
name | The name of the property. |
defaultValue | Its initial value. |
|
static |
Registers a project-wide glm::vec2 property.
name | The name of the property. |
defaultValue | Its initial value. |
|
static |
Registers a project-wide glm::vec4 property.
name | The name of the property. |
defaultValue | Its initial value. |
void Material::updateFloatProperty | ( | const std::string & | name, |
float | value ) |
Updates a float property.
name | The name of the property. |
value | The override value. |
void Material::updateIntProperty | ( | const std::string & | name, |
int | value ) |
Updates an int property.
name | The name of the property |
value | The override value. |
void Material::updateTextureProperty | ( | const std::string & | name, |
std::shared_ptr< Texture > | value ) |
Updates a texture property.
name | The name of the property. |
value | The override value. |
void Material::updateVec2Property | ( | const std::string & | name, |
const glm::vec2 & | value ) |
Updates a glm::vec2 property.
name | The name of the property. |
value | The override value. |
void Material::updateVec4Property | ( | const std::string & | name, |
const glm::vec4 & | value ) |
Updates a glm::vec4 property.
name | The name of the property. |
value | The override value. |
|
staticprivate |
A material instantiated at the start of the application, intended to hold all of the material properties and their default values.
This same material is used to determine whether, when updateXProperty or getXProperty are called, the call is legal.