/OJGL/GLLight.j

http://github.com/tartiflop/ojgl · Unknown · 57 lines · 41 code · 16 blank · 0 comment · 0 complexity · b667cddd62e1d2f1084da86eecb092a3 MD5 · raw file

  1. @import <Foundation/CPObject.j>
  2. @implementation GLLight : CPObject {
  3. Array _position;
  4. Array _ambientLight;
  5. Array _diffuseLight;
  6. Array _specularLight;
  7. float _attenuation;
  8. }
  9. - (id)initWithHexColor:(String)color specularColor:(String)specularColor attenuation:(float)attenuation {
  10. self = [super init];
  11. if (self) {
  12. _position = [0, 0, 0];
  13. _attenuation = attenuation;
  14. _ambientLight = hexToRGB(color);
  15. _diffuseLight = [_ambientLight[0], _ambientLight[1], _ambientLight[2], 1.0];
  16. _specularLight = hexToRGB(specularColor);
  17. }
  18. return self;
  19. }
  20. - (void)setPosition:(Array)position {
  21. _position = position;
  22. }
  23. - (void)setAttenuation:(float)attenuation {
  24. _attenuation = attenuation;
  25. }
  26. - (Array)position {
  27. return [_position[0], _position[1], _position[2], 1];
  28. }
  29. - (Array)ambientLight {
  30. return _ambientLight;
  31. }
  32. - (Array)diffuseLight {
  33. return _diffuseLight;
  34. }
  35. - (Array)specularLight {
  36. return _specularLight;
  37. }
  38. - (float)attenuation {
  39. return _attenuation;
  40. }
  41. @end