Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
OOSingleTextureMaterial.m
Go to the documentation of this file.
1/*
2
3OOSingleTextureMaterial.h
4
5
6Copyright (C) 2007-2013 Jens Ayton
7
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this software and associated documentation files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in all
16copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24SOFTWARE.
25
26*/
27
29#import "OOTexture.h"
32
33
34@implementation OOSingleTextureMaterial
35
36- (id)initWithName:(NSString *)name configuration:(NSDictionary *)configuration
37{
38 id texSpec = nil;
39
40 if (configuration != nil)
41 {
42 texSpec = [configuration oo_textureSpecifierForKey:@"diffuse_map" defaultName:name];
43 }
44 else
45 {
46 texSpec = name;
47 }
48
49 return [self initWithName:name
51 configuration:configuration];
52}
53
54
55- (id) initWithName:(NSString *)name texture:(OOTexture *)texture configuration:(NSDictionary *)configuration
56{
57 if (name != nil && texture != nil)
58 {
59 self = [super initWithName:name configuration:configuration];
60 if (self != nil)
61 {
62 _texture = [texture retain];
63 }
64 }
65 else
66 {
67 DESTROY(self);
68 }
69
70
71 return self;
72}
73
74
75- (void)dealloc
76{
77 [self willDealloc];
78 [_texture release];
79
80 [super dealloc];
81}
82
83
84- (NSString *) descriptionComponents
85{
86 return [_texture description];
87}
88
89
90- (BOOL)doApply
91{
92 if (EXPECT_NOT(![super doApply])) return NO;
93
94 [_texture apply];
95 return YES;
96}
97
98
99- (void)unapplyWithNext:(OOMaterial *)next
100{
101 if (![next isKindOfClass:[OOSingleTextureMaterial class]]) [OOTexture applyNone];
102 [super unapplyWithNext:next];
103}
104
105
107{
108 [_texture ensureFinishedLoading];
109}
110
111
112- (BOOL) isFinishedLoading
113{
114 return [_texture isFinishedLoading];
115}
116
117
119{
120 return [_texture isCubeMap];
121}
122
123
124#ifndef NDEBUG
125- (NSSet *) allTextures
126{
127 return [NSSet setWithObject:_texture];
128}
129#endif
130
131@end
#define DESTROY(x)
Definition OOCocoa.h:77
#define EXPECT_NOT(x)
return nil
id initWithName:texture:configuration:(NSString *name,[texture] OOTexture *texture,[configuration] NSDictionary *configuration)
void applyNone()
Definition OOTexture.m:275
id textureWithConfiguration:(id configuration)
Definition OOTexture.m:192