diff --git a/src/MD2.h b/src/MD2.h index 82095f7..87d23a9 100644 --- a/src/MD2.h +++ b/src/MD2.h @@ -12,7 +12,7 @@ OF_ASSUME_NONNULL_BEGIN + (instancetype)md2; - (bool)loadWithIRI:(OFIRI *)IRI; -- (void)renderWithLight:(OFVector3D)light +- (void)renderWithLight:(OFColor *)light frame:(int)frame range:(int)range position:(OFVector3D)position diff --git a/src/MD2.m b/src/MD2.m index c51ded4..cf4d70e 100644 --- a/src/MD2.m +++ b/src/MD2.m @@ -138,7 +138,7 @@ snap(int sn, float f) } } -- (void)renderWithLight:(OFVector3D)light +- (void)renderWithLight:(OFColor *)light frame:(int)frame range:(int)range position:(OFVector3D)position @@ -158,7 +158,9 @@ snap(int sn, float f) glRotatef(yaw + 180, 0, -1, 0); glRotatef(pitch, 0, 0, 1); - glColor3fv((float *)&light); + float red, green, blue; + [light getRed:&red green:&green blue:&blue alpha:NULL]; + glColor3f(red, green, blue); if (_displaylist && frame == 0 && range == 1) { glCallList(_displaylist); diff --git a/src/rendermd2.m b/src/rendermd2.m index 2854a59..a2f9149 100644 --- a/src/rendermd2.m +++ b/src/rendermd2.m @@ -105,21 +105,25 @@ rendermodel(OFString *mdl, int frame, int range, int tex, float rad, int ix = (int)position.x; int iy = (int)position.z; - OFVector3D light = OFMakeVector3D(1, 1, 1); + OFColor *light = [OFColor colorWithRed:1 green:1 blue:1 alpha:1]; if (!OUTBORD(ix, iy)) { struct sqr *s = S(ix, iy); float ll = 256.0f; // 0.96f; float of = 0.0f; // 0.1f; - light.x = s->r / ll + of; - light.y = s->g / ll + of; - light.z = s->b / ll + of; + light = [OFColor colorWithRed:s->r / ll + of + green:s->g / ll + of + blue:s->b / ll + of + alpha:1]; } if (teammate) { - light.x *= 0.6f; - light.y *= 0.7f; - light.z *= 1.2f; + float red, green, blue; + [light getRed:&red green:&green blue:&blue alpha:NULL]; + light = [OFColor colorWithRed:red * 0.6f + green:green * 0.7f + blue:blue * 1.2f + alpha:1]; } [m renderWithLight:light