34@interface OOBreakPatternEntity (Private)
36- (void) setInnerColorComponents:(GLfloat[4])color1 outerColorComponents:(GLfloat[4])color2;
43- (id) initWithPolygonSides:(NSUInteger)sides startAngle:(
float)startAngleDegrees aspectRatio:(
float)aspectRatio
47 if ((
self = [super init]))
49 _vertexCount = (sides + 1) * 2;
50 float angle = startAngleDegrees *
M_PI / 180.0f;
51 float deltaAngle =
M_PI * 2.0f / sides;
52 float xAspect = fmin(1.0f, aspectRatio);
53 float yAspect = fmin(1.0f, 1.0f / aspectRatio);
56 for (NSUInteger i = 0; i < sides; i++)
58 float s = sin(angle) * xAspect;
59 float c = cos(angle) * yAspect;
61 _vertexPosition[vi++] = (Vector) { s * 50, c * 50, -40 };
62 _vertexPosition[vi++] = (Vector) { s * 40, c * 40, 0 };
67 _vertexPosition[vi++] = _vertexPosition[0];
68 _vertexPosition[vi++] = _vertexPosition[1];
76 isImmuneToBreakPatternHide = YES;
83+ (instancetype) breakPatternWithPolygonSides:(NSUInteger)sides startAngle:(
float)startAngleDegrees aspectRatio:(
float)aspectRatio
85 return [[[
self alloc] initWithPolygonSides:sides startAngle:startAngleDegrees aspectRatio:aspectRatio] autorelease];
89- (void) setInnerColor:(
OOColor *)color1 outerColor:(
OOColor *)color2
91 GLfloat inner[4], outer[4];
94 [
self setInnerColorComponents:inner outerColorComponents:outer];
98- (void) setInnerColorComponents:(GLfloat[4])color1 outerColorComponents:(GLfloat[4])color2
100 GLfloat *colors[2] = { color1, color2 };
102 for (NSUInteger i = 0; i < _vertexCount; i++)
104 GLfloat *color = colors[i & 1];
105 memcpy(&_vertexColor[i], color,
sizeof (GLfloat) * 4);
110- (void) setLifetime:(
double)lifetime
112 _lifetime = lifetime;
118 [
super update:delta_t];
123 [UNIVERSE removeEntity:self];
128- (void) drawImmediate:(
bool)immediate translucent:(
bool)translucent
131 if (!isImmuneToBreakPatternHide)
return;
133 if (translucent || immediate)
138 OOGL(glDisable(GL_LIGHTING));
139 OOGL(glDisable(GL_TEXTURE_2D));
140 OOGL(glEnable(GL_BLEND));
141 OOGL(glDepthMask(GL_FALSE));
142 OOGL(glDisableClientState(GL_NORMAL_ARRAY));
144 OOGL(glVertexPointer(3, GL_FLOAT, 0, _vertexPosition));
145 OOGL(glEnableClientState(GL_COLOR_ARRAY));
146 OOGL(glColorPointer(4, GL_FLOAT, 0, _vertexColor));
148 OOGL(glDrawArrays(GL_TRIANGLE_STRIP, 0, _vertexCount));
150 OOGL(glEnable(GL_LIGHTING));
151 OOGL(glEnable(GL_TEXTURE_2D));
152 OOGL(glDisable(GL_BLEND));
153 OOGL(glDepthMask(GL_TRUE));
154 OOGL(glEnableClientState(GL_NORMAL_ARRAY));
155 OOGL(glDisableClientState(GL_COLOR_ARRAY));
169- (BOOL) isBreakPattern
177@implementation Entity (OOBreakPatternEntity)
179- (BOOL) isBreakPattern
@ kOOBreakPatternMaxSides
#define BREAK_PATTERN_RING_SPEED
#define OO_ENTER_OPENGL()
#define OOVerifyOpenGLState()
BOOL OOCheckOpenGLErrors(NSString *format,...)
#define OOSetOpenGLState(STATE)
void setScanClass:(OOScanClass sClass)
void setStatus:(OOEntityStatus stat)
void setInnerColorComponents:outerColorComponents:(GLfloat[4] color1, [outerColorComponents] GLfloat[4] color2)
void getRed:green:blue:alpha:(float *red,[green] float *green,[blue] float *blue,[alpha] float *alpha)