PointFile.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #include "../../idlib/precompiled.h"
  21. #pragma hdrstop
  22. #include "qe3.h"
  23. #define MAX_POINTFILE 8192
  24. static idVec3 s_pointvecs[MAX_POINTFILE];
  25. static int s_num_points, s_check_point;
  26. void Pointfile_Delete (void)
  27. {
  28. char name[1024];
  29. strcpy (name, currentmap);
  30. StripExtension (name);
  31. strcat (name, ".lin");
  32. remove(name);
  33. }
  34. // advance camera to next point
  35. void Pointfile_Next (void)
  36. {
  37. idVec3 dir;
  38. if (s_check_point >= s_num_points-2)
  39. {
  40. Sys_Status ("End of pointfile", 0);
  41. return;
  42. }
  43. s_check_point++;
  44. VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetCamera()->Camera().origin);
  45. VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetXYWnd()->GetOrigin());
  46. VectorSubtract (s_pointvecs[s_check_point+1], g_pParentWnd->GetCamera()->Camera().origin, dir);
  47. dir.Normalize();
  48. g_pParentWnd->GetCamera()->Camera().angles[1] = atan2 (dir[1], dir[0])*180/3.14159;
  49. g_pParentWnd->GetCamera()->Camera().angles[0] = asin (dir[2])*180/3.14159;
  50. Sys_UpdateWindows (W_ALL);
  51. }
  52. // advance camera to previous point
  53. void Pointfile_Prev (void)
  54. {
  55. idVec3 dir;
  56. if ( s_check_point == 0)
  57. {
  58. Sys_Status ("Start of pointfile", 0);
  59. return;
  60. }
  61. s_check_point--;
  62. VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetCamera()->Camera().origin);
  63. VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetXYWnd()->GetOrigin());
  64. VectorSubtract (s_pointvecs[s_check_point+1], g_pParentWnd->GetCamera()->Camera().origin, dir);
  65. dir.Normalize();
  66. g_pParentWnd->GetCamera()->Camera().angles[1] = atan2 (dir[1], dir[0])*180/3.14159;
  67. g_pParentWnd->GetCamera()->Camera().angles[0] = asin (dir[2])*180/3.14159;
  68. Sys_UpdateWindows (W_ALL);
  69. }
  70. void WINAPI Pointfile_Check (void)
  71. {
  72. char name[1024];
  73. FILE *f;
  74. idVec3 v;
  75. strcpy (name, currentmap);
  76. StripExtension (name);
  77. strcat (name, ".lin");
  78. f = fopen (name, "r");
  79. if (!f)
  80. return;
  81. common->Printf ("Reading pointfile %s\n", name);
  82. if (!g_qeglobals.d_pointfile_display_list)
  83. g_qeglobals.d_pointfile_display_list = qglGenLists(1);
  84. s_num_points = 0;
  85. qglNewList (g_qeglobals.d_pointfile_display_list, GL_COMPILE);
  86. qglColor3f (1, 0, 0);
  87. qglDisable(GL_TEXTURE_2D);
  88. qglDisable(GL_TEXTURE_1D);
  89. qglLineWidth (2);
  90. qglBegin(GL_LINE_STRIP);
  91. do
  92. {
  93. if (fscanf (f, "%f %f %f\n", &v[0], &v[1], &v[2]) != 3)
  94. break;
  95. if (s_num_points < MAX_POINTFILE)
  96. {
  97. VectorCopy (v, s_pointvecs[s_num_points]);
  98. s_num_points++;
  99. }
  100. qglVertex3fv( v.ToFloatPtr() );
  101. } while (1);
  102. qglEnd();
  103. qglLineWidth (0.5);
  104. qglEndList ();
  105. s_check_point = 0;
  106. fclose (f);
  107. //Pointfile_Next ();
  108. }
  109. void Pointfile_Draw( void )
  110. {
  111. int i;
  112. qglColor3f( 1.0F, 0.0F, 0.0F );
  113. qglDisable(GL_TEXTURE_2D);
  114. qglDisable(GL_TEXTURE_1D);
  115. qglLineWidth (2);
  116. qglBegin(GL_LINE_STRIP);
  117. for ( i = 0; i < s_num_points; i++ )
  118. {
  119. qglVertex3fv( s_pointvecs[i].ToFloatPtr() );
  120. }
  121. qglEnd();
  122. qglLineWidth( 0.5 );
  123. }
  124. void Pointfile_Clear (void)
  125. {
  126. if (!g_qeglobals.d_pointfile_display_list)
  127. return;
  128. qglDeleteLists (g_qeglobals.d_pointfile_display_list, 1);
  129. g_qeglobals.d_pointfile_display_list = 0;
  130. Sys_UpdateWindows (W_ALL);
  131. }