From 51175c2ffb55ed157e1f609e02e533f319a3717d Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 6 Jul 2014 20:55:11 +0000 Subject: Added initial definitions for material layers. --- src/model/layer.cc | 42 ++++++++++++++++ src/model/layer.h | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 185 insertions(+) create mode 100644 src/model/layer.cc create mode 100644 src/model/layer.h (limited to 'src/model') diff --git a/src/model/layer.cc b/src/model/layer.cc new file mode 100644 index 0000000..81faa6c --- /dev/null +++ b/src/model/layer.cc @@ -0,0 +1,42 @@ +/* + model/layer.cc + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +#include "model/layer.h" + +namespace model +{ + +Layer::Layer() : + layer_rgbgen(RGBGenIdentity), + layer_color(), + layer_texmap(TexMapNone), + layer_texture_name(), + layer_texture_id(0), + layer_tcgen(TCGenNone) +{ +} + +Layer::~Layer() +{ +} + +void Layer::set_rgbgen(const RGBGen rgbgen) +{ + layer_rgbgen = rgbgen; +} + +void Layer::set_color(const math::Color & color) +{ + layer_color.assign(color); +} + +void Layer::set_tcgen(const TCGen tcgen) +{ + layer_tcgen = tcgen; +} + +} + diff --git a/src/model/layer.h b/src/model/layer.h new file mode 100644 index 0000000..52ab9d8 --- /dev/null +++ b/src/model/layer.h @@ -0,0 +1,143 @@ +/* + model/material.h + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +#ifndef __INCLUDED_MODEL_LAYER_H__ +#define __INCLUDED_MODEL_LAYER_H__ + +#include "math/color.h" + +namespace model +{ + +/** + * @brief a single layer within a material + * */ +class Layer { +public: + /** + * @brief color generation type definition + * */ + enum RGBGen { + RGBGenIdentity = 1, // unmodified + RGBGenColor = 2, // modified by layer color + RGBGenEngine = 3, // modified by engine color + RGBGenPrimary = 4, // modified by primary entity color + RGBGenSecondary = 5, // modified by secondary entity color + RGBGenTertiary = 6 // modified by tertiary entity color + }; + + /** + * @brief texture coordinate generation type definition + * */ + enum TCGen { + TCGenNone = 0, // no texture coordinate generation + TCGenTexCoords = 1, // use texture coordinates from vertex array + TCGenEnvironment = 2 // texture coordinates generated by GL_SPHERE_MAP/GL_REFLECTION_MAP + }; + + /** + * @brief texture map type definition + * */ + enum TexMap { + TexMapNone = 0, // no texture map + TexMapImage = 1, // texture map from image + TexMapEnvironment = 2, // texture map with skybox + TexMapLogo = 3 // use current logo texture + }; + + /** + * @brief default constructor + * */ + Layer(); + + /** + * @brief default destructor + * */ + ~Layer(); + + /* ---- inspectors ----------------------------------------- */ + + /** + * @brief rgb color generation source for this material layer + * */ + inline const RGBGen rgbgen() const + { + return layer_rgbgen; + } + + /** + * @brief layer color + * The layer color is used if color source if rgbgen() is set to RGBGenColor + * */ + inline const math::Color & color() const + { + return layer_color; + } + + /** + * @brief layer texture map + */ + const TexMap texmap() const + { + return layer_texmap; + } + + /** + * @brief layer texture map name + * The layer texture mapa name is used if texmap() is set to TexMapTexture + * */ + inline const std::string &texture_name() const + { + return layer_texture_name; + } + + /** + * @brief layer texture map renderer id + * */ + inline const size_t texture_id() const + { + return layer_texture_id; + } + + /** + * @brief texture coordinates generation source for this material layer + * */ + inline const TCGen tcgen() const + { + return layer_tcgen; + } + + /* ---- mutators ------------------------------------------- */ + + /** + * @brief set rgb color generation source + * */ + void set_rgbgen(const RGBGen rgbgen); + + /** + * @brief set layer color + * */ + void set_color(const math::Color & color); + + /** + * @brief set texture coordinates generation source + * */ + void set_tcgen(const TCGen tcgen); + +private: + RGBGen layer_rgbgen; + math::Color layer_color; + + TexMap layer_texmap; + std::string layer_texture_name; + size_t layer_texture_id; + + TCGen layer_tcgen; +}; + +} // namespace model + +#endif // __INCLUDED_MODEL_LAYER_H__ -- cgit v1.2.3