POINTS.CPP 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. ===========================================================================
  3. Copyright (C) 1999-2005 Id Software, Inc.
  4. This file is part of Quake III Arena source code.
  5. Quake III Arena source code is free software; you can redistribute it
  6. and/or modify it under the terms of the GNU General Public License as
  7. published by the Free Software Foundation; either version 2 of the License,
  8. or (at your option) any later version.
  9. Quake III Arena source code is distributed in the hope that it will be
  10. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with Foobar; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. ===========================================================================
  17. */
  18. #include "stdafx.h"
  19. #include "qe3.h"
  20. #define MAX_POINTFILE 8192
  21. static vec3_t s_pointvecs[MAX_POINTFILE];
  22. static int s_num_points, s_check_point;
  23. void Pointfile_Delete (void)
  24. {
  25. char name[1024];
  26. strcpy (name, currentmap);
  27. StripExtension (name);
  28. strcat (name, ".lin");
  29. remove(name);
  30. }
  31. // advance camera to next point
  32. void Pointfile_Next (void)
  33. {
  34. vec3_t dir;
  35. if (s_check_point >= s_num_points-2)
  36. {
  37. Sys_Status ("End of pointfile", 0);
  38. return;
  39. }
  40. s_check_point++;
  41. VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetCamera()->Camera().origin);
  42. VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetXYWnd()->GetOrigin());
  43. VectorSubtract (s_pointvecs[s_check_point+1], g_pParentWnd->GetCamera()->Camera().origin, dir);
  44. VectorNormalize (dir);
  45. g_pParentWnd->GetCamera()->Camera().angles[1] = atan2 (dir[1], dir[0])*180/3.14159;
  46. g_pParentWnd->GetCamera()->Camera().angles[0] = asin (dir[2])*180/3.14159;
  47. Sys_UpdateWindows (W_ALL);
  48. }
  49. // advance camera to previous point
  50. void Pointfile_Prev (void)
  51. {
  52. vec3_t dir;
  53. if ( s_check_point == 0)
  54. {
  55. Sys_Status ("Start of pointfile", 0);
  56. return;
  57. }
  58. s_check_point--;
  59. VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetCamera()->Camera().origin);
  60. VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetXYWnd()->GetOrigin());
  61. VectorSubtract (s_pointvecs[s_check_point+1], g_pParentWnd->GetCamera()->Camera().origin, dir);
  62. VectorNormalize (dir);
  63. g_pParentWnd->GetCamera()->Camera().angles[1] = atan2 (dir[1], dir[0])*180/3.14159;
  64. g_pParentWnd->GetCamera()->Camera().angles[0] = asin (dir[2])*180/3.14159;
  65. Sys_UpdateWindows (W_ALL);
  66. }
  67. void WINAPI Pointfile_Check (void)
  68. {
  69. char name[1024];
  70. FILE *f;
  71. vec3_t v;
  72. strcpy (name, currentmap);
  73. StripExtension (name);
  74. strcat (name, ".lin");
  75. f = fopen (name, "r");
  76. if (!f)
  77. return;
  78. Sys_Printf ("Reading pointfile %s\n", name);
  79. if (!g_qeglobals.d_pointfile_display_list)
  80. g_qeglobals.d_pointfile_display_list = qglGenLists(1);
  81. s_num_points = 0;
  82. qglNewList (g_qeglobals.d_pointfile_display_list, GL_COMPILE);
  83. qglColor3f (1, 0, 0);
  84. qglDisable(GL_TEXTURE_2D);
  85. qglDisable(GL_TEXTURE_1D);
  86. qglLineWidth (4);
  87. qglBegin(GL_LINE_STRIP);
  88. do
  89. {
  90. if (fscanf (f, "%f %f %f\n", &v[0], &v[1], &v[2]) != 3)
  91. break;
  92. if (s_num_points < MAX_POINTFILE)
  93. {
  94. VectorCopy (v, s_pointvecs[s_num_points]);
  95. s_num_points++;
  96. }
  97. qglVertex3fv (v);
  98. } while (1);
  99. qglEnd();
  100. qglLineWidth (1);
  101. qglEndList ();
  102. s_check_point = 0;
  103. fclose (f);
  104. //Pointfile_Next ();
  105. }
  106. void Pointfile_Draw( void )
  107. {
  108. int i;
  109. qglColor3f( 1.0F, 0.0F, 0.0F );
  110. qglDisable(GL_TEXTURE_2D);
  111. qglDisable(GL_TEXTURE_1D);
  112. qglLineWidth (4);
  113. qglBegin(GL_LINE_STRIP);
  114. for ( i = 0; i < s_num_points; i++ )
  115. {
  116. qglVertex3fv( s_pointvecs[i] );
  117. }
  118. qglEnd();
  119. qglLineWidth( 1 );
  120. }
  121. void Pointfile_Clear (void)
  122. {
  123. if (!g_qeglobals.d_pointfile_display_list)
  124. return;
  125. qglDeleteLists (g_qeglobals.d_pointfile_display_list, 1);
  126. g_qeglobals.d_pointfile_display_list = 0;
  127. Sys_UpdateWindows (W_ALL);
  128. }