Line data Source code
1 0 : /* 2 : 3 : OOBasicMaterial.h 4 : 5 : Material using basic OpenGL properties. Normal materials 6 : (OOSingleTextureMaterial, OOShaderMaterial) are subclasses of this. It may be 7 : desireable to have a material which does not use normal GL material 8 : properties, in which case it should be based on OOMaterial directly. 9 : 10 : 11 : Copyright (C) 2007-2013 Jens Ayton 12 : 13 : Permission is hereby granted, free of charge, to any person obtaining a copy 14 : of this software and associated documentation files (the "Software"), to deal 15 : in the Software without restriction, including without limitation the rights 16 : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 : copies of the Software, and to permit persons to whom the Software is 18 : furnished to do so, subject to the following conditions: 19 : 20 : The above copyright notice and this permission notice shall be included in all 21 : copies or substantial portions of the Software. 22 : 23 : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 : SOFTWARE. 30 : 31 : */ 32 : 33 : #import "OOMaterial.h" 34 : #import "OOColor.h" 35 : 36 : 37 0 : @interface OOBasicMaterial: OOMaterial 38 : { 39 : @private 40 0 : NSString *materialName; 41 : 42 : // Colours 43 0 : GLfloat diffuse[4], 44 0 : specular[4], 45 0 : ambient[4], 46 0 : emission[4]; 47 : 48 : // Specular exponent 49 0 : uint8_t shininess; // Default: 0.0 50 : } 51 : 52 : /* Initialize with default values (historical Olite defaults, not GL defaults): 53 : diffuse { 1.0, 1.0, 1.0, 1.0 } 54 : specular { 0.0, 0.0, 0.0, 1.0 } 55 : ambient { 1.0, 1.0, 1.0, 1.0 } 56 : emission { 0.0, 0.0, 0.0, 1.0 } 57 : shininess 0 58 : */ 59 0 : - (id)initWithName:(NSString *)name; 60 : 61 : /* Initialize with dictionary. Accepted keys: 62 : diffuse colour description 63 : specular colour description 64 : ambient colour description 65 : emission colour description 66 : shininess integer 67 : 68 : "Colour description" refers to anything +[OOColor colorWithDescription:] 69 : will accept. 70 : */ 71 0 : - (id)initWithName:(NSString *)name configuration:(NSDictionary *)configuration; 72 : 73 0 : - (OOColor *)diffuseColor; 74 0 : - (void)setDiffuseColor:(OOColor *)color; 75 0 : - (void)setAmbientAndDiffuseColor:(OOColor *)color; 76 0 : - (OOColor *)specularColor; 77 0 : - (void)setSpecularColor:(OOColor *)color; 78 0 : - (OOColor *)ambientColor; 79 0 : - (void)setAmbientColor:(OOColor *)color; 80 0 : - (OOColor *)emmisionColor; 81 0 : - (void)setEmissionColor:(OOColor *)color; 82 : 83 0 : - (void)getDiffuseComponents:(GLfloat[4])outComponents; 84 0 : - (void)setDiffuseComponents:(const GLfloat[4])components; 85 0 : - (void)setAmbientAndDiffuseComponents:(const GLfloat[4])components; 86 0 : - (void)getSpecularComponents:(GLfloat[4])outComponents; 87 0 : - (void)setSpecularComponents:(const GLfloat[4])components; 88 0 : - (void)getAmbientComponents:(GLfloat[4])outComponents; 89 0 : - (void)setAmbientComponents:(const GLfloat[4])components; 90 0 : - (void)getEmissionComponents:(GLfloat[4])outComponents; 91 0 : - (void)setEmissionComponents:(const GLfloat[4])components; 92 : 93 0 : - (void)setDiffuseRed:(GLfloat)r green:(GLfloat)g blue:(GLfloat)b alpha:(GLfloat)a; 94 0 : - (void)setAmbientAndDiffuseRed:(GLfloat)r green:(GLfloat)g blue:(GLfloat)b alpha:(GLfloat)a; 95 0 : - (void)setSpecularRed:(GLfloat)r green:(GLfloat)g blue:(GLfloat)b alpha:(GLfloat)a; 96 0 : - (void)setAmbientRed:(GLfloat)r green:(GLfloat)g blue:(GLfloat)b alpha:(GLfloat)a; 97 0 : - (void)setEmissionRed:(GLfloat)r green:(GLfloat)g blue:(GLfloat)b alpha:(GLfloat)a; 98 : 99 0 : - (uint8_t)shininess; 100 0 : - (void)setShininess:(uint8_t)value; // Clamped to [0, 128] 101 : 102 : 103 : /* For subclasses: return true to permit specular settings, false to deny 104 : them. By default, this is ![UNIVERSE reducedDetail]. 105 : */ 106 0 : - (BOOL) permitSpecular; 107 : 108 : @end