45@interface OOLightParticleEntity (Private)
54- (id) initWithDiameter:(
float)diameter
56 if ((
self = [super init]))
62 _colorComponents[0] = 1.0f;
63 _colorComponents[1] = 1.0f;
64 _colorComponents[2] = 1.0f;
65 _colorComponents[3] = 1.0f;
81- (void) setDiameter:(
float)diameter
87- (void) setColor:(
OOColor *)color
89 [color
getRed:&_colorComponents[0]
green:&_colorComponents[1]
blue:&_colorComponents[2]
alpha:&_colorComponents[3]];
93- (void) setColor:(
OOColor *)color alpha:(GLfloat)alpha
95 [
self setColor:color];
96 _colorComponents[3] = alpha;
100- (void) drawSubEntityImmediate:(
bool)immediate translucent:(
bool)translucent
102 if (!translucent)
return;
108 cam_zero_distance = [[
self owner] camZeroDistance];
109 if (no_draw_distance <= cam_zero_distance)
return;
111 Entity *father = [
self owner];
113 HPVector abspos = position;
115 while (father !=
nil && father != last && father !=
NO_TARGET)
121 if (![father isSubEntity])
break;
122 father = [father
owner];
132 [
self drawImmediate:immediate translucent:translucent];
138- (void) drawImmediate:(
bool)immediate translucent:(
bool)translucent
140 if (!translucent)
return;
141 if ([
UNIVERSE breakPatternHide] && ![
self isImmuneToBreakPatternHide])
143 Entity *father = [
self owner];
146 if (![father isSubEntity])
break;
147 father = [father
owner];
149 if (![father isImmuneToBreakPatternHide])
154 if (no_draw_distance <= cam_zero_distance)
return;
159 OOGL(glPushAttrib(GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT));
160 OOGL(glEnable(GL_BLEND));
161 OOGL(glBlendFunc(GL_SRC_ALPHA, GL_ONE));
163 OOGL(glEnable(GL_TEXTURE_2D));
164 OOGL(glDepthMask(GL_FALSE));
166 GLfloat distanceAttenuation = cam_zero_distance / no_draw_distance;
167 distanceAttenuation = 1.0 - distanceAttenuation;
168 GLfloat components[4] = { _colorComponents[0], _colorComponents[1], _colorComponents[2], _colorComponents[3] * distanceAttenuation };
169 OOGL(glColor4fv(components));
171 OOGL(glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, components));
172 OOGL(glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND));
174 OOViewID viewDir = [UNIVERSE viewDirection];
176 [[
self texture] apply];
183 float viewOffset = _diameter * 0.5f;
189 case VIEW_GUI_DISPLAY:
190 glTexCoord2f(0.0, 1.0);
191 glVertex3f(-_diameter, -_diameter, -viewOffset);
193 glTexCoord2f(1.0, 1.0);
194 glVertex3f(_diameter, -_diameter, -viewOffset);
196 glTexCoord2f(1.0, 0.0);
197 glVertex3f(_diameter, _diameter, -viewOffset);
199 glTexCoord2f(0.0, 0.0);
200 glVertex3f(-_diameter, _diameter, -viewOffset);
204 glTexCoord2f(0.0, 1.0);
205 glVertex3f(_diameter, -_diameter, viewOffset);
207 glTexCoord2f(1.0, 1.0);
208 glVertex3f(-_diameter, -_diameter, viewOffset);
210 glTexCoord2f(1.0, 0.0);
211 glVertex3f(-_diameter, _diameter, viewOffset);
213 glTexCoord2f(0.0, 0.0);
214 glVertex3f(_diameter, _diameter, viewOffset);
218 glTexCoord2f(0.0, 1.0);
219 glVertex3f(-viewOffset, -_diameter, _diameter);
221 glTexCoord2f(1.0, 1.0);
222 glVertex3f(-viewOffset, -_diameter, -_diameter);
224 glTexCoord2f(1.0, 0.0);
225 glVertex3f(-viewOffset, _diameter, -_diameter);
227 glTexCoord2f(0.0, 0.0);
228 glVertex3f(-viewOffset, _diameter, _diameter);
232 glTexCoord2f(0.0, 1.0);
233 glVertex3f(viewOffset, -_diameter, -_diameter);
235 glTexCoord2f(1.0, 1.0);
236 glVertex3f(viewOffset, -_diameter, _diameter);
238 glTexCoord2f(1.0, 0.0);
239 glVertex3f(viewOffset, _diameter, _diameter);
241 glTexCoord2f(0.0, 0.0);
242 glVertex3f(viewOffset, _diameter, -_diameter);
249 Vector vj = [player
customViewUpVector]; vj.x *= _diameter; vj.y *= _diameter; vj.z *= _diameter;
251 glTexCoord2f(0.0, 1.0);
252 glVertex3f(-vi.x -vj.x -vk.x, -vi.y -vj.y -vk.y, -vi.z -vj.z -vk.z);
253 glTexCoord2f(1.0, 1.0);
254 glVertex3f(+vi.x -vj.x -vk.x, +vi.y -vj.y -vk.y, +vi.z -vj.z -vk.z);
255 glTexCoord2f(1.0, 0.0);
256 glVertex3f(+vi.x +vj.x -vk.x, +vi.y +vj.y -vk.y, +vi.z +vj.z -vk.z);
257 glTexCoord2f(0.0, 0.0);
258 glVertex3f(-vi.x +vj.x -vk.x, -vi.y +vj.y -vk.y, -vi.z +vj.z -vk.z);
263 glTexCoord2f(0.0, 1.0);
264 glVertex3f(-_diameter, -_diameter, -_diameter);
266 glTexCoord2f(1.0, 1.0);
267 glVertex3f(_diameter, -_diameter, -_diameter);
269 glTexCoord2f(1.0, 0.0);
270 glVertex3f(_diameter, _diameter, -_diameter);
272 glTexCoord2f(0.0, 0.0);
273 glVertex3f(-_diameter, _diameter, -_diameter);
278 OOGL(glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE));
297 options:kOOTextureMinFilterMipMap | kOOTextureMagFilterLinear | kOOTextureAlphaMask
333- (NSSet *) allTextures
335 return [NSSet setWithObject:[
self texture]];
id textureWithName:inFolder:options:anisotropy:lodBias:(NSString *name,[inFolder] NSString *directory,[options] OOTextureFlags options,[anisotropy] GLfloat anisotropy,[lodBias] GLfloat lodBias)