Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
OOBasicMaterial Class Reference

#include <OOBasicMaterial.h>

+ Inheritance diagram for OOBasicMaterial:
+ Collaboration diagram for OOBasicMaterial:

Instance Methods

(id) - initWithName:
 
(id) - initWithName:configuration:
 
(OOColor *) - diffuseColor
 
(void) - setDiffuseColor:
 
(void) - setAmbientAndDiffuseColor:
 
(OOColor *) - specularColor
 
(void) - setSpecularColor:
 
(OOColor *) - ambientColor
 
(void) - setAmbientColor:
 
(OOColor *) - emmisionColor
 
(void) - setEmissionColor:
 
(void) - getDiffuseComponents:
 
(void) - setDiffuseComponents:
 
(void) - setAmbientAndDiffuseComponents:
 
(void) - getSpecularComponents:
 
(void) - setSpecularComponents:
 
(void) - getAmbientComponents:
 
(void) - setAmbientComponents:
 
(void) - getEmissionComponents:
 
(void) - setEmissionComponents:
 
(void) - setDiffuseRed:green:blue:alpha:
 
(void) - setAmbientAndDiffuseRed:green:blue:alpha:
 
(void) - setSpecularRed:green:blue:alpha:
 
(void) - setAmbientRed:green:blue:alpha:
 
(void) - setEmissionRed:green:blue:alpha:
 
(uint8_t) - shininess
 
(void) - setShininess:
 
(BOOL) - permitSpecular
 
(void) - dealloc [implementation]
 
(NSString *) - name [implementation]
 
(BOOL) - doApply [implementation]
 
(void) - unapplyWithNext: [implementation]
 
(NSSet *) - allTextures [implementation]
 
- Instance Methods inherited from OOMaterial
(void) - apply
 
(void) - ensureFinishedLoading
 
(BOOL) - isFinishedLoading
 
(void) - setBindingTarget:
 
(BOOL) - wantsNormalsAsTextureCoordinates
 
(NSString *) - descriptionComponents [implementation]
 
(void) - willDealloc
 

Private Attributes

NSString * materialName
 
GLfloat diffuse [4]
 
GLfloat specular [4]
 
GLfloat ambient [4]
 
GLfloat emission [4]
 
uint8_t shininess
 

Additional Inherited Members

- Class Methods inherited from OOMaterial
(void) + setUp
 
(void) + applyNone
 
(OOMaterial *) + current
 
(OOMaterial *) + materialWithName:cacheKey:configuration:macros:bindingTarget:forSmoothedMesh:
 
(OOMaterial *) + materialWithName:cacheKey:materialDictionary:shadersDictionary:macros:bindingTarget:forSmoothedMesh:
 
(NSDictionary *) + synthesizeMaterialDictionaryWithName:configuration:macros: [implementation]
 
(OOMaterial *) + defaultShaderMaterialWithName:cacheKey:configuration:macros:bindingTarget: [implementation]
 

Detailed Description

Definition at line 37 of file OOBasicMaterial.h.

Method Documentation

◆ allTextures

- (NSSet *) allTextures
implementation

Reimplemented from OOMaterial.

Reimplemented in OOSingleTextureMaterial.

Definition at line 36 of file OOBasicMaterial.m.

343{
344 return [NSSet set];
345}

◆ ambientColor

- (OOColor *) ambientColor

Definition at line 36 of file OOBasicMaterial.m.

183{
184 return [OOColor colorWithRed:ambient[0]
185 green:ambient[1]
186 blue:ambient[2]
187 alpha:ambient[3]];
188}
OOColor * colorWithRed:green:blue:alpha:(float red,[green] float green,[blue] float blue,[alpha] float alpha)
Definition OOColor.m:95

◆ dealloc

- (void) dealloc
implementation

Reimplemented from OOMaterial.

Reimplemented in OOSingleTextureMaterial.

Definition at line 36 of file OOBasicMaterial.m.

93{
94 [super willDealloc];
95 [materialName release];
96
97 [super dealloc];
98}

◆ diffuseColor

- (OOColor *) diffuseColor

Definition at line 36 of file OOBasicMaterial.m.

134{
135 return [OOColor colorWithRed:diffuse[0]
136 green:diffuse[1]
137 blue:diffuse[2]
138 alpha:diffuse[3]];
139}

◆ doApply

- (BOOL) doApply
implementation

Reimplemented from OOMaterial.

Reimplemented in OOSingleTextureMaterial.

Definition at line 36 of file OOBasicMaterial.m.

108{
109 OOGL(glMaterialfv(FACE, GL_DIFFUSE, diffuse));
110 OOGL(glMaterialfv(FACE, GL_SPECULAR, specular));
111 OOGL(glMaterialfv(FACE, GL_AMBIENT, ambient));
112 OOGL(glMaterialfv(FACE, GL_EMISSION, emission));
113 OOGL(glMateriali(FACE, GL_SHININESS, shininess));
114 if ([self isMemberOfClass:[OOBasicMaterial class]])
115 {
117 }
118
119 return YES;
120}
#define FACE
#define OOGL(statement)
Definition OOOpenGL.h:251
GLfloat emission[4]
GLfloat specular[4]
void applyNone()
Definition OOTexture.m:275

◆ emmisionColor

- (OOColor *) emmisionColor

Definition at line 36 of file OOBasicMaterial.m.

204{
205 return [OOColor colorWithRed:emission[0]
206 green:emission[1]
207 blue:emission[2]
208 alpha:emission[3]];
209}

◆ getAmbientComponents:

- (void) getAmbientComponents: (GLfloat[4]) outComponents

Definition at line 36 of file OOBasicMaterial.m.

255 :(GLfloat[4])outComponents
256{
257 memcpy(outComponents, ambient, 4 * sizeof *outComponents);
258}

◆ getDiffuseComponents:

- (void) getDiffuseComponents: (GLfloat[4]) outComponents

Definition at line 36 of file OOBasicMaterial.m.

224 :(GLfloat[4])outComponents
225{
226 memcpy(outComponents, diffuse, 4 * sizeof *outComponents);
227}

◆ getEmissionComponents:

- (void) getEmissionComponents: (GLfloat[4]) outComponents

Definition at line 36 of file OOBasicMaterial.m.

267 :(GLfloat[4])outComponents
268{
269 memcpy(outComponents, emission, 4 * sizeof *outComponents);
270}

◆ getSpecularComponents:

- (void) getSpecularComponents: (GLfloat[4]) outComponents

Definition at line 36 of file OOBasicMaterial.m.

243 :(GLfloat[4])outComponents
244{
245 memcpy(outComponents, specular, 4 * sizeof *outComponents);
246}

◆ initWithName:

- (id) initWithName: (NSString *) name

Definition at line 36 of file OOBasicMaterial.m.

44 :(NSString *)name
45{
46 self = [super init];
47 if (EXPECT_NOT(self == nil)) return nil;
48
49 materialName = [name copy];
50
51 [self setDiffuseRed:1.0f green:1.0f blue:1.0f alpha:1.0f];
52 [self setAmbientRed:1.0f green:1.0f blue:1.0f alpha:1.0f];
53 specular[3] = 1.0;
54 emission[3] = 1.0;
55
56 return self;
57}
#define EXPECT_NOT(x)
return nil
NSString * materialName

◆ initWithName:configuration:

- (id) initWithName: (NSString *) name
configuration: (NSDictionary *) configuration 

Reimplemented in OOSingleTextureMaterial.

Definition at line 36 of file OOBasicMaterial.m.

60 :(NSString *)name configuration:(NSDictionary *)configuration
61{
62 id colorDesc = nil;
63 int specularExponent;
64
65 self = [self initWithName:name];
66 if (EXPECT_NOT(self == nil)) return nil;
67
68 if (configuration == nil) configuration = [NSDictionary dictionary];
69
70 colorDesc = [configuration oo_diffuseColor];
71 if (colorDesc != nil) [self setDiffuseColor:[OOColor colorWithDescription:colorDesc]];
72
73 colorDesc = [configuration oo_ambientColor];
74 if (colorDesc != nil) [self setAmbientColor:[OOColor colorWithDescription:colorDesc]];
75 else [self setAmbientColor:[self diffuseColor]];
76
77 colorDesc = [configuration oo_emissionColor];
78 if (colorDesc != nil) [self setEmissionColor:[OOColor colorWithDescription:colorDesc]];
79
80 specularExponent = [configuration oo_specularExponent];
81 if (specularExponent != 0 && [self permitSpecular])
82 {
83 colorDesc = [configuration oo_specularColor];
84 [self setShininess:specularExponent];
85 if (colorDesc != nil) [self setSpecularColor:[OOColor colorWithDescription:colorDesc]];
86 }
87
88 return self;
89}
OOColor * colorWithDescription:(id description)
Definition OOColor.m:127

◆ name

- (NSString *) name
implementation

Reimplemented from OOMaterial.

Definition at line 36 of file OOBasicMaterial.m.

102{
103 return materialName;
104}

Referenced by OOSingleTextureMaterial::allTextures.

+ Here is the caller graph for this function:

◆ permitSpecular

- (BOOL) permitSpecular

Definition at line 36 of file OOBasicMaterial.m.

336{
337 return ![UNIVERSE reducedDetail];
338}

◆ setAmbientAndDiffuseColor:

- (void) setAmbientAndDiffuseColor: (OOColor *) color

Definition at line 36 of file OOBasicMaterial.m.

154 :(OOColor *)color
155{
156 [self setAmbientColor:color];
157 [self setDiffuseColor:color];
158}

◆ setAmbientAndDiffuseComponents:

- (void) setAmbientAndDiffuseComponents: (const GLfloat[4]) components

Definition at line 36 of file OOBasicMaterial.m.

236 :(const GLfloat[4])components
237{
238 [self setAmbientComponents:components];
239 [self setDiffuseComponents:components];
240}

◆ setAmbientAndDiffuseRed:green:blue:alpha:

- (void) setAmbientAndDiffuseRed: (GLfloat) r
green: (GLfloat) g
blue: (GLfloat) b
alpha: (GLfloat) a 

Definition at line 36 of file OOBasicMaterial.m.

288 :(GLfloat)r green:(GLfloat)g blue:(GLfloat)b alpha:(GLfloat)a
289{
290 [self setAmbientRed:r green:g blue:b alpha:a];
291 [self setDiffuseRed:r green:g blue:b alpha:a];
292}

◆ setAmbientColor:

- (void) setAmbientColor: (OOColor *) color

Definition at line 36 of file OOBasicMaterial.m.

191 :(OOColor *)color
192{
193 if (color != nil)
194 {
195 [self setAmbientRed:[color redComponent]
196 green:[color greenComponent]
197 blue:[color blueComponent]
198 alpha:[color alphaComponent]];
199 }
200}
float alphaComponent()
Definition OOColor.m:486
float blueComponent()
Definition OOColor.m:362
float redComponent()
Definition OOColor.m:350
float greenComponent()
Definition OOColor.m:356

◆ setAmbientComponents:

- (void) setAmbientComponents: (const GLfloat[4]) components

Definition at line 36 of file OOBasicMaterial.m.

261 :(const GLfloat[4])components
262{
263 memcpy(ambient, components, 4 * sizeof *components);
264}

◆ setAmbientRed:green:blue:alpha:

- (void) setAmbientRed: (GLfloat) r
green: (GLfloat) g
blue: (GLfloat) b
alpha: (GLfloat) a 

Definition at line 36 of file OOBasicMaterial.m.

304 :(GLfloat)r green:(GLfloat)g blue:(GLfloat)b alpha:(GLfloat)a
305{
306 ambient[0] = r;
307 ambient[1] = g;
308 ambient[2] = b;
309 ambient[3] = a;
310}

◆ setDiffuseColor:

- (void) setDiffuseColor: (OOColor *) color

Definition at line 36 of file OOBasicMaterial.m.

142 :(OOColor *)color
143{
144 if (color != nil)
145 {
146 [self setDiffuseRed:[color redComponent]
147 green:[color greenComponent]
148 blue:[color blueComponent]
149 alpha:[color alphaComponent]];
150 }
151}

◆ setDiffuseComponents:

- (void) setDiffuseComponents: (const GLfloat[4]) components

Definition at line 36 of file OOBasicMaterial.m.

230 :(const GLfloat[4])components
231{
232 memcpy(diffuse, components, 4 * sizeof *components);
233}

◆ setDiffuseRed:green:blue:alpha:

- (void) setDiffuseRed: (GLfloat) r
green: (GLfloat) g
blue: (GLfloat) b
alpha: (GLfloat) a 

Definition at line 36 of file OOBasicMaterial.m.

279 :(GLfloat)r green:(GLfloat)g blue:(GLfloat)b alpha:(GLfloat)a
280{
281 diffuse[0] = r;
282 diffuse[1] = g;
283 diffuse[2] = b;
284 diffuse[3] = a;
285}

◆ setEmissionColor:

- (void) setEmissionColor: (OOColor *) color

Definition at line 36 of file OOBasicMaterial.m.

212 :(OOColor *)color
213{
214 if (color != nil)
215 {
216 [self setEmissionRed:[color redComponent]
217 green:[color greenComponent]
218 blue:[color blueComponent]
219 alpha:[color alphaComponent]];
220 }
221}

◆ setEmissionComponents:

- (void) setEmissionComponents: (const GLfloat[4]) components

Definition at line 36 of file OOBasicMaterial.m.

273 :(const GLfloat[4])components
274{
275 memcpy(emission, components, 4 * sizeof *components);
276}

◆ setEmissionRed:green:blue:alpha:

- (void) setEmissionRed: (GLfloat) r
green: (GLfloat) g
blue: (GLfloat) b
alpha: (GLfloat) a 

Definition at line 36 of file OOBasicMaterial.m.

313 :(GLfloat)r green:(GLfloat)g blue:(GLfloat)b alpha:(GLfloat)a
314{
315 emission[0] = r;
316 emission[1] = g;
317 emission[2] = b;
318 emission[3] = a;
319}

◆ setShininess:

- (void) setShininess: (uint8_t) value

Definition at line 36 of file OOBasicMaterial.m.

329 :(uint8_t)value
330{
331 shininess = MIN(value, 128);
332}
#define MIN(A, B)
Definition OOMaths.h:111

◆ setSpecularColor:

- (void) setSpecularColor: (OOColor *) color

Definition at line 36 of file OOBasicMaterial.m.

170 :(OOColor *)color
171{
172 if (color != nil)
173 {
174 [self setSpecularRed:[color redComponent]
175 green:[color greenComponent]
176 blue:[color blueComponent]
177 alpha:[color alphaComponent]];
178 }
179}

◆ setSpecularComponents:

- (void) setSpecularComponents: (const GLfloat[4]) components

Definition at line 36 of file OOBasicMaterial.m.

249 :(const GLfloat[4])components
250{
251 memcpy(specular, components, 4 * sizeof *components);
252}

◆ setSpecularRed:green:blue:alpha:

- (void) setSpecularRed: (GLfloat) r
green: (GLfloat) g
blue: (GLfloat) b
alpha: (GLfloat) a 

Definition at line 36 of file OOBasicMaterial.m.

295 :(GLfloat)r green:(GLfloat)g blue:(GLfloat)b alpha:(GLfloat)a
296{
297 specular[0] = r;
298 specular[1] = g;
299 specular[2] = b;
300 specular[3] = a;
301}

◆ shininess

- (uint8_t) shininess

◆ specularColor

- (OOColor *) specularColor

Definition at line 36 of file OOBasicMaterial.m.

162{
163 return [OOColor colorWithRed:specular[0]
164 green:specular[1]
165 blue:specular[2]
166 alpha:specular[3]];
167}

◆ unapplyWithNext:

- (void) unapplyWithNext: (OOMaterial *) next
implementation

Reimplemented from OOMaterial.

Reimplemented in OOSingleTextureMaterial.

Definition at line 36 of file OOBasicMaterial.m.

123 :(OOMaterial *)next
124{
125 if (![next isKindOfClass:[OOBasicMaterial class]])
126 {
127 if (EXPECT_NOT(sDefaultMaterial == nil)) sDefaultMaterial = [[OOBasicMaterial alloc] initWithName:@"<default material>"];
128 [sDefaultMaterial doApply];
129 }
130}
static OOBasicMaterial * sDefaultMaterial

Member Data Documentation

◆ ambient

- (GLfloat ambient[4])
private

Definition at line 45 of file OOBasicMaterial.h.

◆ diffuse

- (GLfloat diffuse[4])
private

Definition at line 43 of file OOBasicMaterial.h.

◆ emission

- (GLfloat emission[4])
private

Definition at line 46 of file OOBasicMaterial.h.

◆ materialName

- (NSString*) materialName
private

Definition at line 40 of file OOBasicMaterial.h.

◆ shininess

- (uint8_t) shininess
private

Definition at line 49 of file OOBasicMaterial.h.

◆ specular

- (GLfloat specular[4])
private

Definition at line 44 of file OOBasicMaterial.h.


The documentation for this class was generated from the following files: