1
0

LIGHT.C 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /******************************************************************************
  2. Plush Version 1.2
  3. light.c
  4. Light Control
  5. Copyright (c) 1996-2000, Justin Frankel
  6. ******************************************************************************/
  7. #include "plush.h"
  8. pl_Light *plLightSet(pl_Light *light, pl_uChar mode, pl_Float x, pl_Float y,
  9. pl_Float z, pl_Float intensity, pl_Float halfDist) {
  10. pl_Float m[16], m2[16];
  11. light->Type = mode;
  12. light->Intensity = intensity;
  13. light->HalfDistSquared = halfDist*halfDist;
  14. switch (mode) {
  15. case PL_LIGHT_VECTOR:
  16. plMatrixRotate(m,1,x);
  17. plMatrixRotate(m2,2,y);
  18. plMatrixMultiply(m,m2);
  19. plMatrixRotate(m2,3,z);
  20. plMatrixMultiply(m,m2);
  21. plMatrixApply(m,0.0,0.0,-1.0,&light->Xp, &light->Yp, &light->Zp);
  22. break;
  23. case PL_LIGHT_POINT_ANGLE:
  24. case PL_LIGHT_POINT_DISTANCE:
  25. case PL_LIGHT_POINT:
  26. light->Xp = x;
  27. light->Yp = y;
  28. light->Zp = z;
  29. break;
  30. }
  31. return light;
  32. }
  33. pl_Light *plLightCreate() {
  34. pl_Light *l;
  35. l = malloc(sizeof(pl_Light));
  36. if (!l) return 0;
  37. memset(l,0,sizeof(pl_Light));
  38. return (l);
  39. }
  40. void plLightDelete(pl_Light *l) {
  41. if (l) free(l);
  42. }