Oolite
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 36 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 133 of file OOCrosshairs.m.

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

References count, and OOClamp_0_1_f().

Referenced by setUpDataWithPoints:scale:color:overallAlpha:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setUpDataWithPoints:scale:color:overallAlpha:

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

Extends class OOCrosshairs.

Definition at line 105 of file OOCrosshairs.m.

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

References OOColor::getRed:green:blue:alpha:, and OOCrosshairs::setUpDataForOnePoint:scale:colorComps:overallAlpha:data:.

Referenced by OOCrosshairs::initWithPoints:scale:color:overallAlpha:.

Here is the call graph for this function:
Here is the caller graph for this function:

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