1 2 // 3 // This source file is part of appleseed. 4 // Visit https://appleseedhq.net/ for additional information and resources. 5 // 6 // This software is released under the MIT license. 7 // 8 // Copyright (c) 2010-2013 Francois Beaune, Jupiter Jazz Limited 9 // Copyright (c) 2014-2018 Francois Beaune, The appleseedhq Organization 10 // 11 // Permission is hereby granted, free of charge, to any person obtaining a copy 12 // of this software and associated documentation files (the "Software"), to deal 13 // in the Software without restriction, including without limitation the rights 14 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 // copies of the Software, and to permit persons to whom the Software is 16 // furnished to do so, subject to the following conditions: 17 // 18 // The above copyright notice and this permission notice shall be included in 19 // all copies or substantial portions of the Software. 20 // 21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 // THE SOFTWARE. 28 // 29 30 #pragma once 31 32 // appleseed.renderer headers. 33 #include "renderer/modeling/entity/entity.h" 34 35 // appleseed.foundation headers. 36 #include "foundation/image/colorspace.h" 37 #include "foundation/math/vector.h" 38 #include "foundation/platform/compiler.h" 39 #include "foundation/utility/api/specializedapiarrays.h" 40 #include "foundation/utility/autoreleaseptr.h" 41 #include "foundation/utility/uid.h" 42 43 // appleseed.main headers. 44 #include "main/dllsymbol.h" 45 46 // Forward declarations. 47 namespace foundation { class DictionaryArray; } 48 namespace renderer { class ParamArray; } 49 50 namespace renderer 51 { 52 53 // 54 // An array of color values. 55 // 56 57 typedef foundation::FloatArray ColorValueArray; 58 59 60 // 61 // Color entity. 62 // 63 // todo: allow to specify the lighting conditions of a color. 64 // 65 66 class APPLESEED_DLLSYMBOL ColorEntity 67 : public Entity 68 { 69 public: 70 // Return the unique ID of this class of entities. 71 static foundation::UniqueID get_class_uid(); 72 73 // Delete this instance. 74 void release() override; 75 76 // Return the color values. 77 const ColorValueArray& get_values() const; 78 79 // Return the alpha values. 80 const ColorValueArray& get_alpha() const; 81 82 // Return the color space of this color. 83 foundation::ColorSpace get_color_space() const; 84 85 // Return the range of wavelength of this color (spectral color space only). 86 const foundation::Vector2f& get_wavelength_range() const; 87 88 // Retrieve the multiplier value. 89 float get_multiplier() const; 90 91 private: 92 friend class ColorEntityFactory; 93 94 struct Impl; 95 Impl* impl; 96 97 // Constructors. 98 ColorEntity( 99 const char* name, 100 const ParamArray& params); 101 ColorEntity( 102 const char* name, 103 const ParamArray& params, 104 const ColorValueArray& values); 105 ColorEntity( 106 const char* name, 107 const ParamArray& params, 108 const ColorValueArray& values, 109 const ColorValueArray& alpha); 110 111 // Destructor. 112 ~ColorEntity() override; 113 114 void extract_parameters(); 115 void extract_values(); 116 void remove_color_alpha_parameters(); 117 void check_validity(); 118 }; 119 120 121 // 122 // Color entity factory. 123 // 124 125 class APPLESEED_DLLSYMBOL ColorEntityFactory 126 { 127 public: 128 // Return a set of input metadata for this color entity model. 129 static foundation::DictionaryArray get_input_metadata(); 130 131 // Create a new color entity. 132 static foundation::auto_release_ptr<ColorEntity> create( 133 const char* name, 134 const ParamArray& params); 135 static foundation::auto_release_ptr<ColorEntity> create( 136 const char* name, 137 const ParamArray& params, 138 const ColorValueArray& values); 139 static foundation::auto_release_ptr<ColorEntity> create( 140 const char* name, 141 const ParamArray& params, 142 const ColorValueArray& values, 143 const ColorValueArray& alpha); 144 }; 145 146 } // namespace renderer 147