Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OOCrosshairs(Private) Category Reference

Instance Methods

(void) - setUpDataWithPoints:scale:color:overallAlpha:
 
(void) - setUpDataForOnePoint:scale:colorComps:overallAlpha:data:
 

Detailed Description

Definition at line 37 of file OOCrosshairs.m.

Method Documentation

◆ setUpDataForOnePoint:scale:colorComps:overallAlpha:data:

- (void) setUpDataForOnePoint: (NSArray *) pointInfo
scale: (GLfloat) scale
colorComps: (float) colorComps[4]
overallAlpha: (GLfloat) alpha
data: (GLfloat *) ioBuffer 

Extends class OOCrosshairs.

Definition at line 1 of file OOCrosshairs.m.

142 :(NSArray *)pointInfo
143 scale:(GLfloat)scale
144 colorComps:(float[4])colorComps
145 overallAlpha:(GLfloat)alpha
146 data:(GLfloat *)ioBuffer
147{
148 GLfloat x1, y1, a1, x2, y2, a2;
149 GLfloat r, g, b, a;
150
151 if ([pointInfo count] >= 6)
152 {
153 a1 = [pointInfo oo_floatAtIndex:0];
154 x1 = [pointInfo oo_floatAtIndex:1] * scale;
155 y1 = [pointInfo oo_floatAtIndex:2] * scale;
156 a2 = [pointInfo oo_floatAtIndex:3];
157 x2 = [pointInfo oo_floatAtIndex:4] * scale;
158 y2 = [pointInfo oo_floatAtIndex:5] * scale;
159 r = colorComps[0];
160 g = colorComps[1];
161 b = colorComps[2];
162 a = colorComps[3];
163
164 /* a1/a2 * a is hud.plist and crosshairs.plist - specified alpha,
165 which must be clamped to 0..1 so the plist-specified alpha can't
166 "escape" the overall alpha range. The result of scaling this by
167 overall HUD alpha is then clamped again for robustness.
168 */
169 a1 = OOClamp_0_1_f(OOClamp_0_1_f(a1 * a) * alpha);
170 a2 = OOClamp_0_1_f(OOClamp_0_1_f(a2 * a) * alpha);
171 }
172 else
173 {
174 // Bad entry, write red point in middle.
175 x1 = -0.01f;
176 x2 = 0.01f;
177 y1 = y2 = 0.0f;
178 r = 1.0f;
179 g = b = 0.0f;
180 a1 = a2 = 1.0;
181 }
182
183 *ioBuffer++ = x1;
184 *ioBuffer++ = y1;
185 *ioBuffer++ = r;
186 *ioBuffer++ = g;
187 *ioBuffer++ = b;
188 *ioBuffer++ = a1;
189
190 *ioBuffer++ = x2;
191 *ioBuffer++ = y2;
192 *ioBuffer++ = r;
193 *ioBuffer++ = g;
194 *ioBuffer++ = b;
195 *ioBuffer++ = a2;
196
197 (void)ioBuffer;
198}
unsigned count

◆ setUpDataWithPoints:scale:color:overallAlpha:

- (void) setUpDataWithPoints: (NSArray *) points
scale: (GLfloat) scale
color: (OOColor *) color
overallAlpha: (GLfloat) alpha 

Extends class OOCrosshairs.

Definition at line 1 of file OOCrosshairs.m.

113 :(NSArray *)points
114 scale:(GLfloat)scale
115 color:(OOColor *)color
116 overallAlpha:(GLfloat)alpha
117{
118 NSUInteger i;
119 float colorComps[4] = { 0.0f, 1.0f, 0.0f, 1.0f };
120 GLfloat *data = NULL;
121
122 _count = [points count];
123 if (_count == 0) return;
124
125 _data = malloc(sizeof (GLfloat) * 12 * _count); // 2 coordinates, 4 colour components for each endpoint of each line segment
126 [color getRed:&colorComps[0] green:&colorComps[1] blue:&colorComps[2] alpha:&colorComps[3]];
127
128 // Turn NSArray into GL-friendly element array
129 data = _data;
130 for (i = 0; i < _count; i++)
131 {
132 [self setUpDataForOnePoint:[points oo_arrayAtIndex:i]
133 scale:scale
134 colorComps:colorComps
135 overallAlpha:alpha
136 data:data];
137 data += 12;
138 }
139}
void getRed:green:blue:alpha:(float *red,[green] float *green,[blue] float *blue,[alpha] float *alpha)
Definition OOColor.m:368

The documentation for this category was generated from the following file: