/xbmc/visualizations/Goom/goom2k4-0/src/v3d.h

http://github.com/xbmc/xbmc · C++ Header · 65 lines · 41 code · 11 blank · 13 comment · 2 complexity · 91ded00753689597919d97ca329d7dc5 MD5 · raw file

  1. #ifndef _V3D_H
  2. #define _V3D_H
  3. #include <math.h>
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #include "mathtools.h"
  7. typedef struct {
  8. float x,y,z;
  9. } v3d;
  10. typedef struct {
  11. int x,y;
  12. } v2d;
  13. typedef struct {
  14. double x,y;
  15. } v2g;
  16. /*
  17. * projete le vertex 3D sur le plan d'affichage
  18. * retourne (0,0) si le point ne doit pas etre affiche.
  19. *
  20. * bonne valeur pour distance : 256
  21. */
  22. #define V3D_TO_V2D(v3,v2,width,height,distance) \
  23. { \
  24. int Xp, Yp; \
  25. if (v3.z > 2) { \
  26. F2I((distance * v3.x / v3.z),Xp) ; \
  27. F2I((distance * v3.y / v3.z),Yp) ; \
  28. v2.x = Xp + (width>>1); \
  29. v2.y = -Yp + (height>>1); \
  30. } \
  31. else v2.x=v2.y=-666; \
  32. }
  33. void v3d_to_v2d(v3d *src, int nbvertex, int width, int height, float distance, v2d *v2_array);
  34. /*
  35. * rotation selon Y du v3d vi d'angle a (cosa=cos(a), sina=sin(a))
  36. * centerz = centre de rotation en z
  37. */
  38. #define Y_ROTATE_V3D(vi,vf,sina,cosa)\
  39. {\
  40. vf.x = vi.x * cosa - vi.z * sina;\
  41. vf.z = vi.x * sina + vi.z * cosa;\
  42. vf.y = vi.y;\
  43. }
  44. /*
  45. * translation
  46. */
  47. #define TRANSLATE_V3D(vsrc,vdest)\
  48. {\
  49. vdest.x += vsrc.x;\
  50. vdest.y += vsrc.y;\
  51. vdest.z += vsrc.z;\
  52. }
  53. #define MUL_V3D(lf,v) {v.x*=lf;v.y*=lf;v.z*=lf;}
  54. #endif