render_data.h
上传用户:gzqinmao
上传日期:2022-07-13
资源大小:472k
文件大小:2k
源码类别:

OpenGL

开发平台:

Visual C++

  1. #include "Vector4.h"
  2. #include "Matrix4x4.h"
  3. struct Vertex_VC
  4. {
  5. float m_Position[3];
  6. // R,G,B,A in OpenGL
  7. // B,G,R,A in Direct3D 9
  8. // Direct3D 10可是是两种其中之1, 看设置而定.
  9. unsigned char m_RGBA[4];
  10. };
  11. // 球的数据
  12. extern Vertex_VC *g_pSunVertices;
  13. extern Vertex_VC *g_pEarthVertices;
  14. extern Vertex_VC *g_pMoonVertices;
  15. extern unsigned short *g_pSphereIndices;
  16. extern int g_iNumSphereVertices;
  17. extern int g_iNumSphereTriangles;
  18. extern int g_iNumSphereIndices;
  19. extern float g_simulation_days;
  20. extern float g_fRotate_X, g_fRotate_Y;
  21. const float PI = 3.14159;
  22. const float PI_double = PI * 2.0f;
  23. const float days_a_year = 365.0f;
  24. const float days_a_month = 28.0f;
  25. const float days_a_year_mercury = 88.0f;
  26. const float days_a_year_venus = 224.7f;
  27. const float sun_spin_x = 180.0f;
  28. const float earth_to_sun_distance = 8.0f; // 地球离太阳的假设值
  29. const float mercury_to_sun_distance = 3.0f; // 水星离太阳的假设值
  30. const float venus_to_sun_distance = 5.0f; // 水星离太阳的假设值
  31. const float moon_to_earth_distance = 2.0f; // 月球离地球的假设值
  32. const float simulation_speed = 60.0f; // 1秒相当于60天
  33. // 镜头位置
  34. extern Vector4 g_eye; 
  35. // 镜头对准的点
  36. extern Vector4 g_lookat; 
  37. // 镜头正上方的方向
  38. extern Vector4 g_up; 
  39. // 镜头转换矩阵
  40. extern Matrix4x4 g_view_matrix;
  41. // 
  42. extern Matrix4x4 g_sun_matrix, g_earth_matrix, g_moon_matrix;
  43. // 生成球模型的程序
  44. bool CreateSphere(float radius, Vertex_VC **ppVertices, unsigned short **ppIndices, float *color=NULL, int stacks = 20, int pieces = 20);