Advertisement
gattispilot

Untitled

Jul 11th, 2021
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 442.33 KB | None | 0 0
  1. // ==============================================================
  2. // ORBITER MODULE: Atlantis
  3. // Part of the ORBITER SDK
  4. // Copyright (C) 2001-20012 Martin Schweiger
  5. // All rights reserved
  6. //
  7. // Atlantis.cpp
  8. // Reference implementation of Atlantis (Space Shuttle) vessel
  9. // class module
  10. //
  11. // RMS, grappling and MMU capabilities by Robert Conley
  12. // ==============================================================
  13.  
  14. #define STRICT 1
  15. #define ORBITER_MODULE
  16. #include "Atlantis.h"
  17. #include "PlBayOp.h"
  18. //#include "AscentAP.h"
  19. #include "DlgCtrl.h"
  20. #include "meshres.h"
  21. #include "meshresods.h"
  22. #include "RMS2meshres.h"
  23. #include "meshres_vc_hi.h"
  24. #include "resource.h"
  25. #include <stdio.h>
  26. #include <fstream>
  27. #include <UltraMath.h>
  28. #include <CameraMFD_API.h>
  29. #ifdef _DEBUG
  30. // D. Beachy: for BoundsChecker debugging
  31. extern int GrowStack();
  32. #endif
  33.  
  34. #define LOADBMP(id) (LoadBitmap (g_Param.hDLL, MAKEINTRESOURCE (id)))
  35.  
  36. // ==============================================================
  37. // Global (class-wide) parameters
  38.  
  39. GDIParams g_Param;
  40.  
  41. char *ActionString[5] = {"STOPPED", "ISCLOSED", "ISOPEN", "CLOSE", "OPEN"};
  42.  
  43. HELPCONTEXT g_hc = {
  44. "html/vessels/Atlantis.chm",
  45. 0,
  46. "html/vessels/Atlantis.chm::/Atlantis.hhc",
  47. "html/vessels/Atlantis.chm::/Atlantis.hhk"
  48. };
  49.  
  50.  
  51. // ==============================================================
  52. // Local prototypes
  53.  
  54. BOOL CALLBACK Atlantis_DlgProc (HWND, UINT, WPARAM, LPARAM);
  55. BOOL CALLBACK RMS_DlgProc (HWND, UINT, WPARAM, LPARAM);
  56. BOOL CALLBACK LIGHT_DlgProc(HWND, UINT, WPARAM, LPARAM);
  57. BOOL CALLBACK PAYLOADOPERATION_DlgProc(HWND, UINT, WPARAM, LPARAM);
  58. BOOL CALLBACK EVA_DlgProc(HWND, UINT, WPARAM, LPARAM);
  59. //extern void GetSRB_State (double met, double &thrust_level, double &prop_level);
  60. // 1. vertical lift component (wings and body)
  61.  
  62. int tpir(const double* list, int n_items, double target) {
  63. // char buf[64];
  64. if (target<list[0]) return 0;
  65. if (target >= list[n_items - 1]) return n_items - 2;
  66. // sprintf(oapiDebugString(),"target %f n_items %d ",target,n_items);
  67. for (int i = 1; i<n_items; i++) {
  68. if (i>10) {
  69. // sprintf(buf,"list[%d] %.2f ",i,list[i]);
  70. // strcat(oapiDebugString(),buf);
  71. }
  72. if (list[i] >= target) {
  73. //sprintf(buf,"result %d",i-1);
  74. //strcat(oapiDebugString(),buf);
  75. return i - 1;
  76. }
  77. }
  78. // sprintf(buf,"result %d",-46);
  79. // strcat(oapiDebugString(),buf);
  80. return -46;
  81. }
  82.  
  83. double linterp(double x0, double y0, double x1, double y1, double x) {
  84. double t = (x - x0) / (x1 - x0);
  85. return y0*(1 - t) + y1*t;
  86. }
  87.  
  88. double listerp(const double* listx, const double* listy, int n_items, double x) {
  89. int i = tpir(listx, n_items, x);
  90. // sprintf(oapiDebugString(),"i %d x0 %f y0 %f x1 %f y1 %f x %f",i,listx[i],listy[i],listx[i+1],listy[i+1],x);
  91. return linterp(listx[i], listy[i], listx[i + 1], listy[i + 1], x);
  92. }
  93.  
  94. double tableterp(const double* table, const double* listrow, int n_row, const double* listcol, int n_col, double rowlookup, double collookup) {
  95. int i_row = tpir(listrow, n_row, rowlookup);
  96. double row0 = listerp(listcol, &table[i_row*n_col], n_col, collookup);
  97. double row1 = listerp(listcol, &table[(i_row + 1)*n_col], n_col, collookup);
  98. double t = (rowlookup - listrow[i_row]) / (listrow[i_row + 1] - listrow[i_row]);
  99. double result = row0*(1 - t) + row1*t;
  100. // sprintf(oapiDebugString(),"rowlookup %f collookup %f i_row %d row0 %f row1 %f t %f result %f",rowlookup,collookup,i_row,row0,row1,t,result);
  101. return result;
  102. // return 0;
  103. }
  104.  
  105. const double RollOff = 10 * 47.880259;
  106. const double PitchOff = 40 * 47.880259;
  107. const double YawOff = 1.0;
  108.  
  109. const int n_mach = 21;
  110. const double mach[n_mach] = { 0.25, 0.4, 0.6, 0.8, 0.85, 0.9, 0.92, 0.95, 0.98, 1.05, 1.1, 1.2, 1.3, 1.5, 2, 2.5, 3, 4, 5, 8, 10 };
  111. const int n_aoa1 = 19;
  112. const double aoa1[n_aoa1] = { -10, -5, -2.5, 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, 22.5, 25, 30, 35, 40, 45, 50 };
  113. const double clBase[n_aoa1][n_mach] = { { -0.50280, -0.51097, -0.52957, -0.58454, -0.59773, -0.61005, -0.62831, -0.65514, -0.65616, -0.64808, -0.64225, -0.61158, -0.57681, -0.48844, -0.36885, -0.31514, -0.29383, -0.22874, -0.19854, -0.18641, -0.18641 },
  114. { -0.25906, -0.27397, -0.28670, -0.32761, -0.33790, -0.34601, -0.35039, -0.35897, -0.36172, -0.36027, -0.35685, -0.33449, -0.30454, -0.25188, -0.19695, -0.16705, -0.16922, -0.13893, -0.12424, -0.12402, -0.12402 },
  115. { -0.15202, -0.16199, -0.17186, -0.19155, -0.19632, -0.20588, -0.21553, -0.21485, -0.19888, -0.20310, -0.19292, -0.18275, -0.16776, -0.12989, -0.09888, -0.10456, -0.10514, -0.10050, -0.09081, -0.08913, -0.08913 },
  116. { -0.05000, -0.05000, -0.05500, -0.06500, -0.06200, -0.06000, -0.06000, -0.06000, -0.05500, -0.04700, -0.03600, -0.02500, -0.02300, -0.01500, -0.01700, -0.04290, -0.03700, -0.04430, -0.04724, -0.05540, -0.05540 },
  117. { 0.06214, 0.06212, 0.07201, 0.06176, 0.06652, 0.07101, 0.07563, 0.08498, 0.09414, 0.10315, 0.10796, 0.10460, 0.10295, 0.09317, 0.08416, 0.02995, 0.02048, 0.01111, 0.00642, -0.02023, -0.02023 },
  118. { 0.17453, 0.17448, 0.17928, 0.18859, 0.19295, 0.20356, 0.21579, 0.23947, 0.24762, 0.25552, 0.25513, 0.25014, 0.24043, 0.21606, 0.16125, 0.10468, 0.08600, 0.06174, 0.04301, 0.01774, 0.01774 },
  119. { 0.29705, 0.29691, 0.30657, 0.31963, 0.31838, 0.32413, 0.34997, 0.38783, 0.38955, 0.39173, 0.39121, 0.38627, 0.37178, 0.32805, 0.24173, 0.18906, 0.15609, 0.11881, 0.09656, 0.05965, 0.05965 },
  120. { 0.40448, 0.40924, 0.41674, 0.44384, 0.44172, 0.44572, 0.47690, 0.51887, 0.52899, 0.53602, 0.53054, 0.51767, 0.49146, 0.42874, 0.33103, 0.27135, 0.22528, 0.18185, 0.15220, 0.10604, 0.10604 },
  121. { 0.51599, 0.52757, 0.54905, 0.56480, 0.56566, 0.56794, 0.58585, 0.64660, 0.66026, 0.66393, 0.66357, 0.63927, 0.61835, 0.54671, 0.41958, 0.35229, 0.29513, 0.24730, 0.21351, 0.16115, 0.16115 },
  122. { 0.63581, 0.65002, 0.67426, 0.68162, 0.67309, 0.68323, 0.70567, 0.76535, 0.77783, 0.78377, 0.77863, 0.75952, 0.72567, 0.64381, 0.50777, 0.43483, 0.36604, 0.31897, 0.27892, 0.22632, 0.22632 },
  123. { 0.77676, 0.78385, 0.79709, 0.79087, 0.77995, 0.79401, 0.81577, 0.86501, 0.89069, 0.89596, 0.89086, 0.85608, 0.83073, 0.74311, 0.60244, 0.52033, 0.44227, 0.39229, 0.35079, 0.29998, 0.29998 },
  124. { 0.91657, 0.92529, 0.92851, 0.89578, 0.87690, 0.89485, 0.91619, 0.96428, 0.99805, 1.00286, 1.00255, 0.95636, 0.92538, 0.83834, 0.68871, 0.60168, 0.52215, 0.46559, 0.42351, 0.36492, 0.35587 },
  125. { 1.00634, 1.01512, 1.01007, 0.93184, 0.91266, 0.92074, 0.95994, 1.00227, 1.04837, 1.06699, 1.06660, 1.03541, 1.00114, 0.91858, 0.76904, 0.67886, 0.60751, 0.53159, 0.49654, 0.44356, 0.43474 },
  126. { 1.08364, 1.08846, 1.04489, 0.92283, 0.90795, 0.93837, 0.96751, 1.02232, 1.07579, 1.10328, 1.11188, 1.09985, 1.07176, 0.99205, 0.84561, 0.76551, 0.68386, 0.61884, 0.57019, 0.51805, 0.50936 },
  127. { 1.30045, 1.30623, 1.25395, 1.10747, 1.08961, 1.12612, 1.16109, 1.22686, 1.29103, 1.32402, 1.33434, 1.31990, 1.28619, 1.19054, 0.99835, 0.91867, 0.84307, 0.76946, 0.72044, 0.66845, 0.64465 },
  128. { 1.51313, 1.51986, 1.45902, 1.28858, 1.26781, 1.31028, 1.35097, 1.42751, 1.50217, 1.54055, 1.55256, 1.53576, 1.49654, 1.38524, 1.16162, 1.06891, 0.97219, 0.89530, 0.84607, 0.79881, 0.78382 },
  129. { 1.69584, 1.70339, 1.63520, 1.44418, 1.42090, 1.46850, 1.51411, 1.59988, 1.68356, 1.72658, 1.74004, 1.72121, 1.67725, 1.55251, 1.30189, 1.19799, 1.07919, 1.00341, 0.96129, 0.91017, 0.88400 },
  130. { 1.82367, 1.83178, 1.75845, 1.55304, 1.52800, 1.57919, 1.62823, 1.72047, 1.81045, 1.85672, 1.87119, 1.85095, 1.80367, 1.66953, 1.40002, 1.28828, 1.15575, 1.07904, 1.03683, 0.98747, 0.96803 },
  131. { 1.91170, 1.92021, 1.84334, 1.62801, 1.60176, 1.65542, 1.70683, 1.80353, 1.89785, 1.94635, 1.96152, 1.94030, 1.89074, 1.75012, 1.46761, 1.35047, 1.21154, 1.13113, 1.08629, 1.03514, 1.02007 } };
  132.  
  133. const double cdBase[n_aoa1][n_mach] = { { 0.11485, 0.11975, 0.13521, 0.16897, 0.18654, 0.19703, 0.20867, 0.22925, 0.25227, 0.26933, 0.27358, 0.27477, 0.27037, 0.25326, 0.21167, 0.18859, 0.17640, 0.15782, 0.14843, 0.14122, 0.14122 },
  134. { 0.07985, 0.08119, 0.08489, 0.09953, 0.10785, 0.11831, 0.12552, 0.14223, 0.16817, 0.18470, 0.18942, 0.19259, 0.19067, 0.18445, 0.15837, 0.14100, 0.13105, 0.11936, 0.11165, 0.10501, 0.10501 },
  135. { 0.07170, 0.07263, 0.07517, 0.08323, 0.08675, 0.09887, 0.10710, 0.12269, 0.14461, 0.16251, 0.16647, 0.17013, 0.16958, 0.16572, 0.14245, 0.12598, 0.11599, 0.10538, 0.09795, 0.09067, 0.09067 },
  136. { 0.06740, 0.06610, 0.07020, 0.07630, 0.08000, 0.09070, 0.09900, 0.11450, 0.13460, 0.15410, 0.15840, 0.16140, 0.16110, 0.15770, 0.13490, 0.11860, 0.10680, 0.09430, 0.08760, 0.08000, 0.08000 },
  137. { 0.06687, 0.05747, 0.07011, 0.07557, 0.08048, 0.09309, 0.10180, 0.11702, 0.13644, 0.16935, 0.16376, 0.16502, 0.16395, 0.15852, 0.13500, 0.11632, 0.10399, 0.08937, 0.08226, 0.07359, 0.07359 },
  138. { 0.07038, 0.07096, 0.07350, 0.08175, 0.08916, 0.10574, 0.11515, 0.13127, 0.15286, 0.17724, 0.18173, 0.18139, 0.17763, 0.16938, 0.14189, 0.12068, 0.10700, 0.09063, 0.08096, 0.07142, 0.07140 },
  139. { 0.08056, 0.06145, 0.08464, 0.10038, 0.10990, 0.12750, 0.13806, 0.15696, 0.18221, 0.20398, 0.20794, 0.20709, 0.20226, 0.18364, 0.15579, 0.13301, 0.11677, 0.09815, 0.08634, 0.07402, 0.07348 },
  140. { 0.09599, 0.09775, 0.10146, 0.13088, 0.14389, 0.16155, 0.17477, 0.19588, 0.22487, 0.24256, 0.24485, 0.24298, 0.23613, 0.21755, 0.17850, 0.15244, 0.13324, 0.11238, 0.09853, 0.08216, 0.08059 },
  141. { 0.10625, 0.12444, 0.13381, 0.17827, 0.19090, 0.21031, 0.22196, 0.24823, 0.27902, 0.29479, 0.29645, 0.29055, 0.28325, 0.25989, 0.20958, 0.17951, 0.15649, 0.13380, 0.11760, 0.09780, 0.09544 },
  142. { 0.15784, 0.16278, 0.18832, 0.23803, 0.25555, 0.27066, 0.28350, 0.31191, 0.34859, 0.35909, 0.35895, 0.35301, 0.34037, 0.30958, 0.24932, 0.21476, 0.18711, 0.16342, 0.14482, 0.12245, 0.11931 },
  143. { 0.21346, 0.21758, 0.26637, 0.30939, 0.31973, 0.34168, 0.35577, 0.38252, 0.41746, 0.43401, 0.43355, 0.42081, 0.40809, 0.37008, 0.30079, 0.25990, 0.22679, 0.20107, 0.18106, 0.15697, 0.15302 },
  144. { 0.26859, 0.29389, 0.35519, 0.38857, 0.39759, 0.42137, 0.43584, 0.46452, 0.50331, 0.51932, 0.52016, 0.50090, 0.48367, 0.43922, 0.35911, 0.31286, 0.27582, 0.24672, 0.22523, 0.19614, 0.19178 },
  145. { 0.36651, 0.37144, 0.43592, 0.45493, 0.46003, 0.48172, 0.50467, 0.53313, 0.57864, 0.59902, 0.59994, 0.58377, 0.56200, 0.51308, 0.42462, 0.37380, 0.33639, 0.29758, 0.27765, 0.24878, 0.24394 },
  146. { 0.45537, 0.45790, 0.50401, 0.50538, 0.51675, 0.54316, 0.56348, 0.59974, 0.65071, 0.67457, 0.67979, 0.67010, 0.64751, 0.59368, 0.49836, 0.44700, 0.40275, 0.36614, 0.33893, 0.30876, 0.30372 },
  147. { 0.62879, 0.63228, 0.69595, 0.69784, 0.71354, 0.75001, 0.77807, 0.82814, 0.89852, 0.93146, 0.93867, 0.92529, 0.89410, 0.81977, 0.67501, 0.61723, 0.56977, 0.52265, 0.49216, 0.45821, 0.44343 },
  148. { 0.85388, 0.85863, 0.94509, 0.94766, 0.96898, 1.01850, 1.05660, 1.12460, 1.22017, 1.26491, 1.27470, 1.25653, 1.21417, 1.11323, 0.91665, 0.83819, 0.76478, 0.70975, 0.67287, 0.63575, 0.62404 },
  149. { 1.11596, 1.12216, 1.23516, 1.23852, 1.26638, 1.33111, 1.38090, 1.46976, 1.59467, 1.65315, 1.66594, 1.64219, 1.58683, 1.45491, 1.19800, 1.09545, 0.99301, 0.92759, 0.89082, 0.84440, 0.82113 },
  150. { 1.40622, 1.41403, 1.55642, 1.56065, 1.59576, 1.67732, 1.74007, 1.85204, 2.00944, 2.08312, 2.09924, 2.06932, 1.99956, 1.83333, 1.50959, 1.38037, 1.24741, 1.16885, 1.12550, 1.07445, 1.05430 },
  151. { 1.74092, 1.75059, 1.92688, 1.93211, 1.97558, 2.07655, 2.15424, 2.29286, 2.48772, 2.57894, 2.59890, 2.56185, 2.47549, 2.26969, 1.86890, 1.70892, 1.54432, 1.44706, 1.38996, 1.33019, 1.31104 } };
  152.  
  153. const double cmBase[n_aoa1][n_mach] = { { 0.03200, 0.03400, 0.04000, 0.05900, 0.06800, 0.09000, 0.10100, 0.12600, 0.14000, 0.15800, 0.16250, 0.16200, 0.14800, 0.01300, 0.04200, 0.00450, -0.01800, -0.02940, -0.03370, -0.03500, -0.03500 },
  154. { 0.03000, 0.03200, 0.03650, 0.04900, 0.05400, 0.06100, 0.06700, 0.08200, 0.09800, 0.11400, 0.11800, 0.11200, 0.09200, 0.06000, 0.01750, -0.00800, -0.01800, -0.02700, -0.03070, -0.03280, -0.03280 },
  155. { 0.02900, 0.03050, 0.03470, 0.04450, 0.04700, 0.04500, 0.05300, 0.06200, 0.07800, 0.08400, 0.08200, 0.07200, 0.05800, 0.03700, 0.00800, -0.01144, -0.01850, -0.02550, -0.02800, -0.03000, -0.03000 },
  156. { 0.02800, 0.29000, 0.03300, 0.04000, 0.04000, 0.03500, 0.03800, 0.04200, 0.05500, 0.05500, 0.04700, 0.03400, 0.02500, 0.01400, -0.01300, -0.01480, -0.01900, -0.02310, -0.02400, -0.02700, -0.02700 },
  157. { 0.02700, 0.02750, 0.03050, 0.03600, 0.03800, 0.03500, 0.02200, 0.02000, 0.03100, 0.02400, 0.01500, 0.00600, -0.00100, -0.00700, -0.01300, -0.01940, -0.01970, -0.02100, -0.02200, -0.02350, -0.02350 },
  158. { 0.02600, 0.02600, 0.02800, 0.03150, 0.03200, 0.02250, 0.01600, 0.00000, 0.00500, -0.00300, -0.01050, -0.02000, -0.02350, -0.02500, -0.02380, -0.02300, -0.02050, -0.01880, -0.02000, -0.01900, -0.01900 },
  159. { 0.02400, 0.02400, 0.02400, 0.02250, 0.02200, 0.02000, 0.01200, -0.01600, -0.01500, -0.02200, -0.02900, -0.04000, -0.04400, -0.04100, -0.03360, -0.02480, -0.02150, -0.01820, -0.01810, -0.01560, -0.01550 },
  160. { 0.02300, 0.02200, 0.02050, 0.01800, 0.01700, 0.01500, 0.00400, -0.02700, -0.03000, -0.03400, -0.04000, -0.05400, -0.06000, -0.05500, -0.03850, -0.02740, -0.02250, -0.01830, -0.01660, -0.01250, -0.01200 },
  161. { 0.02300, 0.02250, 0.02100, 0.01700, 0.01200, 0.00750, -0.00600, -0.04000, -0.04200, -0.04500, -0.04900, -0.06100, -0.07200, -0.07000, -0.04300, -0.03100, -0.02400, -0.01910, -0.01560, -0.00990, -0.00970 },
  162. { 0.02400, 0.02200, 0.01600, 0.00600, 0.00050, -0.00250, -0.01800, -0.05000, -0.05200, -0.05800, -0.06200, -0.07200, -0.08300, -0.08200, -0.04720, -0.03510, -0.02700, -0.02010, -0.01520, -0.00725, -0.00780 },
  163. { 0.01900, 0.01600, 0.00900, -0.00600, -0.01100, -0.01000, -0.02800, -0.05650, -0.06300, -0.07000, -0.07400, -0.08200, -0.09000, -0.09100, -0.05160, -0.03950, -0.03000, -0.02150, -0.01510, -0.00493, -0.00600 },
  164. { 0.01400, 0.00800, -0.00400, -0.00500, -0.01000, -0.00300, -0.03000, -0.06000, -0.07200, -0.07700, -0.08100, -0.08800, -0.09300, -0.09700, -0.05810, -0.04400, -0.03400, -0.02310, -0.01550, -0.00300, -0.00600 },
  165. { 0.01050, 0.01000, 0.00600, 0.00260, 0.02000, 0.02000, -0.01200, -0.03500, -0.04700, -0.06100, -0.06800, -0.08000, -0.09100, -0.09500, -0.06150, -0.05000, -0.03700, -0.02350, -0.01700, -0.00400, -0.00620 },
  166. { 0.10000, 0.01200, 0.03300, 0.08000, 0.09000, 0.09000, 0.08700, 0.07000, 0.02000, -0.02300, -0.04200, -0.06400, -0.07700, -0.08200, -0.06490, -0.05530, -0.04200, -0.02780, -0.01840, -0.00590, -0.00800 },
  167. { 0.12007, 0.01441, 0.03962, 0.09606, 0.10807, 0.10807, 0.10446, 0.08405, 0.02401, -0.02762, -0.05043, -0.07685, -0.09246, -0.09846, -0.05180, -0.06640, -0.05400, -0.03720, -0.02700, -0.01350, -0.01500 },
  168. { 0.15655, 0.01879, 0.05166, 0.12524, 0.14089, 0.14089, 0.13619, 0.10958, 0.03131, -0.03601, -0.06575, -0.10019, -0.12054, -0.12837, -0.06753, -0.08657, -0.06600, -0.04850, -0.03940, -0.02570, -0.02600 },
  169. { 0.19818, 0.02378, 0.06540, 0.15855, 0.17837, 0.17837, 0.17242, 0.13873, 0.03964, -0.04558, -0.08324, -0.12684, -0.15260, -0.16251, -0.08550, -0.10960, -0.08300, -0.06140, -0.05300, -0.04290, -0.04100 },
  170. { 0.24466, 0.02936, 0.08074, 0.19573, 0.22020, 0.22020, 0.21286, 0.17126, 0.04893, -0.05627, -0.10276, -0.15658, -0.18839, -0.20062, -0.10555, -0.13530, -0.10000, -0.07580, -0.06750, -0.06150, -0.06100 },
  171. { 0.32582, 0.03910, 0.10752, 0.26066, 0.29324, 0.29324, 0.28346, 0.22807, 0.06516, -0.07494, -0.13684, -0.20852, -0.25088, -0.26717, -0.14056, -0.18018, -0.13317, -0.10094, -0.08330, -0.08190, -0.08200 } };
  172.  
  173. const int n_trimExt = 3;
  174. const double trimExt[n_trimExt] = { -11.7, 0, 22.5 };
  175. const double cmTrim[n_trimExt][n_mach] = { { 0.0158, 0.016, 0.0179, 0.0204, 0.020165, 0.01993, 0.020866, 0.02149, 0.01803, 0.01574, 0.0136, 0.0148, 0.01141, 0.00981, 0.00578, 0.004215, 0.00265, 0.00603, 0.00791, 0.012, 0.015 },
  176. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  177. { -0.0424, -0.0442, -0.0488, -0.05562, -0.0559, -0.05618, -0.058004, -0.05922, -0.05222, -0.05241, -0.04894, -0.04195, -0.03722, -0.02979, -0.02112, -0.016505, -0.01189, -0.0328, -0.0442, -0.061, -0.065 } };
  178.  
  179. const double OrbiterS = 2690 * 0.3048*0.3048;
  180. const double Orbiterb = 78.056*0.3048; //Turns out span is not used...
  181. const double Orbiterc = 39.56*0.3048; //...but chord is
  182. const double OrbiterA = Orbiterb*Orbiterb / OrbiterS; //Has to be passed, doesn't have to be correct
  183. void FlatPlateCoeff(double aoa, double *cl, double *cm, double *cd) {
  184. *cl = 1.2*sin(aoa * 2);
  185. *cd = 2 * sin(aoa);
  186. *cm = 0;
  187. }
  188.  
  189. /*
  190. void VLiftCoeff (VESSEL *v, double aoa, double M, double Re, void* lv, double *cl, double *cm, double *cd) {
  191. if(M<mach[0])M=mach[0];
  192. if(M>mach[n_mach-1])M=mach[n_mach-1];
  193. static const int nabsc=11;
  194. static const double cmAoA[nabsc]={ -75.0, -60.0, -45.0, -30.0, -15.0, 0.0, 15.0, 30.0, 45.0, 60.0, 75.0 };
  195. static const double CM[nabsc] = { 0, 0, 0.002, 0.004, 0.0025,0.0012, 0,-0.0012,-0.0007, 0, 0};
  196. double bfDeploy=-22.5*v->GetControlSurfaceLevel(AIRCTRL_ELEVATORTRIM); //In data book, aft end of body flap up
  197. //"up trim" is negative. In Orbiter, this is positive.
  198. if(aoa*180.0/PI<aoa1[0] || aoa*180.0/PI>aoa1[n_aoa1-1]) {
  199. FlatPlateCoeff(aoa,cl,cm,cd);
  200. sprintf(oapiDebugString(),"FlatPlate AoA: %f Cl: %f Cd: %f Cm: %f",aoa*180.0/PI,*cl,*cd,*cm);
  201. } else {
  202. *cl=tableterp(&clBase[0][0], aoa1, n_aoa1, mach, n_mach, aoa*180.0/PI,M);
  203. *cd=tableterp(&cdBase[0][0], aoa1, n_aoa1, mach, n_mach, aoa*180.0/PI,M);
  204. *cm=listerp(cmAoA,CM,nabsc,aoa);
  205. // *cm=tableterp(&cmBase[0][0], aoa1, n_aoa1, mach, n_mach, aoa*180.0/PI,M);
  206. // *cm+=tableterp(&cmTrim[0][0], trimExt, n_trimExt, mach, n_mach, bfDeploy,M);
  207. sprintf(oapiDebugString(),"TableM: %f TableAoA: %f Cl: %f Cd: %f Cm: %f bf: %f",M,aoa*180.0/PI,*cl,*cd,*cm,bfDeploy);
  208. }
  209. }
  210. */
  211. void VLiftCoeff(VESSEL* vv, double aoa, double M, double Re, void* stuff, double *cl, double *cm, double *cd){
  212. Atlantis* v = (Atlantis*)vv;
  213. if (M<mach[0])M = mach[0];
  214. if (M>mach[n_mach - 1])M = mach[n_mach - 1];
  215. double Tablecl = tableterp(&clBase[0][0], aoa1, n_aoa1, mach, n_mach, aoa*180.0 / PI, M);
  216. double Tablecd = tableterp(&cdBase[0][0], aoa1, n_aoa1, mach, n_mach, aoa*180.0 / PI, M);
  217. static const double step = RAD*15.0;
  218. static const double istep = 1.0 / step;
  219. static const int nabsc = 25;
  220. // -180 -165 -150 -135 -120 -105 -90 -75.0 -60.0 -45.0 -30.0 -15.0 0.0 15.0 30.0 45.0 60.0 75.0 90.0 105.0 120.0 135.0 150.0 165.0 180.0
  221. static const double CL[nabsc] = { 0.1, 0.17, 0.2, 0.2, 0.17, 0.1, 0, -0.11, -0.24, -0.38, -0.5, -0.5, -0.02, 0.6355, 0.63, 0.46, 0.28, 0.13, 0.0, -0.16, -0.26, -0.29, -0.24, -0.1, 0.1 };
  222. static const double CM[nabsc] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.002, 0.004, 0.0025, 0.0012, 0, -0.0012, -0.0007, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  223. // lift and moment coefficients from -180 to 180 in 15 degree steps.
  224. // This uses a documented lift slope of 0.0437/deg, everything else is rather ad-hoc
  225.  
  226. // change for drag increase at high Mach:
  227. // Subsonic Equivalents
  228.  
  229. double Cl0, Cl1, Cd0, Cd1, Cd2;
  230. if (M >= 5.0) {
  231. Cl0 = -0.207040;
  232. Cl1 = 1.675600;
  233. Cd0 = 0.078540;
  234. // Cd1 = -0.352900;
  235. // Cd2 = 2.039960;
  236.  
  237. // at 40 deg Alpha, Cd = .078540 - .24637 + .994252 = .826422 Cl = .96275
  238. // want to reduce it 15%
  239. // at 25 deg, it's ok (Cd = .3129)
  240. // then, Cd1p = (.1142-.1904*(Cd40p - Cd0))/.0798
  241. // Cd2p = (.2344-.4363*Cd1p)/.1904
  242. // Cl1p = (Cl40p-.5241)/.2618
  243. // Cl0p = .5241 - Cl1p*.4363
  244.  
  245. // Cd40p = .7025 (Baseline -15%)
  246.  
  247. Cd1 = -0.05767;
  248. Cd2 = 1.3632;
  249.  
  250. // add 5% (Cd40p = .86774)
  251.  
  252. // Cd1 = -0.4519;
  253. // Cd2 = 2.2666;
  254.  
  255. *cl = Cl0 + Cl1*aoa;
  256. *cd = Cd0 + Cd1*aoa + Cd2*aoa* aoa;
  257.  
  258. }
  259. int idx = max(0, min(23, (int)((aoa + PI)*istep)));
  260. double d = (aoa + PI)*istep - idx;
  261. *cm = (CM[idx] + (CM[idx + 1] - CM[idx])*d);
  262. if (M<1.25) {
  263. *cl = CL[idx] + (CL[idx + 1] - CL[idx])*d;
  264. // *cd = 0.05 + oapiGetInducedDrag (*cl, 2.266, 0.75);
  265. *cd = 0.05 + oapiGetInducedDrag(*cl, 2.266, 0.75);
  266. }
  267. else if (M<5.0) {
  268. *cl = CL[idx] + (CL[idx + 1] - CL[idx])*d;
  269. // *cd = 0.09 + oapiGetInducedDrag (*cl, 2.266, 0.5);
  270. *cd = 0.09 + oapiGetInducedDrag(*cl, 2.266, 0.75);
  271.  
  272. }
  273. // sprintf(oapiDebugString(),"P%d Y%d R%d TableM: %f TableAoA: %f Table Cl: %f AFCS Cl: %f Table Cd: %f AFCS Cd: %f",v->PitchActive,v->YawActive,v->RollActive,M,aoa*180.0/PI,Tablecl,*cl,Tablecd,*cd);
  274. *cl = Tablecl;
  275. *cd = Tablecd;
  276. // *cm=tableterp(&cmBase[0][0], aoa1, n_aoa1, mach, n_mach, aoa*180.0/PI,M);
  277. // *cm+=tableterp(&cmTrim[0][0], trimExt, n_trimExt, mach, n_mach, bfDeploy,M);
  278. }
  279.  
  280.  
  281. // 2. horizontal lift component (vertical stabiliser and body)
  282.  
  283. void HLiftCoeff(double beta, double M, double Re, double *cl, double *cm, double *cd)
  284. {
  285. static const double step = RAD*22.5;
  286. static const double istep = 1.0 / step;
  287. static const int nabsc = 17;
  288. static const double CL[nabsc] = { 0, 0.2, 0.3, 0.2, 0, -0.2, -0.3, -0.2, 0, 0.2, 0.3, 0.2, 0, -0.2, -0.3, -0.2, 0 };
  289.  
  290. beta += PI;
  291. int idx = max(0, min(15, (int)(beta*istep)));
  292. double d = beta*istep - idx;
  293. *cl = CL[idx] + (CL[idx + 1] - CL[idx])*d;
  294. *cm = 0.0;
  295. *cd = 0.02 + oapiGetInducedDrag(*cl, 1.5, 0.6);
  296. }
  297.  
  298. // ==============================================================
  299. // Specialised vessel class Atlantis
  300. // ==============================================================
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307. // --------------------------------------------------------------
  308. // Constructor
  309. // --------------------------------------------------------------
  310. Atlantis::Atlantis(OBJHANDLE hObj, int fmodel)
  311. : VESSEL4(hObj, fmodel)
  312. {
  313. #ifdef _DEBUG
  314. // D. Beachy: for BoundsChecker debugging
  315. GrowStack();
  316. #endif
  317. int i;
  318.  
  319. plop = new PayloadBayOp(this);
  320. // ascap = new AscentAP (this);
  321. // ascapMfdId = RegisterAscentApMfd ();
  322. status = 3;
  323. gear_status = AnimState::CLOSED;
  324. gear_proc = 0.0;
  325. ldoor_drag = rdoor_drag = 0.0;
  326. spdb_status = AnimState::CLOSED;
  327. spdb_proc = 0.0;
  328. //light
  329. flood1_status = 0;
  330. flood2_status = 0;
  331. flood3_status = 0;
  332. flood4_status = 0;
  333. flood5_status = 0;
  334. flood6_status = 0;
  335. floodon = 0;
  336. aft_light_status = 0;
  337. rmslight_status = 0;
  338. docklight_status = 0;
  339. Shuttlechutereleased = 0;
  340. wheelbrake = 0;
  341. spintable = 0;
  342. spintable1 = 0;
  343. spintable4 = 0;
  344. spintable5 = 0;
  345. rotchange = 0;
  346. rotchange1 = 0;
  347. rotchange4 = 0;
  348. rotchange5 = 0;
  349.  
  350. //met
  351. GMTmode = 0;
  352. Testmode = 0;
  353. METmode = 1;
  354. FGMTmode = 0;
  355. FTestmode = 0;
  356. FMETmode = 1;
  357. MET = 0;
  358. switchtimer = 0;
  359. AFTtimer_state[0] = 0;
  360. AFTtimer_state[1] = 0;
  361. AFTtimer_state[2] = 0;
  362. AFTtimer_state[3] = 0;
  363. AFTtimer_state[4] = 0;
  364. AFTtimer_state[5] = 0;
  365. AFTtimer_state[6] = 0;
  366. AFTtimer_state[7] = 0;
  367. AFTtimer_state[8] = 0;
  368. Ftimer_state[0] = 0;
  369. Ftimer_state[1] = 0;
  370. Ftimer_state[2] = 0;
  371. Ftimer_state[3] = 0;
  372. Ftimer_state[4] = 0;
  373. Ftimer_state[5] = 0;
  374. Ftimer_state[6] = 0;
  375. Ftimer_state[7] = 0;
  376. Ftimer_state[8] = 0;
  377. //etimer
  378. time = 0;
  379. clk = 0.0;
  380. Etimer_state[0] = 0;
  381. Etimer_state[1] = 0;
  382. Etimer_state[2] = 0;
  383. Etimer_state[3] = 0;
  384. TimerStart = 0;
  385. up = false;
  386. ETest = 0;
  387. TimerReset = 0;
  388. Minutes2set = 0;
  389. Minutes1set = 0;
  390. Minutes4set = 0;
  391. Minutes3set = 0;
  392. FRONTMINUTE2_proc = 0;
  393. FRONTMINUTE1_proc = 0;
  394. FRONTSECOND2_proc = 0;
  395. FRONTSECOND1_proc = 0;
  396. //
  397. timeAFT = 0;
  398. clkAFT = 0.0;
  399. EtimerAFT_state[0] = 0;
  400. EtimerAFT_state[1] = 0;
  401. EtimerAFT_state[2] = 0;
  402. EtimerAFT_state[3] = 0;
  403. TimerStartAFT = 0;
  404. upAFT = false;
  405. ETestAFT = 0;
  406. TimerResetAFT = 0;
  407. Minutes2setAFT = 0;
  408. Minutes1setAFT = 0;
  409. Minutes4setAFT = 0;
  410. Minutes3setAFT = 0;
  411. AFTMINUTE2_proc = 0;
  412. AFTMINUTE1_proc = 0;
  413. AFTSECOND2_proc = 0;
  414. AFTSECOND1_proc = 0;
  415. A2Test = 0;
  416. PANELa2pwr = 1;//pwr is on
  417. currentHudMode = 0;
  418. //
  419. engine_light_level = 0.0;
  420. COLOUR4 col_diff = {1,0.8,0.8,0};
  421. COLOUR4 col_zero = {0,0,0,0};
  422. //engine_light = AddPointLight (_V(0,0,-25), 300, 2e-4, 0, 4e-4, col_diff, col_zero, col_zero);
  423. //engine_light->SetIntensityRef (&engine_light_level);
  424. ARM_OPERATING_SPEED = .005;
  425. OV = 103;
  426. LoadMeshes();
  427. reset_sat = false;
  428. render_cockpit = false;
  429. rmsspeed = 5;
  430. //for (i = 0; i < 6; i++)
  431. // mfdbright[i] = 1.0;
  432.  
  433. // propellant resources
  434. ph_oms = CreatePropellantResource (ORBITER_MAX_PROPELLANT_MASS); // OMS propellant
  435. SetDefaultPropellantResource (ph_oms); // display OMS tank level in generic HUD
  436.  
  437. // Orbiter engines
  438. CreateSSME(); // main thrusters
  439. CreateOMS(); // OMS thrusters (activated only after tank separation)
  440. CreateRCS(); // Reaction control system (activated only after tank separation)
  441.  
  442. // Animations
  443. DefineAnimations();
  444.  
  445. // Aerodynamics
  446. CreateAirfoils();
  447.  
  448. //hDockODS = CreateDock(ORBITER_DOCKPOS, _V(0, 1, 0), _V(0, 0, -1)); //dock for ods
  449. // CreateDock(_V(0.0, -.8, 10.5), _V(0, 1, 0), _V(0, 0, -1));
  450. // hDockET = CreateDock (_V(0.0,-2.48, 8.615), _V(0,-1,0), _V(0,0,1));
  451. //dock for eva
  452. //pET = NULL; // ET reference
  453.  
  454. center_arm = false;
  455. arm_moved = arm_scheduled = armOBSS_moved =false;
  456. //bManualSeparate = false;
  457.  
  458. // do_eva = false;
  459. do_plat = false;
  460. do_cargostatic = false;
  461. vis = NULL;
  462. cargo_static_ofs =_V(0,0,0);
  463. //
  464. spbrkx = 0;
  465. EXT_proc = 0;
  466. ORIGINAL = 0;
  467. MIDMODEL = 0;
  468. EVA1 = 0;
  469. EVA2 = 0;
  470. EVA3 = 0;
  471. EVA4 = 0;
  472. NOKU = 0;
  473. NOWIRE = 0;
  474. GRAB = 0;
  475. distattach = 0;
  476. geararmed = 0;
  477. EXT_status = HATCH_UP;
  478. OBSS_status = HATCH_UP;
  479. DOCKRING_status = HATCH_UP;
  480. DOCKRING_proc = 0;
  481. Armtilt_status = HATCH_UP;
  482. Armtilt_proc = 0;
  483. CHUTE_status = HATCH_DOWN;
  484. CHUTE_proc = 1;
  485. OBSS_proc = 0;
  486. DRAGCHUTEDEPLOYED = 0;
  487. ODS = 0;
  488. EXTAIRLOCK = 0;
  489. SETD_status = HATCH_UP;
  490. PETD_status = HATCH_UP;
  491. SETD_proc = 0;
  492. PETD_proc = 0;
  493. ssmestow_status = HATCH_UP;
  494. ssmestow_proc = 0;
  495. ADTA_status = HATCH_UP;
  496. ADTA_proc = 0;
  497. IUS_check = IUS_STOP;
  498. ius_proc = 0;
  499. mfd1pwr = 0;
  500. mfd2pwr = 0;
  501. mfdApwr = 0;
  502. mfd0pwr = 0;
  503. firstStep = true;
  504. // default arm status: stowed
  505. rmsspeed = 0;
  506. arm_sy = 0.5;
  507. arm_sp = 0.0;
  508. arm_ep = 0.0;
  509. arm_wp = 0.5;
  510. arm_wy = 0.5;
  511. arm_wr = 0.5;
  512. spdb_on = 0;
  513. spdb_off = 0;
  514. spdb_plus = 0;
  515. spdb_minus = 0;
  516. RMSSELECT = 0;
  517. storerms = 0;
  518. recallstored = 0;
  519. rmsexecute = 0;
  520. RMSDIALOG = 0;
  521. //ku
  522. elevation = 0;
  523.  
  524.  
  525. //
  526. //
  527. //scn read if payload mass is used or not set to zero
  528. PMASS0 = 0;
  529. PMASS1 = 0;
  530. PMASS2 = 0;
  531. PMASS3 = 0;
  532. //VCCAM
  533. VCCAM = 0;
  534. KURATE = 0;
  535. KUAZ = 0;
  536. KUEL = 0;
  537. //payload mass set to 0
  538. MASS1 = 0.0;
  539. MASS2 = 0.0;
  540. MASS3 = 0.0;
  541. MASS0 = 0.0;
  542. //new
  543. ft_pad_att_pos = _V(0, 0.7, 11.321);
  544. ft_pad_att1_pos = _V(0, 0.7, 11.321);
  545. ft_pad_att2_pos = _V(0, 0.7, 11.321);
  546. ft_pad_att3_pos = _V(0, 0.7, 11.321);
  547.  
  548. ft_pad_att_dir = _V(0, 1, 0);// _V(0, 1, 0), _V(0, 0, -1),
  549. ft_pad_att1_dir = _V(0, 1, 0);
  550. ft_pad_att2_dir = _V(0, 1, 0);
  551. ft_pad_att3_dir = _V(0, 1, 0);
  552.  
  553. ft_pad_att_rot = _V(0, 0, -1);
  554. ft_pad_att1_rot = _V(0, 0, -1);
  555. ft_pad_att2_rot = _V(0, 0, -1);
  556. ft_pad_att3_rot = _V(0, 0, -1);
  557.  
  558. //rms new
  559. arm1_Bp = arm2_Bp = arm3_Bp = arm4_Bp = arm6_Bp = 0.0;
  560. arm1_By = arm2_By = arm3_By = arm4_By = 0.0;
  561. arm1_ep = arm2_ep = arm3_ep = arm4_ep = arm6_ep = 0.0;
  562. arm1_Ar = arm2_Ar = arm3_Ar = arm4_Ar = 0.0;
  563. arm1_Ap = arm2_Ap = arm3_Ap = arm4_Ap = 0.0;
  564. arm1_Ay = arm2_Ay = arm3_Ay = arm4_Ay = 0.0;
  565. systart = .5;
  566. spstart = 0.0136;
  567. epstart = 0.0123;
  568. wrstart = .6;
  569. wystart = .5;
  570. wpstart = .5;
  571. arm6_By = .5;
  572. arm6_Ap = 0.5;
  573. arm6_Ar = 0.5;
  574. arm6_Ay = 0.5;
  575. Seqindex = 0;
  576.  
  577. update_vectors = true;
  578. //arm_tip[0] = _V(-2.26,1.71,-6.5);
  579. //arm_tip[1] = _V(-2.26,1.71,-7.5);
  580. //arm_tip[2] = _V(-2.26,2.71,-6.5);
  581.  
  582. arm_tip[0] = RMS_EE_POS;
  583. arm_tip[1] = RMS_EE_POS + _V(0.0, 0.0, -1.0); // to calculate EE attachment direction (-Z coordinate of attachment point is negative, so subtract 1 here)
  584. arm_tip[2] = RMS_EE_POS + RMS_Z_AXIS; // to calculate rot vector for attachment
  585. //arm_tip[3] = RMS_EE_POS + RotateVectorZ(_V(0.0, -1.0, 0.0), RMS_ROLLOUT_ANGLE); // to calculate arm_ee_rot (rot vector in IK frame)
  586. arm_tip[3] = RMS_EE_CAM_POS; // to calculate EE camera position
  587. arm_tip[4] = RMS_EE_LIGHT_POS;
  588. arm_tip[5] = RMS_ELBOW_CAM_POS;
  589.  
  590. //RMS elbow camera
  591. camRMSElbowLoc[0] = RMS_ELBOW_CAM_POS;
  592. camRMSElbowLoc[1] = camRMSElbowLoc[0] + _V(0, 0, -1);
  593. camRMSElbowLoc[2] = camRMSElbowLoc[0] + RMS_ELBOW_CAM_AXIS;
  594.  
  595. armobss_tip[0] = OBSS_POS;
  596. armobss_tip[1] = OBSS_POS + _V(0.0, 1.0, 0.0);
  597. armobss_tip[2] = OBSS_POS + _V(0.0, 0.0, 1.0);
  598.  
  599. arm_ius[0] = pl1_ofs;
  600. arm_ius[1] = pl1_ofs + _V(0.0, 0.0, 1.0);
  601. arm_ius[2] = pl1_ofs + _V(1.0, 0.0, 0.0);
  602.  
  603.  
  604. stow_time = 0;
  605. //RMSDIALOG = 3;
  606. //dockpos = _V(0.0, 2.40, 10.15);
  607. ringpos = _V(0.0, 2.259, 10.141);
  608. olddockpos = 2.0;
  609. SPIN0 = 0;
  610. //USEIUS
  611. USEIUS = 0;
  612. NOSLIDEWIRE = 0;
  613. tiltvalue = 10;
  614. tilt = 0;
  615. spintable_vel = 0;
  616. spintable_phi = 0;
  617. // Entry particle stream
  618. PARTICLESTREAMSPEC rps = {
  619. 0, 20, 20, 0, 0.03, 0.5, 100, 3, PARTICLESTREAMSPEC::DIFFUSE,
  620. PARTICLESTREAMSPEC::LVL_FLAT, 1, 1, PARTICLESTREAMSPEC::ATM_PLIN, 6e7, 12e7
  621. };
  622. AddReentryStream (&rps);
  623. vccameracase = 4;
  624. //CAMERA
  625. PBCAMERA = 0;
  626. MAX_PLB_CAM_PAN = 65;
  627. MAX_PLB_CAM_TILT = 170;
  628. CAMRATE = .1;
  629. a = 0.0;
  630. b = 0.0;
  631. c = 0.0;
  632. for (int i = 0; i < 4; i++) {
  633. camYaw[i] = 0;
  634. camPitch[i] = 0;
  635. }
  636.  
  637.  
  638. camera_moved = false;
  639.  
  640. //eva
  641. CREW1 = 0;
  642. CREW2 = 0;
  643. CREW3 = 0;
  644. CREW4 = 0;
  645. strcpy(crew2_name, "Eva_2");
  646. strcpy(crew2_cfg, "SHUTTLEEVA2");
  647. strcpy(crew1_name, "Eva_1");
  648. strcpy(crew1_cfg, "SHUTTLEEVA1");
  649. strcpy(crew3_name, "Eva_3");
  650. strcpy(crew3_cfg, "SHUTTLEEVA3");
  651. strcpy(crew4_name, "Eva_4");
  652. strcpy(crew4_cfg, "SHUTTLEEVA4");
  653.  
  654. //ascentApDlg = 0;
  655. cameraMFD[0] = cameraMFD[1] = cameraMFD[2] = nullptr;
  656.  
  657.  
  658. // oapi::Font* font1 = oapiCreateFont(50, true, "*Seven Segment");
  659. // oapi::Font* font2 = oapiCreateFont(40, true, "*Seven Segment");
  660. // oapi::Font* font3 = oapiCreateFont(-11, true, "Arial");
  661.  
  662. //gBlackBrush = oapiCreateBrush(0x000000);
  663. }
  664.  
  665. // --------------------------------------------------------------
  666. // Destructor
  667. // --------------------------------------------------------------
  668. Atlantis::~Atlantis ()
  669. {
  670. // UnregisterMFDMode (ascapMfdId);
  671. // if (ascentApDlg) delete ascentApDlg;
  672. // delete ascap;
  673. delete plop;
  674. int i;
  675. for (i = 0; i < 6; i++) delete rms_anim[i];
  676.  
  677. }
  678. void Atlantis::SelectCockpitView(int CAM)
  679. {
  680. /* if (CAM == 0) {
  681.  
  682. SetCameraDefaultDirection(_V(0, 0, 1));
  683. SetCameraOffset(_V(-0.67, 2.55, 14.4));
  684. oapiCameraSetCockpitDir(0, 0);
  685. }
  686. if (CAM == 1) {
  687.  
  688. SetCameraDefaultDirection(_V(0, 0, -1));
  689. SetCameraOffset(_V(-1.850, 1.8, 11.750));
  690. oapiCameraSetCockpitDir(0, 0);
  691. }
  692. if (CAM == 2){
  693. SetCameraDefaultDirection(_V(0, 0, 1));
  694. SetCameraOffset(_V(-2.2, 1.8, -6.250));
  695. oapiCameraSetCockpitDir(0, 0);
  696. };
  697. if (CAM == 3){
  698. SetCameraDefaultDirection(_V(0, 0, 1));
  699. SetCameraOffset(_V(2.2, 1.8, -6.250));
  700. oapiCameraSetCockpitDir(0, 0);
  701. };
  702. if (CAM == 4){
  703. SetCameraDefaultDirection(_V(0, 0, -1));
  704. SetCameraOffset(_V(1.850, 1.8, 11.750));
  705. oapiCameraSetCockpitDir(0, 0);
  706. };
  707.  
  708. if (CAM == 5){
  709. SetCameraDefaultDirection(_V(0, 1, 0));
  710. SetCameraOffset(KEELCAM);
  711. oapiCameraSetCockpitDir(0, 0);
  712. };
  713. if (CAM == 8){
  714.  
  715. SetCameraDefaultDirection(_V(0, 1, 0));
  716. SetCameraOffset(_V(0, 1.27, 10.138));
  717. // sprintf(oapiDebugString(), "armtip3x %2.2f armtip3y %2.2f armtip3z %2.2f", arm_tip[5].x, arm_tip[5].y, arm_tip[5].z);
  718.  
  719. oapiCameraSetCockpitDir(0, 0);
  720. }
  721. /*
  722. if (CAM == 6){
  723.  
  724. VECTOR3 dir = camRMSElbowLoc[1] - camRMSElbowLoc[0];
  725. if (Eq(dotp(dir, _V(0, -1, 0)), 1.0, 1e-4)) dir = _V(1.74532924314e-4, -0.999999984769, 0.0);
  726. else if (Eq(dotp(dir, _V(0, 1, 0)), 1.0, 1e-4)) dir = _V(1.74532924314e-4, 0.999999984769, 0.0);
  727. VECTOR3 orbiter_cam_rot = crossp(crossp(dir, _V(0, 1, 0)), dir);
  728. orbiter_cam_rot /= length(orbiter_cam_rot);
  729. if (orbiter_cam_rot.y < 0) orbiter_cam_rot = -orbiter_cam_rot;
  730. double angle = SignedAngle(orbiter_cam_rot, camRMSElbowLoc[2] - camRMSElbowLoc[0], dir);
  731. SetCameraDefaultDirection(dir, angle);
  732. SetCameraOffset(camRMSElbowLoc[0]);
  733. oapiCameraSetCockpitDir(0.0, 0.0);
  734. }
  735. if (CAM == 7){ //ee view
  736. // calculate rotation angle for EE cam
  737. VECTOR3 dir = arm_tip[1] - arm_tip[0];
  738. // if camera is pointing straight up or down, make it slightly offset from (0,1,0) vector
  739. if (Eq(dotp(dir, _V(0, -1, 0)), 1.0, 1e-4)) dir = _V(1.74532924314e-4, -0.999999984769, 0.0);
  740. else if (Eq(dotp(dir, _V(0, 1, 0)), 1.0, 1e-4)) dir = _V(1.74532924314e-4, 0.999999984769, 0.0);
  741. VECTOR3 orbiter_cam_rot = crossp(crossp(dir, _V(0, 1, 0)), dir);
  742. orbiter_cam_rot /= length(orbiter_cam_rot);
  743. if (orbiter_cam_rot.y < 0) orbiter_cam_rot = -orbiter_cam_rot;
  744. double angle = SignedAngle(orbiter_cam_rot, arm_tip[2] - arm_tip[0], dir);
  745.  
  746. //sprintf_s(oapiDebugString(), 255, "Rot Vec: %f %f %f dir: %f %f %f dot_prod: %f Angle: %f %f", orbiter_cam_rot.x, orbiter_cam_rot.y, orbiter_cam_rot.z, dir.x, dir.y, dir.z, dot_prod, angle, angle*DEG);
  747. //sprintf_s(oapiDebugString(), 255, "Rot Vec: %f %f %f cam dir: %f %f %f dir: %f %f %f Angle: %f %f length: %f", orbiter_cam_rot.x, orbiter_cam_rot.y, orbiter_cam_rot.z, arm_tip[2].x-arm_tip[0].x, arm_tip[2].y-arm_tip[0].y, arm_tip[2].z-arm_tip[0].z, dir.x, dir.y, dir.z, angle, angle*DEG, length(dir));
  748. //sprintf_s(oapiDebugString(), 255, "dot_prod: %f Angle: %f %f", dot_prod, angle, angle*DEG);
  749.  
  750. SetCameraOffset( arm_tip[4] );
  751. //STS()->SetCameraDefaultDirection (arm_tip[1]-arm_tip[0], 0.0);
  752. SetCameraDefaultDirection(dir, angle);
  753. oapiCameraSetCockpitDir(0.0, 0.0);
  754. }
  755.  
  756.  
  757.  
  758. /*
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774. //SetCameraDefaultDirection(_V(0, 0, -1));
  775. VECTOR3 dir = arm_tip[1] - arm_tip[0];
  776. //oapiAnnotationSetText(nhCameraLabel, "LEE camera");
  777. // double CalculateCameraRotationAngle(VECTOR3& dir, const VECTOR3& rot);
  778.  
  779. SetCameraOffset(arm_tip[5]);
  780. Cameraangle = (arm_tip[2] - arm_tip[0]);
  781. SetCameraDefaultDirection(dir);
  782. sprintf(oapiDebugString(), "armtip3x %2.2f armtip3y %2.2f armtip3z %2.2f Cam_x %2.2f Cam_y %2.2f Cam_z %2.2f", arm_tip[5].x, arm_tip[5].y, arm_tip[5].z, dir.x, dir.y, dir.z);
  783. //sprintf(oapiDebugString(), "armtip3x %2.2f armtip3y %2.2f armtip3z %2.2f", Cameraangle.x, Cameraangle.y, Cameraangle.z);
  784.  
  785. oapiCameraSetCockpitDir(0, 0);
  786. };
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794. //SetCameraDefaultDirection(_V(0, 1, 0));
  795. //SetCameraOffset(_V(0, 1.27, 10.138));
  796. // sprintf(oapiDebugString(), "armtip3x %2.2f armtip3y %2.2f armtip3z %2.2f", arm_tip[5].x, arm_tip[5].y, arm_tip[5].z);
  797.  
  798. //oapiCameraSetCockpitDir(0, 0);
  799. */
  800. }
  801.  
  802. // --------------------------------------------------------------
  803. // Load the meshes for cockpit and exterior
  804. // --------------------------------------------------------------
  805. void Atlantis::LoadMeshes()
  806. {
  807. // Retrieve mesh handles
  808.  
  809.  
  810. hOrbiterCockpitMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\EARLYVCMFDCCTV3EXTERNAL"); // mesh 0
  811. //which orbitermesh
  812. if ((OV == 102) && (ORIGINAL == 0) && (MIDMODEL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\Columbia\\ColumbiaLATE2016H2");//new shuttlebody2/8/20
  813. else if ((OV == 104) && (ORIGINAL == 0) && (MIDMODEL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\Atlantis\\Atlantis2016H1");//new shuttlebody2/8/20
  814. else if ((OV == 99) && (ORIGINAL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\Challenger\\Challengerlate2016H2");//new shuttlebody2/8/20
  815. else if ((OV == 99) && (ORIGINAL == 1)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\Challenger\\ChallengerORG2016H2");//new shuttlebody2/8/20
  816.  
  817. else if ((OV == 103) && (ORIGINAL == 0)&& (MIDMODEL==0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\Discovery\\Discoverylate2016H2");//new shuttlebody2/8/20
  818. else if ((OV == 105) && (ORIGINAL == 0))hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\Endeavour\\Endeavour2016h");//new shuttlebody2/8/20
  819. else if (OV == 108)hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\Constellation\\Constellation2016g");//new shuttlebody2/8/20
  820. else if (OV == 109)hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\Constellation\\ConstellationUSA2016F"); //new shuttlebody2/8/20
  821. else if (OV == 107)hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\Intrepid\\Intrepid2016F");//new shuttlebody2/8/20
  822.  
  823. else if (OV == 106 )hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\Constitution\\Constitution2016F");//new shuttlebody1/27/20
  824.  
  825. else if ((OV == 103) && (ORIGINAL == 1) && (MIDMODEL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\Discovery\\DiscoveryORG2016H2");//new shuttlebody2/8/20
  826. else if ((OV == 105) && (ORIGINAL == 1))hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\Endeavour\\EndeavourORG2016h");//new shuttlebody2/8/20
  827. else if ((OV == 102) && (ORIGINAL == 1) && (MIDMODEL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\Columbia\\ColumbiaORG2016H7");//new shuttlebody2/8/20
  828. else if ((OV == 104) && (ORIGINAL == 1)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\Atlantis\\AtlantisORG2016H2");//new shuttlebody2/8/20
  829. else if ((OV == 103) && (MIDMODEL == 1) && (ORIGINAL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\Discovery\\DiscoveryMID2016H2");//new shuttlebody2/8/20
  830. else if ((OV == 102) && (ORIGINAL == 1) && (MIDMODEL == 1)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\Columbia\\Columbiamid2016G");//new shuttlebody2/8/20
  831. else if ((OV == 102) && (ORIGINAL == 0) && (MIDMODEL == 1)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\Columbia\\Columbiamid2016G");//new shuttlebody2/8/20
  832.  
  833. //new fictional
  834. else if ((OV == 98) && (ORIGINAL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\STSPATHFINDER2016B");////new shuttlebody1/27/20
  835. else if ((OV == 149) && (ORIGINAL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\STSSHUTTLETWA2016B");//new shuttlebody1/27/20
  836. else if ((OV == 121) && (ORIGINAL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\STSSHUTTLEUSAF2016B");//new shuttlebody1/27/20
  837. else if ((OV == 111) && (ORIGINAL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\STSSHUTTLEENDEAVOURUSA2016B"); //new shuttlebody1/27/20
  838. else if ((OV == 112) && (ORIGINAL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\STSSHUTTLEATLANTISUSAF2016B");//new shuttlebody1/27/20
  839. else if ((OV == 101) && (ORIGINAL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\STSENTERPRISE2016B");//new shuttlebody1/27/20
  840. else if ((OV == 140) && (ORIGINAL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\STSAMERICA2016B");//new shuttlebody1/27/20
  841. else if ((OV == 141) && (ORIGINAL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\STSDESTINY2016B");//new shuttlebody1/27/20
  842. else if ((OV == 142) && (ORIGINAL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\STSEXPLORER2016B");//new shuttlebody1/27/20
  843. else if ((OV == 143) && (ORIGINAL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\STSDAEDALUS2016B");//new shuttlebody1/27/20
  844. else if ((OV == 007) && (ORIGINAL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\STSMOONRAKER2016B"); //new shuttlebody1/27/20
  845. else if ((OV == 130) && (ORIGINAL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\STSVENTURE");//new shuttlebody1/27/20
  846. else if ((OV == 131) && (ORIGINAL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\STSVENTURE1");//new shuttlebody1/27/20
  847. else if ((OV == 132) && (ORIGINAL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\STSVENTURE2");//new shuttlebody1/27/20
  848. else if ((OV == 133) && (ORIGINAL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\STSVENTURE3");//new shuttlebody1/27/20
  849. else if ((OV == 134) && (ORIGINAL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\STSVENTURE4");//new shuttlebody1/27/20
  850. else if ((OV == 135) && (ORIGINAL == 0)) hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\STSVENTURE5");//new shuttlebody1/27/20
  851. else hOrbiterMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\Discovery\\DiscoveryORG2016H2");//new shuttlebody2/8/20
  852.  
  853. //mesh 1
  854.  
  855.  
  856. hOrbiterVCMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\EARLYvcmfdCCTV3MET21");//mesh 2
  857. hOrbiterODSMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\NEWODS3");//mesh 3
  858. hOrbiterRMS1Mesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\RMS4A");//mesh 4
  859. hOrbiterdragchuteMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\shuttlechutedeployed");//mesh 3
  860. //hOrbiterdragchutereleasedMesh = oapiLoadMeshGlobal("2016SPACESHUTTLE\\shuttlechutereleased");//mesh 3
  861. hOrbiterMPMobss = oapiLoadMeshGlobal("2016SPACESHUTTLE\\OBSSMPM");
  862. hOrbiterEXTAIRLOCK = oapiLoadMeshGlobal("2016SPACESHUTTLE\\EXTERNALAIRLOCK4");
  863. hOrbiterKU = oapiLoadMeshGlobal("2016SPACESHUTTLE\\KU_BAND_ANTENNAnew");
  864. hOrbiterSLIDEWIRE = oapiLoadMeshGlobal("2016SPACESHUTTLE\\SLIDEWIRE");
  865. hOrbiterSHUTTLEWIRE = oapiLoadMeshGlobal("2016SPACESHUTTLE\\SHUTTLEWIRE");
  866. hOrbiterTHERMALCOVER = oapiLoadMeshGlobal("2016SPACESHUTTLE\\THERMALCOVER");
  867. hOrbiterDRAGCHUTEHUD = oapiLoadMeshGlobal("2016SPACESHUTTLE\\DRAGCHUTEHUD");
  868.  
  869. // Load meshes
  870. mesh_cockpit = AddMesh(hOrbiterCockpitMesh);//mesh 0
  871. SetMeshVisibilityMode(mesh_cockpit, MESHVIS_EXTERNAL);
  872.  
  873. mesh_orbiter = AddMesh(hOrbiterMesh);//mesh 1
  874. SetMeshVisibilityMode(mesh_orbiter, MESHVIS_EXTERNAL | MESHVIS_VC | MESHVIS_EXTPASS);
  875. //SetMeshVisibilityMode(mesh_orbiter, MESHVIS_COCKPIT);
  876.  
  877. mesh_vc = AddMesh(hOrbiterVCMesh);//mesh 2
  878. SetMeshVisibilityMode(mesh_vc, MESHVIS_VC) ;
  879.  
  880. mesh_ODS = AddMesh(hOrbiterODSMesh);//mesh 3
  881. SetMeshVisibilityMode(mesh_ODS, MESHVIS_NEVER);
  882.  
  883. mesh_RMS1 = AddMesh(hOrbiterRMS1Mesh);//mesh 4
  884. SetMeshVisibilityMode(mesh_RMS1, MESHVIS_NEVER);
  885.  
  886. mesh_DRAGCHUTE = AddMesh(hOrbiterdragchuteMesh);//mesh 5
  887. SetMeshVisibilityMode(mesh_DRAGCHUTE, MESHVIS_NEVER);
  888.  
  889. mesh_EXTAIRLOCK = AddMesh(hOrbiterEXTAIRLOCK);//mesh 6
  890. SetMeshVisibilityMode(mesh_EXTAIRLOCK, MESHVIS_NEVER);
  891.  
  892. //mesh_DRAGCHUTERELEASED = AddMesh(hOrbiterdragchutereleasedMesh);//mesh 6
  893. //SetMeshVisibilityMode(mesh_DRAGCHUTERELEASED, MESHVIS_NEVER);
  894.  
  895. mesh_MPMOBSS = AddMesh(hOrbiterMPMobss);//mesh7
  896. SetMeshVisibilityMode(mesh_MPMOBSS, MESHVIS_NEVER);
  897.  
  898. mesh_KU = AddMesh(hOrbiterKU);//mesh8
  899. SetMeshVisibilityMode(mesh_KU, MESHVIS_EXTERNAL | MESHVIS_VC | MESHVIS_EXTPASS);
  900.  
  901. mesh_SLIDEWIRE = AddMesh(hOrbiterSLIDEWIRE);//mesh9
  902. SetMeshVisibilityMode(mesh_SLIDEWIRE, MESHVIS_EXTERNAL | MESHVIS_VC | MESHVIS_EXTPASS);
  903.  
  904. mesh_SHUTTLEWIRE = AddMesh(hOrbiterSHUTTLEWIRE);//mesh10
  905. SetMeshVisibilityMode(mesh_SHUTTLEWIRE, MESHVIS_EXTERNAL | MESHVIS_VC | MESHVIS_EXTPASS);
  906.  
  907. mesh_THERMALCOVER = AddMesh(hOrbiterTHERMALCOVER);//mesh11
  908. SetMeshVisibilityMode(mesh_THERMALCOVER, MESHVIS_EXTERNAL | MESHVIS_VC | MESHVIS_EXTPASS);
  909.  
  910. mesh_DRAGCHUITEHUD = AddMesh(hOrbiterDRAGCHUTEHUD);//mesh11
  911. SetMeshVisibilityMode(mesh_DRAGCHUITEHUD, MESHVIS_NEVER);
  912.  
  913. //ShiftMesh(2, _V(0.01, -0.0380, -.4125));
  914. //ShiftMesh(4, _V(-.2, 0, 0));
  915. // Optonal meshes
  916. mesh_cargo = NULL;
  917. mesh_platform = NULL;
  918.  
  919. // Visual handle
  920. vis = NULL;
  921. }
  922.  
  923. // --------------------------------------------------------------
  924. // Initialise the thrusters for the shuttle main engines
  925. // --------------------------------------------------------------
  926. void Atlantis::CreateSSME()
  927. {
  928. // Not connected to a propellant resource - they connect to the ET's tank as long
  929. // as it is attached (checked in clbkPreStep)
  930. th_main[0] = CreateThruster (THRUSTREF_SSME0, THRUSTGIMBAL_LAUNCH, ORBITER_MAIN_THRUST, NULL, ORBITER_MAIN_ISP0, ORBITER_MAIN_ISP1);
  931. th_main[1] = CreateThruster (THRUSTREF_SSME1, THRUSTGIMBAL_LAUNCH, ORBITER_MAIN_THRUST, NULL, ORBITER_MAIN_ISP0, ORBITER_MAIN_ISP1);
  932. th_main[2] = CreateThruster (THRUSTREF_SSME2, THRUSTGIMBAL_LAUNCH, ORBITER_MAIN_THRUST, NULL, ORBITER_MAIN_ISP0, ORBITER_MAIN_ISP1);
  933. thg_main = CreateThrusterGroup (th_main, 3, THGROUP_MAIN);
  934. gimbal_pos = THRUSTGIMBAL_LAUNCH; // the initial pitch gimbal setting positions the SSMEs to cancel pitch moment in launch configuration
  935.  
  936. SURFHANDLE tex_main = oapiRegisterExhaustTexture ("Exhaust_atsme");
  937. for (int i = 0; i < 3; i++)
  938. AddExhaust (th_main[i], 30.0, 2.0, tex_main);
  939. }
  940.  
  941. // --------------------------------------------------------------
  942. // Initialise the thrusters for the orbital maneuvering system
  943. // --------------------------------------------------------------
  944. void Atlantis::CreateOMS()
  945.  
  946. {
  947.  
  948. //contrail_tex = oapiRegisterParticleTexture("Exhaust_atrcs");
  949. th_oms[0] = CreateThruster (THRUSTREF_OMSL, THRUSTDIR_OMSL, ORBITER_OMS_THRUST, ph_oms, ORBITER_OMS_ISP0, ORBITER_OMS_ISP1);
  950. th_oms[1] = CreateThruster (THRUSTREF_OMSR, THRUSTDIR_OMSR, ORBITER_OMS_THRUST, ph_oms, ORBITER_OMS_ISP0, ORBITER_OMS_ISP1);
  951. // we don't yet define a thruster group for the OMS engines
  952. // They will be assigned to the MAIN group as soon as the ET is jettisoned
  953. for (int i = 0; i < 2; i++)
  954. AddExhaust(th_oms[i], 2.5, 0.6); //2.5, 0.6
  955.  
  956. PARTICLESTREAMSPEC OMSex = {
  957. 0, .5, 1000, 5, .01, .1, 0, 0, PARTICLESTREAMSPEC::EMISSIVE,
  958. PARTICLESTREAMSPEC::LVL_LIN, 0, 1,
  959. PARTICLESTREAMSPEC::ATM_FLAT, 0.5, 1.0
  960. };
  961.  
  962. AddExhaustStream(th_oms[0], _V(-2.8, 3.5, -13.5), &OMSex);
  963. AddExhaustStream(th_oms[1], _V(2.8, 3.5, -13.5), &OMSex);
  964.  
  965. }
  966.  
  967. // --------------------------------------------------------------
  968. // Attitude controls (RCS) during orbital phase
  969. // Inactive by default. Activated with EnableRCS(true)
  970. // --------------------------------------------------------------
  971. void Atlantis::CreateRCS()
  972. {
  973. SURFHANDLE tex_rcs = oapiRegisterExhaustTexture ("Exhaust_atrcs");
  974. const double eh = 6.0; // exhaust length scale
  975. const double ew1 = 0.4, ew2 = 0.8; // exhaust width scales
  976.  
  977. // set of attitude thrusters (idealised). The arrangement is such that no angular
  978. // momentum is created in linear mode, and no linear momentum is created in rotational mode.
  979. THRUSTER_HANDLE th_att_rot[4], th_att_lin[4];
  980. th_att_rot[0] = th_att_lin[0] = CreateThruster (_V(0,0, 15.5), _V(0, 1,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1);
  981. th_att_rot[1] = th_att_lin[3] = CreateThruster (_V(0,0,-15.5), _V(0,-1,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1);
  982. th_att_rot[2] = th_att_lin[2] = CreateThruster (_V(0,0, 15.5), _V(0,-1,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1);
  983. th_att_rot[3] = th_att_lin[1] = CreateThruster (_V(0,0,-15.5), _V(0, 1,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1);
  984. CreateThrusterGroup (th_att_rot, 2, THGROUP_ATT_PITCHUP);
  985. CreateThrusterGroup (th_att_rot+2, 2, THGROUP_ATT_PITCHDOWN);
  986. CreateThrusterGroup (th_att_lin, 2, THGROUP_ATT_UP);
  987. CreateThrusterGroup (th_att_lin+2, 2, THGROUP_ATT_DOWN);
  988.  
  989. AddExhaust (th_att_rot[0], eh, ew1, _V( 1.60,-0.20, 18.78), _V( 0.4339,-0.8830,-0.1793), tex_rcs);//F2D
  990. AddExhaust (th_att_rot[0], eh, ew1, _V( 1.68,-0.18, 18.40), _V( 0.4339,-0.8830,-0.1793), tex_rcs);//F4D
  991. AddExhaust (th_att_rot[0], eh, ew1, _V(-1.55,-0.20, 18.78), _V(-0.4339,-0.8830,-0.1793), tex_rcs);//F1D
  992. AddExhaust (th_att_rot[0], eh, ew1, _V(-1.63,-0.18, 18.40), _V(-0.4339,-0.8830,-0.1793), tex_rcs);//F3D
  993.  
  994. AddExhaust (th_att_rot[1], eh, ew1, _V(-3.46, 3.20,-12.30), _V(0, 1,0), tex_rcs);//L4U
  995. AddExhaust (th_att_rot[1], eh, ew1, _V(-3.46, 3.20,-12.70), _V(0, 1,0), tex_rcs);//L2U
  996. AddExhaust(th_att_rot[1], eh, ew1, _V(-3.46, 3.20, -11.906), _V(0, 1, 0), tex_rcs);//L1U
  997.  
  998. AddExhaust (th_att_rot[1], eh, ew1, _V( 3.43, 3.20,-12.30), _V(0, 1,0), tex_rcs);//R4U
  999. AddExhaust (th_att_rot[1], eh, ew1, _V( 3.43, 3.20,-12.70), _V(0, 1,0), tex_rcs);//R2U
  1000. AddExhaust(th_att_rot[1], eh, ew1, _V(3.43, 3.20, -11.906), _V(0, 1, 0), tex_rcs);//R1U
  1001.  
  1002. AddExhaust (th_att_rot[2], eh, ew1, _V(-0.4 , 1.10, 18.3 ), _V(0, 1,0), tex_rcs);//F1U
  1003. AddExhaust (th_att_rot[2], eh, ew1, _V( 0.0 , 1.15 ,18.3 ), _V(0, 1,0), tex_rcs);//F3U
  1004. AddExhaust (th_att_rot[2], eh, ew1, _V( 0.4 , 1.10, 18.3 ), _V(0, 1,0), tex_rcs);//F2U
  1005.  
  1006. AddExhaust(th_att_rot[3], eh, ew1, _V(-3.15, 1.3769, -12.126), _V(-0.2844, -0.9481, -0.1422), tex_rcs);//L4D
  1007. AddExhaust(th_att_rot[3], eh, ew1, _V(-3.15, 1.4302, -12.459), _V(-0.2844, -0.9481, -0.1422), tex_rcs);//L2D
  1008. AddExhaust(th_att_rot[3], eh, ew1, _V(-3.15, 1.5034, -12.805), _V(-0.2844, -0.9481, -0.1422), tex_rcs);//L3D
  1009.  
  1010. AddExhaust(th_att_rot[3], eh, ew1, _V(3.15, 1.3769, -12.126), _V(0.2844, -0.9481, -0.1422), tex_rcs);//R4D
  1011. AddExhaust(th_att_rot[3], eh, ew1, _V(3.15, 1.4302, -12.459), _V(0.2844, -0.9481, -0.1422), tex_rcs);//R2D
  1012. AddExhaust(th_att_rot[3], eh, ew1, _V(3.15, 1.5034, -12.805), _V(0.2844, -0.9481, -0.1422), tex_rcs);//R3D
  1013.  
  1014. th_att_rot[0] = th_att_lin[0] = CreateThruster (_V(0,0, 15.5), _V(-1,0,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1);
  1015. th_att_rot[1] = th_att_lin[3] = CreateThruster (_V(0,0,-15.5), _V( 1,0,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1);
  1016. th_att_rot[2] = th_att_lin[2] = CreateThruster (_V(0,0, 15.5), _V( 1,0,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1);
  1017. th_att_rot[3] = th_att_lin[1] = CreateThruster (_V(0,0,-15.5), _V(-1,0,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1);
  1018. CreateThrusterGroup (th_att_rot, 2, THGROUP_ATT_YAWLEFT);
  1019. CreateThrusterGroup (th_att_rot+2, 2, THGROUP_ATT_YAWRIGHT);
  1020. CreateThrusterGroup (th_att_lin, 2, THGROUP_ATT_LEFT);
  1021. CreateThrusterGroup (th_att_lin+2, 2, THGROUP_ATT_RIGHT);
  1022.  
  1023. AddExhaust (th_att_rot[0], eh, ew2, _V( 1.8 ,-0.3 , 18.0 ), _V( 1,0,0), tex_rcs);//F4R
  1024. AddExhaust (th_att_rot[0], eh, ew2, _V( 1.75, 0.1 , 18.05), _V( 1,0,0), tex_rcs);//F2R
  1025. AddExhaust (th_att_rot[2], eh, ew2, _V(-1.7 ,-0.3 , 18.0 ), _V(-1,0,0), tex_rcs);//F1L
  1026. AddExhaust (th_att_rot[2], eh, ew2, _V(-1.65,-0.1 , 18.05), _V(-1,0,0), tex_rcs);//F3L
  1027.  
  1028. AddExhaust(th_att_rot[1], eh, ew2, _V(-4.0, 2.35, -11.919), _V(-1, 0, 0), tex_rcs);//L4L
  1029. AddExhaust(th_att_rot[1], eh, ew2, _V(-4.0, 2.35, -12.219), _V(-1, 0, 0), tex_rcs);//L2L
  1030. AddExhaust(th_att_rot[1], eh, ew2, _V(-4.0, 2.35, -12.592), _V(-1, 0, 0), tex_rcs);//L3L
  1031. AddExhaust(th_att_rot[1], eh, ew2, _V(-4.0, 2.35, -12.932), _V(-1, 0, 0), tex_rcs);//L1L
  1032.  
  1033. AddExhaust(th_att_rot[3], eh, ew2, _V(4.0, 2.35, -11.919), _V(1, 0, 0), tex_rcs);//R4R
  1034. AddExhaust(th_att_rot[3], eh, ew2, _V(4.0, 2.35, -12.219), _V(1, 0, 0), tex_rcs);//R2R
  1035. AddExhaust(th_att_rot[3], eh, ew2, _V(4.0, 2.35, -12.592), _V(1, 0, 0), tex_rcs);//R3R
  1036. AddExhaust(th_att_rot[3], eh, ew2, _V(4.0, 2.35, -12.932), _V(1, 0, 0), tex_rcs);//R1R
  1037.  
  1038. th_att_rot[0] = CreateThruster (_V( 2.7,0,0), _V(0, 1,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1);
  1039. th_att_rot[1] = CreateThruster (_V(-2.7,0,0), _V(0,-1,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1);
  1040. th_att_rot[2] = CreateThruster (_V(-2.7,0,0), _V(0, 1,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1);
  1041. th_att_rot[3] = CreateThruster (_V( 2.7,0,0), _V(0,-1,0), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1);
  1042. CreateThrusterGroup (th_att_rot, 2, THGROUP_ATT_BANKLEFT);
  1043. CreateThrusterGroup (th_att_rot+2, 2, THGROUP_ATT_BANKRIGHT);
  1044.  
  1045. AddExhaust (th_att_rot[0], eh, ew1, _V( 1.60,-0.20, 18.78), _V( 0.4339,-0.8830,-0.1793), tex_rcs);//F2D
  1046. AddExhaust (th_att_rot[0], eh, ew1, _V( 1.68,-0.18, 18.40), _V( 0.4339,-0.8830,-0.1793), tex_rcs);//F4D
  1047. AddExhaust (th_att_rot[2], eh, ew1, _V(-1.55,-0.20, 18.78), _V(-0.4339,-0.8830,-0.1793), tex_rcs);//F1D
  1048. AddExhaust (th_att_rot[2], eh, ew1, _V(-1.63,-0.18, 18.40), _V(-0.4339,-0.8830,-0.1793), tex_rcs);//F3D
  1049.  
  1050. AddExhaust (th_att_rot[1], eh, ew1, _V(-3.46, 3.20,-12.30), _V(0, 1,0), tex_rcs);//L4U
  1051. AddExhaust (th_att_rot[1], eh, ew1, _V(-3.46, 3.20,-12.70), _V(0, 1,0), tex_rcs);//L2U
  1052. AddExhaust (th_att_rot[1], eh, ew1, _V(-3.46, 3.20,-13.10), _V(0, 1,0), tex_rcs);//L1U
  1053.  
  1054. AddExhaust (th_att_rot[3], eh, ew1, _V( 3.43, 3.20,-12.30), _V(0, 1,0), tex_rcs);//R4U
  1055. AddExhaust (th_att_rot[3], eh, ew1, _V( 3.43, 3.20,-12.70), _V(0, 1,0), tex_rcs);//R2U
  1056. AddExhaust (th_att_rot[3], eh, ew1, _V( 3.43, 3.20,-13.10), _V(0, 1,0), tex_rcs);//R1U
  1057.  
  1058. AddExhaust (th_att_rot[2], eh, ew1, _V(-3.1 , 1.55,-12.45), _V(-0.2844,-0.9481,-0.1422), tex_rcs);//L4D
  1059. AddExhaust (th_att_rot[2], eh, ew1, _V(-3.1 , 1.6 ,-12.8 ), _V(-0.2844,-0.9481,-0.1422), tex_rcs);//L2D
  1060. AddExhaust (th_att_rot[2], eh, ew1, _V(-3.1 , 1.65,-13.15), _V(-0.2844,-0.9481,-0.1422), tex_rcs);//L3D
  1061.  
  1062. AddExhaust (th_att_rot[0], eh, ew1, _V( 3.15, 1.55,-12.45), _V( 0.2844,-0.9481,-0.1422), tex_rcs);//R4D
  1063. AddExhaust (th_att_rot[0], eh, ew1, _V( 3.15, 1.6 ,-12.8 ), _V( 0.2844,-0.9481,-0.1422), tex_rcs);//R2D
  1064. AddExhaust (th_att_rot[0], eh, ew1, _V( 3.15, 1.65,-13.15), _V( 0.2844,-0.9481,-0.1422), tex_rcs);//R3D
  1065.  
  1066. th_att_lin[0] = CreateThruster (_V(0,0,-16), _V(0,0, 1), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1);
  1067. th_att_lin[1] = CreateThruster (_V(0,0, 16), _V(0,0,-1), ORBITER_RCS_THRUST, NULL, ORBITER_RCS_ISP0, ORBITER_RCS_ISP1);
  1068. CreateThrusterGroup (th_att_lin, 1, THGROUP_ATT_FORWARD);
  1069. CreateThrusterGroup (th_att_lin+1, 1, THGROUP_ATT_BACK);
  1070.  
  1071. AddExhaust (th_att_lin[0], eh, ew1, _V(-3.59, 2.8 ,-13.6 ), _V(0,0,-1), tex_rcs);//L1A
  1072. AddExhaust (th_att_lin[0], eh, ew1, _V(-3.27, 2.8 ,-13.6 ), _V(0,0,-1), tex_rcs);//L3A
  1073. AddExhaust (th_att_lin[0], eh, ew1, _V( 3.64, 2.8 ,-13.6 ), _V(0,0,-1), tex_rcs);//R1A
  1074. AddExhaust (th_att_lin[0], eh, ew1, _V( 3.27, 2.8 ,-13.6 ), _V(0,0,-1), tex_rcs);//R3A
  1075. AddExhaust (th_att_lin[1], eh, ew1, _V( 0.0 , 0.75, 19.2 ), _V(0, 0.0499, 0.9988), tex_rcs);//F3F
  1076. AddExhaust (th_att_lin[1], eh, ew1, _V(-0.4 , 0.7 , 19.2 ), _V(0, 0.0499, 0.9988), tex_rcs);//F1F
  1077. AddExhaust (th_att_lin[1], eh, ew1, _V( 0.4 , 0.7 , 19.2 ), _V(0, 0.0499, 0.9988), tex_rcs);//F2F
  1078.  
  1079. }
  1080.  
  1081. // --------------------------------------------------------------
  1082. // Initialise airfoils, aerodynamic control surfaces and drag elements
  1083. // --------------------------------------------------------------
  1084. void Atlantis::CreateAirfoils ()
  1085. {
  1086. CreateAirfoil (LIFT_VERTICAL, _V(0,0,-0.5), VLiftCoeff, 20, 270, 2.266);
  1087. CreateAirfoil (LIFT_HORIZONTAL, _V(0,0,-4), HLiftCoeff, 20, 50, 1.5);
  1088.  
  1089. CreateControlSurface (AIRCTRL_ELEVATOR, 5.0, 1.5, _V( 0, 0, -15), AIRCTRL_AXIS_XPOS, anim_elev);
  1090. CreateControlSurface (AIRCTRL_RUDDER, 2.0, 1.5, _V( 0, 3, -16), AIRCTRL_AXIS_YPOS, anim_rudder);
  1091. CreateControlSurface (AIRCTRL_AILERON, 3.0, 1.5, _V( 7,-0.5,-15), AIRCTRL_AXIS_XPOS, anim_raileron);
  1092. CreateControlSurface (AIRCTRL_AILERON, 3.0, 1.5, _V(-7,-0.5,-15), AIRCTRL_AXIS_XNEG, anim_laileron);
  1093. CreateControlSurface2(AIRCTRL_ELEVATORTRIM, 5, 1.75, _V(0, 0, -17), AIRCTRL_AXIS_XPOS, anim_bf);
  1094.  
  1095. CreateVariableDragElement (&spdb_proc, 5, _V(0, 7.5, -14)); // speedbrake drag
  1096. CreateVariableDragElement (&gear_proc, 2, _V(0,-3,0)); // landing gear drag
  1097. CreateVariableDragElement (&rdoor_drag, 7, _V(2.9,0,10)); // right cargo door drag
  1098. CreateVariableDragElement (&ldoor_drag, 7, _V(-2.9,0,10)); // right cargo door drag
  1099. }
  1100.  
  1101. // --------------------------------------------------------------
  1102. // Airfoil coefficient function
  1103. // Return lift, moment and zero-lift drag coefficients as a
  1104. // function of angle of attack
  1105. // 1. vertical lift component (wings and body)
  1106. // --------------------------------------------------------------
  1107. void Atlantis::VLiftCoeff (double aoa, double M, double Re, double *cl, double *cm, double *cd)
  1108. {
  1109. static const double step = RAD*15.0;
  1110. static const double istep = 1.0/step;
  1111. static const int nabsc = 25;
  1112. static const double CL[nabsc] = {0.1, 0.17, 0.2, 0.2, 0.17, 0.1, 0, -0.11, -0.24, -0.38, -0.5, -0.5, -0.02, 0.6355, 0.63, 0.46, 0.28, 0.13, 0.0, -0.16, -0.26, -0.29, -0.24, -0.1, 0.1};
  1113. static const double CM[nabsc] = { 0, 0, 0, 0, 0, 0, 0, 0, 0,0.002,0.004, 0.0025,0.0012, 0,-0.0012,-0.0007, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  1114. // lift and moment coefficients from -180 to 180 in 15 degree steps.
  1115. // This uses a documented lift slope of 0.0437/deg, everything else is rather ad-hoc
  1116.  
  1117. aoa += PI;
  1118. int idx = max (0, min (23, (int)(aoa*istep)));
  1119. double d = aoa*istep - idx;
  1120. *cl = CL[idx] + (CL[idx+1]-CL[idx])*d;
  1121. *cm = CM[idx] + (CM[idx+1]-CM[idx])*d;
  1122. *cd = 0.06 + oapiGetInducedDrag (*cl, 2.266, 0.6);
  1123. }
  1124.  
  1125. // --------------------------------------------------------------
  1126. // Airfoil coefficient functions
  1127. // Return lift, moment and zero-lift drag coefficients as a
  1128. // function of slip angle (beta)
  1129. // 2. horizontal lift component (vertical stabiliser and body)
  1130. // --------------------------------------------------------------
  1131. void Atlantis::HLiftCoeff (double beta, double M, double Re, double *cl, double *cm, double *cd)
  1132. {
  1133. static const double step = RAD*22.5;
  1134. static const double istep = 1.0/step;
  1135. static const int nabsc = 17;
  1136. static const double CL[nabsc] = {0, 0.2, 0.3, 0.2, 0, -0.2, -0.3, -0.2, 0, 0.2, 0.3, 0.2, 0, -0.2, -0.3, -0.2, 0};
  1137.  
  1138. beta += PI;
  1139. int idx = max (0, min (15, (int)(beta*istep)));
  1140. double d = beta*istep - idx;
  1141. *cl = CL[idx] + (CL[idx+1]-CL[idx])*d;
  1142. *cm = 0.0;
  1143. *cd = 0.02 + oapiGetInducedDrag (*cl, 1.5, 0.6);
  1144. }
  1145.  
  1146. // --------------------------------------------------------------
  1147. // Enable/disable Space Shuttle Main Engines
  1148. // --------------------------------------------------------------
  1149. bool Atlantis::EnableSSME (bool enable)
  1150. {
  1151. PROPELLANT_HANDLE hProp = NULL;
  1152.  
  1153. if (enable) {
  1154. // if (pET) hProp = pET->GetPropHandle();
  1155. //else return false; // can't activate without attached ET
  1156. }
  1157.  
  1158. for (DWORD i = 0; i < 3; i++)
  1159. SetThrusterResource (th_main[i], hProp);
  1160.  
  1161. if (enable) {
  1162. if (GetGroupThrusterCount (THGROUP_MAIN) != 3) {
  1163. // switch MAIN group to SSME
  1164. DelThrusterGroup (THGROUP_MAIN);
  1165. thg_main = CreateThrusterGroup (th_main, 3, THGROUP_MAIN);
  1166. }
  1167. SetDefaultPropellantResource (hProp);
  1168. }
  1169. return true;
  1170. }
  1171.  
  1172. // --------------------------------------------------------------
  1173. // Enable/disable Orbital Maneuvering System
  1174. // --------------------------------------------------------------
  1175. void Atlantis::EnableOMS (bool enable)
  1176. {
  1177. PROPELLANT_HANDLE hProp = (enable ? ph_oms : NULL);
  1178.  
  1179. for (DWORD i = 0; i < 2; i++)
  1180. SetThrusterResource (th_oms[i], hProp);
  1181.  
  1182. if (enable) {
  1183. if (GetGroupThrusterCount (THGROUP_MAIN) > 2) {
  1184. // switch MAIN group to OMS
  1185. DelThrusterGroup (THGROUP_MAIN);
  1186. thg_main = CreateThrusterGroup (th_oms, 2, THGROUP_MAIN);
  1187. }
  1188. SetDefaultPropellantResource (ph_oms);
  1189. }
  1190. }
  1191.  
  1192. // --------------------------------------------------------------
  1193. // Enable/disable Reaction Control System
  1194. // --------------------------------------------------------------
  1195. void Atlantis::EnableRCS (bool enable)
  1196. {
  1197. PROPELLANT_HANDLE hProp = (enable ? ph_oms : NULL);
  1198. DWORD i;
  1199.  
  1200. for (i = 0; i < GetGroupThrusterCount (THGROUP_ATT_PITCHUP); i++)
  1201. SetThrusterResource (GetGroupThruster (THGROUP_ATT_PITCHUP, i), hProp);
  1202. for (i = 0; i < GetGroupThrusterCount (THGROUP_ATT_PITCHDOWN); i++)
  1203. SetThrusterResource (GetGroupThruster (THGROUP_ATT_PITCHDOWN, i), hProp);
  1204.  
  1205. for (i = 0; i < GetGroupThrusterCount (THGROUP_ATT_YAWLEFT); i++)
  1206. SetThrusterResource (GetGroupThruster (THGROUP_ATT_YAWLEFT, i), hProp);
  1207. for (i = 0; i < GetGroupThrusterCount (THGROUP_ATT_YAWRIGHT); i++)
  1208. SetThrusterResource (GetGroupThruster (THGROUP_ATT_YAWRIGHT, i), hProp);
  1209.  
  1210. for (i = 0; i < GetGroupThrusterCount (THGROUP_ATT_BANKLEFT); i++)
  1211. SetThrusterResource (GetGroupThruster (THGROUP_ATT_BANKLEFT, i), hProp);
  1212. for (i = 0; i < GetGroupThrusterCount (THGROUP_ATT_BANKRIGHT); i++)
  1213. SetThrusterResource (GetGroupThruster (THGROUP_ATT_BANKRIGHT, i), hProp);
  1214.  
  1215. for (i = 0; i < GetGroupThrusterCount (THGROUP_ATT_UP); i++)
  1216. SetThrusterResource (GetGroupThruster (THGROUP_ATT_UP, i), hProp);
  1217. for (i = 0; i < GetGroupThrusterCount (THGROUP_ATT_DOWN); i++)
  1218. SetThrusterResource (GetGroupThruster (THGROUP_ATT_DOWN, i), hProp);
  1219.  
  1220. for (i = 0; i < GetGroupThrusterCount (THGROUP_ATT_LEFT); i++)
  1221. SetThrusterResource (GetGroupThruster (THGROUP_ATT_LEFT, i), hProp);
  1222. for (i = 0; i < GetGroupThrusterCount (THGROUP_ATT_RIGHT); i++)
  1223. SetThrusterResource (GetGroupThruster (THGROUP_ATT_RIGHT, i), hProp);
  1224.  
  1225. for (i = 0; i < GetGroupThrusterCount (THGROUP_ATT_FORWARD); i++)
  1226. SetThrusterResource (GetGroupThruster (THGROUP_ATT_FORWARD, i), hProp);
  1227. for (i = 0; i < GetGroupThrusterCount (THGROUP_ATT_BACK); i++)
  1228. SetThrusterResource (GetGroupThruster (THGROUP_ATT_BACK, i), hProp);
  1229.  
  1230. bool enable_as = (GetAttitudeMode() == RCS_NONE || enable == false);
  1231. SetADCtrlMode (enable_as ? 7 : 0);
  1232. }
  1233.  
  1234. // --------------------------------------------------------------
  1235. // Define animation sequences for moving parts
  1236. // --------------------------------------------------------------
  1237. void Atlantis::DefineAnimations (void)
  1238. {
  1239.  
  1240. UINT midx = 1; // mesh index for all external animations
  1241. UINT vidx = 2; // mesh index for all VC animations
  1242. UINT ridx = 4; // mesh index for all rms animations
  1243.  
  1244.  
  1245. // ***** 1. Cargo door and radiator animations *****
  1246. ANIMATIONCOMPONENT_HANDLE doorparentR, doorparentL,RADPARENTL,RADPARENTR;
  1247. static UINT RCargoDoorGrp[10] = { GRP_cargodooroutR, GRP_cargodoorinright, GRP_radiatorBRnew, GRP_rightdoorpipe, GRP_sillraillright,GRP_cargodoorhookright,GRP_MID_FWD_HO,GRP_MID_AFT_HO,GRP_FWD_HOOKS,GRP_AFT_HOOKS };
  1248. static MGROUP_ROTATE RCargoDoor (midx, RCargoDoorGrp, 10,
  1249. _V(2.84, 1.284, 0), _V(0,0,1), (float)(-175.5*RAD));
  1250. static UINT LCargoDoorGrp[6] = { GRP_cargodooroutL, GRP_cargodoorinleft, GRP_radiatorBLnew, GRP_leftdoorpipe, GRP_sillrailleft,GRP_cargodoorhookleft };
  1251. static MGROUP_ROTATE LCargoDoor (midx, LCargoDoorGrp, 6,
  1252. _V(-2.84, 1.284, 0), _V(0,0,1), (float)(175.5*RAD));
  1253.  
  1254.  
  1255. static UINT LCargoDoorhingeGrp[2] = { GRP_leftdoormech2, GRP_leftdoormech3 };
  1256. static MGROUP_ROTATE LCargoDoorHINGE(midx, LCargoDoorhingeGrp, 2,
  1257. _V(-2.689438, 1.166027, 0), _V(0, 0, 1), (float)(90*RAD));
  1258.  
  1259. //static UINT RCargoDoorhinge1Grp[1] = { GRP_rightdoormech1 };
  1260. //static MGROUP_TRANSLATE RCargoDoorHINGE1(midx, RCargoDoorhinge1Grp, 3, _V(0, .1, 0));
  1261.  
  1262. //static UINT LCargoDoorhinge1Grp[1] = { GRP_leftdoormech1 };
  1263. //static MGROUP_TRANSLATE LCargoDoorHINGE1(midx, LCargoDoorhinge1Grp, 1, _V(0, .1, 0));
  1264.  
  1265. static UINT LCargoDoorhinge1Grp[1] = { GRP_leftdoormech1 };
  1266. static MGROUP_ROTATE LCargoDoorHINGE1(midx, LCargoDoorhinge1Grp, 1,
  1267. _V(-2.594612, 1.028044, 0), _V(0, 0, 1), (float)(-90 * RAD));
  1268.  
  1269.  
  1270. static UINT RCargoDoorhingeGrp[2] = { GRP_rightdoormech2, GRP_rightdoormech3 };
  1271. static MGROUP_ROTATE RCargoDoorHINGE(midx, RCargoDoorhingeGrp, 2,
  1272. _V(2.689438, 1.166027, 0), _V(0, 0, 1), (float)(-90*RAD));
  1273.  
  1274. static UINT RCargoDoorhinge1Grp[1] = { GRP_rightdoormech1 };
  1275. static MGROUP_ROTATE RCargoDoorHINGE1(midx, RCargoDoorhinge1Grp, 1,
  1276. _V(2.594612, 1.028044, 0), _V(0, 0, 1), (float)(90 * RAD));
  1277. anim_door = CreateAnimation(0);
  1278. // doorparentR = AddAnimationComponent(anim_door, 0, .8, &RCargoDoorHINGE1);//swing out
  1279. doorparentR = AddAnimationComponent(anim_door, 0.0, 0.4632, &RCargoDoorHINGE);//swing out
  1280. doorparentL = AddAnimationComponent(anim_door, 0.5368, 1.0, &LCargoDoorHINGE);//swing out
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286. AddAnimationComponent(anim_door, 0.0, 0.4632, &RCargoDoorHINGE1, doorparentR);
  1287. AddAnimationComponent(anim_door, 0.5368, 1.0, &LCargoDoorHINGE1, doorparentL);
  1288.  
  1289. //AddAnimationComponent(anim_door, 0.0, 0.4632, &RCargoDoorHINGE);
  1290. //AddAnimationComponent(anim_door, 0.5368, 1.0, &LCargoDoorHINGE);
  1291.  
  1292. //SetDirection(arm_tip[1]-arm_tip[0]);
  1293.  
  1294. RADPARENTR = AddAnimationComponent(anim_door, 0.0, 0.4632, &RCargoDoor);
  1295. RADPARENTL = AddAnimationComponent(anim_door, 0.5368, 1.0, &LCargoDoor);
  1296.  
  1297. static UINT RRadiatorGrp[1] = {GRP_radiatorFRnew};
  1298. static MGROUP_ROTATE RRadiator (midx, RRadiatorGrp, 1,
  1299. _V(2.686, 1.508, 0), _V(0, 0, 1), (float)(35.5*RAD));
  1300. static UINT LRadiatorGrp[1] = {GRP_radiatorFLnew};
  1301. static MGROUP_ROTATE LRadiator (midx, LRadiatorGrp, 1,
  1302. _V(-2.686, 1.508, 0), _V(0, 0, 1), (float)(-35.5*RAD));
  1303.  
  1304. anim_PRADIATOR = CreateAnimation(0);
  1305. anim_SRADIATOR = CreateAnimation(0);
  1306. AddAnimationComponent(anim_PRADIATOR, 0, 1, &RRadiator,RADPARENTR);
  1307. AddAnimationComponent(anim_SRADIATOR, 0, 1, &LRadiator,RADPARENTL);
  1308.  
  1309. // ***** 2. Landing gear animation *****
  1310.  
  1311. static UINT LNosewheelDoorGrp[1] = {GRP_Lnosedoor};
  1312. static MGROUP_ROTATE LNosewheelDoor (midx, LNosewheelDoorGrp, 1,
  1313. _V(-0.78, -2.15, 17), _V(0, 0.195, 0.981), (float)(-60.0*RAD));
  1314. static UINT RNosewheelDoorGrp[1] = {GRP_Rnosedoor};
  1315. static MGROUP_ROTATE RNosewheelDoor (midx, RNosewheelDoorGrp, 1,
  1316. _V(0.78, -2.15, 17), _V(0, 0.195, 0.981), (float)(60.0*RAD));
  1317. static UINT NosewheelGrp[2] = {GRP_nosewheel,GRP_nosegear};
  1318. static MGROUP_ROTATE Nosewheel (midx, NosewheelGrp, 2,
  1319. _V(0.0, -1.95, 17.45), _V(1, 0, 0), (float)(109.0*RAD));
  1320. static UINT RGearDoorGrp[1] = {GRP_geardoorR};
  1321. static MGROUP_ROTATE RGearDoor (midx, RGearDoorGrp, 1,
  1322. _V(4.35, -2.64, -1.69), _V(0, 0.02, 0.9), (float)(96.2*RAD));
  1323. static UINT LGearDoorGrp[1] = {GRP_geardoorL};
  1324. static MGROUP_ROTATE LGearDoor (midx, LGearDoorGrp, 1,
  1325. _V(-4.35, -2.64, -1.69), _V(0, 0.02, 0.9), (float)(-96.2*RAD));
  1326. static UINT MainGearGrp[4] = {GRP_wheelR,GRP_gearR,GRP_wheelL,GRP_gearL};
  1327. static MGROUP_ROTATE MainGear (midx, MainGearGrp, 4,
  1328. _V(0, -2.66, -3.68), _V(1, 0, 0), (float)(94.5*RAD));
  1329.  
  1330. anim_gear = CreateAnimation (0);
  1331. AddAnimationComponent (anim_gear, 0, 0.5, &LNosewheelDoor);
  1332. AddAnimationComponent (anim_gear, 0, 0.5, &RNosewheelDoor);
  1333. AddAnimationComponent (anim_gear, 0.4, 1.0, &Nosewheel);
  1334. AddAnimationComponent (anim_gear, 0, 0.5, &RGearDoor);
  1335. AddAnimationComponent (anim_gear, 0, 0.5, &LGearDoor);
  1336. AddAnimationComponent (anim_gear, 0.4, 1.0, &MainGear);
  1337. //LANDINGGEAR INDICATORS/
  1338. anim_LEFTGEARARMON = CreateAnimation(0);
  1339. anim_LEFTGEARDN = CreateAnimation(0);
  1340. anim_LEFTGEARTALKBACK = CreateAnimation(0);
  1341. // anim_LEFTGEARARMOFF = CreateAnimation(0);
  1342. // anim_LEFTGEARUP = CreateAnimation(0);
  1343.  
  1344. //static UINT LEFTGEARARMOFFGrp[1] = { GRP_leftarmoff };
  1345. //static MGROUP_TRANSLATE LEFTGEARARMOFF(2, LEFTGEARARMOFFGrp, 1, _V(0, 0, .01));
  1346. static UINT LEFTGEARARM0NGrp[1] = { GRP_leftarmon };
  1347. static MGROUP_TRANSLATE LEFTGEARARMON(2, LEFTGEARARM0NGrp, 1, _V(0, 0, -.002));
  1348.  
  1349. ////static UINT LEFTGEARUPGrp[1] = { GRP_leftgearup };
  1350. //static MGROUP_TRANSLATE LEFTGEARUP(2, LEFTGEARUPGrp, 1, _V(0, 0, .01));
  1351. static UINT LEFTGEARDNGrp[1] = { GRP_leftgeardn };
  1352. static MGROUP_TRANSLATE LEFTGEARDN(2, LEFTGEARDNGrp, 1, _V(0, 0, -.002));
  1353.  
  1354. //AddAnimationComponent(anim_LEFTGEARUP, 0, 1, &LEFTGEARUP);
  1355.  
  1356. AddAnimationComponent(anim_LEFTGEARDN, 0, 1, &LEFTGEARDN);
  1357.  
  1358. //AddAnimationComponent(anim_LEFTGEARARMOFF, 0, 1, &LEFTGEARARMOFF);
  1359.  
  1360. AddAnimationComponent(anim_LEFTGEARARMON, 0, 1, &LEFTGEARARMON);
  1361.  
  1362. static UINT LEFTGEARtalkbackGrp[1] = { GRP_leftgeartalkback };
  1363. static MGROUP_TRANSLATE LEFTGEARtalkback(2, LEFTGEARtalkbackGrp, 1, _V(0, 0.01, .005));
  1364. AddAnimationComponent(anim_LEFTGEARTALKBACK, 0, 1, &LEFTGEARtalkback);
  1365. //RIGHT
  1366. anim_RIGHTGEARARMON = CreateAnimation(0);
  1367. anim_RIGHTGEARDN = CreateAnimation(0);
  1368. anim_RIGHTGEARTALKBACK = CreateAnimation(0);
  1369. // anim_RIGHTGEARARMOFF = CreateAnimation(0);
  1370. // anim_RIGHTGEARUP = CreateAnimation(0);
  1371.  
  1372. // static UINT RIGHTGEARARMOFFGrp[1] = { GRP_rightarmoff };
  1373. // static MGROUP_TRANSLATE RIGHTGEARARMOFF(2, RIGHTGEARARMOFFGrp, 1, _V(0, 0, .01));
  1374. static UINT RIGHTGEARARM0NGrp[1] = { GRP_rightarmon };
  1375. static MGROUP_TRANSLATE RIGHTGEARARMON(2, RIGHTGEARARM0NGrp, 1, _V(0, 0, -.003));
  1376.  
  1377. // static UINT RIGHTGEARUPGrp[1] = { GRP_rightgearup };
  1378. // static MGROUP_TRANSLATE RIGHTGEARUP(2, RIGHTGEARUPGrp, 1, _V(0, 0, .01));
  1379. static UINT RIGHTGEARDNGrp[1] = { GRP_rightgeardn };
  1380. static MGROUP_TRANSLATE RIGHTGEARDN(2, RIGHTGEARDNGrp, 1, _V(0, 0, -.003));
  1381.  
  1382. // AddAnimationComponent(anim_RIGHTGEARUP, 0, 1, &RIGHTGEARUP);
  1383.  
  1384. AddAnimationComponent(anim_RIGHTGEARDN, 0, 1, &RIGHTGEARDN);
  1385.  
  1386. // AddAnimationComponent(anim_RIGHTGEARARMOFF, 0, 1, &RIGHTGEARARMOFF);
  1387.  
  1388. AddAnimationComponent(anim_RIGHTGEARARMON, 0, 1, &RIGHTGEARARMON);
  1389.  
  1390. static UINT RIGHTGEARtalkbackGrp[1] = { GRP_rightgeartalkback };
  1391. static MGROUP_TRANSLATE RIGHTGEARtalkback(2, RIGHTGEARtalkbackGrp, 1, _V(0, 0.01, .005));
  1392. AddAnimationComponent(anim_RIGHTGEARTALKBACK, 0, 1, &RIGHTGEARtalkback);
  1393. anim_dragdeploy = CreateAnimation(0);
  1394. static UINT chutedeployGrp[1] = { 4 };
  1395. static MGROUP_TRANSLATE chutedeploy(12, chutedeployGrp, 1, _V(0, 0, .01));
  1396. AddAnimationComponent(anim_dragdeploy, 0, 1, &chutedeploy);
  1397.  
  1398. anim_chutejett = CreateAnimation(0);
  1399. static UINT chutejettGrp[1] = { 3 };
  1400. static MGROUP_TRANSLATE chutejett(12, chutejettGrp, 1, _V(0, 0, .01));
  1401. AddAnimationComponent(anim_chutejett, 0, 1, &chutejett);
  1402.  
  1403.  
  1404.  
  1405.  
  1406. // ***** 3. Ku-band antenna animation *****
  1407. ANIMATIONCOMPONENT_HANDLE KUBANDparent, KUBANDparent1;
  1408. static UINT KuBandDEAGrp[1] = { 2 };
  1409. static MGROUP_ROTATE KuBand1(8, KuBandDEAGrp, 1, _V(2.59, 0.85, 11.773), _V(0, 1, 0), (float)(-113 * RAD));
  1410.  
  1411. static UINT KuBand2Grp[1] = { 3 };
  1412. static MGROUP_ROTATE KuBand2(8, KuBand2Grp, 1, _V(2.341, 1.979, 11.122), _V(0.504249, 0, 0.863558), (float)(-180 * RAD));
  1413.  
  1414. static UINT KuBand3Grp[4] = { 1, 4, 0, 5 };
  1415. static MGROUP_ROTATE KuBand3(8, KuBand3Grp, 4, _V(2.29315, 1.939795, 11.028), _V(0.460305, -0.866073, -0.195029), (float)(-60 * RAD));
  1416.  
  1417. anim_kubd = CreateAnimation(0);
  1418. KUBANDparent = AddAnimationComponent(anim_kubd, 0, .8, &KuBand1);//swing out
  1419. KUBANDparent1 = AddAnimationComponent(anim_kubd, .8, .9, &KuBand2, KUBANDparent);//rotate alpha
  1420. AddAnimationComponent(anim_kubd, .9, 1, &KuBand3, KUBANDparent1);//rotate dish
  1421. // ***** 4. Elevator animation of elevons *****
  1422.  
  1423. static UINT ElevGrp[4] = {GRP_flapR,GRP_flapL,GRP_aileronL,GRP_aileronR};
  1424. static MGROUP_ROTATE Elevator (midx, ElevGrp, 4,
  1425. _V(0,-2.173,-8.84), _V(1,0,0), (float)(30.0*RAD));
  1426. anim_elev = CreateAnimation (0.5);
  1427. AddAnimationComponent (anim_elev, 0, 1, &Elevator);
  1428.  
  1429. // ***** 5. Aileron animation of elevons *****
  1430.  
  1431. static UINT LAileronGrp[2] = {GRP_flapL,GRP_aileronL};
  1432. static MGROUP_ROTATE LAileron (midx, LAileronGrp, 2,
  1433. _V(0,-2.173,-8.84), _V(-1,0,0), (float)(10.0*RAD));
  1434. static UINT RAileronGrp[2] = {GRP_flapR,GRP_aileronR};
  1435. static MGROUP_ROTATE RAileron (midx, RAileronGrp, 2,
  1436. _V(0,-2.173,-8.84), _V(1,0,0), (float)(10.0*RAD));
  1437. anim_laileron = CreateAnimation (0.5);
  1438. AddAnimationComponent (anim_laileron, 0, 1, &LAileron);
  1439. anim_raileron = CreateAnimation (0.5);
  1440. AddAnimationComponent (anim_raileron, 0, 1, &RAileron);
  1441.  
  1442. //INDICATOR
  1443. static UINT leftelevonINDGrp[1] = { GRP_ELEVONSLEFTIND };
  1444. static MGROUP_TRANSLATE leftelevonIND(vidx, leftelevonINDGrp, 1, _V(0, .067, 0));
  1445. anim_leftelevonINDICATOR = CreateAnimation(0.0);
  1446. AddAnimationComponent(anim_leftelevonINDICATOR, 0, 1, &leftelevonIND);
  1447.  
  1448.  
  1449.  
  1450.  
  1451. // ***** 6. Rudder animation *****
  1452.  
  1453. static UINT RudderGrp[2] = {GRP_rudderR,GRP_rudderL};
  1454. static MGROUP_ROTATE Rudder (midx, RudderGrp, 2,
  1455. _V(0,5.77,-12.17), _V(-0.037,0.833,-0.552), (float)(-54.2*RAD));
  1456. anim_rudder = CreateAnimation (0.5);
  1457. AddAnimationComponent (anim_rudder, 0, 1, &Rudder);
  1458.  
  1459. //INDICATOR
  1460. static UINT rdINDGrp[1] = { GRP_RUDDERDEGREEIND };
  1461. static MGROUP_TRANSLATE rudderIND(vidx,rdINDGrp, 1, _V(.067, 0, 0));
  1462. anim_rudderINDICATOR = CreateAnimation(0.5);
  1463. AddAnimationComponent(anim_rudderINDICATOR, 0, 1, &rudderIND);
  1464.  
  1465.  
  1466.  
  1467.  
  1468. // ***** 7. Speedbrake animation *****
  1469.  
  1470. static UINT SB1Grp[1] = {GRP_rudderR};
  1471. static MGROUP_ROTATE SB1 (midx, SB1Grp, 1,
  1472. _V(0.32,5.77,-12.17), _V(-0.037,0.833,-0.552), (float)(-49.3*RAD));
  1473. static UINT SB2Grp[1] = {GRP_rudderL};
  1474. static MGROUP_ROTATE SB2 (midx, SB2Grp, 1,
  1475. _V(-0.32,5.77,-12.17), _V(0.037,0.833,-0.552), (float)(49.3*RAD));
  1476.  
  1477. anim_spdb = CreateAnimation (0);
  1478. AddAnimationComponent (anim_spdb, 0, 1, &SB1);
  1479. AddAnimationComponent (anim_spdb, 0, 1, &SB2);
  1480.  
  1481.  
  1482. //INDICATOR
  1483. static UINT sbINDGrp[2] = { GRP_SPEEDBRAKEIND,GRP_COMMANDSPDBRAKE };
  1484. static MGROUP_TRANSLATE speedbrakeIND(vidx, sbINDGrp, 2, _V(0.066, 0, 0));
  1485. anim_speedbrakeINDICATOR = CreateAnimation(0.0);
  1486. AddAnimationComponent(anim_speedbrakeINDICATOR, 0, 1, &speedbrakeIND);
  1487.  
  1488.  
  1489.  
  1490. // ***** 8. RMS arm animation *****
  1491. // Note that the animation components can't be declared static here, since
  1492. // their rotation parameters are modified by the respective parent transforms
  1493. //default arm
  1494.  
  1495. ANIMATIONCOMPONENT_HANDLE parent, obssparent,parent2;
  1496.  
  1497. static UINT SHOULDERYAWGrp1[1] = { GRP_Shoulder_Yaw };//rotate2 SHOULDERSHOULDERPITCH part
  1498. static UINT ELBOWGrp1[2] = { GRP_ELBOW_BOOM, GRP_ELBOW_CAM_BASE };//rotate part
  1499. static UINT SHOULDERPITCHGrp3[1] = { GRP_SHOULDER_BOOM };//rotate part
  1500. static UINT WPITCHGrp[1] = { GRP_Wristpitch };//rotate part
  1501. static UINT WYAWGrp[1] = { GRP_Wrist_Yaw };//rotate part
  1502. static UINT EEGrp3[1] = { GRP_Endeffector };//rotate part
  1503.  
  1504.  
  1505. anim_MPM = CreateAnimation(0.0);
  1506. anim_arm_sy = CreateAnimation(0.5);
  1507. anim_arm_sp = CreateAnimation(0.0136);
  1508. anim_arm_ep = CreateAnimation(0.0123);
  1509. anim_arm_wp = CreateAnimation(0.5);
  1510. anim_arm_wy = CreateAnimation(0.5);
  1511. anim_arm_wr = CreateAnimation(0.5);
  1512. anim_rms_ee = CreateAnimation(0.0);
  1513. anim_camRMSElbow[PAN] = CreateAnimation(0.5);
  1514. anim_camRMSElbow[TILT] = CreateAnimation(0.5);
  1515.  
  1516. static UINT RMSmpm[3] = { 6, 0,1 };//3/7
  1517. rms_anim[0] = new MGROUP_ROTATE(ridx, RMSmpm, 3, _V(-2.519, 1.149, 9.613), _V(0, 0, 1), (float)(19 * RAD)); // -180 .. +180
  1518. rms_anim[1] = new MGROUP_ROTATE(ridx, SHOULDERYAWGrp1, 1, _V(-2.523, 1.551, 9.589), _V(0, 1, 0), (float)(-360 * RAD)); // -2 .. +145 KNEE BEND
  1519. rms_anim[2] = new MGROUP_ROTATE(ridx, SHOULDERPITCHGrp3, 1, _V(-2.512, 2.059, 9.59), _V(1, 0, 0), (float)(147 * RAD)); // -2 .. +145 WAIST SWIVEL
  1520.  
  1521. rms_anim[3] = new MGROUP_ROTATE(ridx, ELBOWGrp1, 2, _V(-2.512, 1.896298, 3.2241), _V(1, 0, 0), (float)(-162 * RAD)); // -2 .. +145 KNEE BEND
  1522.  
  1523. rms_anim[4] = new MGROUP_ROTATE(ridx, WPITCHGrp, 1, _V(-2.512, 2.061, -3.827), _V(1, 0, 0), (float)(242.6 * RAD)); // -2 .. +145 KNEE BEND
  1524. rms_anim[5] = new MGROUP_ROTATE(ridx, WYAWGrp, 1, _V(-2.512, 2.055, -4.326), _V(0, 1, 0), (float)(242.8 * RAD)); // -2 .. +145 KNEE BEND
  1525. rms_anim[6] = new MGROUP_ROTATE(ridx, EEGrp3, 1, _V(-2.515, 2.059, -5.5327), _V(0, 0, 1), (float)(894 * RAD)); // -2 .. +145 KNEE BEND
  1526. rms_anim[7] = new MGROUP_ROTATE(LOCALVERTEXLIST, MAKEGROUPARRAY(arm_tip), 6, _V(-2.515, 2.059, -5.5327), _V(0, 0, 1), (float)(894 * RAD)); // -447 .. +447
  1527.  
  1528.  
  1529. static UINT RMSElbowCamGrp[2] = { GRP_ELBOW_CAM, GRP_PANTILT_ELBOW_CAM };
  1530. MGROUP_ROTATE* pRMSElbowCamPan = new MGROUP_ROTATE(ridx, RMSElbowCamGrp + 1, 1, _V(-2.318106, 2.368114, 2.63319), _V(0.7, 0.7, 0), (float)(340 * RAD));
  1531.  
  1532. MGROUP_ROTATE* pRMSElbowCamTilt = new MGROUP_ROTATE(ridx, RMSElbowCamGrp, 1, _V(-2.116386, 2.48436, 2.63319), _V(0.7, -0.7, 0), (float)(340 * RAD));
  1533.  
  1534. MGROUP_ROTATE* pRMSElbowCamLoc = new MGROUP_ROTATE(LOCALVERTEXLIST, MAKEGROUPARRAY(camRMSElbowLoc), 3, _V(-2.57968, 0.296129, -0.0332794), _V(1, 0, 0), 0.0f);
  1535.  
  1536.  
  1537. parent = AddAnimationComponent(anim_MPM, 0, 1, rms_anim[0]);
  1538. parent = AddAnimationComponent(anim_arm_sy, 0, 1, rms_anim[1],parent);
  1539. parent = AddAnimationComponent(anim_arm_sp, 0, 1, rms_anim[2], parent);
  1540. parent = AddAnimationComponent(anim_arm_ep, 0, 1, rms_anim[3], parent);
  1541. parent2 = AddAnimationComponent(anim_camRMSElbow[PAN], 0, 1, pRMSElbowCamPan, parent);
  1542. parent2 = AddAnimationComponent(anim_camRMSElbow[TILT], 0, 1, pRMSElbowCamTilt, parent2);
  1543. AddAnimationComponent(anim_camRMSElbow[TILT], 0, 1, pRMSElbowCamLoc, parent2);
  1544.  
  1545. parent = AddAnimationComponent(anim_arm_wp, 0, 1, rms_anim[4], parent);
  1546. parent = AddAnimationComponent(anim_arm_wy, 0, 1, rms_anim[5], parent);
  1547. parent = AddAnimationComponent(anim_arm_wr, 0, 1, rms_anim[6], parent);
  1548. hAC_arm1 = AddAnimationComponent(anim_rms_ee, 0, 1, rms_anim[7], parent);
  1549.  
  1550.  
  1551.  
  1552.  
  1553. //IK setup
  1554. VECTOR3 shoulder_pos = _V(-9.784, -2.10, 2.05);
  1555. VECTOR3 elbow_pos = _V(-3.3, -2.26, 1.7);
  1556. VECTOR3 wrist_pos = _V(3.55, -2.26, 1.7);
  1557. elbow_pos -= shoulder_pos;
  1558. wrist_pos -= shoulder_pos;
  1559. shoulder_pos -= shoulder_pos;
  1560. lu = length(elbow_pos);
  1561. ll = length(elbow_pos - wrist_pos);
  1562. shoulder_neutral = 0.0136; //In anim coordinate
  1563. shoulder_range = 147; //in deg
  1564. shoulder_min = shoulder_range*-shoulder_neutral; //Min angle, deg
  1565. shoulder_max = shoulder_range*(1 - shoulder_neutral); //Max angle, deg
  1566. elbow_neutral = 0.0123;
  1567. elbow_range = 162;
  1568. elbow_min = elbow_range*-elbow_neutral; //Min angle, deg
  1569. elbow_max = elbow_range*(1 - elbow_neutral); //Max angle, deg
  1570. wrist_neutral = 0.5; //In anim coordinate
  1571. wrist_range = 240; //in deg
  1572. wrist_min = wrist_range*-wrist_neutral; //Min angle, deg
  1573. wrist_max = wrist_range*(1 - wrist_neutral); //Max angle, deg
  1574. arm_wrist_pos = wrist_pos;
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586. //anim_rms_ee = CreateAnimation(0.0);
  1587. //AddAnimationComponent(anim_rms_ee, 0, 1, rms_anim[6] , parent);
  1588. //hAC_arm = AddAnimationComponent(anim_rms_ee, 0, 1, rms_anim[6], parent);
  1589.  
  1590.  
  1591. // ***** 9. SSME pitch gimbal animations
  1592. double init_gimbal = -10*RAD;
  1593. float max_gimbal = (float)(-0.2*PI);
  1594. anim_ssmes = CreateAnimation (init_gimbal/max_gimbal);
  1595.  
  1596. static UINT SSMEL_Grp = GRP_SSMEL;
  1597. ssme_anim[0] = new MGROUP_ROTATE (midx, &SSMEL_Grp, 1, _V(-1.55,-0.37,-12.5), _V(-1,0,0), max_gimbal);
  1598. AddAnimationComponent (anim_ssmes, 0, 1, ssme_anim[0]);
  1599.  
  1600. static UINT SSMER_Grp = GRP_SSMER;
  1601. ssme_anim[1] = new MGROUP_ROTATE (midx, &SSMER_Grp, 1, _V( 1.55,-0.37,-12.5), _V(-1,0,0), max_gimbal);
  1602. AddAnimationComponent (anim_ssmes, 0, 1, ssme_anim[1]);
  1603.  
  1604. static UINT SSMET_Grp = GRP_SSMET;
  1605. ssme_anim[2] = new MGROUP_ROTATE (midx, &SSMET_Grp, 1, _V(0.0, 2.7, -12.5), _V(-1,0,0), max_gimbal);
  1606. AddAnimationComponent (anim_ssmes, 0, 1, ssme_anim[2]);
  1607.  
  1608. //SSME STOW
  1609. anim_ssmestow = CreateAnimation(0);
  1610.  
  1611. static UINT SSMEL1_Grp = GRP_SSMEL;
  1612. ssme_animSTOW[0] = new MGROUP_ROTATE(midx, &SSMEL1_Grp, 1, _V(-1.55, -0.37, -12.5), _V(-0.70710678, 0.70710678, 0), -7.1 * RAD);
  1613. AddAnimationComponent(anim_ssmestow, 0, 1, ssme_animSTOW[0]);
  1614.  
  1615. static UINT SSMER1_Grp = GRP_SSMER;
  1616. ssme_animSTOW[1] = new MGROUP_ROTATE(midx, &SSMER1_Grp, 1, _V(1.55, -0.37, -12.5), _V(0.70710678, 0.70710678, 0), 7.1 * RAD);
  1617. AddAnimationComponent(anim_ssmestow, 0, 1, ssme_animSTOW[1]);
  1618.  
  1619. static UINT SSMET1_Grp = GRP_SSMET;
  1620. ssme_animSTOW[2] = new MGROUP_ROTATE(midx, &SSMET1_Grp, 1, _V(0.0, 2.7, -12.5), _V(-1, 0, 0), 11.6 * RAD);
  1621. AddAnimationComponent(anim_ssmestow, 0, 1, ssme_animSTOW[2]);
  1622.  
  1623.  
  1624. // ***** 10. ext airlock *****
  1625.  
  1626. static UINT extDoorGrp[1] = { 0 };
  1627. static MGROUP_ROTATE newextDoor(11, extDoorGrp, 1,
  1628. _V(0, -.9320414, 12.04634), _V(1, 0, 0), (float)(-120 * RAD));
  1629. // static UINT LCargoDoorGrp[4] = { GRP_cargodooroutL, GRP_cargodoorinL, GRP_radiatorFL, GRP_radiatorBL };
  1630. // static MGROUP_ROTATE LCargoDoor(midx, LCargoDoorGrp, 4,
  1631. // _V(-2.88, 1.3, 0), _V(0, 0, 1), (float)(175.5*RAD));
  1632.  
  1633. static UINT extDoor1Grp[1] = { GRP_INNERAIRLOACK };
  1634. static MGROUP_ROTATE newextDoor1(midx, extDoor1Grp, 1,
  1635. _V(0, -1.082, 12.238), _V(1, 0, 0), (float)(90 * RAD));
  1636.  
  1637. anim_extdoor = CreateAnimation(0);
  1638. AddAnimationComponent(anim_extdoor, 0.0, 1, &newextDoor);
  1639. AddAnimationComponent(anim_extdoor, 0.0, 1, &newextDoor1);
  1640.  
  1641.  
  1642. // ***** 11. ext airlock ***** WITH ODS
  1643. static UINT extodsDoorGrp[1] = { 6 };
  1644. static MGROUP_ROTATE newextodsDoor(3, extodsDoorGrp, 1,
  1645. _V(0, -1.11, 9.168), _V(1, 0, 0), (float)(-120 * RAD));
  1646. // static UINT LCargoDoorGrp[4] = { GRP_cargodooroutL, GRP_cargodoorinL, GRP_radiatorFL, GRP_radiatorBL };
  1647. // static MGROUP_ROTATE LCargoDoor(midx, LCargoDoorGrp, 4,
  1648. // _V(-2.88, 1.3, 0), _V(0, 0, 1), (float)(175.5*RAD));
  1649.  
  1650. static UINT extodsDoor1Grp[1] = { 27 };
  1651. static MGROUP_ROTATE newextodsDoor1(3, extodsDoor1Grp, 1,
  1652. _V(0, -1.045832, 9.199), _V(-1, 0, 0), (float)(-90 * RAD));
  1653.  
  1654. anim_extodsdoor = CreateAnimation(0);
  1655. AddAnimationComponent(anim_extodsdoor, 0.0, 1, &newextodsDoor);
  1656. AddAnimationComponent(anim_extodsdoor, 0.0, 1, &newextodsDoor1);
  1657.  
  1658. // ***** 11. ext airlock ***** WITHOUT ODS
  1659. static UINT EXTAIRLOCKDoorGrp[3] = { 5};
  1660. static MGROUP_ROTATE EXTAIRLOCKDoor(6, EXTAIRLOCKDoorGrp, 1,
  1661. _V(0, -1.11, 9.168), _V(1, 0, 0), (float)(-120 * RAD));
  1662. // static UINT LCargoDoorGrp[4] = { GRP_cargodooroutL, GRP_cargodoorinL, GRP_radiatorFL, GRP_radiatorBL };
  1663. // static MGROUP_ROTATE LCargoDoor(midx, LCargoDoorGrp, 4,
  1664. // _V(-2.88, 1.3, 0), _V(0, 0, 1), (float)(175.5*RAD));
  1665. static UINT EXTAIRLOCKDoor1Grp[3] = { 26 };
  1666. static MGROUP_ROTATE EXTAIRLOCK1Door(6, EXTAIRLOCKDoor1Grp, 1,
  1667. _V(0, -1.045832, 9.199), _V(-1, 0, 0), (float)(-120 * RAD));
  1668. anim_EXTAIRLOCK = CreateAnimation(0);
  1669. AddAnimationComponent(anim_EXTAIRLOCK, 0.0, 1, &EXTAIRLOCKDoor);
  1670. AddAnimationComponent(anim_EXTAIRLOCK, 0.0, 1, &EXTAIRLOCK1Door);
  1671.  
  1672. //*******EXternalTankHAtch
  1673. static UINT exhGrp[1] = { GRP_Group9 };
  1674. static MGROUP_ROTATE ExternalTankHatch1(midx, exhGrp, 1,
  1675. _V(1.341984, -2.849617, -7.251037), _V(0, -0.0523, 0.9986), (float)(-180 * RAD));
  1676. static UINT exh1Grp[1] = { GRP_Group10 };
  1677. static MGROUP_ROTATE ExternalTankHatch2(midx, exh1Grp, 1,
  1678. _V(-1.341984, -2.849617, -7.251037), _V(0, -0.0523, 0.9986), (float)(180 * RAD));
  1679.  
  1680.  
  1681. anim_SETD = CreateAnimation(0.0);
  1682. anim_PETD = CreateAnimation(0.0);
  1683. AddAnimationComponent(anim_PETD, 0, 1, &ExternalTankHatch1);
  1684. AddAnimationComponent(anim_SETD, 0, 1, &ExternalTankHatch2);
  1685.  
  1686.  
  1687.  
  1688. //********12 Drag chute****************
  1689. static UINT CHUTE[2] = {0,1 };
  1690. static MGROUP_SCALE DCHUTE(5, CHUTE, 2,
  1691. _V(0, 4.5, -12.158), _V(.01, .01, .01));
  1692. anim_CHUTE = CreateAnimation(0.0);
  1693. AddAnimationComponent(anim_CHUTE, 0, 1, &DCHUTE);
  1694.  
  1695. //*******13 Dock Ring
  1696. anim_DOCKRING = CreateAnimation(0.0);
  1697. static UINT RING[4] = { 6, 10, 7, 5, };
  1698. static MGROUP_TRANSLATE RING1(3, RING, 4,_V(0, .45, 0));
  1699.  
  1700. static UINT ROD1_1[1] = { 12};
  1701. static MGROUP_TRANSLATE ROD1(3, ROD1_1, 1, _V(-.025, .45, 0));
  1702.  
  1703. static UINT ROD1_2[1] = { 11 };
  1704. static MGROUP_TRANSLATE ROD1A(3, ROD1_2, 1, _V(.025, .45, 0));
  1705.  
  1706. static UINT ROD2_1[1] = { 9 };
  1707. static MGROUP_TRANSLATE ROD2(3, ROD2_1, 1, _V(0, .45, .025));
  1708.  
  1709. static UINT ROD2_2[1] = { 10 };
  1710. static MGROUP_TRANSLATE ROD2A(3, ROD2_2, 1, _V(0, .45, -.025));
  1711.  
  1712. static UINT ROD3_1[1] = { 8 };
  1713. static MGROUP_TRANSLATE ROD3(3, ROD3_1, 1, _V(0, .45, -.025));
  1714.  
  1715. static UINT ROD3_2[1] = { 7 };
  1716. static MGROUP_TRANSLATE ROD3A(3, ROD3_2, 1, _V(0, .45, .025));
  1717.  
  1718.  
  1719.  
  1720. AddAnimationComponent(anim_DOCKRING, 0, 1, &ROD1);
  1721. AddAnimationComponent(anim_DOCKRING, 0, 1, &ROD1A);
  1722.  
  1723. AddAnimationComponent(anim_DOCKRING, 0, 1, &ROD2);
  1724. AddAnimationComponent(anim_DOCKRING, 0, 1, &ROD2A);
  1725.  
  1726. AddAnimationComponent(anim_DOCKRING, 0, 1, &ROD3);
  1727. AddAnimationComponent(anim_DOCKRING, 0, 1, &ROD3A);
  1728.  
  1729. AddAnimationComponent(anim_DOCKRING, 0, 1, &RING1);
  1730. //********14 mpmobss
  1731. static UINT OBSSmpm[1] = { 0 };
  1732. static MGROUP_ROTATE OBSS_A(7, OBSSmpm, 1,_V(2.544, 1.187, 9.613), _V(0, 0, 1), (float)(-30 * RAD)); // -180 .. +180
  1733. anim_MPMOBSS = CreateAnimation(0.0);
  1734. // obssparent = AddAnimationComponent(anim_MPMOBSS, 0, 1, &OBSS_A);
  1735. // obss_anim[0] = new MGROUP_ROTATE(LOCALVERTEXLIST, MAKEGROUPARRAY(armobss_tip), 3, OBSS_POS, _V(0, 0, 1), (float)(0.0));
  1736. // AddAnimationComponent(anim_MPMOBSS, 0, 1, obss_anim[0], obssparent);
  1737.  
  1738. //*******Body flap
  1739. static UINT bfGrp[1] = { GRP_Group2 };
  1740. static MGROUP_ROTATE BodyFlap(midx, bfGrp, 1,
  1741. _V(0, -2.199202, - 12.13037), _V(-1,0,0), (float)(34.2*RAD));
  1742. anim_bf = CreateAnimation(0.34);
  1743. AddAnimationComponent(anim_bf, 0, 1, &BodyFlap);
  1744. //INDICATOR
  1745. static UINT bfINDGrp[1] = { GRP_INDBODYFLAP };
  1746. static MGROUP_TRANSLATE BodyFlapIND(vidx, bfINDGrp, 1, _V(0, -.0485, -.013));
  1747. anim_BODYFLAPINDICATOR = CreateAnimation(0.0);
  1748. AddAnimationComponent(anim_BODYFLAPINDICATOR, 0, 1, &BodyFlapIND);
  1749.  
  1750. static UINT autobfINDGrp[1] = { GRP_LEFTSPDAUTO };
  1751. static MGROUP_TRANSLATE autoBodyFlapIND(vidx, autobfINDGrp, 1, _V(-.002, 0, -.002));
  1752. static UINT autobfINDGrpr[1] = { GRP_RIGHTSPDAUTO };
  1753. static MGROUP_TRANSLATE autoBodyFlapINDr(vidx, autobfINDGrpr, 1, _V(.002, 0, -.002));
  1754.  
  1755. anim_AUTOBDYFLAP = CreateAnimation(0.0);
  1756. AddAnimationComponent(anim_AUTOBDYFLAP, 0, 1, &autoBodyFlapIND);
  1757. AddAnimationComponent(anim_AUTOBDYFLAP, 0, 1, &autoBodyFlapINDr);
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763. //newius
  1764. anim_ius = CreateAnimation(0.0);
  1765.  
  1766. ius_anim[0] = new MGROUP_ROTATE(LOCALVERTEXLIST, MAKEGROUPARRAY(arm_ius), 3, pl1_ofs, _V(1, 0, 0), (float)(-59*RAD));
  1767.  
  1768. AddAnimationComponent(anim_ius, 0, 1, ius_anim[0]);
  1769.  
  1770.  
  1771. static UINT ADTADoorGrp[1] = { GRP_leftairprobe };
  1772. static MGROUP_ROTATE LEFTADTA1(midx, ADTADoorGrp, 1,
  1773. _V(-1.038175, - 1.2254, 19.25658), _V(0, 1, 0), (float)(-180 * RAD));
  1774.  
  1775. static UINT ADTADoor1Grp[1] = { GRP_rightairprobe };
  1776. static MGROUP_ROTATE RIGHTADTA1(midx, ADTADoor1Grp, 1,
  1777. _V(1.038175, -1.2254, 19.25658), _V(0, 1, 0), (float)(180 * RAD));
  1778. // static UINT LCargoDoorGrp[4] = { GRP_cargodooroutL, GRP_cargodoorinL, GRP_radiatorFL, GRP_radiatorBL };
  1779. // static MGROUP_ROTATE LCargoDoor(midx, LCargoDoorGrp, 4,
  1780. // _V(-2.88, 1.3, 0), _V(0, 0, 1), (float)(175.5*RAD));
  1781.  
  1782. anim_ADTA = CreateAnimation(1.0);
  1783. AddAnimationComponent(anim_ADTA, 0.0, 1, &LEFTADTA1);
  1784. AddAnimationComponent(anim_ADTA, 0.0, 1, &RIGHTADTA1);
  1785.  
  1786.  
  1787. //mfdswitches
  1788. static UINT mfd1pwrGrp[1] = { GRP_CRT1_PWR };
  1789. static MGROUP_ROTATE MFDPWR1(vidx, mfd1pwrGrp, 1,
  1790. _V(-0.110675, 1.80093, 14.44304), _V(1, 0, 0), (float)(45 * RAD));
  1791.  
  1792.  
  1793.  
  1794. anim_mfd1 = CreateAnimation(0.5);
  1795. AddAnimationComponent(anim_mfd1, 0.0, 1, &MFDPWR1);
  1796. //MFD0
  1797. static UINT mfd0pwrGrp[1] = { GRP_CRT3_PWR };
  1798. static MGROUP_ROTATE MFDPWR0(vidx, mfd0pwrGrp, 1,
  1799. _V(-0.110675, 1.80093, 14.44304), _V(1, 0, 0), (float)(45 * RAD));
  1800.  
  1801.  
  1802.  
  1803. anim_mfd0 = CreateAnimation(0.5);
  1804. AddAnimationComponent(anim_mfd0, 0.0, 1, &MFDPWR0);
  1805. //MFD2
  1806. static UINT mfd2pwrGrp[1] = { GRP_CRT2_PWR };
  1807. static MGROUP_ROTATE MFDPWR2(vidx, mfd2pwrGrp, 1,
  1808. _V(-0.110675, 1.80093, 14.44304), _V(1, 0, 0), (float)(45 * RAD));
  1809. anim_mfd2 = CreateAnimation(0.5);
  1810. AddAnimationComponent(anim_mfd2, 0.0, 1, &MFDPWR2);
  1811. //aft mfd
  1812. static UINT mfdApwrGrp[1] = { GRP_R11LS1 };
  1813. static MGROUP_ROTATE MFDPWRA(vidx, mfdApwrGrp, 1,
  1814. _V(1.2786, 2.1382, 13.29), _V(0, 0, 1), (float)(45 * RAD));
  1815.  
  1816.  
  1817.  
  1818. anim_mfdAFT = CreateAnimation(0.5);
  1819. AddAnimationComponent(anim_mfdAFT, 0.0, 1, &MFDPWRA);
  1820.  
  1821.  
  1822. //AFTMET TIMER
  1823. anim_AFTMETTIMER = CreateAnimation(0.5);
  1824.  
  1825.  
  1826. static UINT AFTMETSELECTGrp[1] = { GRP_aftmissionmettimer };
  1827. static MGROUP_ROTATE AFTMET(vidx, AFTMETSELECTGrp, 1,
  1828. _V(-0.8209285, 2.869725, 12.25803), _V(1, 0, -.2), (float)(45 * RAD));
  1829. AddAnimationComponent(anim_AFTMETTIMER, 0.0, 1, &AFTMET);
  1830.  
  1831. //afteventtimer
  1832.  
  1833. anim_AFTSETRESET = CreateAnimation(0.5);
  1834.  
  1835.  
  1836. static UINT AFTSETRESETGrp[1] = { GRP_AFTTIMERSETRESET };
  1837. static MGROUP_ROTATE AFTSETRESET(vidx, AFTSETRESETGrp, 1,
  1838. _V(0.352, 2.4346, 12.314), _V(1, 0, 0), (float)(60 * RAD));
  1839. AddAnimationComponent(anim_AFTSETRESET, 0.0, 1, &AFTSETRESET);
  1840.  
  1841. anim_AFTTIMERSTARTSTOP = CreateAnimation(0.5);
  1842.  
  1843.  
  1844. static UINT AFTSTARTSTOPGrp[1] = { GRP_AFTTIMERSTARTSTOP };
  1845. static MGROUP_ROTATE AFTSTARTSTOP(vidx, AFTSTARTSTOPGrp, 1,
  1846. _V(0.381, 2.4346, 12.314), _V(1, 0, 0), (float)(60 * RAD));
  1847. AddAnimationComponent(anim_AFTTIMERSTARTSTOP, 0.0, 1, &AFTSTARTSTOP);
  1848.  
  1849. anim_AFTTIMERUPDOWNTEST = CreateAnimation(0.5);
  1850.  
  1851.  
  1852. static UINT AFTUPDOWNTESTGrp[1] = { GRP_AFTTIMERUPDOWNTEST };
  1853. static MGROUP_ROTATE AFTTIMERUPDOWNTEST(vidx, AFTUPDOWNTESTGrp, 1,
  1854. _V(0.412, 2.4346, 12.314), _V(1, 0, 0), (float)(60 * RAD));
  1855. AddAnimationComponent(anim_AFTTIMERUPDOWNTEST, 0.0, 1, &AFTTIMERUPDOWNTEST);
  1856. //AFT TIMER CONTROLS
  1857. anim_AFTEVENTMINUTE2 = CreateAnimation(0.0);
  1858. static UINT AFTMINUTE2Grp[1] = { GRP_A6Utog1 };
  1859. static MGROUP_ROTATE AFTTIMERMINUTE2(vidx, AFTMINUTE2Grp, 1,
  1860. _V(.415, 2.498, 12.285), _V(1, 0, 0), (float)(360 * RAD));
  1861. AddAnimationComponent(anim_AFTEVENTMINUTE2, 0.0, 1, &AFTTIMERMINUTE2);
  1862.  
  1863. anim_AFTEVENTMINUTE1 = CreateAnimation(0.0);
  1864. static UINT AFTMINUTE1Grp[1] = { GRP_A6Utog2 };
  1865. static MGROUP_ROTATE AFTTIMERMINUTE1(vidx, AFTMINUTE1Grp, 1,
  1866. _V(.393, 2.498, 12.285), _V(1, 0, 0), (float)(360 * RAD));
  1867. AddAnimationComponent(anim_AFTEVENTMINUTE1, 0.0, 1, &AFTTIMERMINUTE1);
  1868.  
  1869. anim_AFTEVENTSECOND1 = CreateAnimation(0.0);
  1870. static UINT AFTSECOND1Grp[1] = { GRP_A6Utog3 };
  1871. static MGROUP_ROTATE AFTTIMERSECOND1(vidx, AFTSECOND1Grp, 1,
  1872. _V(.369, 2.498, 12.285), _V(1, 0, 0), (float)(360 * RAD));
  1873. AddAnimationComponent(anim_AFTEVENTSECOND1, 0.0, 1, &AFTTIMERSECOND1);
  1874.  
  1875. anim_AFTEVENTSECOND2 = CreateAnimation(0.0);
  1876. static UINT AFTSECOND2Grp[1] = { GRP_A6Utog4 };
  1877. static MGROUP_ROTATE AFTTIMERSECOND2(vidx, AFTSECOND2Grp, 1,
  1878. _V(.346, 2.498, 12.285), _V(1, 0, 0), (float)(360 * RAD));
  1879. AddAnimationComponent(anim_AFTEVENTSECOND2, 0.0, 1, &AFTTIMERSECOND2);
  1880.  
  1881. //FRONT TIMER CONTROLS
  1882. anim_FRTEVENTMINUTE2 = CreateAnimation(0.0);
  1883. static UINT FRONTMINUTE2Grp[1] = { GRP_frontminutesselect2 };
  1884. static MGROUP_ROTATE FRONTTIMERMINUTE2(vidx, FRONTMINUTE2Grp, 1,
  1885. _V(-0.00718, 1.691, 14.36001), _V(1,0, 0), (float)(360 * RAD));
  1886. AddAnimationComponent(anim_FRTEVENTMINUTE2, 0.0, 1, &FRONTTIMERMINUTE2);
  1887.  
  1888. anim_FRTEVENTMINUTE1 = CreateAnimation(0.0);
  1889. static UINT FRONTMINUTE1Grp[1] = { GRP_frontminutes1select };
  1890. static MGROUP_ROTATE FRONTTIMERMINUTE1(vidx, FRONTMINUTE1Grp, 1,
  1891. _V(.014, 1.691, 14.36001), _V(1, 0, 0), (float)(360 * RAD));
  1892. AddAnimationComponent(anim_FRTEVENTMINUTE1, 0.0, 1, &FRONTTIMERMINUTE1);
  1893.  
  1894. anim_FRTEVENTSECOND1 = CreateAnimation(0.0);
  1895. static UINT FRONTSECOND1Grp[1] = { GRP_frontseconds1select };
  1896. static MGROUP_ROTATE FRONTTIMERSECOND1(vidx, FRONTSECOND1Grp, 1,
  1897. _V(.06, 1.691, 14.36001), _V(1, 0, 0), (float)(360 * RAD));
  1898. AddAnimationComponent(anim_FRTEVENTSECOND1, 0.0, 1, &FRONTTIMERSECOND1);
  1899.  
  1900. anim_FRTEVENTSECOND2 = CreateAnimation(0.0);
  1901. static UINT FRONTSECOND2Grp[1] = { GRP_frontseconds2select };
  1902. static MGROUP_ROTATE FRONTTIMERSECOND2(vidx, FRONTSECOND2Grp, 1,
  1903. _V(.04, 1.691, 14.36001), _V(1, 0, 0), (float)(360 * RAD));
  1904. AddAnimationComponent(anim_FRTEVENTSECOND2, 0.0, 1, &FRONTTIMERSECOND2);
  1905.  
  1906. anim_FRTSETRESET = CreateAnimation(0.5);
  1907. anim_FRTTIMERSTARTSTOP = CreateAnimation(0.5);
  1908. anim_FRTTIMERUPDOWNTEST = CreateAnimation(0.5);
  1909.  
  1910.  
  1911. static UINT FRTSETRESETGrp[1] = { GRP_FRONTTIMERSETRESET };
  1912. static MGROUP_ROTATE FRTSETRESET(vidx, FRTSETRESETGrp, 1,
  1913. _V(0.102, 1.687, 14.33), _V(1, 0, 0), (float)(45 * RAD));
  1914. AddAnimationComponent(anim_FRTSETRESET, 0.0, 1, &FRTSETRESET);
  1915.  
  1916.  
  1917. static UINT FRTSTARTSTOPGrp[1] = { GRP_FRONTTIMERSTARTSTOP };
  1918. static MGROUP_ROTATE FRTSTARTSTOP(vidx, FRTSTARTSTOPGrp, 1,
  1919. _V(-0.074, 1.687, 14.33), _V(1, 0, 0), (float)(45 * RAD));
  1920. AddAnimationComponent(anim_FRTTIMERSTARTSTOP, 0.0, 1, &FRTSTARTSTOP);
  1921.  
  1922.  
  1923. static UINT FRTTIMERUPDOWNTESTGrp[1] = { GRP_FRONTEVENTTIMERUPDOWNTEST };
  1924. static MGROUP_ROTATE FTIMERUPDOWNTEST(vidx, FRTTIMERUPDOWNTESTGrp, 1,
  1925. _V(-.105, 1.687, 14.33), _V(1, 0, 0), (float)(45 * RAD));
  1926. AddAnimationComponent(anim_FRTTIMERUPDOWNTEST, 0.0, 1, &FTIMERUPDOWNTEST);
  1927.  
  1928. //FRONT MET
  1929. anim_FRTMET = CreateAnimation(0.5);
  1930.  
  1931.  
  1932. static UINT FRTMETSELECTGrp[1] = { GRP_FRONTGMTTEST };
  1933. static MGROUP_ROTATE FRTMET(vidx, FRTMETSELECTGrp, 1,
  1934. _V(.512, 2.715, 14.294), _V(1, 0, 0), (float)(45 * RAD));
  1935. AddAnimationComponent(anim_FRTMET, 0.0, 1, &FRTMET);
  1936.  
  1937. //PANELA2
  1938. anim_PANELA2SCALE = CreateAnimation(0.5);
  1939.  
  1940. static UINT A2SCALESELECTGrp[1] = { GRP_A2U2 };
  1941. static MGROUP_ROTATE A2SCALE(vidx, A2SCALESELECTGrp, 1,
  1942. _V(0, 3.125, 12.231), _V(1, 0, 0), (float)(45 * RAD));
  1943. AddAnimationComponent(anim_PANELA2SCALE, 0.0, 1, &A2SCALE);
  1944.  
  1945. anim_PANELA2TEST = CreateAnimation(0.5);
  1946.  
  1947. static UINT A2TESTSELECTGrp[1] = { GRP_A2U1 };
  1948. static MGROUP_ROTATE A2TEST(vidx, A2TESTSELECTGrp, 1,
  1949. _V(0, 3.188, 12.231), _V(1, 0, 0), (float)(45 * RAD));
  1950. AddAnimationComponent(anim_PANELA2TEST, 0.0, 1, &A2TEST);
  1951.  
  1952. anim_PANELA2pwr = CreateAnimation(0.5);
  1953.  
  1954. static UINT A2pwrSELECTGrp[1] = { GRP_A1US12 };
  1955. static MGROUP_ROTATE A2pwr(vidx, A2pwrSELECTGrp, 1,
  1956. _V(1.282, 2.703, 12.147), _V(1, 0, 0), (float)(45 * RAD));
  1957. AddAnimationComponent(anim_PANELA2pwr, 0.0, 1, &A2pwr);
  1958. //ku controls
  1959. anim_KUAZ = CreateAnimation(0.5);
  1960.  
  1961. static UINT KUAZGrp[1] = { GRP_A1US2 };
  1962. static MGROUP_ROTATE KUAZ(vidx, KUAZGrp, 1,
  1963. _V(1.147, 2.88, 12.147), _V(0, 1, 0), (float)(45 * RAD));
  1964. AddAnimationComponent(anim_KUAZ, 0.0, 1, &KUAZ);
  1965.  
  1966. anim_KUEL = CreateAnimation(0.5);
  1967.  
  1968. static UINT KUELGrp[1] = { GRP_A1US3 };
  1969. static MGROUP_ROTATE KUEL(vidx, KUELGrp, 1,
  1970. _V(1.102, 2.88, 12.147), _V(1, 0, 0), (float)(45 * RAD));
  1971. AddAnimationComponent(anim_KUEL, 0.0, 1, &KUEL);
  1972.  
  1973. anim_KURATE = CreateAnimation(0.5);
  1974. static UINT KUrateGrp[1] = { GRP_A1US4 };
  1975. static MGROUP_ROTATE KUrate(vidx, KUrateGrp, 1,
  1976. _V(1.069, 2.88, 12.147), _V(1, 0, 0), (float)(45 * RAD));
  1977. AddAnimationComponent(anim_KURATE, 0.0, 1, &KUrate);
  1978.  
  1979. //lighting
  1980. static UINT floodpwrGrp[1] = { GRP_floodlighting };
  1981. static MGROUP_ROTATE FLOODPWR(vidx, floodpwrGrp, 1,
  1982. _V(0.43404, 2.772718 , 12.21255), _V(1, 0, 0), (float)(60 * RAD));
  1983.  
  1984. static UINT AFTPORTpwrGrp[1] = { GRP_AFTPORT };
  1985. static MGROUP_ROTATE AFTPORTPWR(vidx, AFTPORTpwrGrp, 1,
  1986. _V(0.176, 2.694968, 12.235), _V(1, 0, 0), (float)(60 * RAD));
  1987.  
  1988. static UINT AFTSTBDpwrGrp[1] = { GRP_AFTSTBD };
  1989. static MGROUP_ROTATE AFTSTBDPWR(vidx, AFTSTBDpwrGrp, 1,
  1990. _V(0.221, 2.694968, 12.235), _V(1, 0, 0), (float)(60 * RAD));
  1991.  
  1992. static UINT MIDPORTpwrGrp[1] = { GRP_MIDPORT };
  1993. static MGROUP_ROTATE MIDPORTPWR(vidx, MIDPORTpwrGrp, 1,
  1994. _V(0.176, 2.635005, 12.25304), _V(1, 0, 0), (float)(60 * RAD));
  1995.  
  1996. static UINT MIDSTBDpwrGrp[1] = { GRP_MIDSTBD };
  1997. static MGROUP_ROTATE MIDSTBDPWR(vidx, MIDSTBDpwrGrp, 1,
  1998. _V(0.221, 2.635005, 12.25304), _V(1, 0, 0), (float)(60 * RAD));
  1999.  
  2000. static UINT FWDPORTpwrGrp[1] = { GRP_FWDPORT };
  2001. static MGROUP_ROTATE FWDPORTPWR(vidx, FWDPORTpwrGrp, 1,
  2002. _V(0.176, 2.571194 , 12.27293), _V(1, 0, 0), (float)(60 * RAD));
  2003.  
  2004. static UINT FWDSTBDpwrGrp[1] = { GRP_FWDSTBD };
  2005. static MGROUP_ROTATE FWDSTBDPWR(vidx, FWDSTBDpwrGrp, 1,
  2006. _V(0.221, 2.571194, 12.27293), _V(1, 0, 0), (float)(60 * RAD));
  2007.  
  2008.  
  2009. static UINT DOCKpwrGrp[1] = { GRP_DOCKINGLIGHT };
  2010. static MGROUP_ROTATE DOCKPWR(vidx, DOCKpwrGrp, 1,
  2011. _V(0.22196 , 2.517156, 12.28897), _V(1, 0, 0), (float)(60 * RAD));
  2012.  
  2013.  
  2014. anim_docklight = CreateAnimation(0.5);
  2015. AddAnimationComponent(anim_docklight, 0.0, 1, &DOCKPWR);
  2016.  
  2017.  
  2018. static UINT FWDpwrGrp[1] = { GRP_FWDLIGHT };
  2019. static MGROUP_ROTATE FWDPWR(vidx, FWDpwrGrp, 1,
  2020. _V(0.17696, 2.51693, 12.28904), _V(1, 0, 0), (float)(-60 * RAD));
  2021.  
  2022.  
  2023. anim_fwdlight = CreateAnimation(0.5);
  2024. AddAnimationComponent(anim_fwdlight, 0.0, 1, &FWDPWR);
  2025.  
  2026. anim_floodstbdaft = CreateAnimation(0.5);
  2027. AddAnimationComponent(anim_floodstbdaft, 0.0, 1, &AFTSTBDPWR);
  2028.  
  2029. anim_floodportaft = CreateAnimation(0.5);
  2030. AddAnimationComponent(anim_floodportaft, 0.0, 1, &AFTPORTPWR);
  2031.  
  2032. anim_floodstbdmid = CreateAnimation(0.5);
  2033. AddAnimationComponent(anim_floodstbdmid, 0.0, 1, &MIDSTBDPWR);
  2034.  
  2035. anim_floodportmid = CreateAnimation(0.5);
  2036. AddAnimationComponent(anim_floodportmid, 0.0, 1, &MIDPORTPWR);
  2037.  
  2038. anim_floodstbdfwd = CreateAnimation(0.5);
  2039. AddAnimationComponent(anim_floodstbdfwd, 0.0, 1, &FWDSTBDPWR);
  2040.  
  2041. anim_floodportfwd = CreateAnimation(0.5);
  2042. AddAnimationComponent(anim_floodportfwd, 0.0, 1, &FWDPORTPWR);
  2043.  
  2044.  
  2045.  
  2046. anim_floodon = CreateAnimation(0.5);
  2047. AddAnimationComponent(anim_floodon, 0.0, 1, &FLOODPWR);
  2048.  
  2049. static UINT HUDpwrGrp[1] = { GRP_HUDPOWERLEFT };
  2050. static MGROUP_ROTATE HUDPWR(vidx, HUDpwrGrp, 1,_V(-0.538165 , 2.355418, 14.53427), _V(1, 0, 0), (float)(-60 * RAD));
  2051.  
  2052. static UINT HUDpwr1Grp[1] = { GRP_HUDPOWERONRIGHT };
  2053. static MGROUP_ROTATE HUDPWR1(vidx, HUDpwr1Grp, 1, _V(0.530135 , 2.355064 , 14.53435), _V(1, 0, 0), (float)(-60 * RAD));
  2054.  
  2055.  
  2056. anim_HUDpower = CreateAnimation(0.5);
  2057. AddAnimationComponent(anim_HUDpower, 0.0, 1, &HUDPWR);
  2058. AddAnimationComponent(anim_HUDpower, 0.0, 1, &HUDPWR1);
  2059.  
  2060.  
  2061. static UINT ATDApwrGrp[1] = { GRP_leftadtastow };
  2062. static MGROUP_ROTATE ATDAPWR(vidx, ATDApwrGrp, 1, _V(-0.22296, 1.599788, 14.11368), _V(1, 0, 0), (float)(-60 * RAD));
  2063.  
  2064. static UINT ATDApwr1Grp[1] = { GRP_rightadtastow };
  2065. static MGROUP_ROTATE ATDAPWR1(vidx, ATDApwr1Grp, 1, _V(-0.18793, 1.599788, 14.11341), _V(1, 0, 0), (float)(-60 * RAD));
  2066.  
  2067.  
  2068. anim_ATDADeploy = CreateAnimation(0.5);
  2069. AddAnimationComponent(anim_ATDADeploy, 0.0, 1, &ATDAPWR);
  2070. AddAnimationComponent(anim_ATDADeploy, 0.0, 1, &ATDAPWR1);
  2071.  
  2072.  
  2073. // ***** 9 Payload bay cameras animation *****
  2074. // FRONT LEFT A
  2075. static UINT camFLYawGrp[1] = { GRP_Group43 };
  2076. MGROUP_ROTATE* CameraFLYaw = new MGROUP_ROTATE(midx, camFLYawGrp, 1,
  2077. _V(-1.791455, 1.574, 11.82927), _V(0, 1, 0), (float)(340 * RAD));
  2078. anim_camFLyaw = CreateAnimation(0.5);
  2079.  
  2080. parent = AddAnimationComponent(anim_camFLyaw, 0, 1, CameraFLYaw);
  2081.  
  2082. static UINT camFLPitchGrp[1] = { GRP_Group44 };
  2083. MGROUP_ROTATE* CameraFLPitch = new MGROUP_ROTATE(midx, camFLPitchGrp, 1,
  2084. _V(-1.791455, 1.574, 11.82927), _V(1, 0, 0), (float)(340 * RAD));
  2085. anim_camFLpitch = CreateAnimation(0.5);
  2086. //anim_camFLpitch = CreateAnimation (0.7647);
  2087.  
  2088. parent = AddAnimationComponent(anim_camFLpitch, 0, 1, CameraFLPitch, parent);
  2089.  
  2090. MGROUP_TRANSFORM* CameraFLPos = new MGROUP_TRANSFORM(LOCALVERTEXLIST, MAKEGROUPARRAY(&plbCamPos[0]), 1);
  2091. AddAnimationComponent(anim_camFLpitch, 0, 1, CameraFLPos, parent);
  2092.  
  2093. // FRONT RIGHT D
  2094. static UINT camFRYawGrp[1] = { GRP_Group48 };
  2095. MGROUP_ROTATE* CameraFRYaw = new MGROUP_ROTATE(midx, camFRYawGrp, 1,
  2096. _V(1.791455, 1.574, 11.82927), _V(0, 1, 0), (float)(340 * RAD));
  2097. anim_camFRyaw = CreateAnimation(0.5);
  2098.  
  2099. parent = AddAnimationComponent(anim_camFRyaw, 0, 1, CameraFRYaw);
  2100.  
  2101. static UINT camFRPitchGrp[1] = { GRP_Group47 };
  2102. MGROUP_ROTATE* CameraFRPitch = new MGROUP_ROTATE(midx, camFRPitchGrp, 1,
  2103. _V(1.791455, 1.574, 11.82927), _V(1, 0, 0), (float)(340 * RAD));
  2104. anim_camFRpitch = CreateAnimation(0.5);
  2105.  
  2106. parent = AddAnimationComponent(anim_camFRpitch, 0, 1, CameraFRPitch, parent);
  2107.  
  2108. MGROUP_TRANSFORM* CameraFRPos = new MGROUP_TRANSFORM(LOCALVERTEXLIST, MAKEGROUPARRAY(&plbCamPos[3]), 1);
  2109. AddAnimationComponent(anim_camFRpitch, 0, 1, CameraFRPos, parent);
  2110.  
  2111. // BACK RIGHT C
  2112. static UINT camBRYawGrp[1] = { GRP_Group49 };
  2113. MGROUP_ROTATE* CameraBRYaw = new MGROUP_ROTATE(midx, camBRYawGrp, 1,
  2114. _V(2.29455, 1.748, -6.476198), _V(0, 1, 0), (float)(340 * RAD));
  2115. anim_camBRyaw = CreateAnimation(0.5);
  2116.  
  2117. parent = AddAnimationComponent(anim_camBRyaw, 0, 1, CameraBRYaw);
  2118.  
  2119. static UINT camBRPitchGrp[1] = { GRP_Group50 };
  2120. MGROUP_ROTATE* CameraBRPitch = new MGROUP_ROTATE(midx, camBRPitchGrp, 1,
  2121. _V(2.29455, 1.748, -6.476198), _V(-1, 0, 0), (float)(340 * RAD));
  2122. anim_camBRpitch = CreateAnimation(0.5);
  2123.  
  2124. parent = AddAnimationComponent(anim_camBRpitch, 0, 1, CameraBRPitch, parent);
  2125.  
  2126. MGROUP_TRANSFORM* CameraBRPos = new MGROUP_TRANSFORM(LOCALVERTEXLIST, MAKEGROUPARRAY(&plbCamPos[2]), 1);
  2127. AddAnimationComponent(anim_camBRpitch, 0, 1, CameraBRPos, parent);
  2128.  
  2129. // BACK LEFT b
  2130. static UINT camBLYawGrp[1] = { GRP_Group46 };
  2131. MGROUP_ROTATE* CameraBLYaw = new MGROUP_ROTATE(midx, camBLYawGrp, 1,
  2132. _V(-2.29455, 1.748, -6.476198), _V(0, 1, 0), (float)(340 * RAD));
  2133. anim_camBLyaw = CreateAnimation(0.5);
  2134.  
  2135. parent = AddAnimationComponent(anim_camBLyaw, 0, 1, CameraBLYaw);
  2136.  
  2137. static UINT camBLPitchGrp[1] = { GRP_Group45 };
  2138. MGROUP_ROTATE* CameraBLPitch = new MGROUP_ROTATE(midx, camBLPitchGrp, 1,
  2139. _V(-2.29455, 1.748, -6.476198), _V(-1, 0, 0), (float)(340 * RAD));
  2140. anim_camBLpitch = CreateAnimation(0.5);
  2141.  
  2142. parent = AddAnimationComponent(anim_camBLpitch, 0, 1, CameraBLPitch, parent);
  2143.  
  2144. MGROUP_TRANSFORM* CameraBLPos = new MGROUP_TRANSFORM(LOCALVERTEXLIST, MAKEGROUPARRAY(&plbCamPos[1]), 1);
  2145. AddAnimationComponent(anim_camBLpitch, 0, 1, CameraBLPos, parent);
  2146.  
  2147. anim_SLIDEWIRE = CreateAnimation(0);
  2148. // doorparentR = AddAnimationComponent(anim_door, 0, .8, &RCargoDoorHINGE1);//swing out
  2149. //doorparentR = AddAnimationComponent(anim_door, 0.0, 0.4632, &RCargoDoorHINGE);//swing out
  2150. ANIMATIONCOMPONENT_HANDLE SLIDEWIRER, SLIDEWIREL, SLIDEWIRERPARENT, SLIDEWIRELPARENT;
  2151. static UINT SLIDEWIRERGrp[1] = { 4 };
  2152. static MGROUP_ROTATE RSLIDEWIRE(9, SLIDEWIRERGrp, 1,
  2153. _V(2.84, 1.284, 0), _V(0, 0, 1), (float)(-175.5*RAD));
  2154.  
  2155. static UINT SLIDEWIRER1Grp[3] = { 0,8,10};
  2156. static MGROUP_ROTATE RSLIDEWIRE1(9, SLIDEWIRER1Grp, 3,
  2157. _V(2.694777, 1.411242, 3.038241), _V(0, 0, 1), (float)(135*RAD));
  2158.  
  2159. static UINT SLIDEWIRER2Grp[1] = { 3 };
  2160. static MGROUP_ROTATE RSLIDEWIRE2(9, SLIDEWIRER2Grp, 1,
  2161. _V(2.600686, 1.585991, 2.797316), _V(0, 0, 1), (float)(-30 * RAD));
  2162.  
  2163.  
  2164. static UINT SLIDEWIRELGrp[1] = { 5 };
  2165. static MGROUP_ROTATE LSLIDEWIRE(9, SLIDEWIRELGrp, 1,
  2166. _V(-2.84, 1.284, 0), _V(0, 0, 1), (float)(175.5*RAD));
  2167.  
  2168. static UINT SLIDEWIREl1Grp[3] = { 1,9,11 };
  2169. static MGROUP_ROTATE lSLIDEWIRE1(9, SLIDEWIREl1Grp, 3,
  2170. _V(-2.694777, 1.411242, 3.038241), _V(0, 0, 1), (float)(-135 * RAD));
  2171.  
  2172. static UINT SLIDEWIREL2Grp[1] = { 7 };
  2173. static MGROUP_ROTATE LSLIDEWIRE2(9, SLIDEWIREL2Grp, 1,
  2174. _V(-2.599019, 1.578824, 2.775872), _V(0, 0, 1), (float)(30 * RAD));
  2175.  
  2176. SLIDEWIRER = AddAnimationComponent(anim_door, 0.0, 0.4632, &RSLIDEWIRE);//swing out
  2177. SLIDEWIRERPARENT=AddAnimationComponent(anim_door, 0.0, 0.4632, &RSLIDEWIRE1, SLIDEWIRER);
  2178. AddAnimationComponent(anim_door, 0.0, 0.4632, &RSLIDEWIRE2, SLIDEWIRERPARENT);
  2179.  
  2180.  
  2181. SLIDEWIREL = AddAnimationComponent(anim_door, 0.5368, 1.0, &LSLIDEWIRE);//swing out
  2182. SLIDEWIRELPARENT=AddAnimationComponent(anim_door, 0.5368, 1.0, &lSLIDEWIRE1, SLIDEWIREL);
  2183. AddAnimationComponent(anim_door, 0.5368, 1.0, &LSLIDEWIRE2, SLIDEWIRELPARENT);
  2184.  
  2185.  
  2186. //rcsindicators
  2187.  
  2188. anim_pitchup = CreateAnimation(0.0);
  2189. anim_pitchdown = CreateAnimation(0.0);
  2190. anim_rollleft = CreateAnimation(0.0);
  2191. anim_rollright = CreateAnimation(0.0);
  2192. anim_yawleft = CreateAnimation(0.0);
  2193. anim_yawright = CreateAnimation(0.0);
  2194.  
  2195. static UINT PITCHUPGrp[1] = { GRP_PITCHUP };
  2196. static MGROUP_TRANSLATE PITCHUP(vidx, PITCHUPGrp, 1,_V(0, 0, -.001));
  2197. AddAnimationComponent(anim_pitchup, 0.0, 1, &PITCHUP);
  2198.  
  2199. static UINT PITCHDOWNGrp[1] = { GRP_PITCHDOWN };
  2200. static MGROUP_TRANSLATE PITCHDOWN(vidx, PITCHDOWNGrp, 1, _V(0, 0, -.002));
  2201. AddAnimationComponent(anim_pitchdown, 0.0, 1, &PITCHDOWN);
  2202.  
  2203. static UINT ROLLLEFTGrp[1] = { GRP_LEFTROLL };
  2204. static MGROUP_TRANSLATE ROLLLEFT(vidx, ROLLLEFTGrp, 1, _V(0, 0, -.002));
  2205. AddAnimationComponent(anim_rollleft, 0.0, 1, &ROLLLEFT);
  2206.  
  2207. static UINT ROLLRIGHTGrp[1] = { GRP_RIGHTROLL };
  2208. static MGROUP_TRANSLATE ROLLRIGHT(vidx, ROLLRIGHTGrp, 1, _V(0, 0, -.002));
  2209. AddAnimationComponent(anim_rollright, 0.0, 1, &ROLLRIGHT);
  2210.  
  2211. static UINT YAWLEFTGrp[1] = { GRP_LEFTYAW };
  2212. static MGROUP_TRANSLATE YAWLEFT(vidx, YAWLEFTGrp, 1, _V(0, 0, -.002));
  2213. AddAnimationComponent(anim_yawleft, 0.0, 1, &YAWLEFT);
  2214.  
  2215. static UINT YAWRIGHTGrp[1] = { GRP_RIGHTYAW };
  2216. static MGROUP_TRANSLATE YAWRIGHT(vidx, YAWRIGHTGrp, 1, _V(0, 0, -.003));
  2217. AddAnimationComponent(anim_yawright, 0.0, 1, &YAWRIGHT);
  2218.  
  2219.  
  2220. // ======================================================
  2221. // VC animation definitions
  2222. // ======================================================
  2223. plop->DefineAnimations(vidx);
  2224. }
  2225.  
  2226.  
  2227. // --------------------------------------------------------------
  2228. // Register the MFD interface for the ascent autopilot
  2229. // --------------------------------------------------------------
  2230. //int Atlantis::RegisterAscentApMfd ()
  2231. //{
  2232. // static char *name = "AscentAP";
  2233. // MFDMODESPECEX spec;
  2234. // spec.name = name;
  2235. // spec.key = OAPI_KEY_B;
  2236. // spec.context = NULL;
  2237. // spec.msgproc = AscentApMfd::MsgProc;
  2238. // return RegisterMFDMode (spec);
  2239. //}
  2240.  
  2241. // --------------------------------------------------------------
  2242. // Open the dialog interface for the ascent autopilot
  2243. // --------------------------------------------------------------
  2244. //void Atlantis::CreateAscentAPDlg ()
  2245. //{
  2246. // if (!ascentApDlg) {
  2247. // ascentApDlg = new AscentAPDlg(ascap);
  2248. // ascentApDlg->Open (g_Param.hDLL, true);
  2249. // }
  2250. //}
  2251.  
  2252. // --------------------------------------------------------------
  2253. // Close the dialog interface for the ascent autopilot
  2254. // --------------------------------------------------------------
  2255. //void Atlantis::DestroyAscentAPDlg ()
  2256. //{
  2257. // if (ascentApDlg) {
  2258. // delete ascentApDlg;
  2259. // ascentApDlg = 0;
  2260. // }
  2261. //}
  2262.  
  2263. // --------------------------------------------------------------
  2264. // Jettison both SRBs from ET
  2265. // --------------------------------------------------------------
  2266.  
  2267.  
  2268. // --------------------------------------------------------------
  2269. // Jettison ET from orbiter
  2270. // --------------------------------------------------------------
  2271. //rms
  2272. void Atlantis::ToggleGrapple(void)
  2273. {
  2274.  
  2275. HWND hDlg;
  2276. OBJHANDLE hV = GetAttachmentStatus(rms_attach);
  2277.  
  2278. if (hV) { // release satellite
  2279.  
  2280. ATTACHMENTHANDLE hAtt = CanArrest();
  2281. DetachChild(rms_attach, 0);
  2282. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  2283. SetWindowText(GetDlgItem(hDlg, IDC_GRAPPLE), "Grapple");
  2284. EnableWindow(GetDlgItem(hDlg, IDC_STOW), TRUE);
  2285. }
  2286.  
  2287.  
  2288. #ifdef UNDEF
  2289. VECTOR3 pos, dir, rot, gbay, gpos;
  2290. GetAttachmentParams(sat_attach, pos, dir, rot);
  2291. Local2Global(pos, gbay);
  2292. VESSEL* v = oapiGetVesselInterface(hV);
  2293. DWORD nAttach = v->AttachmentCount(true);
  2294. for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points
  2295. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  2296. v->GetAttachmentParams(hAtt, pos, dir, rot);
  2297. v->Local2Global(pos, gpos);
  2298. if (dist(gpos, gbay) < MAXGRAPPLINGDIST) {
  2299. AttachChild(hV, sat_attach, hAtt);
  2300. return;
  2301. }
  2302. }
  2303. #endif
  2304.  
  2305. }
  2306. else { // grapple satellite
  2307.  
  2308. VECTOR3 gpos, grms, pos, dir, rot;
  2309. Local2Global(arm_tip[0], grms); // global position of RMS tip
  2310.  
  2311. // Search the complete vessel list for a grappling candidate.
  2312. // Not very scalable ...
  2313. for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
  2314. OBJHANDLE hV = oapiGetVesselByIndex(i);
  2315. if (hV == GetHandle()) continue; // we don't want to grapple ourselves ...
  2316. oapiGetGlobalPos(hV, &gpos);
  2317. //sprintf(oapiDebugString(), "dist2 %0.4f ,%0.4f", dist(gpos, grms), oapiGetSize(hV));
  2318. //if (dist(gpos, grms) < oapiGetSize(hV))
  2319. { // in range
  2320. VESSEL* v = oapiGetVesselInterface(hV);
  2321. DWORD nAttach = v->AttachmentCount(true);
  2322. for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points of the candidate
  2323. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  2324. const char* id = v->GetAttachmentId(hAtt);
  2325. if (strncmp(id, "GS", 2)) continue; // attachment point not compatible
  2326. v->GetAttachmentParams(hAtt, pos, dir, rot);
  2327. v->Local2Global(pos, gpos);
  2328. distattach = (dist(gpos, grms));
  2329.  
  2330. //sprintf(oapiDebugString(), "dist2 %0.4f ,%0.4f", distattach, MAXGRAPPLINGDIST);
  2331. if (dist(gpos, grms) < .2) { // found one!
  2332. // check whether satellite is currently clamped into payload bay
  2333. //if (hV == GetAttachmentStatus(sat_attach))
  2334. // DetachChild(sat_attach);
  2335. AttachChild(hV, rms_attach, hAtt);
  2336. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  2337. SetWindowText(GetDlgItem(hDlg, IDC_GRAPPLE), "Release");
  2338. //EnableWindow(GetDlgItem(hDlg, IDC_STOW), FALSE);
  2339.  
  2340. }
  2341. return;
  2342. }
  2343. }
  2344. }
  2345. }
  2346.  
  2347. }
  2348. }
  2349.  
  2350. void Atlantis::ToggleArrest(void)
  2351. {
  2352. { // try to arrest satellite
  2353. ToggleGrapple();
  2354. }
  2355. }
  2356.  
  2357. // check whether the currently grappled object can be stowed in the cargo bay
  2358. ATTACHMENTHANDLE Atlantis::CanArrest(void) const
  2359. {
  2360. OBJHANDLE hV = GetAttachmentStatus(rms_attach);
  2361. if (!hV) return 0;
  2362. VESSEL* v = oapiGetVesselInterface(hV);
  2363. DWORD nAttach = v->AttachmentCount(true);
  2364. VECTOR3 pos, dir, rot, gpos, gbay;
  2365. GetAttachmentParams(rms_attach, pos, dir, rot);
  2366. Local2Global(pos, gbay);
  2367. for (DWORD j = 0; j < nAttach; j++) {
  2368. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  2369. if (strncmp(v->GetAttachmentId(hAtt), "GS", 2)) continue; // attachment point not compatible
  2370. v->GetAttachmentParams(hAtt, pos, dir, rot);
  2371. v->Local2Global(pos, gpos);
  2372. if (dist(gpos, gbay) < .2) {
  2373. return hAtt;
  2374. }
  2375. }
  2376. return 0;
  2377. }
  2378.  
  2379. /*
  2380. void Atlantis::ToggleGrapple(void)
  2381. {
  2382. HWND hDlg;
  2383. OBJHANDLE hV = GetAttachmentStatus(rms_attach);
  2384.  
  2385. if (hV) { // release satellite
  2386.  
  2387. ATTACHMENTHANDLE hAtt = CanArrest();
  2388. DetachChild(rms_attach);
  2389. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  2390. SetWindowText(GetDlgItem(hDlg, IDC_GRAPPLE), "Grapple");
  2391. EnableWindow(GetDlgItem(hDlg, IDC_STOW), TRUE);
  2392. }
  2393. // check whether the object being ungrappled is ready to be clamped into the payload bay
  2394.  
  2395.  
  2396. #ifdef UNDEF
  2397. VECTOR3 pos, dir, rot, gbay, gpos;
  2398. GetAttachmentParams (sat_attach, pos, dir, rot);
  2399. Local2Global (pos, gbay);
  2400. VESSEL *v = oapiGetVesselInterface (hV);
  2401. DWORD nAttach = v->AttachmentCount (true);
  2402. for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points
  2403. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle (true, j);
  2404. v->GetAttachmentParams (hAtt, pos, dir, rot);
  2405. v->Local2Global (pos, gpos);
  2406. if (dist(gpos, gbay) < MAX_GRAPPLING_DIST) {
  2407. AttachChild(hV, sat_attach, hAtt);
  2408. return;
  2409. }
  2410. }
  2411. #endif
  2412.  
  2413. }
  2414. else { // grapple satellite
  2415.  
  2416. VECTOR3 gpos, grms, pos, dir, rot;
  2417. Local2Global(arm_tip[0], grms); // global position of RMS tip
  2418.  
  2419. // Search the complete vessel list for a grappling candidate.
  2420. // Not very scalable ...
  2421. for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
  2422. OBJHANDLE hV = oapiGetVesselByIndex(i);
  2423. if (hV == GetHandle()) continue; // we don't want to grapple ourselves ...
  2424. oapiGetGlobalPos(hV, &gpos);
  2425. if (dist(gpos, grms) < oapiGetSize(hV)) { // in range
  2426. VESSEL *v = oapiGetVesselInterface(hV);
  2427. DWORD nAttach = v->AttachmentCount(true);
  2428. for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points of the candidate
  2429. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  2430. //const char *id = v->GetAttachmentId(hAtt);
  2431. //if (strncmp(id, "GS", 2)) continue; // attachment point not compatible
  2432. v->GetAttachmentParams(hAtt, pos, dir, rot);
  2433. v->Local2Global(pos, gpos);
  2434. if (dist(gpos, grms) < MAX_GRAPPLING_DIST) { // found one!
  2435. // check whether satellite is currently clamped into payload bay
  2436. AttachChild(hV, rms_attach, hAtt);
  2437. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  2438. SetWindowText(GetDlgItem(hDlg, IDC_GRAPPLE), "Release");
  2439. EnableWindow(GetDlgItem(hDlg, IDC_STOW), FALSE);
  2440. }
  2441. return;
  2442. }
  2443. }
  2444. }
  2445. }
  2446.  
  2447. }
  2448. }
  2449. */
  2450. //togglegrappleobss
  2451. void Atlantis::ToggleGrappleOBSS(void)
  2452. {
  2453. HWND hDlg;
  2454. OBJHANDLE hV = GetAttachmentStatus(OBSS_attach);
  2455.  
  2456. if (hV) {
  2457.  
  2458. ATTACHMENTHANDLE hAtt = CanArrestOBSS();
  2459. DetachChild(OBSS_attach);
  2460. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  2461. SetWindowText(GetDlgItem(hDlg, IDC_GRAPPLE2), "Grapple");
  2462. //EnableWindow(GetDlgItem(hDlg, IDC_STOW), TRUE);
  2463. }
  2464. // check whether the object being ungrappled is ready to be clamped into the payload bay
  2465.  
  2466.  
  2467.  
  2468. #ifdef UNDEF
  2469. VECTOR3 pos, dir, rot, gbay, gpos;
  2470. GetAttachmentParams(sat_attach, pos, dir, rot);
  2471. Local2Global(pos, gbay);
  2472. VESSEL *v = oapiGetVesselInterface(hV);
  2473. DWORD nAttach = v->AttachmentCount(true);
  2474. for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points
  2475. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  2476. v->GetAttachmentParams(hAtt, pos, dir, rot);
  2477. v->Local2Global(pos, gpos);
  2478. if (dist(gpos, gbay) < MAX_GRAPPLING_DIST) {
  2479. AttachChild(hV, sat_attach, hAtt);
  2480. return;
  2481. }
  2482. }
  2483. #endif
  2484.  
  2485.  
  2486. }
  2487. else { // grapple satellite
  2488.  
  2489. VECTOR3 gpos, grms, pos, dir, rot;
  2490. Local2Global(armobss_tip[0], grms); // global position of RMS tip
  2491. EnableWindow(GetDlgItem(hDlg, IDC_GRAPPLE2), FALSE);
  2492. // Search the complete vessel list for a grappling candidate.
  2493. // Not very scalable ...
  2494. for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
  2495. OBJHANDLE hV = oapiGetVesselByIndex(i);
  2496. if (hV == GetHandle()) continue; // we don't want to grapple ourselves ...
  2497. oapiGetGlobalPos(hV, &gpos);
  2498. if (dist(gpos, grms) < oapiGetSize(hV)) { // in range
  2499. VESSEL *v = oapiGetVesselInterface(hV);
  2500. DWORD nAttach = v->AttachmentCount(true);
  2501. for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points of the candidate
  2502. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  2503. const char *id = v->GetAttachmentId(hAtt);
  2504. if (strncmp(id, "OS", 2)) continue; // attachment point not compatible
  2505. v->GetAttachmentParams(hAtt, pos, dir, rot);
  2506. v->Local2Global(pos, gpos);
  2507. if (dist(gpos, grms) < MAX_GRAPPLING_DIST) { // found one!
  2508. // check whether satellite is currently clamped into payload bay
  2509. EnableWindow(GetDlgItem(hDlg, IDC_GRAPPLE2), TRUE);
  2510. if (hV == GetAttachmentStatus(OBSS_attach))
  2511. DetachChild(OBSS_attach);
  2512. AttachChild(hV, OBSS_attach, hAtt);
  2513. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  2514. SetWindowText(GetDlgItem(hDlg, IDC_GRAPPLE2), "Release");
  2515. //EnableWindow(GetDlgItem(hDlg, IDC_STOW), FALSE);
  2516. }
  2517. return;
  2518. }
  2519. }
  2520. }
  2521. }
  2522.  
  2523.  
  2524. }
  2525.  
  2526. }
  2527.  
  2528. //toggle2
  2529. void Atlantis::ToggleGrapple2(void)
  2530. {
  2531. HWND hDlg;
  2532. OBJHANDLE hV1 = GetAttachmentStatus(sat_attach2);
  2533.  
  2534. if (hV1) { // release satellite
  2535.  
  2536. ATTACHMENTHANDLE hAtt = CanArrest2();
  2537. DetachChild(sat_attach2,.1);
  2538. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  2539. SetWindowText(GetDlgItem(hDlg, IDC_PAYLOAD2), "Arrest");
  2540. //EnableWindow(GetDlgItem(hDlg, IDC_STOW), TRUE);
  2541. }
  2542. // check whether the object being ungrappled is ready to be clamped into the payload bay
  2543.  
  2544.  
  2545.  
  2546. #ifdef UNDEF
  2547. VECTOR3 pos, dir, rot, gbay, gpos;
  2548. GetAttachmentParams (sat_attach, pos, dir, rot);
  2549. Local2Global (pos, gbay);
  2550. VESSEL *v = oapiGetVesselInterface (hV);
  2551. DWORD nAttach = v->AttachmentCount (true);
  2552. for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points
  2553. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle (true, j);
  2554. v->GetAttachmentParams (hAtt, pos, dir, rot);
  2555. v->Local2Global (pos, gpos);
  2556. if (dist (gpos, gbay) < MAX_GRAPPLING_DIST) {
  2557. AttachChild (hV, sat_attach, hAtt);
  2558. return;
  2559. }
  2560. }
  2561. #endif
  2562.  
  2563.  
  2564. }
  2565. else { // grapple satellite
  2566.  
  2567. VECTOR3 aphpos, aphdir, aphrot, gaph;
  2568. VECTOR3 shippos, shipdir, shiprot, gpship;
  2569.  
  2570. // get attachment point positions based on selected point
  2571. {
  2572.  
  2573. GetAttachmentParams(sat_attach2, aphpos, aphdir, aphrot);
  2574.  
  2575. }
  2576. // change the position to a global one rather then a local one. This will allow me to offset it from the local center.
  2577. // the local position is stored in gaph
  2578. Local2Global(aphpos, gaph);
  2579.  
  2580. for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
  2581. OBJHANDLE hV = oapiGetVesselByIndex(i);
  2582. // if (strncmp (hV->GetClassName(), "QJFFS", 5)!=0 ){ //restrict to only QuadJ ships to make it easy.
  2583.  
  2584. // Look for any ship with a child attach point. This allows the Mule to grap any object
  2585. if (hV == GetHandle()) continue; // If self then continue onward because we don't want to grapple ourselves ...
  2586.  
  2587. oapiGetGlobalPos(hV, &gpship); // get global postion of ship and put into gpship
  2588. VESSEL *v = oapiGetVesselInterface(hV);
  2589. // Only look for child attach point
  2590. DWORD nAttach = v->AttachmentCount(true); //Get attachment count. I do this so that I can grap any child point.
  2591. if (nAttach > 0){ // Only continue if ship has a child attach point
  2592. for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points of the candidate and check how far away from the attach point it is
  2593. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  2594. ///* this would allow me to filter out all but QJ ships but I don't want to right now
  2595. const char *id = v->GetAttachmentId(hAtt);
  2596.  
  2597.  
  2598. if (strncmp(id, "XS", 2)) continue; // attachment point not compatible
  2599. v->GetAttachmentParams(hAtt, shippos, shipdir, shiprot); //lets get the attach point position
  2600. v->Local2Global(shippos, gpship); // and change it to a global position Recycle of gpship cause I can
  2601. if (dist(gpship, gaph) < .5) { // Is it close enough to grab?
  2602. if (hV == GetAttachmentStatus(sat_attach2))
  2603. {
  2604. DetachChild(sat_attach2, .1);
  2605. SetWindowText(GetDlgItem(hDlg, IDC_PAYLOAD2), "Arrest");
  2606. }
  2607. AttachChild(hV, sat_attach2, hAtt);
  2608.  
  2609. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  2610. SetWindowText(GetDlgItem(hDlg, IDC_PAYLOAD2), "Release");
  2611. // EnableWindow(GetDlgItem(hDlg, IDC_STOW), FALSE);
  2612. }
  2613. return;
  2614. }
  2615. }
  2616. }
  2617. }
  2618.  
  2619. }
  2620. }
  2621. void Atlantis::ToggleArrest2(void)
  2622. {
  2623.  
  2624.  
  2625. HWND hDlg;
  2626.  
  2627. { // try to arrest satellite
  2628. ToggleGrapple2();
  2629.  
  2630. }
  2631.  
  2632. }
  2633.  
  2634.  
  2635.  
  2636.  
  2637. // check whether the currently grappled object can be stowed in the cargo bay
  2638. ATTACHMENTHANDLE Atlantis::CanArrest2(void) const
  2639. {
  2640. OBJHANDLE hV = GetAttachmentStatus(sat_attach2);
  2641. if (!hV) return 0;
  2642. VESSEL *v = oapiGetVesselInterface(hV);
  2643. DWORD nAttach = v->AttachmentCount(true);
  2644. VECTOR3 pos, dir, rot, gpos, gbay;
  2645. //GetAttachmentParams(sat_attach, pos, dir, rot);
  2646. Local2Global(pos, gbay);
  2647. for (DWORD j = 0; j < nAttach; j++) {
  2648. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  2649. // if (strncmp(v->GetAttachmentId(hAtt), "XS", 2)) continue; // attachment point not compatible
  2650. v->GetAttachmentParams(hAtt, pos, dir, rot);
  2651. v->Local2Global(pos, gpos);
  2652. if (dist(gpos, gbay) < MAX_GRAPPLING_DIST) {
  2653. return hAtt;
  2654. }
  2655. }
  2656. return 0;
  2657. }
  2658.  
  2659. //toggle1
  2660. void Atlantis::ToggleGrapple1(void)
  2661. {
  2662. HWND hDlg;
  2663. OBJHANDLE hV1 = GetAttachmentStatus(sat_attach);
  2664.  
  2665. if (hV1) { // release satellite
  2666.  
  2667. ATTACHMENTHANDLE hAtt = CanArrest();
  2668. DetachChild(sat_attach, .1);
  2669. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  2670. SetWindowText(GetDlgItem(hDlg, IDC_PAYLOAD), "Arrest");
  2671. //EnableWindow(GetDlgItem(hDlg, IDC_STOW), TRUE);
  2672. }
  2673. // check whether the object being ungrappled is ready to be clamped into the payload bay
  2674.  
  2675.  
  2676.  
  2677. #ifdef UNDEF
  2678. VECTOR3 pos, dir, rot, gbay, gpos;
  2679. GetAttachmentParams(sat_attach, pos, dir, rot);
  2680. Local2Global(pos, gbay);
  2681. VESSEL *v = oapiGetVesselInterface(hV);
  2682. DWORD nAttach = v->AttachmentCount(true);
  2683. for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points
  2684. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  2685. v->GetAttachmentParams(hAtt, pos, dir, rot);
  2686. v->Local2Global(pos, gpos);
  2687. if (dist(gpos, gbay) < MAX_GRAPPLING_DIST) {
  2688. AttachChild(hV, sat_attach, hAtt);
  2689. return;
  2690. }
  2691. }
  2692. #endif
  2693.  
  2694.  
  2695. }
  2696. else { // grapple satellite
  2697.  
  2698. VECTOR3 aphpos, aphdir, aphrot, gaph;
  2699. VECTOR3 shippos, shipdir, shiprot, gpship;
  2700.  
  2701. // get attachment point positions based on selected point
  2702. {
  2703.  
  2704. GetAttachmentParams(sat_attach, aphpos, aphdir, aphrot);
  2705.  
  2706. }
  2707. // change the position to a global one rather then a local one. This will allow me to offset it from the local center.
  2708. // the local position is stored in gaph
  2709. Local2Global(aphpos, gaph);
  2710.  
  2711. for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
  2712. OBJHANDLE hV = oapiGetVesselByIndex(i);
  2713. // if (strncmp (hV->GetClassName(), "QJFFS", 5)!=0 ){ //restrict to only QuadJ ships to make it easy.
  2714.  
  2715. // Look for any ship with a child attach point. This allows the Mule to grap any object
  2716. if (hV == GetHandle()) continue; // If self then continue onward because we don't want to grapple ourselves ...
  2717.  
  2718. oapiGetGlobalPos(hV, &gpship); // get global postion of ship and put into gpship
  2719. VESSEL *v = oapiGetVesselInterface(hV);
  2720. // Only look for child attach point
  2721. DWORD nAttach = v->AttachmentCount(true); //Get attachment count. I do this so that I can grap any child point.
  2722. if (nAttach > 0){ // Only continue if ship has a child attach point
  2723. for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points of the candidate and check how far away from the attach point it is
  2724. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  2725. ///* this would allow me to filter out all but QJ ships but I don't want to right now
  2726. const char *id = v->GetAttachmentId(hAtt);
  2727. if (strncmp(id, "XS", 2)) continue; // attachment point not compatible
  2728.  
  2729. v->GetAttachmentParams(hAtt, shippos, shipdir, shiprot); //lets get the attach point position
  2730. v->Local2Global(shippos, gpship); // and change it to a global position Recycle of gpship cause I can
  2731. if (dist(gpship, gaph) < 2) { // Is it close enough to grab?
  2732. if (hV == GetAttachmentStatus(sat_attach))
  2733. {
  2734. DetachChild(sat_attach, .1);
  2735. SetWindowText(GetDlgItem(hDlg, IDC_PAYLOAD), "Arrest");
  2736. }
  2737. AttachChild(hV, sat_attach, hAtt);
  2738.  
  2739. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  2740. SetWindowText(GetDlgItem(hDlg, IDC_PAYLOAD), "Release");
  2741. // EnableWindow(GetDlgItem(hDlg, IDC_STOW), FALSE);
  2742. }
  2743. return;
  2744. }
  2745. }
  2746. }
  2747. }
  2748.  
  2749. }
  2750. }
  2751. void Atlantis::ToggleArrest1(void)
  2752. {
  2753.  
  2754.  
  2755. HWND hDlg;
  2756.  
  2757. { // try to arrest satellite
  2758. ToggleGrapple1();
  2759.  
  2760. }
  2761.  
  2762. }
  2763. ATTACHMENTHANDLE Atlantis::CanArrest1(void) const
  2764. {
  2765. OBJHANDLE hV = GetAttachmentStatus(sat_attach);
  2766. if (!hV) return 0;
  2767. VESSEL *v = oapiGetVesselInterface(hV);
  2768. DWORD nAttach = v->AttachmentCount(true);
  2769. VECTOR3 pos, dir, rot, gpos, gbay;
  2770. //GetAttachmentParams(sat_attach, pos, dir, rot);
  2771. Local2Global(pos, gbay);
  2772. for (DWORD j = 0; j < nAttach; j++) {
  2773. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  2774. // if (strncmp(v->GetAttachmentId(hAtt), "XS", 2)) continue; // attachment point not compatible
  2775. v->GetAttachmentParams(hAtt, pos, dir, rot);
  2776. v->Local2Global(pos, gpos);
  2777. if (dist(gpos, gbay) < MAX_GRAPPLING_DIST) {
  2778. return hAtt;
  2779. }
  2780. }
  2781. return 0;
  2782. }
  2783.  
  2784.  
  2785.  
  2786.  
  2787. //payload3
  2788. void Atlantis::ToggleGrapple3(void)
  2789. {
  2790. HWND hDlg;
  2791. OBJHANDLE hV1 = GetAttachmentStatus(sat_attach3);
  2792.  
  2793. if (hV1) { // release satellite
  2794.  
  2795. ATTACHMENTHANDLE hAtt = CanArrest3();
  2796. DetachChild(sat_attach3, .1);
  2797. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  2798. SetWindowText(GetDlgItem(hDlg, IDC_PAYLOAD3), "Arrest");
  2799. //EnableWindow(GetDlgItem(hDlg, IDC_STOW), TRUE);
  2800. }
  2801. // check whether the object being ungrappled is ready to be clamped into the payload bay
  2802.  
  2803.  
  2804.  
  2805. #ifdef UNDEF
  2806. VECTOR3 pos, dir, rot, gbay, gpos;
  2807. GetAttachmentParams(sat_attach, pos, dir, rot);
  2808. Local2Global(pos, gbay);
  2809. VESSEL *v = oapiGetVesselInterface(hV);
  2810. DWORD nAttach = v->AttachmentCount(true);
  2811. for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points
  2812. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  2813. v->GetAttachmentParams(hAtt, pos, dir, rot);
  2814. v->Local2Global(pos, gpos);
  2815. if (dist(gpos, gbay) < MAX_GRAPPLING_DIST) {
  2816. AttachChild(hV, sat_attach, hAtt);
  2817. return;
  2818. }
  2819. }
  2820. #endif
  2821.  
  2822.  
  2823. }
  2824. else { // grapple satellite
  2825.  
  2826. VECTOR3 aphpos, aphdir, aphrot, gaph;
  2827. VECTOR3 shippos, shipdir, shiprot, gpship;
  2828.  
  2829. // get attachment point positions based on selected point
  2830. {
  2831.  
  2832. GetAttachmentParams(sat_attach3, aphpos, aphdir, aphrot);
  2833.  
  2834. }
  2835. // change the position to a global one rather then a local one. This will allow me to offset it from the local center.
  2836. // the local position is stored in gaph
  2837. Local2Global(aphpos, gaph);
  2838.  
  2839. for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
  2840. OBJHANDLE hV = oapiGetVesselByIndex(i);
  2841. // if (strncmp (hV->GetClassName(), "QJFFS", 5)!=0 ){ //restrict to only QuadJ ships to make it easy.
  2842.  
  2843. // Look for any ship with a child attach point. This allows the Mule to grap any object
  2844. if (hV == GetHandle()) continue; // If self then continue onward because we don't want to grapple ourselves ...
  2845.  
  2846. oapiGetGlobalPos(hV, &gpship); // get global postion of ship and put into gpship
  2847. VESSEL *v = oapiGetVesselInterface(hV);
  2848. // Only look for child attach point
  2849. DWORD nAttach = v->AttachmentCount(true); //Get attachment count. I do this so that I can grap any child point.
  2850. if (nAttach > 0){ // Only continue if ship has a child attach point
  2851. for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points of the candidate and check how far away from the attach point it is
  2852. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  2853. ///* this would allow me to filter out all but QJ ships but I don't want to right now
  2854. const char *id = v->GetAttachmentId(hAtt);
  2855. if (strncmp(id, "XS", 2)) continue; // attachment point not compatible
  2856.  
  2857. v->GetAttachmentParams(hAtt, shippos, shipdir, shiprot); //lets get the attach point position
  2858. v->Local2Global(shippos, gpship); // and change it to a global position Recycle of gpship cause I can
  2859. if (dist(gpship, gaph) < 2) { // Is it close enough to grab?
  2860. if (hV == GetAttachmentStatus(sat_attach3))
  2861. {
  2862. DetachChild(sat_attach3, .1);
  2863. SetWindowText(GetDlgItem(hDlg, IDC_PAYLOAD3), "Arrest");
  2864. }
  2865. AttachChild(hV, sat_attach3, hAtt);
  2866.  
  2867. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  2868. SetWindowText(GetDlgItem(hDlg, IDC_PAYLOAD3), "Release");
  2869. // EnableWindow(GetDlgItem(hDlg, IDC_STOW), FALSE);
  2870. }
  2871. return;
  2872. }
  2873. }
  2874. }
  2875. }
  2876.  
  2877. }
  2878. }
  2879. void Atlantis::ToggleArrest3(void)
  2880. {
  2881.  
  2882.  
  2883. HWND hDlg;
  2884.  
  2885. { // try to arrest satellite
  2886. ToggleGrapple3();
  2887.  
  2888. }
  2889.  
  2890. }
  2891. ATTACHMENTHANDLE Atlantis::CanArrest3(void) const
  2892. {
  2893. OBJHANDLE hV = GetAttachmentStatus(sat_attach3);
  2894. if (!hV) return 0;
  2895. VESSEL *v = oapiGetVesselInterface(hV);
  2896. DWORD nAttach = v->AttachmentCount(true);
  2897. VECTOR3 pos, dir, rot, gpos, gbay;
  2898. //GetAttachmentParams(sat_attach, pos, dir, rot);
  2899. Local2Global(pos, gbay);
  2900. for (DWORD j = 0; j < nAttach; j++) {
  2901. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  2902. // if (strncmp(v->GetAttachmentId(hAtt), "XS", 2)) continue; // attachment point not compatible
  2903. v->GetAttachmentParams(hAtt, pos, dir, rot);
  2904. v->Local2Global(pos, gpos);
  2905. if (dist(gpos, gbay) < MAX_GRAPPLING_DIST) {
  2906. return hAtt;
  2907. }
  2908. }
  2909. return 0;
  2910. }
  2911. void Atlantis::GetSSMEGimbalPos (int which, double &pitch, double &yaw)
  2912. {
  2913. VECTOR3 dir;
  2914. if (status < 3) {
  2915. GetThrusterDir (th_main[which], dir);
  2916. } else {
  2917. dir.x = dir.y = 0.0; dir.z = 1.0;
  2918. }
  2919. pitch = asin(dir.y)+10.5*RAD;
  2920. yaw = atan(dir.x/dir.z);
  2921. }
  2922.  
  2923. void Atlantis::GetSRBGimbalPos (int which, double &pitch, double &yaw)
  2924. {
  2925. VECTOR3 dir;
  2926. if (status < 2) {
  2927. // dir = pET->GetSRBThrustDir(which);
  2928. } else {
  2929. dir.x = dir.y = 0.0; dir.z = 1.0;
  2930. }
  2931. pitch = asin(dir.y);
  2932. if (which) pitch = -pitch, yaw = -yaw;
  2933. yaw = atan(dir.x/dir.z);
  2934. }
  2935.  
  2936. //void Atlantis::ToggleArrest(void)
  2937. //{
  2938.  
  2939.  
  2940. // HWND hDlg;
  2941.  
  2942. //if (CanArrest()) { // try to arrest satellite
  2943. // ToggleGrapple();
  2944.  
  2945. // }
  2946.  
  2947. //}
  2948.  
  2949.  
  2950. /*
  2951.  
  2952.  
  2953. // check whether the currently grappled object can be stowed in the cargo bay
  2954. ATTACHMENTHANDLE Atlantis::CanArrest(void) const
  2955. {
  2956. OBJHANDLE hV = GetAttachmentStatus(rms_attach);
  2957. if (!hV) return 0;
  2958. VESSEL *v = oapiGetVesselInterface(hV);
  2959. DWORD nAttach = v->AttachmentCount(true);
  2960. VECTOR3 pos, dir, rot, gpos, gbay;
  2961. GetAttachmentParams(sat_attach, pos, dir, rot);
  2962. Local2Global(pos, gbay);
  2963. for (DWORD j = 0; j < nAttach; j++) {
  2964. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  2965. if (strncmp(v->GetAttachmentId(hAtt), "XS", 2)) continue; // attachment point not compatible
  2966. v->GetAttachmentParams(hAtt, pos, dir, rot);
  2967. v->Local2Global(pos, gpos);
  2968. if (dist(gpos, gbay) < MAX_GRAPPLING_DIST) {
  2969. return hAtt;
  2970. }
  2971. }
  2972. return 0;
  2973. }
  2974. */
  2975. ATTACHMENTHANDLE Atlantis::CanArrestOBSS(void) const
  2976. {
  2977. OBJHANDLE hV = GetAttachmentStatus(OBSS_attach);
  2978. if (!hV) return 0;
  2979. VESSEL *v = oapiGetVesselInterface(hV);
  2980. DWORD nAttach = v->AttachmentCount(true);
  2981. VECTOR3 pos, dir, rot, gpos, gbay;
  2982. //GetAttachmentParams(sat_attach, pos, dir, rot);
  2983. Local2Global(pos, gbay);
  2984. for (DWORD j = 0; j < nAttach; j++) {
  2985. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  2986. if (strncmp(v->GetAttachmentId(hAtt), "OS", 2)) continue; // attachment point not compatible
  2987. v->GetAttachmentParams(hAtt, pos, dir, rot);
  2988. v->Local2Global(pos, gpos);
  2989. if (dist(gpos, gbay) < MAX_GRAPPLING_DIST) {
  2990. return hAtt;
  2991. }
  2992. }
  2993.  
  2994. return 0;
  2995. }
  2996.  
  2997. void Atlantis::SpawnEVA(void)
  2998. {
  2999. if ((EVA1 == 0) && (EXT_proc>.8)){
  3000. //if (EXT_status == HATCH_DOWN){
  3001. if (GetAttachmentStatus(ft_pad_att) == NULL)
  3002. {
  3003. if ((ODS == 1) || (EXTAIRLOCK == 1))ft_pad_att_pos = _V(0, 0.3, 8.5);
  3004.  
  3005. SetAttachmentParams(ft_pad_att, ft_pad_att_pos, _V(0, 1, 0), _V(0, 0, -1));
  3006.  
  3007. //OBJHANDLE hVessel;
  3008. VESSELSTATUS vs;
  3009. GetStatus(vs);
  3010. hMMU = oapiCreateVessel(crew1_name, crew1_cfg, vs);
  3011.  
  3012.  
  3013. VESSEL *v = oapiGetVesselInterface(hMMU);
  3014. ATTACHMENTHANDLE hAttWFC = v->GetAttachmentHandle(true, 0);
  3015. AttachChild(hMMU, ft_pad_att, hAttWFC);
  3016. oapiSetFocusObject(hMMU);
  3017. EVA1 = 1;
  3018. //}
  3019. }
  3020. }
  3021. }
  3022. void Atlantis::SpawnEVA1(void)
  3023. {
  3024. //if (EXT_status == HATCH_DOWN){
  3025. if ((EVA2 == 0) && (EXT_proc>.8)){
  3026. if (GetAttachmentStatus(ft_pad_att1) == NULL)
  3027. {
  3028. if ((ODS == 1) || (EXTAIRLOCK == 1))ft_pad_att1_pos = _V(0, 0.3, 8.5);
  3029. SetAttachmentParams(ft_pad_att1, ft_pad_att1_pos, _V(0, 1, 0), _V(0, 0, -1));
  3030.  
  3031. //OBJHANDLE hVessel;
  3032. VESSELSTATUS vs;
  3033. GetStatus(vs);
  3034. hMMU = oapiCreateVessel(crew2_name, crew2_cfg, vs);
  3035.  
  3036.  
  3037. VESSEL *v = oapiGetVesselInterface(hMMU);
  3038. ATTACHMENTHANDLE hAttWFC = v->GetAttachmentHandle(true, 0);
  3039. AttachChild(hMMU, ft_pad_att1, hAttWFC);
  3040. oapiSetFocusObject(hMMU);
  3041. //}
  3042. EVA2 = 1;
  3043. }
  3044. }
  3045. }
  3046. void Atlantis::SpawnEVA2(void)
  3047. {
  3048. //if (EXT_status == HATCH_DOWN){
  3049. if ((EVA3 == 0) &&(EXT_proc>.8)){
  3050. if (GetAttachmentStatus(ft_pad_att2) == NULL)
  3051. {
  3052. if ((ODS == 1) || (EXTAIRLOCK == 1))ft_pad_att2_pos = _V(0, 0.3, 8.5);
  3053. SetAttachmentParams(ft_pad_att2, ft_pad_att2_pos, _V(0, 1, 0), _V(0, 0, -1));
  3054.  
  3055. //OBJHANDLE hVessel;
  3056. VESSELSTATUS vs;
  3057. GetStatus(vs);
  3058. hMMU = oapiCreateVessel(crew3_name, crew3_cfg, vs);
  3059.  
  3060.  
  3061. VESSEL *v = oapiGetVesselInterface(hMMU);
  3062. ATTACHMENTHANDLE hAttWFC = v->GetAttachmentHandle(true, 0);
  3063. AttachChild(hMMU, ft_pad_att2, hAttWFC);
  3064. oapiSetFocusObject(hMMU);
  3065. //}
  3066. EVA3 = 1;
  3067. }
  3068. }
  3069. }
  3070. void Atlantis::SpawnEVA3(void)
  3071. {
  3072. //if (EXT_status == HATCH_DOWN){
  3073. if ((EVA4 == 0) && (EXT_proc>.8)){
  3074. if (GetAttachmentStatus(ft_pad_att3) == NULL)
  3075. {
  3076. if ((ODS == 1) || (EXTAIRLOCK == 1))ft_pad_att3_pos = _V(0, 0.3, 8.5);
  3077. SetAttachmentParams(ft_pad_att3, ft_pad_att3_pos, _V(0, 1, 0), _V(0, 0, -1));
  3078.  
  3079. //OBJHANDLE hVessel;
  3080. VESSELSTATUS vs;
  3081. GetStatus(vs);
  3082. hMMU = oapiCreateVessel(crew4_name, crew4_cfg, vs);
  3083.  
  3084.  
  3085. VESSEL *v = oapiGetVesselInterface(hMMU);
  3086. ATTACHMENTHANDLE hAttWFC = v->GetAttachmentHandle(true, 0);
  3087. AttachChild(hMMU, ft_pad_att3, hAttWFC);
  3088. oapiSetFocusObject(hMMU);
  3089. //}
  3090. EVA4 = 1;
  3091. }
  3092. }
  3093. }
  3094.  
  3095.  
  3096. void Atlantis::ENTER_EVA1(void)
  3097. {
  3098.  
  3099. if (((EVA1 == 1) && ((EXTAIRLOCK == 1) || (ODS == 1)) && (EXT_proc>.8))) {//hatch open and eva performed
  3100.  
  3101. GetAttachmentParams(ft_pad_att, ft_pad_att_pos, ft_pad_att_dir, ft_pad_att_rot);
  3102. if ((ft_pad_att_pos.x > -.35 && ft_pad_att_pos.x<.35) && (ft_pad_att_pos.y>-.6 && ft_pad_att_pos.y<.80) && (ft_pad_att_pos.z>7.80 && ft_pad_att_pos.z < 9.7) ){
  3103. for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
  3104. OBJHANDLE hV = oapiGetVesselByIndex(i); //get handle for ship
  3105.  
  3106. OBJHANDLE Focusvessel = oapiGetVesselByName(crew1_name);
  3107. //if (strncmp(hV->GetVesselByName(), "MMU", 3) != 0){
  3108.  
  3109. oapiDeleteVessel(Focusvessel);
  3110. EVA1 = 0;
  3111. //SetMeshVisibilityMode(MMUMeshUINT, MESHVIS_EXTERNAL);
  3112. //EVA = 0;
  3113. //oapiSetFocusObject(hMMU);
  3114. }
  3115. }
  3116. }
  3117. //hatch open and eva performed
  3118. if (((EVA1 == 1) && ((EXTAIRLOCK == 0) && (ODS == 0)) && (EXT_proc>.8))) {
  3119.  
  3120. GetAttachmentParams(ft_pad_att, ft_pad_att_pos, ft_pad_att_dir, ft_pad_att_rot);
  3121. //no ods or airlock
  3122. if ((ft_pad_att_pos.x > -.35 && ft_pad_att_pos.x<.35) && (ft_pad_att_pos.y>-.6 && ft_pad_att_pos.y<.80) && (ft_pad_att_pos.z>11.09 && ft_pad_att_pos.z < 12.39) ){
  3123. for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
  3124. OBJHANDLE hV = oapiGetVesselByIndex(i); //get handle for ship
  3125.  
  3126. OBJHANDLE Focusvessel = oapiGetVesselByName(crew1_name);
  3127. //if (strncmp(hV->GetVesselByName(), "MMU", 3) != 0){
  3128.  
  3129. oapiDeleteVessel(Focusvessel);
  3130. EVA1 = 0;
  3131. //SetMeshVisibilityMode(MMUMeshUINT, MESHVIS_EXTERNAL);
  3132. //EVA = 0;
  3133. //oapiSetFocusObject(hMMU);
  3134. }
  3135. }
  3136.  
  3137.  
  3138.  
  3139. }
  3140.  
  3141.  
  3142.  
  3143. }
  3144.  
  3145. void Atlantis::ENTER_EVA2(void)
  3146. {
  3147.  
  3148. if (((EVA2 == 1) && ((EXTAIRLOCK == 1) || (ODS == 1)) && (EXT_proc>.8))) {//hatch open and eva performed
  3149.  
  3150. GetAttachmentParams(ft_pad_att1, ft_pad_att1_pos, ft_pad_att1_dir, ft_pad_att1_rot);
  3151. if ((ft_pad_att1_pos.x > -.35 && ft_pad_att1_pos.x<.35) && (ft_pad_att1_pos.y>-.6 && ft_pad_att1_pos.y<.80) && (ft_pad_att1_pos.z>7.80 && ft_pad_att1_pos.z < 9.7) ){
  3152. for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
  3153. OBJHANDLE hV = oapiGetVesselByIndex(i); //get handle for ship
  3154.  
  3155. OBJHANDLE Focusvessel = oapiGetVesselByName(crew2_name);
  3156. //if (strncmp(hV->GetVesselByName(), "MMU", 3) != 0){
  3157.  
  3158. oapiDeleteVessel(Focusvessel);
  3159. EVA2 = 0;
  3160. //SetMeshVisibilityMode(MMUMeshUINT, MESHVIS_EXTERNAL);
  3161. //EVA = 0;
  3162. //oapiSetFocusObject(hMMU);
  3163. }
  3164. }
  3165. }
  3166.  
  3167. if (((EVA2 == 1) && ((EXTAIRLOCK == 0) && (ODS == 0)) && (EXT_proc>.8))) {
  3168.  
  3169. GetAttachmentParams(ft_pad_att1, ft_pad_att1_pos, ft_pad_att1_dir, ft_pad_att1_rot);
  3170. if ((ft_pad_att1_pos.x > -.35 && ft_pad_att1_pos.x<.35) && (ft_pad_att1_pos.y>-.6 && ft_pad_att1_pos.y<.80) && (ft_pad_att1_pos.z>11.09 && ft_pad_att1_pos.z < 12.39) ){
  3171. for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
  3172. OBJHANDLE hV = oapiGetVesselByIndex(i); //get handle for ship
  3173.  
  3174. OBJHANDLE Focusvessel = oapiGetVesselByName(crew2_name);
  3175. //if (strncmp(hV->GetVesselByName(), "MMU", 3) != 0){
  3176.  
  3177. oapiDeleteVessel(Focusvessel);
  3178. EVA2 = 0;
  3179. //SetMeshVisibilityMode(MMUMeshUINT, MESHVIS_EXTERNAL);
  3180. //EVA = 0;
  3181. //oapiSetFocusObject(hMMU);
  3182. }
  3183. }
  3184.  
  3185.  
  3186.  
  3187. }
  3188.  
  3189.  
  3190.  
  3191. }
  3192. void Atlantis::ENTER_EVA3(void)
  3193. {
  3194.  
  3195. if (((EVA3 == 1) && ((EXTAIRLOCK == 1) || (ODS == 1)) && (EXT_proc>.8))) {//hatch open and eva performed
  3196.  
  3197. GetAttachmentParams(ft_pad_att2, ft_pad_att2_pos, ft_pad_att2_dir, ft_pad_att2_rot);
  3198. if ((ft_pad_att2_pos.x > -.35 && ft_pad_att2_pos.x<.35) && (ft_pad_att2_pos.y>-.6 && ft_pad_att2_pos.y<.80) && (ft_pad_att2_pos.z>7.80 && ft_pad_att2_pos.z < 9.7) ){
  3199. for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
  3200. OBJHANDLE hV = oapiGetVesselByIndex(i); //get handle for ship
  3201.  
  3202. OBJHANDLE Focusvessel = oapiGetVesselByName(crew3_name);
  3203. //if (strncmp(hV->GetVesselByName(), "MMU", 3) != 0){
  3204.  
  3205. oapiDeleteVessel(Focusvessel);
  3206. EVA3 = 0;
  3207. //SetMeshVisibilityMode(MMUMeshUINT, MESHVIS_EXTERNAL);
  3208. //EVA = 0;
  3209. //oapiSetFocusObject(hMMU);
  3210. }
  3211. }
  3212. }
  3213. if (((EVA3 == 1) && ((EXTAIRLOCK == 0) && (ODS == 0)) && (EXT_proc>.8))) {
  3214.  
  3215. GetAttachmentParams(ft_pad_att2, ft_pad_att2_pos, ft_pad_att2_dir, ft_pad_att2_rot);
  3216. if ((ft_pad_att2_pos.x > -.35 && ft_pad_att2_pos.x<.35) && (ft_pad_att2_pos.y>-.6 && ft_pad_att2_pos.y<.80) && (ft_pad_att2_pos.z>11.09 && ft_pad_att2_pos.z < 12.39) ){
  3217. for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
  3218. OBJHANDLE hV = oapiGetVesselByIndex(i); //get handle for ship
  3219.  
  3220. OBJHANDLE Focusvessel = oapiGetVesselByName(crew3_name);
  3221. //if (strncmp(hV->GetVesselByName(), "MMU", 3) != 0){
  3222.  
  3223. oapiDeleteVessel(Focusvessel);
  3224. EVA3 = 0;
  3225. //SetMeshVisibilityMode(MMUMeshUINT, MESHVIS_EXTERNAL);
  3226. //EVA = 0;
  3227. //oapiSetFocusObject(hMMU);
  3228. }
  3229. }
  3230.  
  3231.  
  3232.  
  3233. }
  3234.  
  3235.  
  3236.  
  3237. }
  3238. void Atlantis::ENTER_EVA4(void)
  3239. {
  3240.  
  3241. if (((EVA4 == 1) && ((EXTAIRLOCK == 1) || (ODS == 1)) && (EXT_proc>.8))) {//hatch open and eva performed
  3242.  
  3243. GetAttachmentParams(ft_pad_att3, ft_pad_att3_pos, ft_pad_att3_dir, ft_pad_att3_rot);
  3244. if ((ft_pad_att3_pos.x > -.35 && ft_pad_att3_pos.x<.35) && (ft_pad_att3_pos.y>-.6 && ft_pad_att3_pos.y<.80) && (ft_pad_att3_pos.z>7.80 && ft_pad_att3_pos.z < 9.7) ){
  3245. for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
  3246. OBJHANDLE hV = oapiGetVesselByIndex(i); //get handle for ship
  3247.  
  3248. OBJHANDLE Focusvessel = oapiGetVesselByName(crew4_name);
  3249. //if (strncmp(hV->GetVesselByName(), "MMU", 3) != 0){
  3250.  
  3251. oapiDeleteVessel(Focusvessel);
  3252. EVA4 = 0;
  3253. //SetMeshVisibilityMode(MMUMeshUINT, MESHVIS_EXTERNAL);
  3254. //EVA = 0;
  3255. //oapiSetFocusObject(hMMU);
  3256. }
  3257. }
  3258. }
  3259.  
  3260.  
  3261. if (((EVA4 == 1) && ((EXTAIRLOCK == 0) && (ODS == 0)) && (EXT_proc>.8))) {
  3262.  
  3263. GetAttachmentParams(ft_pad_att3, ft_pad_att3_pos, ft_pad_att3_dir, ft_pad_att3_rot);
  3264.  
  3265. if ((ft_pad_att3_pos.x > -.35 && ft_pad_att3_pos.x<.35) && (ft_pad_att3_pos.y>-.6 && ft_pad_att3_pos.y<.80) && (ft_pad_att3_pos.z>11.09 && ft_pad_att3_pos.z < 12.39) ){
  3266. for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
  3267. OBJHANDLE hV = oapiGetVesselByIndex(i); //get handle for ship
  3268.  
  3269. OBJHANDLE Focusvessel = oapiGetVesselByName(crew4_name);
  3270. //if (strncmp(hV->GetVesselByName(), "MMU", 3) != 0){
  3271.  
  3272. oapiDeleteVessel(Focusvessel);
  3273. EVA4 = 0;
  3274. //SetMeshVisibilityMode(MMUMeshUINT, MESHVIS_EXTERNAL);
  3275. //EVA = 0;
  3276. //oapiSetFocusObject(hMMU);
  3277. }
  3278. }
  3279.  
  3280.  
  3281.  
  3282. }
  3283.  
  3284.  
  3285.  
  3286. }
  3287.  
  3288.  
  3289.  
  3290.  
  3291.  
  3292. //double Atlantis::GetSRBThrustLevel (int which)
  3293. //{
  3294. // return (pET ? pET->GetSRBThrustLevel (which) : 0);
  3295. //}
  3296.  
  3297. void Atlantis::SetSSMEGimbal (const VECTOR3 &angle)
  3298. {
  3299. const double pitch_gimbal_max = -0.2*PI;
  3300. VECTOR3 dir;
  3301.  
  3302. dir.x = -sin(angle.y); // yaw gimbal
  3303. dir.y = sin(angle.x-angle.z); // pitch+roll gimbal
  3304. dir.z = sqrt(1.0-dir.x*dir.x-dir.y*dir.y);
  3305. SetThrusterDir (th_main[0], dir); // left SSME
  3306.  
  3307. dir.y = sin(angle.x+angle.z); // pitch+roll gimbal
  3308. dir.z = sqrt(1.0-dir.x*dir.x-dir.y*dir.y);
  3309. SetThrusterDir (th_main[1], dir); // right SSME
  3310.  
  3311. dir.y = sin(angle.x); // pitch gimbal
  3312. dir.z = sqrt(1.0-dir.x*dir.x-dir.y*dir.y);
  3313. SetThrusterDir (th_main[2], dir); // top SSME
  3314.  
  3315. SetSSMEPosition (gimbal_pos.x/pitch_gimbal_max);
  3316. }
  3317.  
  3318. // --------------------------------------------------------------
  3319. // Autopilot function: set target pitch angle [rad]
  3320. // during launch phase (until ET separation)
  3321. // --------------------------------------------------------------
  3322. double Atlantis::GetAscentPitchRate (double tgt_pitch)
  3323. {
  3324. const double a = 0.07;
  3325. const double b = 0.035;
  3326.  
  3327. VECTOR3 avel;
  3328. GetAngularVel(avel);
  3329. double dpitch = avel.x; // pitch rate
  3330. double pitch = GetPitch(); // current pitch value
  3331.  
  3332. return a*(pitch-tgt_pitch) + b*dpitch;
  3333. }
  3334.  
  3335. // --------------------------------------------------------------
  3336. // Automatic gimbal adjustment for SSME and SRB engines to correct
  3337. // for CG shift, SRB thrust variations, atmospheric effects, etc.
  3338. //
  3339. // NOTE: We use SSME gimbal for adjusting pitch rate, SRB gimbal for
  3340. // adjusting yaw and roll rate
  3341. //
  3342. // The gimbal changes are implemented individually for each axis as
  3343. // damped harmonic oscillators around target rates
  3344. // --------------------------------------------------------------
  3345. void Atlantis::AutoGimbal (const VECTOR3 &tgt_rate)
  3346. {
  3347. // Harmonic oscillator design parameters
  3348. static const double a_pitch = 2e0;
  3349. static const double b_pitch = 1e0;
  3350. static const double a_yaw = 1e-1;
  3351. static const double b_yaw = 3e-2;
  3352. static const double a_roll_srb = 1e-1;
  3353. static const double b_roll_srb = 3e-2;
  3354. static const double a_roll_ssme = 8e-2;
  3355. static const double b_roll_ssme = 5e-2;
  3356.  
  3357. VECTOR3 avel, aacc;
  3358. GetAngularVel(avel);
  3359. GetAngularAcc(aacc);
  3360. double dt = oapiGetSimStep();
  3361. double dgimbal, maxdg;
  3362. const double pitch_gimbal_max = -21.0*RAD;
  3363. const double yaw_gimbal_max = 4*RAD;
  3364. const double roll_gimbal_max_srb = 8.0*RAD;
  3365. const double roll_gimbal_max_ssme = 6*RAD;
  3366.  
  3367. bool srb_gimbal = status < 2 ;
  3368. double roll_gimbal_max = (srb_gimbal ? roll_gimbal_max_srb : roll_gimbal_max_ssme);
  3369. double a_roll = (srb_gimbal ? a_roll_srb : a_roll_ssme);
  3370. double b_roll = (srb_gimbal ? b_roll_srb : b_roll_ssme);
  3371.  
  3372. // Pitch gimbal settings
  3373. maxdg = dt*0.3; // max gimbal speed [rad/s]
  3374. dgimbal = a_pitch*(avel.x-tgt_rate.x) + b_pitch*aacc.x;
  3375. dgimbal = max(-maxdg, min(maxdg, dgimbal));
  3376. gimbal_pos.x = min (0, max (pitch_gimbal_max, gimbal_pos.x+dgimbal));
  3377.  
  3378. // Yaw gimbal settings
  3379. dgimbal = a_yaw*(avel.y-tgt_rate.y) + b_yaw*aacc.y;
  3380. gimbal_pos.y = min (yaw_gimbal_max, max(-yaw_gimbal_max, gimbal_pos.y+dgimbal));
  3381.  
  3382. // Roll gimbal settings
  3383. dgimbal = a_roll*(avel.z-tgt_rate.z) + b_roll*aacc.z;
  3384. gimbal_pos.z = min (roll_gimbal_max, max(-roll_gimbal_max, gimbal_pos.z+dgimbal));
  3385.  
  3386. // Set SRB gimbals
  3387. // if (status < 2 && pET) {
  3388. // pET->SetSRBGimbal (gimbal_pos);
  3389. // SetSSMEGimbal (_V(gimbal_pos.x,0,0)); // If SRBs are available, we gimbal the SSMEs only in pitch
  3390. // } else {
  3391. // SetSSMEGimbal (gimbal_pos);
  3392. // }
  3393. }
  3394.  
  3395. // --------------------------------------------------------------
  3396. // RCS automatic control for commanding a target attitude rate
  3397. // Used by the ascent autopilot when gimbal control is no longer available
  3398. // (SSME cut off)
  3399. // --------------------------------------------------------------
  3400. void Atlantis::AutoRCS (const VECTOR3 &tgt_rate)
  3401. {
  3402. /* // Harmonic oscillator design parameters
  3403. const double a_pitch = 4;
  3404. const double b_pitch = 2;
  3405. const double a_yaw = 2e-1;
  3406. const double b_yaw = 6e-2;
  3407. const double a_roll = 2e-1;
  3408. const double b_roll = 6e-2;
  3409.  
  3410. VECTOR3 avel, aacc;
  3411. GetAngularVel(avel);
  3412. GetAngularAcc(aacc);
  3413. double dt = oapiGetSimStep();
  3414. double drcs;
  3415.  
  3416. // Pitch RCS settings
  3417. drcs = a_pitch*(tgt_rate.x-avel.x) - b_pitch*aacc.x;
  3418. if (drcs > 0.0) {
  3419. SetThrusterGroupLevel(THGROUP_ATT_PITCHUP, min(drcs, 1.0));
  3420. SetThrusterGroupLevel(THGROUP_ATT_PITCHDOWN, 0);
  3421. } else {
  3422. SetThrusterGroupLevel(THGROUP_ATT_PITCHUP, 0);
  3423. SetThrusterGroupLevel(THGROUP_ATT_PITCHDOWN, min(-drcs, 1.0));
  3424. }
  3425.  
  3426. // Yaw RCS settings
  3427. drcs = a_yaw*(tgt_rate.y-avel.y) - b_yaw*aacc.y;
  3428. if (drcs > 0.0) {
  3429. SetThrusterGroupLevel(THGROUP_ATT_YAWLEFT, min(drcs, 1.0));
  3430. SetThrusterGroupLevel(THGROUP_ATT_YAWRIGHT, 0);
  3431. } else {
  3432. SetThrusterGroupLevel(THGROUP_ATT_YAWLEFT, 0);
  3433. SetThrusterGroupLevel(THGROUP_ATT_YAWRIGHT, min(-drcs, 1.0));
  3434. }
  3435.  
  3436. // Roll RCS settings
  3437. drcs = a_roll*(tgt_rate.z-avel.z) - b_roll*aacc.z;
  3438. if (drcs > 0.0) {
  3439. SetThrusterGroupLevel(THGROUP_ATT_BANKRIGHT, min(drcs, 1.0));
  3440. SetThrusterGroupLevel(THGROUP_ATT_BANKLEFT, 0);
  3441. } else {
  3442. SetThrusterGroupLevel(THGROUP_ATT_BANKRIGHT, 0);
  3443. SetThrusterGroupLevel(THGROUP_ATT_BANKLEFT, min(-drcs, 1.0));
  3444.  
  3445.  
  3446. }
  3447.  
  3448. */
  3449.  
  3450. }
  3451.  
  3452.  
  3453. void Atlantis::LaunchClamps ()
  3454. {
  3455.  
  3456. }
  3457.  
  3458. void Atlantis::SetGearParameters (double state)
  3459. {
  3460. static TOUCHDOWNVTX tdvtx[14] = {
  3461. {_V( 0, -3.3,18.75), 1e8, 1e6, 1.6, 0.1},
  3462. {_V(-3.96, -5.5, -3.2), 1e8, 1e6, 3, 0.2},
  3463. {_V( 3.96, -5.5, -3.2), 1e8, 1e6, 3, 0.2},
  3464. {_V(-11.9, -2.1, -10), 1e8, 1e6, 3},
  3465. {_V( 11.9, -2.1, -10), 1e8, 1e6, 3},
  3466. {_V(-11.3, -2.1, -6), 1e8, 1e6, 3},
  3467. {_V( 11.3, -2.1, -6), 1e8, 1e6, 3},
  3468. {_V(-2.95, -2.0,-14.35),1e8, 1e6, 3},
  3469. {_V( 2.95, -2.0,-14.35),1e8, 1e6, 3},
  3470. {_V(-1.9, -1.0,-14.8), 1e8, 1e6, 3},
  3471. {_V( 1.9, -1.0,-14.8), 1e8, 1e6, 3},
  3472. {_V( 0, 11.2,-16.4), 1e8, 1e6, 3},
  3473. {_V( 0, 11.3,-14.0), 1e8, 1e6, 3},
  3474. {_V( 0, -0.9, 20.6), 1e8, 1e6, 3}
  3475. };
  3476. if (state == 1.0) { // gear fully deployed
  3477. static TOUCHDOWNVTX geardn_vtx[3] = {
  3478. {_V( 0, -3.95,17.5), 1e8, 1e6, 1.6, 0.1},
  3479. {_V(-3.96, -5.5, -3.2), 1e8, 1e6, 3, 0.2},
  3480. {_V( 3.96, -5.5, -3.2), 1e8, 1e6, 3, 0.2},
  3481. };
  3482. memcpy (tdvtx, geardn_vtx, 3*sizeof(TOUCHDOWNVTX));
  3483. SetTouchdownPoints (tdvtx, 14);
  3484. SetSurfaceFrictionCoeff (0.05, 0.4);
  3485. } else {
  3486. static TOUCHDOWNVTX gearup_vtx[3] = {
  3487. {_V( 0, -2.2,16.75), 1e8, 1e6, 3},
  3488. {_V(-3.96, -2.7, -3.2), 1e8, 1e6, 3},
  3489. {_V( 3.96, -2.7, -3.2), 1e8, 1e6, 3},
  3490. };
  3491. memcpy (tdvtx, gearup_vtx, 3*sizeof(TOUCHDOWNVTX));
  3492. SetTouchdownPoints (tdvtx, 14);
  3493. SetSurfaceFrictionCoeff (0.4, 0.4);
  3494. }
  3495. }
  3496.  
  3497. void Atlantis::Jettison ()
  3498. {
  3499.  
  3500. }
  3501.  
  3502.  
  3503.  
  3504. // Update moving parts of the orbiter's visual: payload bay doors and gear
  3505. // This should only be called when the visual exists, e.g. from within
  3506. // clbkVisualCreated or clbkAnimate
  3507.  
  3508. void Atlantis::UpdateMesh ()
  3509. {
  3510.  
  3511.  
  3512. // update animation states
  3513. SetAnimation (anim_gear, gear_proc);
  3514. SetAnimation (anim_spdb, spdb_proc);
  3515. SetAnimation (anim_door, plop->BayDoorStatus.pos);
  3516. SetAnimation(anim_PRADIATOR , plop->RadiatorStatus.pos);
  3517. SetAnimation(anim_SRADIATOR, plop->RadiatorStatus.pos);
  3518. SetAnimation (anim_kubd, plop->KuAntennaStatus.pos);
  3519. SetAnimation(anim_SETD, SETD_proc);
  3520. SetAnimation(anim_PETD, PETD_proc);
  3521. SetAnimationArm (anim_arm_sy, arm_sy);
  3522. SetAnimationArm (anim_arm_sp, arm_sp);
  3523. SetAnimationArm (anim_arm_ep, arm_ep);
  3524. SetAnimationArm (anim_arm_wp, arm_wp);
  3525. SetAnimationArm (anim_arm_wy, arm_wy);
  3526. SetAnimationArm (anim_arm_wr, arm_wr);
  3527. SetAnimation(anim_MPM, Armtilt_proc);
  3528. SetAnimation(anim_MPMOBSS, OBSS_proc);
  3529. SetAnimation(anim_SETD, SETD_proc);
  3530. SetAnimation(anim_PETD, PETD_proc);
  3531. SetAnimation(anim_ssmestow, ssmestow_proc);
  3532. SetAnimation(anim_ADTA, ADTA_proc);
  3533. SetAnimation(anim_ius, ius_proc);
  3534. SetAnimation(anim_CHUTE, CHUTE_proc);
  3535. // update MFD brightness
  3536. if (vis) {
  3537. int i;
  3538. MATERIAL mat;
  3539. memset(&mat, 0, sizeof(MATERIAL));
  3540. DEVMESHHANDLE hMesh = GetDevMesh(vis, mesh_vc);
  3541. for (i = 0; i < 4; i++) {
  3542. mat.emissive.r = mat.emissive.g = mat.emissive.b = (float)mfdbright[i];
  3543. mat.emissive.a = 1.0f;
  3544. oapiSetMaterial(hMesh, 21 + i, &mat);
  3545. }
  3546. }
  3547. }
  3548.  
  3549. void Atlantis::SetBayDoorPosition (double pos)
  3550. {
  3551. SetAnimation (anim_door, pos);
  3552. rdoor_drag = sqrt (min (1.0, pos*3.0));
  3553. ldoor_drag = sqrt (min (1.0, max(0.0, pos-0.3656)*3.0));
  3554. }
  3555.  
  3556. void Atlantis::SetRadiatorPosition (double pos)
  3557. {
  3558. SetAnimation (anim_PRADIATOR, pos);
  3559. SetAnimation(anim_SRADIATOR, pos);
  3560. }
  3561.  
  3562.  
  3563. void Atlantis::SetKuAntennaPosition(double pos)
  3564. {
  3565. SetAnimation(anim_kubd, pos);
  3566. }
  3567. void Atlantis::SetSSMEPosition (double pos)
  3568. {
  3569. SetAnimation (anim_ssmes, pos);
  3570. }
  3571.  
  3572. void Atlantis::OperateLandingGear (AnimState::Action action)
  3573. {
  3574. if (status < 3) return;
  3575. // operate landing gear only once the orbiter is free from the tank
  3576.  
  3577. gear_status = action;
  3578. RecordEvent ("GEAR", action == AnimState::CLOSING ? "UP" : "DOWN");
  3579. }
  3580.  
  3581. void Atlantis::RevertLandingGear ()
  3582. {
  3583. if (status < 3) return;
  3584. // operate landing gear only once the orbiter is free from the tank
  3585.  
  3586. OperateLandingGear (gear_status == AnimState::CLOSED || gear_status == AnimState::CLOSING ?
  3587. AnimState::OPENING : AnimState::CLOSING);
  3588. }
  3589.  
  3590. void Atlantis::OperateSpeedbrake (AnimState::Action action)
  3591. {
  3592. spdb_status = action;
  3593. RecordEvent ("SPEEDBRAKE", action == AnimState::CLOSING ? "CLOSE" : "OPEN");
  3594. }
  3595.  
  3596. void Atlantis::RevertSpeedbrake (void)
  3597. {
  3598. OperateSpeedbrake (spdb_status == AnimState::CLOSED || spdb_status == AnimState::CLOSING ?
  3599. AnimState::OPENING : AnimState::CLOSING);
  3600. }
  3601.  
  3602. void Atlantis::SetAnimationArm (UINT anim, double state)
  3603. {
  3604. if (Armtilt_proc == 1){
  3605.  
  3606.  
  3607. SetAnimation (anim, state);
  3608. arm_scheduled = true;
  3609.  
  3610. HWND hDlg;
  3611. if (!SatStowed2() && (hDlg = oapiFindDialog (g_Param.hDLL, IDD_RMS))) {
  3612. //SetWindowText (GetDlgItem (hDlg, IDC_PAYLOAD2), "Arrest");
  3613. //EnableWindow (GetDlgItem (hDlg, IDC_PAYLOAD2), CanArrest2() ? TRUE : FALSE);
  3614. }
  3615. }
  3616. }
  3617.  
  3618.  
  3619.  
  3620. // ==============================================================
  3621. // Overloaded callback functions
  3622. // ==============================================================
  3623.  
  3624. // --------------------------------------------------------------
  3625. // Set vessel class capabilities from config file
  3626. // --------------------------------------------------------------
  3627. void Atlantis::clbkSetClassCaps (FILEHANDLE cfg)
  3628. {
  3629. // *********************** physical parameters *********************************
  3630.  
  3631. SetSize (19.6);
  3632. SetEmptyMass (ORBITER_EMPTY_MASS+MASS1+MASS2+MASS3+MASS0);
  3633. SetPMI (_V(78.2,82.1,10.7));
  3634. SetGravityGradientDamping (20.0);
  3635. SetCrossSections (ORBITER_CS);
  3636. SetRotDrag (_V(0.43,0.43,0.29)); // angular drag
  3637. SetTrimScale (0.05);
  3638. launchelev = 0.0;
  3639. SetMaxWheelbrakeForce(2e5);
  3640. if (!oapiReadItem_bool (cfg, "RenderCockpit", render_cockpit))
  3641. render_cockpit = false;
  3642.  
  3643. static VECTOR3 beacon_pos[8] = { { -1.7113, -1.2597, 7.486 }, { 1.5527, -1.3734, 7.9518 }, { 1.559, -1.3608, 2.1626 }, { -1.559, -1.3608, 2.1626 }, { 1.58, -1.3231, -2.1778 }, { -1.58, -1.3231, -2.1778 }, { 0, 2.9347, 11.9 }, { 0, 2.9347, 11.9 } };
  3644.  
  3645.  
  3646. for (int i = 0; i < 8; i++) {
  3647. spot_beacon[i].shape = BEACONSHAPE_DIFFUSE;
  3648. spot_beacon[i].pos = &beacon_pos[i];
  3649. spot_beacon[i].col = &beacon_col;
  3650. spot_beacon[i].size = 0.25;
  3651. spot_beacon[i].falloff = 0.4;
  3652. spot_beacon[i].period = 0;
  3653. spot_beacon[i].duration = 0;
  3654. spot_beacon[i].tofs = 0;
  3655. spot_beacon[i].active = false;
  3656. AddBeacon(spot_beacon + i);
  3657. }
  3658.  
  3659. //rms
  3660. for (int i = 8; i < 9; i++) {
  3661. spot_beacon[i].shape = BEACONSHAPE_DIFFUSE;
  3662. spot_beacon[i].pos = &arm_tip[4];
  3663. spot_beacon[i].col = &beacon_col;
  3664. spot_beacon[i].size = 0.25;
  3665. spot_beacon[i].falloff = 0.4;
  3666. spot_beacon[i].period = 0;
  3667. spot_beacon[i].duration = 0;
  3668. spot_beacon[i].tofs = 0;
  3669. spot_beacon[i].active = false;
  3670. AddBeacon(spot_beacon + i);
  3671. }
  3672.  
  3673. COLOUR4 col_d = { 1, 1, 0.9, 0 };
  3674. COLOUR4 col_s = { 1, 1, 0.9, 0 };
  3675. COLOUR4 col_a = { 0, 0, 0, 0 };
  3676.  
  3677. static VECTOR3 color = _V(1.0, 0.839, 0.666);
  3678. const COLOUR4 diff = { 1.0f, 0.839f, 0.666f, 0.0f };
  3679. const COLOUR4 amb = { 0.0, 0.0, 0 };
  3680. const COLOUR4 spec = { 0.0f, 0.0f, 0.0f, 0 };
  3681.  
  3682.  
  3683. spotlight1 = (SpotLight*)AddSpotLight(_V(-1.7113, -1.2597, 7.486), _V(0.5, 0.7071, -0.5), 3, 0.5, 0.0, 0.05, (120 * RAD), (10 * RAD), col_d, col_s, col_a);
  3684. spotlight2 = (SpotLight*)AddSpotLight(_V(1.5527, -1.3734, 7.9518), _V(-0.5, 0.7071, -0.5), 3, 0.5, 0.0, 0.05, (120 * RAD), (10 * RAD), col_d, col_s, col_a);
  3685. spotlight3 = (SpotLight*)AddSpotLight(_V(1.559, -1.3608, 2.1626), _V(0.7071, 0.7071, 0), 3, 0.5, 0.0, 0.05, (120 * RAD), (10 * RAD), col_d, col_s, col_a);
  3686. spotlight4 = (SpotLight*)AddSpotLight(_V(-1.559, -1.3608, 2.1626), _V(0.7071, 0.7071, 0), 3, 0.5, 0.0, 0.05, (120 * RAD), (10 * RAD), col_d, col_s, col_a);
  3687. spotlight5 = (SpotLight*)AddSpotLight(_V(1.6380, -1.3773, -2.0453), _V(0.5, 0.7071, 0.5), 3, 0.5, 0.0, 0.05, (120 * RAD), (10 * RAD), col_d, col_s, col_a);
  3688. spotlight6 = (SpotLight*)AddSpotLight(_V(-1.6380, -1.3773, -2.0453), _V(-0.5, 0.7071, 0.5), 3, 0.5, 0.0, 0.05, (120 * RAD), (10 * RAD), col_d, col_s, col_a);
  3689. spotlightDOCK = (SpotLight*)AddSpotLight(_V(0, 2.9347, 11.9), _V(0, 1, 0), 5, 0.5, 0.0, 0.05, (90 * RAD), (180 * RAD), col_d, col_s, col_a);//dock
  3690. spotlight7 = (SpotLight*)AddSpotLight(_V(0, 2.9347, 11.9), _V(0, 0, -1), 5, 0.5, 0.0, 0.05, (90 * RAD), (180 * RAD), col_d, col_s, col_a);//bulkhead
  3691. spotlightRMS = (SpotLight*)AddSpotLight((arm_tip[4]), (arm_tip[1] - arm_tip[0]), 20, 0.25, 0.8, 0.001, 80.0*RAD, 80.0*1.1*RAD,
  3692. diff, spec, amb);
  3693.  
  3694.  
  3695. spotlight1->Activate(false);
  3696. spotlight2->Activate(false);
  3697. spotlight3->Activate(false);
  3698. spotlight4->Activate(false);
  3699. spotlight5->Activate(false);
  3700. spotlight6->Activate(false);
  3701. spotlight7->Activate(false);
  3702. spotlightDOCK->Activate(false);
  3703. spotlightRMS->Activate(false);
  3704.  
  3705.  
  3706. pl1_ofs = _V(0, 6.220, -7.795);
  3707. pl2_ofs = _V(0, 6.220, -7.795);
  3708. pl3_ofs = _V(-1.850, 8.020, 3.955);
  3709. pl4_ofs = _V(-2.2, 8.020, -14.045);
  3710. pl5_ofs = _V(2.2, 8.020, -14.045);
  3711. pl6_ofs = _V(1.850, 8.020, 3.955);
  3712. pl7_ofs = _V(0, 6.220, -7.795);
  3713. pl8_ofs = _V(0, 6.220, -7.795);
  3714. pl9_ofs = _V(0, 6.220, -7.795);
  3715. pl10_ofs = _V(0, 6.220, -7.795);
  3716.  
  3717. pl1_dir = _V(0, 1,0);
  3718. pl2_dir = _V(0, 1, 0);
  3719. pl3_dir = _V(0, 1, 0);
  3720. pl4_dir = _V(0, 1, 0);
  3721. pl5_dir = _V(0, 1, 0);
  3722. pl6_dir = _V(0, 1, 0);
  3723. pl7_dir = _V(0, 1, 0);
  3724. pl8_dir = _V(0, 1, 0);
  3725. pl9_dir = _V(0, 1, 0);
  3726. pl10_dir = _V(0, 1, 0);
  3727.  
  3728.  
  3729. pl1_rot = _V(0, 0, 1);
  3730. pl2_rot = _V(1, 0, 0);
  3731. pl3_rot = _V(0, 0, 1);
  3732. pl4_rot = _V(0, 0, 1);
  3733. pl5_rot = _V(0, 0, 1);
  3734. pl6_rot = _V(0, 0, 1);
  3735. pl7_rot = _V(0, 0, 1);
  3736. pl8_rot = _V(0, 0, 1);
  3737. pl9_rot = _V(0, 0, 1);
  3738. pl10_rot = _V(0, 0, 1);
  3739. KEELCAM = _V(0.1452, -1.500, -1.356);
  3740. ETCAM = _V(-2, - 2.856126, - 7.334826);//ETCAM = _V(1, -3.500, 11.9);
  3741. DOCKCAM = _V(0, 1.58, 10.16);//ETCAM = _V(1, -3.500, 11.9);
  3742.  
  3743. sat_attach = CreateAttachment(false, pl1_ofs, pl1_dir, pl1_rot, "X");//0
  3744. rms_attach = CreateAttachment(false, _V(-2.515, 2.059, -5.5327), _V(0, -1, 0), _V(0, 0, 1), "G", false);
  3745.  
  3746. //rms_attach = CreateAttachment(false, arm_tip[0], arm_tip[1] - arm_tip[0], arm_tip[2] - arm_tip[0], "G", true);//1
  3747. sat_attach2 = CreateAttachment(false, pl2_ofs, pl2_dir, pl2_rot, "0");//2
  3748. sat_attach3 = CreateAttachment(false, pl3_ofs, pl3_dir, pl3_rot, "X");//3
  3749. sat_attach4 = CreateAttachment(false, pl4_ofs, pl4_dir, pl4_rot, "C");//4
  3750. sat_attach5 = CreateAttachment(false, pl5_ofs, pl5_dir, pl5_rot, "D");//5
  3751. sat_attach6 = CreateAttachment(false, pl6_ofs, pl6_dir, pl6_rot, "E");//6
  3752. sat_attach7 = CreateAttachment(false, pl7_ofs, pl7_dir, pl7_rot, "F");//7
  3753. sat_attach8 = CreateAttachment(false, pl8_ofs, pl8_dir, pl8_rot, "G");//8
  3754. sat_attach9 = CreateAttachment(false, pl9_ofs, pl9_dir, pl9_rot, "H");//9
  3755. sat_attach10 = CreateAttachment(false, pl10_ofs, pl10_dir, pl10_rot, "I");//10
  3756. OBSS_attach = CreateAttachment(false, armobss_tip[0], armobss_tip[1] - armobss_tip[0], armobss_tip[2] - armobss_tip[0], "OBSS", true);//1
  3757. ft_pad_att = CreateAttachment(false, ft_pad_att_pos, ft_pad_att_dir, ft_pad_att_rot, "FPD");
  3758. ft_pad_att1 = CreateAttachment(false, ft_pad_att1_pos, ft_pad_att1_dir, ft_pad_att1_rot, "FPD1");
  3759. ft_pad_att2 = CreateAttachment(false, ft_pad_att2_pos, ft_pad_att2_dir, ft_pad_att2_rot, "FPD2");
  3760. ft_pad_att3 = CreateAttachment(false, ft_pad_att3_pos, ft_pad_att3_dir, ft_pad_att3_rot, "FPD3");
  3761. //Dockring = CreateAttachment(false, ringpos, _V(0, 1, 0), _V(0, 0, 1), "Ring");//7
  3762.  
  3763.  
  3764. pl1_ofs_scn = _V(0,0,0);
  3765. pl1_dir_scn = _V(0, 0, 0);
  3766. pl1_rot_scn = _V(0, 0, 0);
  3767.  
  3768. pl2_ofs_scn = _V(0, 0, 0);
  3769. pl2_dir_scn = _V(0, 0, 0);
  3770. pl2_rot_scn = _V(0, 0, 0);
  3771.  
  3772. pl3_ofs_scn = _V(0, 0, 0);
  3773. pl3_dir_scn = _V(0, 0, 0);
  3774. pl3_rot_scn = _V(0, 0, 0);
  3775.  
  3776. pl4_ofs_scn = _V(0, 0, 0);
  3777. pl4_dir_scn = _V(0, 0, 0);
  3778. pl4_rot_scn = _V(0, 0, 0);
  3779.  
  3780. pl5_ofs_scn = _V(0, 0, 0);
  3781. pl5_dir_scn = _V(0, 0, 0);
  3782. pl5_rot_scn = _V(0, 0, 0);
  3783.  
  3784. pl6_ofs_scn = _V(0, 0, 0);
  3785. pl6_dir_scn = _V(0, 0, 0);
  3786. pl6_rot_scn = _V(0, 0, 0);
  3787.  
  3788. pl7_ofs_scn = _V(0, 0, 0);
  3789. pl7_dir_scn = _V(0, 0, 0);
  3790. pl7_rot_scn = _V(0, 0, 0);
  3791.  
  3792. pl8_ofs_scn = _V(0, 0, 0);
  3793. pl8_dir_scn = _V(0, 0, 0);
  3794. pl8_rot_scn = _V(0, 0, 0);
  3795.  
  3796. pl9_ofs_scn = _V(0, 0, 0);
  3797. pl9_dir_scn = _V(0, 0, 0);
  3798. pl9_rot_scn = _V(0, 0, 0);
  3799.  
  3800. pl10_ofs_scn = _V(0, 0, 0);
  3801. pl10_dir_scn = _V(0, 0, 0);
  3802. pl10_rot_scn = _V(0, 0, 0);
  3803.  
  3804. ft_pad_att_pos_scn = _V(0, 0, 0);
  3805. ft_pad_att_dir_scn = _V(0, 0, 0);
  3806. ft_pad_att_rot_scn = _V(0, 0, 0);
  3807.  
  3808. ft_pad_att1_pos_scn = _V(0, 0, 0);
  3809. ft_pad_att1_dir_scn = _V(0, 0, 0);
  3810. ft_pad_att1_rot_scn = _V(0, 0, 0);
  3811.  
  3812. ft_pad_att2_pos_scn = _V(0, 0, 0);
  3813. ft_pad_att2_dir_scn = _V(0, 0, 0);
  3814. ft_pad_att2_rot_scn = _V(0, 0, 0);
  3815.  
  3816. ft_pad_att3_pos_scn = _V(0, 0, 0);
  3817. ft_pad_att3_dir_scn = _V(0, 0, 0);
  3818. ft_pad_att3_rot_scn = _V(0, 0, 0);
  3819.  
  3820.  
  3821.  
  3822.  
  3823.  
  3824. KEELCAM_scn = _V(0, 0, 0);
  3825. ETCAM_scn = _V(0, 0, 0);
  3826. DOCKCAM_scn = _V(0, 0, 0);
  3827.  
  3828. plbCamPos[0] = _V(-1.782, 1.601, 11.581);//2.2, 1.8, -6.250
  3829. plbCamPos[1] = _V(-2.302, 1.738, -6.231);// 1.850, 1.8, 11.750
  3830. plbCamPos[2] = _V(2.302, 1.738, -6.231);//-1.850, 1.8, 11.750
  3831. plbCamPos[3] = _V(1.782, 1.601, 11.581);;//-2.2, 1.8, -6.250
  3832.  
  3833.  
  3834.  
  3835.  
  3836. /*
  3837.  
  3838. //PLB LIGHTS
  3839. PLBLightPosition[0] = _V(1.6380, -1.3773, 8.5024); //forward stbd
  3840. PLBLightPosition[1] = _V(-1.5549, -1.3773, 8.5024); //forward port
  3841. PLBLightPosition[2] = _V(1.6380, -1.3773, 2.4856);//mid stbd
  3842. PLBLightPosition[3] = _V(-1.6380, -1.3773, 2.4856);//mid port
  3843. PLBLightPosition[4] = _V(1.6380, -1.3773, -4.0384);//aft stbd
  3844. PLBLightPosition[5] = _V(-1.6380, -1.3773, -4.0384);//aft port
  3845. FwdBulkheadLightPos = _V(0.0, 1.7550, 11.966);//fwd bulkhead
  3846. DockingLightPos = _V(0.0, 2.0162, 8.952);//docking light
  3847.  
  3848. //CREATE LIGHTS
  3849.  
  3850. {
  3851. //VECTOR3 dir = _V(-(PLBLightPosition[i].x) * 0.642788, 0.766044, 0.0);// light aim about ~50� up
  3852. PLBLight[0] = AddPayloadBayLight(PLBLightPosition[0], _V(1.6380, .624, .766), 135.0, PLB_bspec[0]);
  3853. PLBLight[1] = AddPayloadBayLight(PLBLightPosition[1], _V(-1.5549, .624, .766), 135.0, PLB_bspec[1]);
  3854. PLBLight[2] = AddPayloadBayLight(PLBLightPosition[2], _V(1.6380, .624, .766), 135.0, PLB_bspec[2]);
  3855. PLBLight[3] = AddPayloadBayLight(PLBLightPosition[3], _V(-1.6380, .624, .766), 135.0, PLB_bspec[3]);
  3856. PLBLight[4] = AddPayloadBayLight(PLBLightPosition[4], _V(1.6380, .624, .766), 135.0, PLB_bspec[4]);
  3857. PLBLight[5] = AddPayloadBayLight(PLBLightPosition[5], _V(-1.6300, .624, .766), 135.0, PLB_bspec[5]);
  3858. }
  3859. FwdBulkheadLight = AddPayloadBayLight(FwdBulkheadLightPos, _V(0, 0, -1), 120.0, FwdBulkhead_bspec);
  3860. for (int i = 0; i < 2; i++) {
  3861. DockingLight[i] = AddPayloadBayLight(DockingLightPos, _V(0, 1, 0), 120.0, Docking_bspec[i]); // create two copies of docking light to simulate DIM and BRIGHT settings
  3862. }
  3863.  
  3864.  
  3865.  
  3866.  
  3867.  
  3868. }
  3869. LightEmitter* Atlantis::AddPayloadBayLight(VECTOR3& pos, VECTOR3& dir, double degWidth, BEACONLIGHTSPEC& bspec)
  3870. {
  3871. static VECTOR3 color = _V(0.75, 0.75, 0.75);
  3872. //const COLOUR4 diff = {0.949f, 0.988f, 1.0f, 0.0f}; //RGB for metal halide but it doesn't quite match up with actual photos
  3873. const COLOUR4 diff = { 0.847f, 0.968f, 1.0f, 0.0f }; //RGB for mercury vapor, this better matches photos
  3874. const COLOUR4 amb = { 0.0, 0.0, 0 };
  3875. const COLOUR4 spec = { 0.0f, 0.0f, 0.0f, 0 };
  3876.  
  3877. bspec.active = false;
  3878. bspec.col = &color;
  3879. bspec.duration = 0;
  3880. bspec.falloff = 0.4;
  3881. bspec.period = 0;
  3882. bspec.pos = &pos;
  3883. bspec.shape = BEACONSHAPE_DIFFUSE;
  3884. bspec.size = 0.25;
  3885. bspec.tofs = 0;
  3886. AddBeacon(&bspec);
  3887. return AddSpotLight(pos, dir, 20, 0.5, 0.0, 0.05, degWidth*RAD, degWidth*1.1*RAD,
  3888. diff, spec, amb);
  3889.  
  3890. */
  3891. }
  3892. // --------------------------------------------------------------
  3893. // Set status from a VESSELSTATUS2 structure
  3894. // --------------------------------------------------------------
  3895. void Atlantis::clbkSetStateEx (const void *status)
  3896. {
  3897. // default parameter initialisation
  3898. VESSEL4::clbkSetStateEx (status);
  3899. }
  3900.  
  3901. // --------------------------------------------------------------
  3902. // Read status from scenario file
  3903. // --------------------------------------------------------------
  3904. void Atlantis::clbkLoadStateEx (FILEHANDLE scn, void *vs)
  3905. {
  3906. int action;
  3907. char *line;
  3908. MIDMODEL = 0;
  3909. ORIGINAL = 0;
  3910. OBSS1 = 0;
  3911. //EVA = 0;
  3912. DRAGCHUTE = 0;
  3913. double met = 0.0; // mission elapsed time
  3914. double srbtime = 0.0;
  3915. double sts_sat_x = 0.0;
  3916. double sts_sat_y = 0.0;
  3917. double sts_sat_z = 0.0;
  3918. spdb_status = AnimState::CLOSED; spdb_proc = 0.0;
  3919.  
  3920. while (oapiReadScenario_nextline (scn, line)) {
  3921. if (!_strnicmp (line, "CONFIGURATION", 13)) {
  3922. sscanf (line+13, "%d", &status);
  3923. //} else if (!_strnicmp (line, "MET", 3)) {
  3924. // sscanf (line+3, "%lf", &met);
  3925. }
  3926. else if (!_strnicmp(line, "GEAR", 4)) {
  3927. sscanf(line + 4, "%d%lf", &action, &gear_proc);
  3928. gear_status = (AnimState::Action)(action + 1);
  3929. }
  3930. else if (!strnicmp(line, "MET", 3)) {
  3931. sscanf(line + 3, "%lf", &MET);
  3932. }
  3933. else if (!strnicmp(line, "VCCAM", 5)) {
  3934. sscanf(line + 5, "%d", &VCCAM);
  3935. }
  3936.  
  3937. else if (!_strnicmp(line, "HATCH", 5)) {
  3938. sscanf(line + 5, "%d%lf", &EXT_status, &EXT_proc);
  3939.  
  3940. }
  3941. else if (!_strnicmp(line, "PETD", 4)) {
  3942. sscanf(line + 4, "%d%lf", &PETD_status, &PETD_proc);
  3943.  
  3944. }
  3945. else if (!_strnicmp(line, "SETD", 4)) {
  3946. sscanf(line + 4, "%d%lf", &SETD_status, &SETD_proc);
  3947.  
  3948. }
  3949. else if (!_strnicmp(line, "ADTA", 4)) {
  3950. sscanf(line + 4, "%d%lf", &ADTA_status, &ADTA_proc);
  3951.  
  3952. }
  3953. else if (!_strnicmp(line, "SSMES", 5)) {
  3954. sscanf(line + 5, "%d%lf", &ssmestow_status, &ssmestow_proc);
  3955.  
  3956. }
  3957. else if (!_strnicmp(line, "Armtilt", 7)) {
  3958. sscanf(line + 7, "%d%lf%d%lf", &Armtilt_status, &Armtilt_proc, &OBSS_status, &OBSS_proc);
  3959.  
  3960. }
  3961.  
  3962. else if (!_strnicmp (line, "SPEEDBRAKE", 10)) {
  3963. sscanf(line + 10, " %0.4f", &spdb_proc);
  3964.  
  3965. }
  3966. else if (!_strnicmp (line, "CARGO_STATIC_MESH", 17)) {
  3967. sscanf (line+17, "%s", cargo_static_mesh_name);
  3968. SetMeshVisibilityMode(mesh_cargo, MESHVIS_EXTERNAL | MESHVIS_VC | MESHVIS_EXTPASS);
  3969. do_cargostatic = true;
  3970. } else if (!_strnicmp (line, "CARGO_STATIC_OFS", 16)) {
  3971. sscanf (line+16, "%lf%lf%lf", &cargo_static_ofs.x, &cargo_static_ofs.y, &cargo_static_ofs.z);
  3972. } else if (!_strnicmp (line, "ARM_STATUS", 10)) {
  3973. sscanf (line+10, "%lf%lf%lf%lf%lf%lf", &arm_sy, &arm_sp, &arm_ep, &arm_wp, &arm_wy, &arm_wr);
  3974. }
  3975. else if (!_strnicmp(line, "ARM_SEQ1", 8)) {
  3976. sscanf(line + 8, "%lf%lf%lf%lf%lf%lf", &arm1_By, &arm1_Bp,
  3977. &arm1_ep, &arm1_Ap, &arm1_Ay, &arm1_Ar);
  3978. arm1set = true;
  3979. }
  3980. else if (!_strnicmp(line, "ARM_SEQ2", 8)) {
  3981. sscanf(line + 8, "%lf%lf%lf%lf%lf%lf", &arm2_By, &arm2_Bp,
  3982. &arm2_ep, &arm2_Ap, &arm2_Ay, &arm2_Ar);
  3983. arm2set = true;
  3984. }
  3985. else if (!_strnicmp(line, "ARM_SEQ3", 8)) {
  3986. sscanf(line + 8, "%lf%lf%lf%lf%lf%lf", &arm3_By, &arm3_Bp,
  3987. &arm3_ep, &arm3_Ap, &arm3_Ay, &arm3_Ar);
  3988. arm3set = true;
  3989. }
  3990. else if (!_strnicmp(line, "ARM_SEQ4", 8)) {
  3991. sscanf(line + 8, "%lf%lf%lf%lf%lf%lf", &arm4_By, &arm4_Bp,
  3992. &arm4_ep, &arm4_Ap, &arm4_Ay, &arm4_Ar);
  3993. arm4set = true;
  3994. }
  3995.  
  3996. //CAM
  3997. else if (!_strnicmp(line, "PLB_CAM", 7))
  3998. {
  3999. sscanf(line + 7, "%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf", &camPitch[CAM_A], &camYaw[CAM_A], &camPitch[CAM_B], &camYaw[CAM_B],
  4000. &camPitch[CAM_C], &camYaw[CAM_C], &camPitch[CAM_D], &camYaw[CAM_D], &camRMSElbow[PAN], &camRMSElbow[TILT]);
  4001. cameraMoved = true;
  4002. }
  4003.  
  4004.  
  4005.  
  4006. else if (!strnicmp(line, "PL1_OFS", 7))
  4007. {
  4008. sscanf(line + 7, "%lf%lf%lf", &pl1_ofs_scn.x, &pl1_ofs_scn.y, &pl1_ofs_scn.z);
  4009. }
  4010. else if (!strnicmp(line, "PL2_OFS", 7))
  4011. {
  4012. sscanf(line + 7, "%lf%lf%lf", &pl2_ofs_scn.x, &pl2_ofs_scn.y, &pl2_ofs_scn.z);
  4013. }
  4014. else if (!strnicmp(line, "PL3_OFS", 7))
  4015. {
  4016. sscanf(line + 7, "%lf%lf%lf", &pl3_ofs_scn.x, &pl3_ofs_scn.y, &pl3_ofs_scn.z);
  4017. }
  4018. else if (!strnicmp(line, "PL4_OFS", 7))
  4019. {
  4020. sscanf(line + 7, "%lf%lf%lf", &pl4_ofs_scn.x, &pl4_ofs_scn.y, &pl4_ofs_scn.z);
  4021. }
  4022. else if (!strnicmp(line, "PL5_OFS", 7))
  4023. {
  4024. sscanf(line + 7, "%lf%lf%lf", &pl5_ofs_scn.x, &pl5_ofs_scn.y, &pl5_ofs_scn.z);
  4025. }
  4026. else if (!strnicmp(line, "PL6_OFS", 7))
  4027. {
  4028. sscanf(line + 7, "%lf%lf%lf", &pl6_ofs_scn.x, &pl6_ofs_scn.y, &pl6_ofs_scn.z);
  4029. }
  4030. else if (!strnicmp(line, "PL7_OFS", 7))
  4031. {
  4032. sscanf(line + 7, "%lf%lf%lf", &pl7_ofs_scn.x, &pl7_ofs_scn.y, &pl7_ofs_scn.z);
  4033. }
  4034. else if (!strnicmp(line, "PL8_OFS", 7))
  4035. {
  4036. sscanf(line + 7, "%lf%lf%lf", &pl8_ofs_scn.x, &pl8_ofs_scn.y, &pl8_ofs_scn.z);
  4037. }
  4038. else if (!strnicmp(line, "PL9_OFS", 7))
  4039. {
  4040. sscanf(line + 7, "%lf%lf%lf", &pl9_ofs_scn.x, &pl9_ofs_scn.y, &pl9_ofs_scn.z);
  4041. }
  4042. else if (!strnicmp(line, "pl10_OFS", 8))
  4043. {
  4044. sscanf(line + 8, "%lf%lf%lf", &pl10_ofs_scn.x, &pl10_ofs_scn.y, &pl10_ofs_scn.z);
  4045. }
  4046. else if (!strnicmp(line, "ft_pad_att_POS", 14))
  4047. {
  4048. sscanf(line + 14, "%lf%lf%lf", &ft_pad_att_pos_scn.x, &ft_pad_att_pos_scn.y, &ft_pad_att_pos_scn.z);
  4049. }
  4050. else if (!strnicmp(line, "ft_pad_att1_POS", 15))
  4051. {
  4052. sscanf(line + 15, "%lf%lf%lf", &ft_pad_att1_pos_scn.x, &ft_pad_att1_pos_scn.y, &ft_pad_att1_pos_scn.z);
  4053. }
  4054. else if (!strnicmp(line, "ft_pad_att2_POS", 15))
  4055. {
  4056. sscanf(line + 15, "%lf%lf%lf", &ft_pad_att2_pos_scn.x, &ft_pad_att2_pos_scn.y, &ft_pad_att2_pos_scn.z);
  4057. }
  4058. else if (!strnicmp(line, "ft_pad_att3_POS", 15))
  4059. {
  4060. sscanf(line + 15, "%lf%lf%lf", &ft_pad_att3_pos_scn.x, &ft_pad_att3_pos_scn.y, &ft_pad_att3_pos_scn.z);
  4061. }
  4062. //else if (!strnicmp(line, "PL1_OFS", 7))
  4063. else if (!strnicmp(line, "PL1_ROT", 7))
  4064. {
  4065. sscanf(line + 7, "%lf%lf%lf", &pl1_rot_scn.x, &pl1_rot_scn.y, &pl1_rot_scn.z);
  4066. }
  4067. else if (!strnicmp(line, "PL2_ROT", 7))
  4068. {
  4069. sscanf(line + 7, "%lf%lf%lf", &pl2_rot_scn.x, &pl2_rot_scn.y, &pl2_rot_scn.z);
  4070. }
  4071. else if (!strnicmp(line, "PL3_ROT", 7))
  4072. {
  4073. sscanf(line + 7, "%lf%lf%lf", &pl3_rot_scn.x, &pl3_rot_scn.y, &pl3_rot_scn.z);
  4074. }
  4075. else if (!strnicmp(line, "PL4_ROT", 7))
  4076. {
  4077. sscanf(line + 7, "%lf%lf%lf", &pl4_rot_scn.x, &pl4_rot_scn.y, &pl4_rot_scn.z);
  4078. }
  4079. else if (!strnicmp(line, "PL5_ROT", 7))
  4080. {
  4081. sscanf(line + 7, "%lf%lf%lf", &pl5_rot_scn.x, &pl5_rot_scn.y, &pl5_rot_scn.z);
  4082. }
  4083. else if (!strnicmp(line, "PL6_ROT", 7))
  4084. {
  4085. sscanf(line + 7, "%lf%lf%lf", &pl6_rot_scn.x, &pl6_rot_scn.y, &pl6_rot_scn.z);
  4086. }
  4087. else if (!strnicmp(line, "PL7_ROT", 7))
  4088. {
  4089. sscanf(line + 7, "%lf%lf%lf", &pl7_rot_scn.x, &pl7_rot_scn.y, &pl7_rot_scn.z);
  4090. }
  4091. else if (!strnicmp(line, "PL8_ROT", 7))
  4092. {
  4093. sscanf(line + 7, "%lf%lf%lf", &pl8_rot_scn.x, &pl8_rot_scn.y, &pl8_rot_scn.z);
  4094. }
  4095. else if (!strnicmp(line, "PL9_ROT", 7))
  4096. {
  4097. sscanf(line + 7, "%lf%lf%lf", &pl9_rot_scn.x, &pl9_rot_scn.y, &pl9_rot_scn.z);
  4098. }
  4099. else if (!strnicmp(line, "pl10_ROT", 8))
  4100. {
  4101. sscanf(line + 8, "%lf%lf%lf", &pl10_rot_scn.x, &pl10_rot_scn.y, &pl10_rot_scn.z);
  4102. }
  4103. else if (!strnicmp(line, "ft_pad_att_ROT", 14))
  4104. {
  4105. sscanf(line + 14, "%lf%lf%lf", &ft_pad_att_rot_scn.x, &ft_pad_att_rot_scn.y, &ft_pad_att_rot_scn.z);
  4106. }
  4107. else if (!strnicmp(line, "ft_pad_att1_ROT", 15))
  4108. {
  4109. sscanf(line + 15, "%lf%lf%lf", &ft_pad_att1_rot_scn.x, &ft_pad_att1_rot_scn.y, &ft_pad_att1_rot_scn.z);
  4110. }
  4111. else if (!strnicmp(line, "ft_pad_att2_ROT", 15))
  4112. {
  4113. sscanf(line + 15, "%lf%lf%lf", &ft_pad_att2_rot_scn.x, &ft_pad_att2_rot_scn.y, &ft_pad_att2_rot_scn.z);
  4114. }
  4115. else if (!strnicmp(line, "ft_pad_att3_ROT", 15))
  4116. {
  4117. sscanf(line + 15, "%lf%lf%lf", &ft_pad_att3_rot_scn.x, &ft_pad_att3_rot_scn.y, &ft_pad_att3_rot_scn.z);
  4118. }
  4119. //
  4120. else if (!strnicmp(line, "PL1_DIR", 7))
  4121. {
  4122. sscanf(line + 7, "%lf%lf%lf", &pl1_dir_scn.x, &pl1_dir_scn.y, &pl1_dir_scn.z);
  4123. }
  4124. else if (!strnicmp(line, "PL2_DIR", 7))
  4125. {
  4126. sscanf(line + 7, "%lf%lf%lf", &pl2_dir_scn.x, &pl2_dir_scn.y, &pl2_dir_scn.z);
  4127. }
  4128. else if (!strnicmp(line, "PL3_DIR", 7))
  4129. {
  4130. sscanf(line + 7, "%lf%lf%lf", &pl3_dir_scn.x, &pl3_dir_scn.y, &pl3_dir_scn.z);
  4131. }
  4132. else if (!strnicmp(line, "PL4_DIR", 7))
  4133. {
  4134. sscanf(line + 7, "%lf%lf%lf", &pl4_dir_scn.x, &pl4_dir_scn.y, &pl4_dir_scn.z);
  4135. }
  4136. else if (!strnicmp(line, "PL5_DIR", 7))
  4137. {
  4138. sscanf(line + 7, "%lf%lf%lf", &pl5_dir_scn.x, &pl5_dir_scn.y, &pl5_dir_scn.z);
  4139. }
  4140. else if (!strnicmp(line, "PL6_DIR", 7))
  4141. {
  4142. sscanf(line + 7, "%lf%lf%lf", &pl6_dir_scn.x, &pl6_dir_scn.y, &pl6_dir_scn.z);
  4143. }
  4144. else if (!strnicmp(line, "PL7_DIR", 7))
  4145. {
  4146. sscanf(line + 7, "%lf%lf%lf", &pl7_dir_scn.x, &pl7_dir_scn.y, &pl7_dir_scn.z);
  4147. }
  4148. else if (!strnicmp(line, "PL8_DIR", 7))
  4149. {
  4150. sscanf(line + 7, "%lf%lf%lf", &pl8_dir_scn.x, &pl8_dir_scn.y, &pl8_dir_scn.z);
  4151. }
  4152. else if (!strnicmp(line, "PL9_DIR", 7))
  4153. {
  4154. sscanf(line + 7, "%lf%lf%lf", &pl9_dir_scn.x, &pl9_dir_scn.y, &pl9_dir_scn.z);
  4155. }
  4156. else if (!strnicmp(line, "pl10_DIR", 8))
  4157. {
  4158. sscanf(line + 8, "%lf%lf%lf", &pl10_dir_scn.x, &pl10_dir_scn.y, &pl10_dir_scn.z);
  4159. }
  4160. else if (!strnicmp(line, "ft_pad_att_DIR", 14))
  4161. {
  4162. sscanf(line + 14, "%lf%lf%lf", &ft_pad_att_dir_scn.x, &ft_pad_att_dir_scn.y, &ft_pad_att_dir_scn.z);
  4163. }
  4164.  
  4165. else if (!strnicmp(line, "ft_pad_att1_DIR", 15))
  4166. {
  4167. sscanf(line + 15, "%lf%lf%lf", &ft_pad_att1_dir_scn.x, &ft_pad_att1_dir_scn.y, &ft_pad_att1_dir_scn.z);
  4168. }
  4169. else if (!strnicmp(line, "ft_pad_att2_DIR", 15))
  4170. {
  4171. sscanf(line + 15, "%lf%lf%lf", &ft_pad_att2_dir_scn.x, &ft_pad_att2_dir_scn.y, &ft_pad_att2_dir_scn.z);
  4172. }
  4173. else if (!strnicmp(line, "ft_pad_att3_DIR", 15))
  4174. {
  4175. sscanf(line + 15, "%lf%lf%lf", &ft_pad_att3_dir_scn.x, &ft_pad_att3_dir_scn.y, &ft_pad_att3_dir_scn.z);
  4176. }
  4177.  
  4178. else if (!strnicmp(line, "KEELCAM", 7))
  4179. {
  4180. sscanf(line + 7, "%lf%lf%lf", &KEELCAM_scn.x, &KEELCAM_scn.y, &KEELCAM_scn.z);
  4181. }
  4182. else if (!strnicmp(line, "ETCAM", 5))
  4183. {
  4184. sscanf(line + 5, "%lf%lf%lf", &ETCAM_scn.x, &ETCAM_scn.y, &ETCAM_scn.z);
  4185. }
  4186. else if (!strnicmp(line, "DOCKCAM", 7))
  4187. {
  4188. sscanf(line + 7, "%lf%lf%lf", &DOCKCAM_scn.x, &DOCKCAM_scn.y, &DOCKCAM_scn.z);
  4189. }
  4190. else {
  4191. if (plop->ParseScenarioLine (line)) continue; // offer the line to bay door operations
  4192. //else if (ascap->ParseScenarioLine (line)) continue; // offer to ascent autopilot
  4193. if (!_strnicmp(line, "FLOOD1", 6)) {
  4194. sscanf(line + 6, "%d", &flood1_status);
  4195.  
  4196. }
  4197. if (!_strnicmp(line, "FLOOD2", 6)) {
  4198. sscanf(line + 6, "%d", &flood2_status);
  4199.  
  4200. }
  4201. if (!_strnicmp(line, "FLOOD3", 6)) {
  4202. sscanf(line + 6, "%d", &flood3_status);
  4203.  
  4204. }
  4205. if (!_strnicmp(line, "FLOOD4", 6)) {
  4206. sscanf(line + 6, "%d", &flood4_status);
  4207.  
  4208. }
  4209. if (!_strnicmp(line, "FLOOD5", 6)) {
  4210. sscanf(line + 6, "%d", &flood5_status);
  4211.  
  4212. }
  4213. if (!_strnicmp(line, "FLOOD6", 6)) {
  4214. sscanf(line + 6, "%d", &flood6_status);
  4215.  
  4216. }
  4217. if (!_strnicmp(line, "AFT_LIGHT", 9)) {
  4218. sscanf(line + 9, "%d", &aft_light_status);
  4219.  
  4220. }
  4221. if (!_strnicmp(line, "DOCK_LIGHT", 10)) {
  4222. sscanf(line + 10, "%d", &docklight_status);
  4223.  
  4224. }
  4225. if (!_strnicmp(line, "OV", 2)) {
  4226. sscanf(line + 2, "%d", &OV);
  4227.  
  4228.  
  4229. }
  4230. if (!_strnicmp(line, "NOSLIDEWIRE", 11)) // if ODS is used or not
  4231. {
  4232. sscanf(line + 11, "%d", &NOSLIDEWIRE);
  4233. NOSLIDEWIRE = 1;
  4234. }
  4235. if (!_strnicmp(line, "EXTAIRLOCK", 10)) // if ODS is used or not
  4236. {
  4237. sscanf(line + 10, "%d", &EXTAIRLOCK);
  4238. EXTAIRLOCK = 1;
  4239. }
  4240. if (!_strnicmp(line, "USEIUS",6)){ // use IUS
  4241. sscanf(line + 6, "%d", &USEIUS);
  4242. USEIUS = 1;
  4243. }
  4244. if (!_strnicmp(line, "ORIGINAL", 8))// tells if Original paint job is used
  4245. {
  4246. sscanf(line + 8, "%d", &ORIGINAL);
  4247. ORIGINAL = 1;
  4248. }
  4249. if (!_strnicmp(line, "NOKU", 4))// tells if Original paint job is used
  4250. {
  4251. sscanf(line + 4, "%d", &NOKU);
  4252. NOKU = 1;
  4253. }
  4254. if (!_strnicmp(line, "NOWIRE", 6))// tells if Original paint job is used
  4255. {
  4256. sscanf(line + 6, "%d", &NOWIRE);
  4257. NOWIRE = 1;
  4258. }
  4259. if (!_strnicmp(line, "EVA1", 4))// if eva has happened
  4260. {
  4261. sscanf(line + 4, "%d", &EVA1);
  4262. EVA1 = 1;
  4263. }
  4264. if (!_strnicmp(line, "EVA2", 4))// if eva has happened
  4265. {
  4266. sscanf(line + 4, "%d", &EVA2);
  4267. EVA2 = 1;
  4268. }
  4269. if (!_strnicmp(line, "EVA3", 4))// if eva has happened
  4270. {
  4271. sscanf(line + 4, "%d", &EVA3);
  4272. EVA3 = 1;
  4273. }
  4274. if (!_strnicmp(line, "EVA4", 4))// if eva has happened
  4275. {
  4276. sscanf(line + 4, "%d", &EVA4);
  4277. EVA4 = 1;
  4278. }
  4279. if (!_strnicmp(line, "MID", 3))// if mid range paint model is used
  4280. {
  4281. sscanf(line + 3, "%d", &MIDMODEL);
  4282. MIDMODEL = 1;
  4283. }
  4284. if (!_strnicmp(line, "OBSS", 4)) {//if OBSS is used
  4285. sscanf(line + 4, "%d", &OBSS1);
  4286. OBSS1 = 1;
  4287.  
  4288. }
  4289. if (!_strnicmp(line, "RMSLIGHT", 8)) {//RMS light on/off
  4290. sscanf(line + 8, "%d", &rmslight_status);
  4291.  
  4292. }
  4293. if (!_strnicmp(line, "ODS", 3)) // if ODS is used or not
  4294. {
  4295. sscanf(line + 3, "%d", &ODS);
  4296. ODS = 1;
  4297. }
  4298. if (!_strnicmp(line, "ARMEDGEAR", 9)) // gear armed
  4299. {
  4300. sscanf(line + 9, "%d", &geararmed);
  4301. geararmed = 1;
  4302. }
  4303. if (!_strnicmp(line, "NOCHUTE", 7)) // if drag chute is used or not
  4304. {
  4305. sscanf(line + 7, "%d", &DRAGCHUTE);
  4306. DRAGCHUTE = 1;
  4307. }
  4308. if (!_strnicmp(line, "RMSARM", 6)) // if RMSARM is used or not
  4309. {
  4310. sscanf(line + 6, "%d", &RMSSELECT);
  4311. RMSSELECT = 1;
  4312. }
  4313.  
  4314. if (!_strnicmp(line, "PAYLOAD_MASS1", 13)) // if PAYLOAD_MASS1 is used or not
  4315. {
  4316. sscanf(line + 13, "%lf", &MASS1);//payload mass 1 is used so get the mass
  4317. PMASS1 = 1;//payload mass 1 is used
  4318. }
  4319.  
  4320. else if (!_strnicmp(line, "PAYLOAD_MASS2", 13)) // if PAYLOAD_MASS2 is used or not
  4321. {
  4322. sscanf(line + 13, "%lf", &MASS2);
  4323. PMASS2 = 1;//payload mass 2 is used
  4324. }
  4325. else if (!_strnicmp(line, "PAYLOAD_MASS3", 13)) // if PAYLOAD_MASS3 is used or not
  4326. {
  4327. sscanf(line + 13, "%lf", &MASS3);
  4328. PMASS3 = 1;//payload mass 3 is used
  4329. }
  4330. else if (!_strnicmp(line, "PAYLOAD_MASS0", 12)) // if PAYLOAD_MASS0 is used or not
  4331. {
  4332. sscanf(line + 12, "%lf", &MASS0);
  4333. PMASS0 = 1;//payload mass 0 is used
  4334. }
  4335. if (!_strnicmp(line, "SPIN0", 5)) // if ODS is used or not
  4336. {
  4337. sscanf(line + 5, "%d", &SPIN0);
  4338. SPIN0 = 1;
  4339. }
  4340. if (!_strnicmp(line, "SPIN1", 5)) // if ODS is used or not
  4341. {
  4342. sscanf(line + 5, "%d", &SPIN1);
  4343. SPIN1 = 1;
  4344. }
  4345. if (!_strnicmp(line, "SPIN2", 5)) // if ODS is used or not
  4346. {
  4347. sscanf(line + 5, "%d", &SPIN2);
  4348. SPIN2 = 1;
  4349. }
  4350. if (!_strnicmp(line, "SPIN3", 5)) // if ODS is used or not
  4351. {
  4352. sscanf(line + 5, "%d", &SPIN3);
  4353. SPIN3 = 1;
  4354. }
  4355. if (!_strnicmp(line, "SPIN4", 5)) // if ODS is used or not
  4356. {
  4357. sscanf(line + 5, "%d", &SPIN4);
  4358. SPIN4 = 1;
  4359. }if (!_strnicmp(line, "SPIN5", 5)) // if ODS is used or not
  4360. {
  4361. sscanf(line + 5, "%d", &SPIN5);
  4362. SPIN5 = 1;
  4363. }
  4364. if (!_strnicmp(line, "RMSDIALOG", 9)) // if rmsdialogue open rmsdialogue =3
  4365. {
  4366. sscanf(line + 9, "%d", &RMSDIALOG);
  4367. RMSDIALOG = 3;
  4368. }
  4369. // else if (!strnicmp(line, "tiltangle", 9))
  4370. // {
  4371. // sscanf(line + 9, "%lf %lf", &phi, &tiltvalue);
  4372. // }
  4373. else if (!strnicmp(line, "IUSproc", 7))
  4374. {
  4375. sscanf(line + 7, "%lf", &ius_proc);
  4376.  
  4377. }
  4378. if (!strnicmp(line, "CREW1", 5))
  4379. {
  4380. sscanf(line + 5, "%s%s", &crew1_name, &crew1_cfg);
  4381. CREW1 = 1;
  4382. }
  4383. else if (!strnicmp(line, "CREW2", 5))
  4384. {
  4385. sscanf(line + 5, "%s%s", &crew2_name, &crew2_cfg);
  4386. CREW2 = 1;
  4387. }
  4388. else if (!strnicmp(line, "CREW3", 5))
  4389. {
  4390. sscanf(line + 5, "%s%s", &crew3_name, &crew3_cfg);
  4391. CREW3 = 1;
  4392. }
  4393. else if (!strnicmp(line, "CREW4", 5))
  4394. {
  4395. sscanf(line + 5, "%s%s", &crew4_name, &crew4_cfg);
  4396. CREW4 = 1;
  4397. }
  4398.  
  4399. else ParseScenarioLineEx (line, vs); // unrecognised option - pass to Orbiter's generic parser
  4400. }
  4401. }
  4402. if (status == 0) {
  4403. VESSELSTATUS2 *vs2 = (VESSELSTATUS2*)vs;
  4404. if (vs2->status & 1) { // idle flag
  4405. launchelev = max (0, vs2->vrot.x - 18.962);
  4406. if (vs2->arot.x > 4.0) { // rotation matrix not defined - need to construct manually
  4407. double slng = sin (vs2->surf_lng), clng = cos (vs2->surf_lng);
  4408. double slat = sin (vs2->surf_lat), clat = cos (vs2->surf_lat);
  4409. double sdir = sin (vs2->surf_hdg), cdir = cos (vs2->surf_hdg);
  4410. vs2->arot.x = atan2(slat, clat*slng);
  4411. vs2->arot.y = -asin(clng*clat);
  4412. vs2->arot.z = atan2(clng*slat*cdir+slng*sdir, clng*slat*sdir-slng*cdir);
  4413. }
  4414. } else {
  4415. double rad = length(vs2->rpos);
  4416. double alt = rad - oapiGetSize(vs2->rbody);
  4417. launchelev = max (0, alt - 18.962);
  4418. }
  4419. }
  4420.  
  4421.  
  4422.  
  4423. // optional meshes
  4424.  
  4425. if (do_plat && !mesh_platform) {
  4426. VECTOR3 plat_ofs = _V(-2.59805, 1.69209, -5.15524);
  4427. mesh_platform = AddMesh("shuttle_eva_plat", &plat_ofs);
  4428. }
  4429. //t0 = ascap->GetMT0();
  4430.  
  4431.  
  4432. if (ODS == 0){
  4433. SetAnimation(anim_extdoor, EXT_proc);
  4434. CreateDock(_V(0.0, -.8, 10.5), _V(0, 1, 0), _V(0, 0, 1));
  4435. }
  4436. //if (RMSDIALOG == 1)oapiOpenDialogEx(g_Param.hDLL, IDD_RMS, RMS_DlgProc, 0, this);
  4437. if (flood1_status == 1)
  4438. {
  4439. spotlight1->Activate(true);
  4440. spot_beacon[0].active = true;
  4441. }
  4442.  
  4443. if (flood2_status == 1)
  4444. {
  4445. spotlight2->Activate(true);
  4446. spot_beacon[1].active = true;
  4447. }
  4448. // flood 1 off
  4449. if (flood1_status == 0)
  4450. {
  4451. spotlight1->Activate(false);
  4452. spot_beacon[0].active = false;
  4453. }
  4454. // flood 2 off
  4455. if (flood2_status == 0)
  4456. {
  4457. spotlight2->Activate(false);
  4458. spot_beacon[1].active = false;
  4459. }
  4460. // flood 3 on
  4461. if (flood3_status == 1)
  4462. {
  4463. spotlight3->Activate(true);
  4464. spot_beacon[2].active = true;
  4465. }
  4466. // flood 4 on
  4467. if (flood4_status == 1)
  4468. {
  4469. spotlight4->Activate(true);
  4470. spot_beacon[3].active = true;
  4471. }
  4472. // flood 3 off
  4473. if (flood3_status == 0)
  4474. {
  4475. spotlight3->Activate(false);
  4476. spot_beacon[2].active = false;
  4477. }
  4478. // flood 4 off
  4479. if (flood4_status == 0)
  4480. {
  4481. spotlight4->Activate(false);
  4482. spot_beacon[3].active = false;
  4483. }
  4484. // flood 5 on
  4485. if (flood5_status == 1)
  4486. {
  4487. spotlight5->Activate(true);
  4488. spot_beacon[4].active = true;
  4489. }
  4490. // flood 6 on
  4491. if (flood6_status == 1)
  4492. {
  4493. spotlight6->Activate(true);
  4494. spot_beacon[5].active = true;
  4495. }
  4496. // flood 5 off
  4497. if (flood5_status == 0)
  4498. {
  4499. spotlight5->Activate(false);
  4500. spot_beacon[4].active = false;
  4501. }
  4502. // flood 6 off
  4503. if (flood6_status == 0)
  4504. {
  4505. spotlight6->Activate(false);
  4506. spot_beacon[5].active = false;
  4507. }
  4508. //aft light on
  4509.  
  4510. if (aft_light_status == 1)
  4511. {
  4512.  
  4513.  
  4514. spotlight7->Activate(true);
  4515.  
  4516.  
  4517.  
  4518. spot_beacon[6].active = true;
  4519.  
  4520. }
  4521. //aft light off
  4522. else if (aft_light_status == 0)
  4523. {
  4524.  
  4525. spotlight7->Activate(false);
  4526.  
  4527.  
  4528.  
  4529. spot_beacon[6].active = false;
  4530.  
  4531. }
  4532. //rms light on
  4533. if (rmslight_status == 1)
  4534. {
  4535.  
  4536.  
  4537. spotlightRMS->Activate(true);
  4538. spot_beacon[8].active = true;
  4539.  
  4540. }
  4541. //rms light off
  4542. else if (rmslight_status == 0)
  4543. {
  4544.  
  4545. spotlightRMS->Activate(false);
  4546. spot_beacon[8].active = false;
  4547.  
  4548. }
  4549. //dock light off
  4550. if (docklight_status == 0)
  4551. {
  4552. spotlightDOCK->Activate(false);
  4553. spot_beacon[7].active = false;
  4554. }
  4555. //dock light on
  4556. if (docklight_status == 1)
  4557. {
  4558. spotlightDOCK->Activate(true);
  4559. spot_beacon[7].active = true;
  4560. }
  4561. ClearMeshes();//clear meshes
  4562. LoadMeshes();//load correct meshes
  4563. if (do_cargostatic && !mesh_cargo) {
  4564. mesh_cargo = AddMesh(cargo_static_mesh_name, &cargo_static_ofs);
  4565. }
  4566. if (do_cargostatic)SetMeshVisibilityMode(mesh_cargo, MESHVIS_EXTERNAL | MESHVIS_VC | MESHVIS_EXTPASS);
  4567. if (ODS==1)
  4568. {
  4569. hDockODS = CreateDock(ORBITER_DOCKPOS, _V(0, 1, 0), _V(0, 0, -1));
  4570. SetMeshVisibilityMode(mesh_ODS, MESHVIS_EXTERNAL | MESHVIS_VC | MESHVIS_EXTPASS);//ODS PRESENT SHOW MESH
  4571. //CreateDock(_V(0.0, -.8, 8), _V(0, 1, 0), _V(0, 0, 1));
  4572. SetAnimation(anim_extodsdoor, EXT_proc);
  4573.  
  4574. }
  4575. if (NOSLIDEWIRE == 1)
  4576. {
  4577.  
  4578. SetMeshVisibilityMode(mesh_SLIDEWIRE, MESHVIS_NEVER);//DO NOT SHOW THIS MESH
  4579.  
  4580.  
  4581.  
  4582. }
  4583. if (RMSSELECT==1)
  4584. {
  4585.  
  4586. SetMeshVisibilityMode(mesh_RMS1, MESHVIS_EXTERNAL | MESHVIS_VC | MESHVIS_EXTPASS);//RMS PRESENT SHOW MESH
  4587. }
  4588. if (OBSS1 == 1)
  4589. {
  4590.  
  4591. SetMeshVisibilityMode(mesh_MPMOBSS, MESHVIS_EXTERNAL | MESHVIS_VC | MESHVIS_EXTPASS);//obss PRESENT SHOW MESH
  4592.  
  4593. }
  4594. if (NOKU == 1)
  4595. {
  4596.  
  4597. SetMeshVisibilityMode(mesh_KU, MESHVIS_NEVER);//DO NOT SHOW THIS MESH
  4598.  
  4599. }
  4600. if (NOWIRE == 1)
  4601. {
  4602.  
  4603. SetMeshVisibilityMode(mesh_SHUTTLEWIRE, MESHVIS_NEVER);//DO NOT SHOW THIS MESH
  4604.  
  4605. }
  4606. if (EXTAIRLOCK == 1)
  4607. {
  4608.  
  4609. SetMeshVisibilityMode(mesh_EXTAIRLOCK, MESHVIS_EXTERNAL | MESHVIS_VC | MESHVIS_EXTPASS);//obss PRESENT SHOW MESH
  4610. SetMeshVisibilityMode(mesh_THERMALCOVER, MESHVIS_NEVER);//DO NOT SHOW THIS MESH
  4611. SetAnimation(anim_EXTAIRLOCK, EXT_proc);
  4612.  
  4613. }
  4614. //make changes to attachment based off scn
  4615. //ofs_sts_sat.x = pl1_ofs.x;
  4616. //ofs_sts_sat.y = pl1_ofs.y;
  4617. //ofs_sts_sat.z = pl1_ofs.z;
  4618. SetAttachmentParams(sat_attach, pl1_ofs, pl1_dir, pl1_rot);//0
  4619. SetAttachmentParams(sat_attach2, pl2_ofs, pl2_dir, pl2_rot);//1
  4620. SetAttachmentParams(sat_attach3, pl3_ofs, pl3_dir, pl3_rot);//2
  4621. SetAttachmentParams(sat_attach4, pl4_ofs, pl4_dir, pl4_rot);//3
  4622. SetAttachmentParams(sat_attach5, pl5_ofs, pl5_dir, pl5_rot);//4
  4623. SetAttachmentParams(sat_attach6, pl6_ofs, pl6_dir, pl6_rot);//5
  4624. SetAttachmentParams(sat_attach7, pl7_ofs, pl7_dir, pl7_rot);//6
  4625. SetAttachmentParams(sat_attach8, pl8_ofs, pl8_dir, pl8_rot);//7
  4626. SetAttachmentParams(sat_attach9, pl9_ofs, pl9_dir, pl9_rot);//8
  4627. SetAttachmentParams(sat_attach10, pl10_ofs, pl10_dir, pl10_rot);//9
  4628. SetAttachmentParams(ft_pad_att, ft_pad_att_pos, ft_pad_att_dir, ft_pad_att_rot);//13
  4629. SetAttachmentParams(ft_pad_att1, ft_pad_att1_pos, ft_pad_att1_dir, ft_pad_att1_rot);//14
  4630. SetAttachmentParams(ft_pad_att2, ft_pad_att2_pos, ft_pad_att2_dir, ft_pad_att2_rot);//15
  4631. SetAttachmentParams(ft_pad_att3, ft_pad_att3_pos, ft_pad_att3_dir, ft_pad_att3_rot);//16
  4632. SetAttachmentParams(OBSS_attach, armobss_tip[0], armobss_tip[1] - armobss_tip[0], armobss_tip[2] - armobss_tip[0]);
  4633. //6
  4634. //ius_proc = atan(pl1_dir.y);
  4635. //if (OBSS1 == 1)SetAttachmentParams(sat_attach7, _V(2.850, 2.150, 3.850), _V(0, 1, 0), _V(0, 0, 1));//6
  4636.  
  4637. if (gear_proc>=1) {
  4638. SetAnimation(anim_LEFTGEARDN, 1);
  4639. // SetAnimation(anim_LEFTGEARUP, 1);
  4640. SetAnimation(anim_LEFTGEARTALKBACK, 1);
  4641. SetAnimation(anim_RIGHTGEARDN, 1);
  4642. // SetAnimation(anim_RIGHTGEARUP, 1);
  4643. SetAnimation(anim_RIGHTGEARTALKBACK, 1);
  4644. }
  4645. if (geararmed == 1) {
  4646. SetAnimation(anim_LEFTGEARARMON, 1);
  4647. // SetAnimation(anim_LEFTGEARARMOFF, 1);
  4648. SetAnimation(anim_RIGHTGEARARMON, 1);
  4649. // SetAnimation(anim_RIGHTGEARARMOFF, 1);
  4650. }
  4651. if (flood2_status == 0)SetAnimation(anim_floodportaft, 0);
  4652. if (flood2_status == 1)SetAnimation(anim_floodportaft, 1);
  4653.  
  4654. if (flood1_status == 0)SetAnimation(anim_floodstbdaft, 0);
  4655. if (flood1_status == 1)SetAnimation(anim_floodstbdaft, 1);
  4656.  
  4657. if (flood3_status == 0)SetAnimation(anim_floodportmid, 0);
  4658. if (flood3_status == 1)SetAnimation(anim_floodportmid, 1);
  4659.  
  4660. if (flood4_status == 0)SetAnimation(anim_floodstbdmid, 0);
  4661. if (flood4_status == 1)SetAnimation(anim_floodstbdmid, 1);
  4662.  
  4663. if (flood5_status == 0)SetAnimation(anim_floodportfwd, 0);
  4664. if (flood5_status == 1)SetAnimation(anim_floodportfwd, 1);
  4665.  
  4666. if (flood6_status == 0)SetAnimation(anim_floodstbdfwd, 0);
  4667. if (flood6_status == 1)SetAnimation(anim_floodstbdfwd, 1);
  4668.  
  4669. if (aft_light_status == 0)SetAnimation(anim_fwdlight, 0);
  4670. if (aft_light_status == 1)SetAnimation(anim_fwdlight, 1);
  4671.  
  4672. if (docklight_status == 1)SetAnimation(anim_docklight, .5);
  4673. if (docklight_status == 2)SetAnimation(anim_docklight, 1);
  4674. if (docklight_status == 0)SetAnimation(anim_docklight, 0);
  4675.  
  4676. if ((flood1_status == 0)|| (flood2_status == 0)|| (flood3_status == 0)|| (flood4_status == 0)|| (flood5_status == 0)|| (flood6_status == 0))SetAnimation(anim_floodon, 0);
  4677. if ((flood1_status == 1) || (flood2_status == 1) || (flood3_status == 1) || (flood4_status == 1) || (flood5_status == 1) || (flood6_status == 1))SetAnimation(anim_floodon, 1);
  4678.  
  4679. if (ADTA_proc <= 0)SetAnimation(anim_ATDADeploy, 0);
  4680. if (ADTA_proc >= 1)SetAnimation(anim_ATDADeploy, 1);
  4681. }
  4682.  
  4683. // --------------------------------------------------------------
  4684. // Write status to scenario file
  4685. // --------------------------------------------------------------
  4686. void Atlantis::clbkSaveState(FILEHANDLE scn)
  4687. {
  4688. char cbuf[256];
  4689.  
  4690. // default vessel parameters
  4691. VESSEL4::clbkSaveState(scn);
  4692.  
  4693. // custom parameters
  4694. oapiWriteScenario_int(scn, "CONFIGURATION", status);
  4695.  
  4696. //if (status == 1)
  4697. // oapiWriteScenario_float (scn, "MET", oapiGetSimTime()-t0);
  4698.  
  4699.  
  4700. char savebuff[256], savevalbuff[256];
  4701.  
  4702.  
  4703.  
  4704. sprintf(savebuff, "MET");
  4705. sprintf(savevalbuff, "%.3f", MET);
  4706. oapiWriteScenario_string(scn, savebuff, savevalbuff);
  4707.  
  4708.  
  4709.  
  4710.  
  4711. sprintf(cbuf, "%d %0.4f", gear_status - 1, gear_proc);
  4712. oapiWriteScenario_string(scn, "GEAR", cbuf);
  4713.  
  4714. sprintf(cbuf, "%d %0.4f", EXT_status, EXT_proc);
  4715. oapiWriteScenario_string(scn, "HATCH", cbuf);
  4716.  
  4717. sprintf(cbuf, "%d %0.4f", ADTA_status, ADTA_proc);
  4718. oapiWriteScenario_string(scn, "ADTA", cbuf);
  4719.  
  4720. sprintf(cbuf, "%d %0.4f", ssmestow_status, ssmestow_proc);
  4721. oapiWriteScenario_string(scn, "SSMES", cbuf);
  4722.  
  4723. sprintf(cbuf, "%d ", VCCAM);
  4724. oapiWriteScenario_string(scn, "VCCAM", cbuf);
  4725.  
  4726.  
  4727.  
  4728.  
  4729. sprintf(cbuf, "%d %0.4f", PETD_status, PETD_proc);
  4730. oapiWriteScenario_string(scn, "PETD", cbuf);
  4731.  
  4732. sprintf(cbuf, "%d %0.4f", SETD_status, SETD_proc);
  4733. oapiWriteScenario_string(scn, "SETD", cbuf);
  4734.  
  4735. sprintf(cbuf, "%d ", OV);
  4736. oapiWriteScenario_string(scn, "OV", cbuf);
  4737. if (RMSDIALOG == 2)RMSDIALOG = 3;//dialogue is open so set rmsdialogue to 3
  4738. if (USEIUS == 1) oapiWriteScenario_string(scn, "USEIUS", " ");
  4739. if (SPIN0 == 1) oapiWriteScenario_string(scn, "SPIN0", " "); //INTELSAT6 SPIN
  4740.  
  4741. if (SPIN1 == 1) oapiWriteScenario_string(scn, "SPIN1", " "); //if eva has happened or not
  4742. if (SPIN2 == 1) oapiWriteScenario_string(scn, "SPIN2", " "); //if eva has happened or not
  4743. if (SPIN3 == 1) oapiWriteScenario_string(scn, "SPIN3", " "); //if eva has happened or not
  4744. if (SPIN4 == 1) oapiWriteScenario_string(scn, "SPIN4", " "); //if eva has happened or not
  4745. if (SPIN5 == 1) oapiWriteScenario_string(scn, "SPIN5", " "); //if eva has happened or not
  4746. //if (EVA == 1) oapiWriteScenario_string(scn, "EVA", " "); //if eva has happened or not
  4747. if (ODS == 1) oapiWriteScenario_string(scn, "ODS", " "); // if ODS is used or not
  4748. if (geararmed == 1) oapiWriteScenario_string(scn, "ARMEDGEAR", " ");//gear is armed
  4749. if (RMSDIALOG == 3) oapiWriteScenario_string(scn, "RMSDIALOG", " "); // if rms dialogue is open so write rmsdialogue
  4750. if (ORIGINAL == 1) oapiWriteScenario_string(scn, "ORIGINAL", " ");// if Original paint scheme is used
  4751. if (MIDMODEL == 1) oapiWriteScenario_string(scn, "MID", " ");// if mid range paint scheme is used
  4752. if (RMSSELECT == 1) oapiWriteScenario_string(scn, "RMSARM", " ");// if rmsarm is used
  4753. if (OBSS1 == 1) oapiWriteScenario_string(scn, "OBSS", " ");// if Obss is used
  4754. if (EXTAIRLOCK == 1) oapiWriteScenario_string(scn, "EXTAIRLOCK", " ");// if EXTERNAL AIRLOCKf is used
  4755. if (EVA1 == 1) oapiWriteScenario_string(scn, "EVA1", " ");// if EVA1GUY MADE is used
  4756. if (EVA2 == 1) oapiWriteScenario_string(scn, "EVA2", " ");// if EVA2GUY MADE is used
  4757. if (EVA3 == 1) oapiWriteScenario_string(scn, "EVA3", " ");// if EVA3GUY MADE is used
  4758. if (EVA4 == 1) oapiWriteScenario_string(scn, "EVA4", " ");// if EVA4GUY MADE is used
  4759. if (NOKU == 1) oapiWriteScenario_string(scn, "NOKU", " ");// KU band antenna not used
  4760. if (NOWIRE == 1) oapiWriteScenario_string(scn, "NOWIRE", " ");// NO SHUTTLE CARGO BAY WIRE not used
  4761. if (NOSLIDEWIRE == 1) oapiWriteScenario_string(scn, "NOSLIDEWIRE", " ");
  4762.  
  4763. if (DRAGCHUTE == 1) oapiWriteScenario_string(scn, "NOCHUTE", " ");// if DRAGCHUTE is used
  4764. if (RMSSELECT == 1) {
  4765. if (arm1set) oapiWriteScenario_string(scn, "ARM1SET", " "); //if ARM1SET has happened or not
  4766. if (arm2set) oapiWriteScenario_string(scn, "ARM2SET", " "); //if ARM2SET has happened or not
  4767. if (arm3set) oapiWriteScenario_string(scn, "ARM3SET", " "); //if ARM3SET has happened or not
  4768. if (arm4set) oapiWriteScenario_string(scn, "ARM4SET", " "); //if ARM4SET has happened or not
  4769. sprintf(cbuf, "%0.4f %0.4f %0.4f %0.4f %0.4f %0.4f", arm_sy, arm_sp, arm_ep, arm_wp, arm_wy, arm_wr);
  4770. oapiWriteScenario_string(scn, "ARM_STATUS", cbuf);
  4771.  
  4772. if (arm1set) {
  4773. sprintf(cbuf, " %f %f %f %f %f %f", arm1_By, arm1_Bp,
  4774. arm1_ep, arm1_Ap, arm1_Ay, arm1_Ar);
  4775. oapiWriteScenario_string(scn, "ARM_SEQ1", cbuf);
  4776. }
  4777. if (arm2set) {
  4778. sprintf(cbuf, " %f %f %f %f %f %f", arm2_By, arm2_Bp,
  4779. arm2_ep, arm2_Ap, arm2_Ay, arm2_Ar);
  4780. oapiWriteScenario_string(scn, "ARM_SEQ2", cbuf);
  4781. }
  4782. if (arm3set) {
  4783. sprintf(cbuf, " %f %f %f %f %f %f", arm3_By, arm3_Bp,
  4784. arm3_ep, arm3_Ap, arm3_Ay, arm3_Ar);
  4785. oapiWriteScenario_string(scn, "ARM_SEQ3", cbuf);
  4786. }
  4787. if (arm4set) {
  4788. sprintf(cbuf, " %f %f %f %f %f %f", arm4_By, arm4_Bp,
  4789. arm4_ep, arm4_Ap, arm4_Ay, arm4_Ar);
  4790. oapiWriteScenario_string(scn, "ARM_SEQ4", cbuf);
  4791. }
  4792. sprintf(cbuf, "%d %0.4f %d %0.4f", Armtilt_status, Armtilt_proc, OBSS_status, OBSS_proc);
  4793. oapiWriteScenario_string(scn, "Armtilt", cbuf);
  4794. }
  4795.  
  4796. //PBCAM
  4797. sprintf(cbuf, "%0.4f %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f", camPitch[CAM_A], camYaw[CAM_A], camPitch[CAM_B], camYaw[CAM_B],
  4798. camPitch[CAM_C], camYaw[CAM_C], camPitch[CAM_D], camYaw[CAM_D], camRMSElbow[PAN], camRMSElbow[TILT]);
  4799. oapiWriteScenario_string(scn, "PLB_CAM", cbuf);
  4800.  
  4801.  
  4802. //if (USEIUS == 1){
  4803. // sprintf(cbuf, " %0.4f %0.4f", phi, tiltvalue);
  4804. // oapiWriteScenario_string(scn, "tiltangle", cbuf);
  4805. // }
  4806. if (USEIUS == 1) {
  4807. sprintf(cbuf, " %0.4f", ius_proc);
  4808. oapiWriteScenario_string(scn, "IUSproc", cbuf);
  4809. }
  4810. if (spdb_status != AnimState::CLOSED) {
  4811. sprintf(cbuf, " %0.4f", spdb_proc);
  4812. oapiWriteScenario_string(scn, "SPEEDBRAKE", cbuf);
  4813. }
  4814.  
  4815. //if (status == 0 && launchelev)
  4816. // oapiWriteScenario_float (scn, "LAUNCHELEVATION", launchelev);
  4817.  
  4818.  
  4819. if (PMASS0 == 1) {// PAYLOAD_MASS0 is used
  4820. sprintf(cbuf, " %0.3f", MASS0);
  4821. oapiWriteScenario_string(scn, "PAYLOAD_MASS0", cbuf);// write to scn payload mass 0
  4822. }
  4823. if (PMASS1 == 1) {// PAYLOAD_MASS1 is used
  4824. sprintf(cbuf, " %0.3f", MASS1);
  4825. oapiWriteScenario_string(scn, "PAYLOAD_MASS1", cbuf);
  4826. }
  4827. if (PMASS2 == 1) {// PAYLOAD_MASS2 is used
  4828. sprintf(cbuf, " %0.3f", MASS2);
  4829. oapiWriteScenario_string(scn, "PAYLOAD_MASS2", cbuf);
  4830. }
  4831. if (PMASS3 == 1) {// PAYLOAD_MASS3 is used
  4832. sprintf(cbuf, " %0.3f", MASS3);
  4833. oapiWriteScenario_string(scn, "PAYLOAD_MASS3", cbuf);
  4834. }
  4835. /*
  4836. sprintf(cbuf, "%0.4f %0.4f %0.4f %0.4f %0.4f %0.4f", arm_sy_stored1, arm_sp_stored1, arm_ep_stored1, arm_wp_stored1, arm_wy_stored1, arm_wr_stored1);
  4837. oapiWriteScenario_string(scn, "ARM_SEQ1", cbuf);
  4838.  
  4839. sprintf(cbuf, "%0.4f %0.4f %0.4f %0.4f %0.4f %0.4f", arm6_By, arm6_Bp, arm6_ep, arm6_Ap, arm6_Ay, arm_wr_stored2);
  4840. oapiWriteScenario_string(scn, "ARM_SEQ2", cbuf);
  4841.  
  4842. sprintf(cbuf, "%0.4f %0.4f %0.4f %0.4f %0.4f %0.4f", arm6_By, arm6_Bp, arm6_ep, arm6_Ap, arm6_Ay, arm6_Ar);
  4843. oapiWriteScenario_string(scn, "ARM_SEQ3", cbuf);
  4844.  
  4845. sprintf(cbuf, "%0.4f %0.4f %0.4f %0.4f %0.4f %0.4f", arm6_By, arm6_Bp, arm6_ep, arm6_Ap, arm6_Ay, arm6_Ar);
  4846. oapiWriteScenario_string(scn, "ARM_SEQ4", cbuf);
  4847. */
  4848. // read attachment point loaction,dir, and rot.
  4849. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl1_ofs.x, pl1_ofs.y, pl1_ofs.z);
  4850. oapiWriteScenario_string(scn, "PL1_OFS", cbuf);
  4851.  
  4852. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl1_dir.x, pl1_dir.y, pl1_dir.z);
  4853. oapiWriteScenario_string(scn, "PL1_DIR", cbuf);
  4854.  
  4855. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl1_rot.x, pl1_rot.y, pl1_rot.z);
  4856. oapiWriteScenario_string(scn, "PL1_ROT", cbuf);
  4857.  
  4858. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl2_ofs.x, pl2_ofs.y, pl2_ofs.z);
  4859. oapiWriteScenario_string(scn, "PL2_OFS", cbuf);
  4860.  
  4861. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl2_dir.x, pl2_dir.y, pl2_dir.z);
  4862. oapiWriteScenario_string(scn, "PL2_DIR", cbuf);
  4863.  
  4864. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl2_rot.x, pl2_rot.y, pl2_rot.z);
  4865. oapiWriteScenario_string(scn, "PL2_ROT", cbuf);
  4866.  
  4867. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl3_ofs.x, pl3_ofs.y, pl3_ofs.z);
  4868. oapiWriteScenario_string(scn, "PL3_OFS", cbuf);
  4869.  
  4870. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl3_dir.x, pl3_dir.y, pl3_dir.z);
  4871. oapiWriteScenario_string(scn, "PL3_DIR", cbuf);
  4872.  
  4873. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl3_rot.x, pl3_rot.y, pl3_rot.z);
  4874. oapiWriteScenario_string(scn, "PL3_ROT", cbuf);
  4875.  
  4876. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl4_ofs.x, pl4_ofs.y, pl4_ofs.z);
  4877. oapiWriteScenario_string(scn, "PL4_OFS", cbuf);
  4878.  
  4879. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl4_dir.x, pl4_dir.y, pl4_dir.z);
  4880. oapiWriteScenario_string(scn, "PL4_DIR", cbuf);
  4881.  
  4882. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl4_rot.x, pl4_rot.y, pl4_rot.z);
  4883. oapiWriteScenario_string(scn, "PL4_ROT", cbuf);
  4884.  
  4885. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl5_ofs.x, pl5_ofs.y, pl5_ofs.z);
  4886. oapiWriteScenario_string(scn, "PL5_OFS", cbuf);
  4887.  
  4888. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl5_dir.x, pl5_dir.y, pl5_dir.z);
  4889. oapiWriteScenario_string(scn, "PL5_DIR", cbuf);
  4890.  
  4891. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl5_rot.x, pl5_rot.y, pl5_rot.z);
  4892. oapiWriteScenario_string(scn, "PL5_ROT", cbuf);
  4893.  
  4894. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl6_ofs.x, pl6_ofs.y, pl6_ofs.z);
  4895. oapiWriteScenario_string(scn, "PL6_OFS", cbuf);
  4896.  
  4897. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl6_dir.x, pl6_dir.y, pl6_dir.z);
  4898. oapiWriteScenario_string(scn, "PL6_DIR", cbuf);
  4899.  
  4900. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl6_rot.x, pl6_rot.y, pl6_rot.z);
  4901. oapiWriteScenario_string(scn, "PL6_ROT", cbuf);
  4902.  
  4903. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl7_ofs.x, pl7_ofs.y, pl7_ofs.z);
  4904. oapiWriteScenario_string(scn, "PL7_OFS", cbuf);
  4905.  
  4906. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl7_dir.x, pl7_dir.y, pl7_dir.z);
  4907. oapiWriteScenario_string(scn, "PL7_DIR", cbuf);
  4908.  
  4909. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl7_rot.x, pl7_rot.y, pl7_rot.z);
  4910. oapiWriteScenario_string(scn, "PL7_ROT", cbuf);
  4911.  
  4912. //8
  4913. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl8_ofs.x, pl8_ofs.y, pl8_ofs.z);
  4914. oapiWriteScenario_string(scn, "PL8_OFS", cbuf);
  4915.  
  4916. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl8_dir.x, pl8_dir.y, pl8_dir.z);
  4917. oapiWriteScenario_string(scn, "PL8_DIR", cbuf);
  4918.  
  4919. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl8_rot.x, pl8_rot.y, pl8_rot.z);
  4920. oapiWriteScenario_string(scn, "PL8_ROT", cbuf);
  4921. //9
  4922. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl9_ofs.x, pl9_ofs.y, pl9_ofs.z);
  4923. oapiWriteScenario_string(scn, "PL9_OFS", cbuf);
  4924.  
  4925. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl9_dir.x, pl9_dir.y, pl9_dir.z);
  4926. oapiWriteScenario_string(scn, "PL9_DIR", cbuf);
  4927.  
  4928. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl9_rot.x, pl9_rot.y, pl9_rot.z);
  4929. oapiWriteScenario_string(scn, "PL9_ROT", cbuf);
  4930. //10
  4931. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl10_ofs.x, pl10_ofs.y, pl10_ofs.z);
  4932. oapiWriteScenario_string(scn, "pl10_OFS", cbuf);
  4933.  
  4934. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl10_dir.x, pl10_dir.y, pl10_dir.z);
  4935. oapiWriteScenario_string(scn, "pl10_DIR", cbuf);
  4936.  
  4937. sprintf(cbuf, "%0.4f %0.4f %0.4f", pl10_rot.x, pl10_rot.y, pl10_rot.z);
  4938. oapiWriteScenario_string(scn, "pl10_ROT", cbuf);
  4939.  
  4940. sprintf(cbuf, "%0.4f %0.4f %0.4f", ft_pad_att_pos.x, ft_pad_att_pos.y, ft_pad_att_pos.z);
  4941. oapiWriteScenario_string(scn, "ft_pad_att_pos", cbuf);
  4942.  
  4943. sprintf(cbuf, "%0.4f %0.4f %0.4f", ft_pad_att_dir.x, ft_pad_att_dir.y, ft_pad_att_dir.z);
  4944. oapiWriteScenario_string(scn, "ft_pad_att_dir", cbuf);
  4945.  
  4946. sprintf(cbuf, "%0.4f %0.4f %0.4f", ft_pad_att_rot.x, ft_pad_att_rot.y, ft_pad_att_rot.z);
  4947. oapiWriteScenario_string(scn, "ft_pad_att_rot", cbuf);
  4948.  
  4949. sprintf(cbuf, "%0.4f %0.4f %0.4f", ft_pad_att1_pos.x, ft_pad_att1_pos.y, ft_pad_att1_pos.z);
  4950. oapiWriteScenario_string(scn, "ft_pad_att1_pos", cbuf);
  4951.  
  4952. sprintf(cbuf, "%0.4f %0.4f %0.4f", ft_pad_att1_dir.x, ft_pad_att1_dir.y, ft_pad_att1_dir.z);
  4953. oapiWriteScenario_string(scn, "ft_pad_att1_dir", cbuf);
  4954.  
  4955. sprintf(cbuf, "%0.4f %0.4f %0.4f", ft_pad_att1_rot.x, ft_pad_att1_rot.y, ft_pad_att1_rot.z);
  4956. oapiWriteScenario_string(scn, "ft_pad_att1_rot", cbuf);
  4957.  
  4958. sprintf(cbuf, "%0.4f %0.4f %0.4f", ft_pad_att2_pos.x, ft_pad_att2_pos.y, ft_pad_att2_pos.z);
  4959. oapiWriteScenario_string(scn, "ft_pad_att2_pos", cbuf);
  4960.  
  4961. sprintf(cbuf, "%0.4f %0.4f %0.4f", ft_pad_att2_dir.x, ft_pad_att2_dir.y, ft_pad_att2_dir.z);
  4962. oapiWriteScenario_string(scn, "ft_pad_att2_dir", cbuf);
  4963.  
  4964. sprintf(cbuf, "%0.4f %0.4f %0.4f", ft_pad_att2_rot.x, ft_pad_att2_rot.y, ft_pad_att2_rot.z);
  4965. oapiWriteScenario_string(scn, "ft_pad_att2_rot", cbuf);
  4966.  
  4967. sprintf(cbuf, "%0.4f %0.4f %0.4f", ft_pad_att3_pos.x, ft_pad_att3_pos.y, ft_pad_att3_pos.z);
  4968. oapiWriteScenario_string(scn, "ft_pad_att3_pos", cbuf);
  4969.  
  4970. sprintf(cbuf, "%0.4f %0.4f %0.4f", ft_pad_att3_dir.x, ft_pad_att3_dir.y, ft_pad_att3_dir.z);
  4971. oapiWriteScenario_string(scn, "ft_pad_att3_dir", cbuf);
  4972.  
  4973. sprintf(cbuf, "%0.4f %0.4f %0.4f", ft_pad_att3_rot.x, ft_pad_att3_rot.y, ft_pad_att3_rot.z);
  4974. oapiWriteScenario_string(scn, "ft_pad_att3_rot", cbuf);
  4975.  
  4976. sprintf(cbuf, "%0.4f %0.4f %0.4f", KEELCAM.x, KEELCAM.y, KEELCAM.z);
  4977. oapiWriteScenario_string(scn, "KEEL_CAM", cbuf);
  4978.  
  4979. sprintf(cbuf, "%0.4f %0.4f %0.4f", ETCAM.x, ETCAM.y, ETCAM.z);
  4980. oapiWriteScenario_string(scn, "ET_CAM", cbuf);
  4981.  
  4982. sprintf(cbuf, "%0.4f %0.4f %0.4f", DOCKCAM.x, DOCKCAM.y, DOCKCAM.z);
  4983. oapiWriteScenario_string(scn, "DOCK_CAM", cbuf);
  4984.  
  4985. sprintf(cbuf, "%d ", flood1_status);
  4986. oapiWriteScenario_string(scn, "FLOOD1", cbuf);
  4987.  
  4988. sprintf(cbuf, "%d ", flood2_status);
  4989. oapiWriteScenario_string(scn, "FLOOD2", cbuf);
  4990.  
  4991. sprintf(cbuf, "%d ", flood3_status);
  4992. oapiWriteScenario_string(scn, "FLOOD3", cbuf);
  4993.  
  4994. sprintf(cbuf, "%d ", flood4_status);
  4995. oapiWriteScenario_string(scn, "FLOOD4", cbuf);
  4996.  
  4997. sprintf(cbuf, "%d ", flood5_status);
  4998. oapiWriteScenario_string(scn, "FLOOD5", cbuf);
  4999.  
  5000. sprintf(cbuf, "%d ", flood6_status);
  5001. oapiWriteScenario_string(scn, "FLOOD6", cbuf);
  5002. sprintf(cbuf, "%d ", docklight_status);
  5003. oapiWriteScenario_string(scn, "DOCK_LIGHT", cbuf);
  5004.  
  5005. sprintf(cbuf, "%d ", aft_light_status);
  5006. oapiWriteScenario_string(scn, "AFT_LIGHT", cbuf);
  5007. sprintf(cbuf, "%d ", rmslight_status);
  5008. oapiWriteScenario_string(scn, "RMSLIGHT", cbuf);
  5009.  
  5010. if (do_cargostatic) {
  5011. oapiWriteScenario_string(scn, "CARGO_STATIC_MESH", cargo_static_mesh_name);
  5012. if (cargo_static_ofs.x || cargo_static_ofs.y || cargo_static_ofs.z)
  5013. oapiWriteScenario_vec(scn, "CARGO_STATIC_OFS", cargo_static_ofs);
  5014. }
  5015.  
  5016. if ((CREW1 == 1)&& (EVA1==0)){
  5017. sprintf(cbuf, "%s %s", crew1_name, crew1_cfg);
  5018. oapiWriteScenario_string(scn, "CREW1", cbuf);
  5019. }
  5020. if ((CREW2 == 1) && (EVA2 == 0)){
  5021. sprintf(cbuf, "%s %s", crew2_name, crew2_cfg);
  5022. oapiWriteScenario_string(scn, "CREW2", cbuf);
  5023. }
  5024. if ((CREW3 == 1) && (EVA3 == 0)){
  5025. sprintf(cbuf, "%s %s", crew3_name, crew3_cfg);
  5026. oapiWriteScenario_string(scn, "CREW3", cbuf);
  5027. }
  5028. if ((CREW4 == 1) && (EVA4 == 0)){
  5029. sprintf(cbuf, "%s %s", crew4_name, crew4_cfg);
  5030. oapiWriteScenario_string(scn, "CREW4", cbuf);
  5031. }
  5032. if (EVA1 == 0) {
  5033. if ((ODS == 0) || (EXTAIRLOCK == 0))ft_pad_att_pos = _V(0, 0.7, 11.321);
  5034. else ft_pad_att_pos = _V(0, 0.3, 8.5);
  5035. ft_pad_att_dir = _V(0, 1, 0);
  5036. ft_pad_att_rot = _V(0, 0, -1);
  5037. }
  5038. if (EVA2 == 0) {
  5039. if ((ODS == 0) || (EXTAIRLOCK == 0))ft_pad_att1_pos = _V(0, 0.7, 11.321);
  5040. else ft_pad_att1_pos = _V(0, 0.3, 8.5);
  5041. ft_pad_att1_dir = _V(0, 1, 0);
  5042. ft_pad_att1_rot = _V(0, 0, -1);
  5043. }
  5044. if (EVA3 == 0) {
  5045. if ((ODS == 0) || (EXTAIRLOCK == 0))ft_pad_att2_pos = _V(0, 0.7, 11.321);
  5046. else ft_pad_att2_pos = _V(0, 0.3, 8.5);
  5047. ft_pad_att2_dir = _V(0, 1, 0);
  5048. ft_pad_att2_rot = _V(0, 0, -1);
  5049. }
  5050. if (EVA4 == 0) {
  5051. if ((ODS == 0) || (EXTAIRLOCK == 0))ft_pad_att3_pos = _V(0, 0.7, 11.321);
  5052. else ft_pad_att3_pos = _V(0, 0.3, 8.5);
  5053. ft_pad_att3_dir = _V(0, 1, 0);
  5054. ft_pad_att3_rot = _V(0, 0, -1);
  5055. }
  5056. // save bay door operations status
  5057. plop->SaveState (scn);
  5058. //ascap->SaveState (scn);
  5059. }
  5060.  
  5061. // --------------------------------------------------------------
  5062.  
  5063. void Atlantis::clbkPostCreation ()
  5064. {
  5065. oapi::Font* font1 = oapiCreateFont(50, true, "*Seven Segment");
  5066. oapi::Font* font2 = oapiCreateFont(40, true, "*Seven Segment");
  5067. oapi::Font* font3 = oapiCreateFont(-11, true, "Arial");
  5068.  
  5069. EnableSSME(status < 3);
  5070. EnableRCS(status == 3);
  5071. EnableOMS(status == 3);
  5072. SetADCtrlMode(status < 3 ? 0 : 7);
  5073. //ShiftMesh(4, _V(-.2, 0, 0));
  5074. //LoadMeshes();
  5075. UpdateMesh();
  5076. //if ((OV == 102) || (OV == 103) || (OV == 99) || (OV == 104) || (OV == 105) || (OV == 106) || (OV == 107) || (OV == 108))
  5077. {
  5078. pl1_ofs = _V(0, 6.220, -7.795);
  5079. pl2_ofs = _V(0, 6.220, -7.795);
  5080. pl3_ofs = _V(-1.850, 8.020, 3.955);
  5081. pl4_ofs = _V(-2.2, 8.020, -14.045);
  5082. pl5_ofs = _V(2.2, 8.020, -14.045);
  5083. pl6_ofs = _V(1.850, 8.020, 3.955);
  5084. pl7_ofs = _V(0, 6.220, -7.795);
  5085. pl8_ofs = _V(0, 6.220, -7.795);
  5086. pl9_ofs = _V(0, 0, 0);
  5087. pl10_ofs = _V(0, 0, 0);
  5088.  
  5089. pl1_dir = _V(0, 1, 0);
  5090. pl2_dir = _V(0, 1, 0);
  5091. pl3_dir = _V(0, 1, 0);
  5092. pl4_dir = _V(0, 1, 0);
  5093. pl5_dir = _V(0, 1, 0);
  5094. pl6_dir = _V(0, 1, 0);
  5095. pl7_dir = _V(0, 1, 0);
  5096. pl8_dir = _V(0, 1, 0);
  5097. pl9_dir = _V(0, 1, 0);
  5098. pl10_dir = _V(0, 1, 0);
  5099.  
  5100. pl1_rot = _V(0, 0, 1);
  5101. pl2_rot = _V(1, 0, 0);
  5102. pl3_rot = _V(0, 0, 1);
  5103. pl4_rot = _V(0, 0, 1);
  5104. pl5_rot = _V(0, 0, 1);
  5105. pl6_rot = _V(0, 0, 1);
  5106. pl7_rot = _V(0, 0, 1);
  5107. pl8_rot = _V(0, 0, 1);
  5108. pl9_rot = _V(0, 0, 1);
  5109. pl10_rot = _V(0, 0, 1);
  5110. // default crew
  5111.  
  5112. //if now eva set to start places.
  5113.  
  5114.  
  5115.  
  5116. //ft_pad_att_dir = _V(0, 1, 0);// _V(0, 1, 0), _V(0, 0, -1),
  5117. //ft_pad_att1_dir = _V(0, 1, 0);
  5118. //ft_pad_att2_dir = _V(0, 1, 0);
  5119. //ft_pad_att3_dir = _V(0, 1, 0);
  5120.  
  5121. //ft_pad_att_rot = _V(0, 0, -1);
  5122. // ft_pad_att1_rot = _V(0, 0, -1);
  5123. // ft_pad_att2_rot = _V(0, 0, -1);
  5124. // ft_pad_att3_rot = _V(0, 0, -1);
  5125.  
  5126. }
  5127. /*
  5128. if (CREW1 == 1){
  5129. crew1_name[40] = crew1_name_scn[40];
  5130. crew1_cfg[40] = crew1_cfg_scn[40];
  5131. }
  5132. if (CREW2 == 1){
  5133. char*crew2_name = crew2_name_scn;
  5134. char*crew2_cfg = crew2_cfg_scn;
  5135. }if (CREW3 == 1){
  5136. char*crew3_name = crew3_name_scn;
  5137. char*crew3_cfg = crew3_cfg_scn;
  5138. }if (CREW4 == 1){
  5139. char*crew4_name = crew4_name_scn;
  5140. char*crew4_cfg = crew4_cfg_scn;
  5141. }
  5142. */
  5143.  
  5144. if (length(pl1_dir_scn) > 0)
  5145. {
  5146. pl1_ofs = pl1_ofs_scn;
  5147. pl1_dir = pl1_dir_scn;
  5148. pl1_rot = pl1_rot_scn;
  5149. }
  5150. if (length(pl2_dir_scn) > 0)
  5151. {
  5152. pl2_ofs = pl2_ofs_scn;
  5153. pl2_dir = pl2_dir_scn;
  5154. pl2_rot = pl2_rot_scn;
  5155. }
  5156. if (length(pl3_dir_scn) > 0)
  5157. {
  5158. pl3_ofs = pl3_ofs_scn;
  5159. pl3_dir = pl3_dir_scn;
  5160. pl3_rot = pl3_rot_scn;
  5161. }
  5162. if (length(pl4_dir_scn) > 0)
  5163. {
  5164. pl4_ofs = pl4_ofs_scn;
  5165. pl4_dir = pl4_dir_scn;
  5166. pl4_rot = pl4_rot_scn;
  5167. }
  5168. if (length(pl5_dir_scn) > 0)
  5169. {
  5170. pl5_ofs = pl5_ofs_scn;
  5171. pl5_dir = pl5_dir_scn;
  5172. pl5_rot = pl5_rot_scn;
  5173. }
  5174. if (length(pl6_dir_scn) > 0)
  5175. {
  5176. pl6_ofs = pl6_ofs_scn;
  5177. pl6_dir = pl6_dir_scn;
  5178. pl6_rot = pl6_rot_scn;
  5179. }
  5180. if (length(pl7_dir_scn) > 0)
  5181. {
  5182. pl7_ofs = pl7_ofs_scn;
  5183. pl7_dir = pl7_dir_scn;
  5184. pl7_rot = pl7_rot_scn;
  5185. }
  5186. if (length(pl8_dir_scn) > 0)
  5187. {
  5188. pl8_ofs = pl8_ofs_scn;
  5189. pl8_dir = pl8_dir_scn;
  5190. pl8_rot = pl8_rot_scn;
  5191. }
  5192. if (length(pl9_dir_scn) > 0)
  5193. {
  5194. pl9_ofs = pl9_ofs_scn;
  5195. pl9_dir = pl9_dir_scn;
  5196. pl9_rot = pl9_rot_scn;
  5197. }
  5198. if (length(pl10_dir_scn) > 0)
  5199. {
  5200. pl10_ofs = pl10_ofs_scn;
  5201. pl10_dir = pl10_dir_scn;
  5202. pl10_rot = pl10_rot_scn;
  5203. }
  5204. if (length(KEELCAM_scn) > 0)
  5205. {
  5206. KEELCAM = KEELCAM_scn;
  5207.  
  5208. }
  5209. if (length(ETCAM_scn) > 0)
  5210. {
  5211. ETCAM = ETCAM_scn;
  5212.  
  5213. }
  5214. if (length(DOCKCAM_scn) > 0)
  5215. {
  5216. DOCKCAM = DOCKCAM_scn;
  5217.  
  5218. }
  5219. if (length(ft_pad_att_dir_scn) > 0)
  5220. {
  5221. ft_pad_att_pos = ft_pad_att_pos_scn;
  5222. ft_pad_att_dir = ft_pad_att_dir_scn;
  5223. ft_pad_att_rot = ft_pad_att_rot_scn;
  5224. }
  5225.  
  5226. if (length(ft_pad_att1_dir_scn) > 0)
  5227. {
  5228. ft_pad_att1_pos = ft_pad_att1_pos_scn;
  5229. ft_pad_att1_dir = ft_pad_att1_dir_scn;
  5230. ft_pad_att1_rot = ft_pad_att1_rot_scn;
  5231. }
  5232.  
  5233. if (length(ft_pad_att_dir_scn) > 0)
  5234. {
  5235. ft_pad_att2_pos = ft_pad_att2_pos_scn;
  5236. ft_pad_att2_dir = ft_pad_att2_dir_scn;
  5237. ft_pad_att2_rot = ft_pad_att2_rot_scn;
  5238. }
  5239. if (length(ft_pad_att_dir_scn) > 0)
  5240. {
  5241. ft_pad_att3_pos = ft_pad_att3_pos_scn;
  5242. ft_pad_att3_dir = ft_pad_att3_dir_scn;
  5243. ft_pad_att3_rot = ft_pad_att3_rot_scn;
  5244. }
  5245.  
  5246.  
  5247.  
  5248.  
  5249.  
  5250.  
  5251.  
  5252.  
  5253.  
  5254.  
  5255.  
  5256.  
  5257.  
  5258.  
  5259.  
  5260. SetAttachmentParams(sat_attach, pl1_ofs, pl1_dir, pl1_rot);//0
  5261. SetAttachmentParams(sat_attach2, pl2_ofs, pl2_dir, pl2_rot);//1
  5262. SetAttachmentParams(sat_attach3, pl3_ofs, pl3_dir, pl3_rot);//2
  5263. SetAttachmentParams(sat_attach4, pl4_ofs, pl4_dir, pl4_rot);//3
  5264. SetAttachmentParams(sat_attach5, pl5_ofs, pl5_dir, pl5_rot);//4
  5265. SetAttachmentParams(sat_attach6, pl6_ofs, pl6_dir, pl6_rot);//5
  5266. SetAttachmentParams(sat_attach7, pl7_ofs, pl7_dir, pl7_rot);//6
  5267. SetAttachmentParams(sat_attach8, pl8_ofs, pl8_dir, pl8_rot);//7
  5268. SetAttachmentParams(sat_attach9, pl9_ofs, pl9_dir, pl9_rot);//8
  5269. SetAttachmentParams(sat_attach10, pl10_ofs, pl10_dir, pl10_rot);//8
  5270. SetAttachmentParams(ft_pad_att, ft_pad_att_pos, ft_pad_att_dir, ft_pad_att_rot);
  5271. SetAttachmentParams(ft_pad_att1, ft_pad_att1_pos, ft_pad_att1_dir, ft_pad_att1_rot);
  5272. SetAttachmentParams(ft_pad_att2, ft_pad_att2_pos, ft_pad_att2_dir, ft_pad_att2_rot);
  5273. SetAttachmentParams(ft_pad_att3, ft_pad_att3_pos, ft_pad_att3_dir, ft_pad_att3_rot);
  5274.  
  5275.  
  5276. //set attachments for OBSS
  5277. // if (OBSS1 == 1)SetAttachmentParams(sat_attach7, _V(2.850, .850, 1.760), _V(-.5, .866, 0), _V(0, 0, 1));//6_V(2.850, .850, 1.760), _V(-.5, .866, 0), _V(0, 0, 1))
  5278. //if (OBSS1 == 1)SetAttachmentParams(sat_attach2, _V(2.85, 1.9, 3.550), _V(0, 1, 0), _V(0, 0, 1));//6
  5279.  
  5280.  
  5281. SetAnimation(anim_spdb, spdb_proc);
  5282. SetAnimationCameras();
  5283.  
  5284. /* char name[256];
  5285. VESSELSTATUS vs;
  5286. VESSEL *pV;
  5287.  
  5288. VESSEL4::clbkPostCreation();
  5289. if (status < 3) {
  5290. OBJHANDLE hET = GetDockStatus (GetDockHandle (1));
  5291. if (!hET) {
  5292. strcpy (name, GetName());
  5293. strcat (name, "_ET");
  5294. hET = oapiGetVesselByName(name);
  5295. if (!hET || strcmp (oapiGetVesselInterface(hET)->GetClassName(), "Atlantis_Tank")) {
  5296. GetStatus (vs);
  5297. hET = oapiCreateVessel (name, "Atlantis_Tank", vs);
  5298. }
  5299. Dock (hET, 1, 0, 1);
  5300. }
  5301. pET = (Atlantis_Tank*)oapiGetVesselInterface(hET);
  5302. if (status < 2) {
  5303. pV = oapiGetVesselInterface (hET);
  5304. for (UINT i = 0; i < 2; i++) {
  5305. OBJHANDLE hSRB = pV->GetDockStatus (pV->GetDockHandle (i+1));
  5306. if (!hSRB) {
  5307. sprintf (name, "%s-SRB%d", GetName(), i+1);
  5308. hSRB = oapiGetVesselByName(name);
  5309. if (!hSRB || strcmp (oapiGetVesselInterface(hSRB)->GetClassName(), "Atlantis_SRB")) {
  5310. GetStatus (vs);
  5311. hSRB = oapiCreateVessel (name, "Atlantis_SRB", vs);
  5312. }
  5313. pV->Dock (hSRB, i+1, 0, 1);
  5314. }
  5315. }
  5316. if (status < 1) {
  5317. if (launchelev) {
  5318. pET->SetSRBLaunchElevation (launchelev);
  5319.  
  5320. }
  5321. }
  5322. }
  5323. } else {
  5324. if (hDockET) {
  5325. DelDock (hDockET); // remove the ET docking port
  5326. hDockET = NULL;
  5327. }
  5328. }
  5329. EnableSSME (status < 3);
  5330. EnableRCS (status == 3);
  5331. EnableOMS (status == 3);
  5332. SetADCtrlMode (status < 3 ? 0 : 7);
  5333.  
  5334.  
  5335. UpdateMesh ();
  5336.  
  5337.  
  5338. */
  5339. }
  5340.  
  5341. // --------------------------------------------------------------
  5342. // Vessel gains or loses input focus
  5343. // --------------------------------------------------------------
  5344. void Atlantis::clbkFocusChanged (bool getfocus, OBJHANDLE newv, OBJHANDLE oldv)
  5345. {
  5346. if (getfocus) {
  5347. oapiDisableMFDMode (MFD_LANDING);
  5348. // no VTOL MFD mode for Atlantis
  5349. }
  5350. }
  5351.  
  5352. // --------------------------------------------------------------
  5353. // Simulation time step
  5354. // --------------------------------------------------------------
  5355. void Atlantis::clbkPreStep(double simt, double simdt, double mjd)
  5356. {
  5357. //load redraw
  5358. oapiVCTriggerRedrawArea(-1, AID_METTIME);
  5359. //oapiVCTriggerRedrawArea(-1, AID_EVENTTIME);
  5360. oapiVCTriggerRedrawArea(-1, AID_RCSQTY);
  5361.  
  5362.  
  5363. if (RMSDIALOG == 3) {//rms dialogue was open so now open window
  5364. oapiOpenDialogEx(g_Param.hDLL, IDD_RMS, RMS_DlgProc, DLG_CAPTIONCLOSE, this);
  5365. //RMSDIALOG = 0;
  5366. }
  5367.  
  5368. // sprintf(oapiDebugString(), "%0.4f %0.4f %0.4f %0.4f %0.4f %0.4f", arm_sy, arm_sp, arm_ep, arm_wp, arm_wy, arm_wr);
  5369.  
  5370. //dragchute
  5371.  
  5372.  
  5373. spot_beacon[8].pos = &arm_tip[4];
  5374. spotlightRMS->SetPosition(arm_tip[4]);
  5375. spotlightRMS->SetDirection(arm_tip[1] - arm_tip[0]);
  5376. // sprintf(oapiDebugString(), "armtip4x %2.2f armtip4y %2.2f armtip4z %2.2f", arm_tip[4].x, arm_tip[4].y, arm_tip[4].z);
  5377. if (rmslight_status == 0){
  5378. spotlightRMS->Activate(false);
  5379. spot_beacon[8].active = false;
  5380. }
  5381. if (rmslight_status == 1){
  5382. spotlightRMS->Activate(true);
  5383. spot_beacon[8].active = true;
  5384. }
  5385. // ascap->Update (simt);
  5386. // if (ascentApDlg) ascentApDlg->Update (simt);
  5387.  
  5388. //double met = (status == 0 ? 0.0 : simt-t0);
  5389. //double met = ascap->GetMET (simt)
  5390.  
  5391. ATMPRESSURE = GetAtmPressure();
  5392. if (ATMPRESSURE >.1)//in atmosphere so use control surfaces
  5393. {
  5394. //EnableRCS(true);
  5395. SetADCtrlMode(7);//set control surface enable
  5396. (SetAttitudeMode(0));//no rcs
  5397. }
  5398. else {
  5399. //in space
  5400. SetADCtrlMode(0);//disable control surfaces
  5401. //(SetAttitudeMode(1));
  5402. //(SetAttitudeMode(2));
  5403. EnableRCS(status == 3);
  5404. }
  5405. double leftelevon = (GetControlSurfaceLevel(AIRCTRL_AILERON));
  5406. double flapdegree = (GetControlSurfaceLevel(AIRCTRL_ELEVATORTRIM) );
  5407.  
  5408. if (flapdegree < 0)SetAnimation(anim_BODYFLAPINDICATOR, ((flapdegree) / 2) + .35);
  5409. if (flapdegree > 0)SetAnimation(anim_BODYFLAPINDICATOR, ((flapdegree) / 1.5) + .35);// 0 to 1 add .5 so as to start at the middle
  5410. if (flapdegree == 0)SetAnimation(anim_BODYFLAPINDICATOR, .35);
  5411.  
  5412.  
  5413. //if (flapdegree < 0)SetAnimation(anim_BODYFLAPINDICATOR, ((flapdegree) * 0, 354 - 0.177);
  5414.  
  5415. //TRIM * 0, 354 - 0. 177
  5416.  
  5417. //SetAnimation(anim_AUTOBDYFLAP, 1);
  5418.  
  5419.  
  5420. // if (flapdegree<=0)SetAnimation(anim_BODYFLAPINDICATOR, 0);
  5421. // else SetAnimation(anim_BODYFLAPINDICATOR, flapdegree);
  5422.  
  5423.  
  5424. //SetAnimation(anim_BODYFLAPINDICATOR, flapdegree);
  5425.  
  5426. double rudderdegree = (GetControlSurfaceLevel(AIRCTRL_RUDDER));
  5427.  
  5428. if (rudderdegree < 0)SetAnimation(anim_rudderINDICATOR, ((rudderdegree)/2)+.5);
  5429. if (rudderdegree > 0)SetAnimation(anim_rudderINDICATOR, ((rudderdegree) / 2) + .5);// 0 to 1 add .5 so as to start at the middle
  5430. if (rudderdegree == 0)SetAnimation(anim_rudderINDICATOR, .5);
  5431. //SetAnimation(anim_rudderINDICATOR, rudderdegree);
  5432. SetAnimation(anim_speedbrakeINDICATOR, spdb_proc);
  5433.  
  5434.  
  5435. // if (leftelevon < 0)SetAnimation(anim_leftelevonINDICATOR, ((leftelevon) / 2) + .5);
  5436. // if (leftelevon > 0)SetAnimation(anim_leftelevonINDICATOR, ((leftelevon) / 2) + .5);// 0 to 1 add .5 so as to start at the middle
  5437. // if (leftelevon == 0)SetAnimation(anim_leftelevonINDICATOR, .5);
  5438.  
  5439.  
  5440.  
  5441.  
  5442. //spdb_proc
  5443. //sprintf(oapiDebugString(), "flapdegree %lf,rudderdegree %lf,leftelevon %lf;", flapdegree, rudderdegree, leftelevon);
  5444.  
  5445. if (oapiCameraMode() != CAM_COCKPIT){ //not in cockpit so delete note
  5446.  
  5447. oapiDelAnnotation(hNote);
  5448. }
  5449.  
  5450. if (oapiCameraMode() == CAM_COCKPIT){
  5451. if (CAM == 6){
  5452.  
  5453.  
  5454. oapiDelAnnotation(hNote);
  5455. char imstr[256];
  5456. strcpy(imstr, "RMS ELBOW");
  5457. VECTOR3 col = _V(0.8, 0.7, 0.1);
  5458. hNote = oapiCreateAnnotation(true, 1, col);
  5459. oapiAnnotationSetPos(hNote, 0.468, 0.05, 0.66, 0.1);
  5460. oapiAnnotationSetText(hNote, imstr);
  5461.  
  5462.  
  5463.  
  5464.  
  5465. }
  5466. if (CAM == 7){
  5467.  
  5468.  
  5469. oapiDelAnnotation(hNote);
  5470. char imstr[256];
  5471. strcpy(imstr, "RMS WRIST");
  5472. VECTOR3 col = _V(0.8, 0.7, 0.1);
  5473. hNote = oapiCreateAnnotation(true, 1, col);
  5474. oapiAnnotationSetPos(hNote, 0.468, 0.05, 0.66, 0.1);
  5475. oapiAnnotationSetText(hNote, imstr);
  5476.  
  5477.  
  5478.  
  5479. }
  5480. if (CAM == 1){
  5481.  
  5482.  
  5483. oapiDelAnnotation(hNote);
  5484. char imstr[256];
  5485. strcpy(imstr, "Payload Camera (A)");
  5486. VECTOR3 col = _V(0.8, 0.7, 0.1);
  5487. hNote = oapiCreateAnnotation(true, 1, col);
  5488. oapiAnnotationSetPos(hNote, 0.468, 0.05, 0.66, 0.1);
  5489. oapiAnnotationSetText(hNote, imstr);
  5490.  
  5491.  
  5492.  
  5493.  
  5494. }
  5495. if (CAM == 2){
  5496.  
  5497.  
  5498.  
  5499. oapiDelAnnotation(hNote);
  5500. char imstr[256];
  5501. strcpy(imstr, "Payload Camera (B)");
  5502. VECTOR3 col = _V(0.8, 0.7, 0.1);
  5503. hNote = oapiCreateAnnotation(true, 1, col);
  5504. oapiAnnotationSetPos(hNote, 0.468, 0.05, 0.66, 0.1);
  5505. oapiAnnotationSetText(hNote, imstr);
  5506.  
  5507.  
  5508.  
  5509.  
  5510. }
  5511. if (CAM == 3){
  5512.  
  5513.  
  5514. oapiDelAnnotation(hNote);
  5515. char imstr[256];
  5516. strcpy(imstr, "Payload Camera (C)");
  5517. VECTOR3 col = _V(0.8, 0.7, 0.1);
  5518. hNote = oapiCreateAnnotation(true, 1, col);
  5519. oapiAnnotationSetPos(hNote, 0.468, 0.05, 0.66, 0.1);
  5520. oapiAnnotationSetText(hNote, imstr);
  5521.  
  5522.  
  5523.  
  5524.  
  5525. }
  5526. if (CAM == 4){
  5527.  
  5528.  
  5529.  
  5530. oapiDelAnnotation(hNote);
  5531. char imstr[256];
  5532. strcpy(imstr, "Payload Camera (D)");
  5533. VECTOR3 col = _V(0.8, 0.7, 0.1);
  5534. hNote = oapiCreateAnnotation(true, 1, col);
  5535. oapiAnnotationSetPos(hNote, 0.468, 0.05, 0.66, 0.1);
  5536. oapiAnnotationSetText(hNote, imstr);
  5537.  
  5538.  
  5539.  
  5540.  
  5541. }
  5542. if (CAM == 5){
  5543.  
  5544.  
  5545.  
  5546. oapiDelAnnotation(hNote);
  5547. char imstr[256];
  5548. strcpy(imstr, "Keel");
  5549. VECTOR3 col = _V(0.8, 0.7, 0.1);
  5550. hNote = oapiCreateAnnotation(true, 1, col);
  5551. oapiAnnotationSetPos(hNote, 0.468, 0.05, 0.66, 0.1);
  5552. oapiAnnotationSetText(hNote, imstr);
  5553.  
  5554.  
  5555. }
  5556. if (CAM == 9) {
  5557.  
  5558.  
  5559.  
  5560. oapiDelAnnotation(hNote);
  5561. char imstr[256];
  5562. strcpy(imstr, "ET");
  5563. VECTOR3 col = _V(0.8, 0.7, 0.1);
  5564. hNote = oapiCreateAnnotation(true, 1, col);
  5565. oapiAnnotationSetPos(hNote, 0.468, 0.05, 0.66, 0.1);
  5566. oapiAnnotationSetText(hNote, imstr);
  5567.  
  5568.  
  5569. }
  5570. if ((CAM == 0)&&(vccameracase==4)){
  5571. oapiDelAnnotation(hNote);
  5572. char imstr[256];
  5573. strcpy(imstr, "Cockpit");
  5574. VECTOR3 col = _V(0.8, 0.7, 0.1);
  5575. hNote = oapiCreateAnnotation(true, 1, col);
  5576. oapiAnnotationSetPos(hNote, 0.468, 0.05, 0.66, 0.1);
  5577. oapiAnnotationSetText(hNote, imstr);
  5578. }
  5579. if ((CAM == 0) && (vccameracase == 0)){
  5580. oapiDelAnnotation(hNote);
  5581. char imstr[256];
  5582. strcpy(imstr, "Commander");
  5583. VECTOR3 col = _V(0.8, 0.7, 0.1);
  5584. hNote = oapiCreateAnnotation(true, 1, col);
  5585. oapiAnnotationSetPos(hNote, 0.468, 0.05, 0.66, 0.1);
  5586. oapiAnnotationSetText(hNote, imstr);
  5587. }
  5588. if ((CAM == 0) && (vccameracase == 1)){
  5589. oapiDelAnnotation(hNote);
  5590. char imstr[256];
  5591. strcpy(imstr, "Pilot");
  5592. VECTOR3 col = _V(0.8, 0.7, 0.1);
  5593. hNote = oapiCreateAnnotation(true, 1, col);
  5594. oapiAnnotationSetPos(hNote, 0.468, 0.05, 0.66, 0.1);
  5595. oapiAnnotationSetText(hNote, imstr);
  5596. }
  5597. if ((CAM == 0) && (vccameracase == 2)){
  5598. oapiDelAnnotation(hNote);
  5599. char imstr[256];
  5600. strcpy(imstr, "Aft");
  5601. VECTOR3 col = _V(0.8, 0.7, 0.1);
  5602. hNote = oapiCreateAnnotation(true, 1, col);
  5603. oapiAnnotationSetPos(hNote, 0.468, 0.05, 0.66, 0.1);
  5604. oapiAnnotationSetText(hNote, imstr);
  5605. }
  5606. if (CAM == 8){
  5607.  
  5608.  
  5609. oapiDelAnnotation(hNote);
  5610. char imstr[256];
  5611. strcpy(imstr, "DOCK");
  5612. VECTOR3 col = _V(0.8, 0.7, 0.1);
  5613. hNote = oapiCreateAnnotation(true, 1, col);
  5614. oapiAnnotationSetPos(hNote, 0.468, 0.05, 0.66, 0.1);
  5615. oapiAnnotationSetText(hNote, imstr);
  5616.  
  5617.  
  5618.  
  5619.  
  5620. }
  5621. }
  5622. if (oapiGetFocusObject() != GetHandle()) // focus vessel is not my vessel
  5623. {
  5624. oapiDelAnnotation(hNote);
  5625.  
  5626. }
  5627. engine_light_level = GetThrusterGroupLevel(THGROUP_MAIN);
  5628.  
  5629.  
  5630.  
  5631.  
  5632. VECTOR3 tgt_rate = _V(0, 0, 0); // target rotation rates - used for setting engine gimbals
  5633.  
  5634. {
  5635. // ascent autopilot
  5636. // ascap->GetTargetRate (met, tgt_rate);
  5637.  
  5638. // manual override
  5639. double man_pitch = GetManualControlLevel(THGROUP_ATT_PITCHUP, MANCTRL_ROTMODE, MANCTRL_ANYDEVICE);
  5640. if (!man_pitch) man_pitch = -GetManualControlLevel(THGROUP_ATT_PITCHDOWN, MANCTRL_ROTMODE, MANCTRL_ANYDEVICE);
  5641. if (man_pitch) tgt_rate.x = man_pitch*0.07;
  5642.  
  5643. double man_yaw = GetManualControlLevel(THGROUP_ATT_YAWLEFT, MANCTRL_ROTMODE, MANCTRL_ANYDEVICE);
  5644. if (!man_yaw) man_yaw = -GetManualControlLevel(THGROUP_ATT_YAWRIGHT, MANCTRL_ROTMODE, MANCTRL_ANYDEVICE);
  5645. if (man_yaw) tgt_rate.y = man_yaw*0.07;
  5646.  
  5647. double man_roll = -GetManualControlLevel(THGROUP_ATT_BANKLEFT, MANCTRL_ROTMODE, MANCTRL_ANYDEVICE);
  5648. if (!man_roll) man_roll = GetManualControlLevel(THGROUP_ATT_BANKRIGHT, MANCTRL_ROTMODE, MANCTRL_ANYDEVICE);
  5649. if (man_roll) tgt_rate.z = man_roll*0.07;
  5650. }
  5651.  
  5652. switch (status) {
  5653. case 0: // launch configuration
  5654. //if (!ascap->Active() && pET && GetEngineLevel (ENGINE_MAIN) > 0.95) {
  5655. // pET->IgniteSRBs ();
  5656. // t0 = ascap->StartMissionTime (simt);
  5657. //t0 = simt /*+ SRB_STABILISATION_TIME*/; // store designated liftoff time
  5658. // status = 1;
  5659. //} else if (GetEngineLevel (ENGINE_MAIN) > 0) {
  5660. //AutoGimbal (tgt_rate);
  5661. //}
  5662. break;
  5663. case 1: // SRBs ignited
  5664. // if (met > SRB_SEPARATION_TIME && !Playback() || bManualSeparate) {
  5665. // SeparateBoosters (met);
  5666. // bManualSeparate = false;
  5667. //} else {
  5668. // AutoGimbal (tgt_rate);
  5669. //}
  5670. //break;
  5671. case 2: // Orbiter+ET configuration
  5672. // AutoGimbal (tgt_rate);
  5673. // if (pET && (/*pET->GetMainPropellantMass () < 10.0 ||*/ bManualSeparate)) {
  5674. // SeparateTank ();
  5675. // bManualSeparate = false;
  5676. // }
  5677. break;
  5678.  
  5679. case 3: // Orbiter
  5680. //if (ascap->Active())
  5681. AutoRCS(tgt_rate);
  5682.  
  5683. //if (bManualSeparate && GetAttachmentStatus(sat_attach)) {
  5684. // DetachChild(sat_attach, 0.1);
  5685. // bManualSeparate = false;
  5686. //}
  5687.  
  5688.  
  5689. break;
  5690. }
  5691.  
  5692. // Execute payload bay operations
  5693. plop->Step(simt, simdt);
  5694.  
  5695. // ***** Animate landing gear *****
  5696. if (geararmed == 1) {//ONLY OPERATE IF GEAR IS ARMED
  5697. if (gear_status >= AnimState::CLOSING) {
  5698. double da = simdt * GEAR_OPERATING_SPEED;
  5699. // if (gear_status == AnimState::CLOSING) { // retract gear
  5700. // if (gear_proc > 0.0) gear_proc = max(0.0, gear_proc - da);
  5701. // else gear_status = AnimState::CLOSED;
  5702. //}
  5703. // else { // deploy gear
  5704. if (gear_proc < 1.0) gear_proc = min(1.0, gear_proc + da);
  5705. else gear_status = AnimState::OPEN;
  5706. }
  5707. SetAnimation(anim_gear, gear_proc);
  5708. SetGearParameters(gear_proc);
  5709. if (gear_status == AnimState::OPEN) {
  5710. SetAnimation(anim_LEFTGEARDN, 1);
  5711. SetAnimation(anim_LEFTGEARUP, 1);
  5712. SetAnimation(anim_LEFTGEARTALKBACK, 1);
  5713. SetAnimation(anim_RIGHTGEARDN, 1);
  5714. SetAnimation(anim_RIGHTGEARUP, 1);
  5715. SetAnimation(anim_RIGHTGEARTALKBACK, 1);
  5716. }
  5717. }
  5718. //}
  5719.  
  5720. // ***** Animate speedbrake *****
  5721.  
  5722. if (spdb_auto == 1){
  5723. spdb_proc = .65;
  5724. AIRSPEEDKNOT = (GetAirspeed() *0.514444);
  5725. if (AIRSPEEDKNOT > 300)
  5726. spdb_proc = spdb_proc + .05;
  5727. if (AIRSPEEDKNOT < 300)spdb_auto = 0;
  5728.  
  5729. }
  5730.  
  5731. if (spdb_auto == 0){
  5732. //if (spdb_on == 1) spdb_proc = 1;
  5733. //if (spdb_off == 1) spdb_proc = 0;
  5734.  
  5735.  
  5736. if (spdb_plus == 1){
  5737. spdb_proc = spdb_proc + .05;
  5738. spdb_plus = 0;
  5739. }
  5740. if (spdb_minus == 1)
  5741. {
  5742. spdb_proc = spdb_proc - .05;
  5743. spdb_minus = 0;
  5744. }
  5745.  
  5746. if (spdb_proc > 1)spdb_proc = 1;
  5747. if (spdb_proc < 0)spdb_proc = 0;
  5748. }
  5749.  
  5750.  
  5751.  
  5752.  
  5753.  
  5754.  
  5755.  
  5756.  
  5757.  
  5758.  
  5759.  
  5760. if (spdb_status >= AnimState::CLOSING) {
  5761. double da = simdt * SPEEDBRAKE_OPERATING_SPEED;
  5762. if (spdb_status == AnimState::CLOSING) { // retract brake
  5763. if (spdb_proc > 0.0) spdb_proc = max(0.0, spdb_proc - da);
  5764. else spdb_status = AnimState::CLOSED;
  5765. }
  5766. else { // deploy antenna
  5767. if (spdb_proc < 1.0) spdb_proc = min(1.0, spdb_proc + da);
  5768. else spdb_status = AnimState::OPEN;
  5769. }
  5770. }
  5771. SetAnimation(anim_spdb, spdb_proc);
  5772.  
  5773.  
  5774. //}
  5775. //lights
  5776.  
  5777. // turn PLBD lights on/off
  5778. //if (pMission->HasBulkheadFloodlights()) {
  5779. // bool state = FwdBulkheadLightPower;
  5780. // FwdBulkheadLight->Activate(true);
  5781. // FwdBulkhead_bspec.active = true;
  5782.  
  5783. // check docking light (which has DIM and BRIGHT positions)
  5784. // if (DockingLightDim) {
  5785. // DockingLight[0]->Activate(true);
  5786. // Docking_bspec[0].active = true;
  5787. // DockingLight[1]->Activate(false);
  5788. // Docking_bspec[1].active = false;
  5789. // }
  5790. // else if (DockingLightBright)
  5791. {
  5792. // DockingLight[0]->Activate(true);
  5793. // Docking_bspec[0].active = true;
  5794. // DockingLight[1]->Activate(true);
  5795. // Docking_bspec[1].active = true;
  5796. }
  5797. //else { // off
  5798. // for (int i = 0; i < 2; i++) {
  5799. // DockingLight[i]->Activate(false);
  5800. // Docking_bspec[i].active = false;
  5801. // }
  5802. //}
  5803. //}
  5804. //else { // turn off FWD bulkhead & docking lights
  5805. // FwdBulkheadLight->Activate(false);
  5806. // FwdBulkhead_bspec.active = false;
  5807. // for (int i = 0; i < 2; i++) {
  5808. // DockingLight[i]->Activate(false);
  5809. // Docking_bspec[i].active = false;
  5810. // }
  5811. //}
  5812. //for (int i = 0; i < 6; i++) {
  5813. //bool state = PLBLightPower[i].IsSet();
  5814. //PLBLight[i]->Activate(true);
  5815. //PLB_bspec[i].active = true;
  5816. //}
  5817. // ***** Stow RMS arm *****
  5818. //
  5819. if (center_arm) SeqSSRMS();
  5820. CheckFlags();
  5821. //sprintf(oapiDebugString(), "arm_wr_stored %2.2f arm_wr_stored %2.2f", arm6_Bp, arm1_By);
  5822. //SetAnimation(anim_MPM, 1.0);
  5823. //sprintf(oapiDebugString(), "arm_wr_stored %d arm_wr %d ", recallstored, rmsexecute);
  5824.  
  5825.  
  5826. /*
  5827. if ((rmsexecute == 1) && (recallstored == 1) && (Armtilt_proc == 1)){
  5828.  
  5829. //sprintf(oapiDebugString(), "arm_wr_stored %2.2f arm_wr %2.2f ", arm_wr_stored1, arm_wr);
  5830. double t0 = oapiGetSimTime();
  5831. double dt = t0 - center_arm_t; // time step
  5832. double da = ARM_OPERATING_SPEED*dt; // total rotation angle
  5833. if (da && (arm_wr != arm6_Ar)) { // wrist roll not the stored value
  5834. if (da >= fabs(arm_wr - arm6_Ar)) //
  5835. arm_wr = arm6_Ar, da -= fabs(arm_wr - arm6_Ar);
  5836. else
  5837. arm_wr -= (arm_wr > arm6_Ar ? da : -da), da = 0;
  5838. // sprintf(oapiDebugString(), "arm_wr_stored %2.2f arm_wr %2.2f arm_speed %2.2f ", arm_wr_stored1, arm_wr,ARM_OPERATING_SPEED);
  5839.  
  5840.  
  5841. SetAnimationArm(anim_arm_wr, arm_wr);
  5842. }
  5843.  
  5844. if (da && (arm_wy != arm6_Ay)) { // zero wrist yaw
  5845. if (da >= fabs(arm_wy - arm6_Ay)) // finished
  5846. arm_wy = arm6_Ay, da -= fabs(arm_wy - arm6_Ay);
  5847. else
  5848. arm_wy -= (arm_wy > arm6_Ay ? da : -da), da = 0;
  5849. SetAnimationArm(anim_arm_wy, arm_wy);
  5850. }
  5851.  
  5852.  
  5853. if (da && (arm_wp != arm6_Ap)) { // wrist pitch not stored value
  5854. if (da >= fabs(arm_wp - arm6_Ap)) // finished
  5855. arm_wp = arm6_Ap, da -= fabs(arm_wp - arm6_Ap);
  5856. else
  5857. arm_wp -= (arm_wp > arm6_Ap ? da : -da), da = 0;
  5858. SetAnimationArm(anim_arm_wp, arm_wp);
  5859. }
  5860.  
  5861. if (da && (arm_ep != arm6_ep)) { // zero wrist pitch
  5862. if (da >= fabs(arm_ep - arm6_ep)) // finished
  5863. arm_ep = arm6_ep, da -= fabs(arm_ep - arm6_ep);
  5864. else
  5865. arm_ep -= (arm_ep > arm6_ep ? da : -da), da = 0;
  5866. SetAnimationArm(anim_arm_ep, arm_ep);
  5867. }
  5868. if (da && (arm_ep != arm6_ep)) { // zero wrist pitch
  5869. if (da >= fabs(arm_ep - arm6_ep)) // finished
  5870. arm_ep = arm6_ep, da -= fabs(arm_ep - arm6_ep);
  5871. else
  5872. arm_ep -= (arm_ep > arm6_ep ? da : -da), da = 0;
  5873. SetAnimationArm(anim_arm_ep, arm_ep);
  5874. }
  5875.  
  5876. if (da && (arm_sp != arm6_Bp)) { // zero wrist pitch
  5877. if (da >= fabs(arm_sp - arm6_Bp)) // finished
  5878. arm_sp = arm6_Bp, da -= fabs(arm_sp - arm6_Bp);
  5879. else
  5880. arm_sp -= (arm_sp > arm6_Bp ? da : -da), da = 0;
  5881. SetAnimationArm(anim_arm_sp, arm_sp);
  5882. }
  5883.  
  5884. if (da && (arm_sy != arm6_By)) { // zero wrist yitch
  5885. if (da >= fabs(arm_sy - arm6_By)) // finished
  5886. arm_sy = arm6_By, da -= fabs(arm_sy - arm6_By);
  5887. else
  5888. arm_sy -= (arm_sy > arm6_By ? da : -da), da = 0;
  5889. SetAnimationArm(anim_arm_sy, arm_sy);
  5890. }
  5891.  
  5892.  
  5893.  
  5894.  
  5895. center_arm_t = t0;
  5896. if (da) {
  5897. rmsexecute = 0;; // finished stowing
  5898. HWND hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS);
  5899. if (hDlg) EnableWindow(GetDlgItem(hDlg, IDC_GRAPPLE), FALSE);
  5900.  
  5901. }
  5902.  
  5903.  
  5904.  
  5905. }
  5906.  
  5907. //store=2
  5908. if ((rmsexecute == 1) && (recallstored == 2) && (Armtilt_proc == 1)) {
  5909. //sprintf(oapiDebugString(), "arm_wr_stored %2.2f arm_wr %2.2f ", arm_wr_stored1, arm_wr);
  5910. double t0 = oapiGetSimTime();
  5911. double dt = t0 - center_arm_t; // time step
  5912. double da = ARM_OPERATING_SPEED*dt; // total rotation angle
  5913. if (da && (arm_wr != arm6_Ar)) { // wrist roll not the stored value
  5914. if (da >= fabs(arm_wr - arm6_Ar)) //
  5915. arm_wr = arm6_Ar, da -= fabs(arm_wr - arm6_Ar);
  5916. else
  5917. arm_wr -= (arm_wr > arm6_Ar ? da : -da), da = 0;
  5918. // sprintf(oapiDebugString(), "arm_wr_stored %2.2f arm_wr %2.2f arm_speed %2.2f ", arm_wr_stored1, arm_wr,ARM_OPERATING_SPEED);
  5919.  
  5920.  
  5921. SetAnimationArm(anim_arm_wr, arm_wr);
  5922. }
  5923.  
  5924. if (da && (arm_wy != arm6_Ay)) { // zero wrist yaw
  5925. if (da >= fabs(arm_wy - arm6_Ay)) // finished
  5926. arm_wy = arm6_Ay, da -= fabs(arm_wy - arm6_Ay);
  5927. else
  5928. arm_wy -= (arm_wy > arm6_Ay ? da : -da), da = 0;
  5929. SetAnimationArm(anim_arm_wy, arm_wy);
  5930. }
  5931.  
  5932.  
  5933. if (da && (arm_wp != arm6_Ap)) { // wrist pitch not stored value
  5934. if (da >= fabs(arm_wp - arm6_Ap)) // finished
  5935. arm_wp = arm6_Ap, da -= fabs(arm_wp - arm6_Ap);
  5936. else
  5937. arm_wp -= (arm_wp > arm6_Ap ? da : -da), da = 0;
  5938. SetAnimationArm(anim_arm_wp, arm_wp);
  5939. }
  5940.  
  5941. if (da && (arm_ep != arm6_ep)) { // zero wrist pitch
  5942. if (da >= fabs(arm_ep - arm6_ep)) // finished
  5943. arm_ep = arm6_ep, da -= fabs(arm_ep - arm6_ep);
  5944. else
  5945. arm_ep -= (arm_ep > arm6_ep ? da : -da), da = 0;
  5946. SetAnimationArm(anim_arm_ep, arm_ep);
  5947. }
  5948. if (da && (arm_ep != arm6_ep)) { // zero wrist pitch
  5949. if (da >= fabs(arm_ep - arm6_ep)) // finished
  5950. arm_ep = arm6_ep, da -= fabs(arm_ep - arm6_ep);
  5951. else
  5952. arm_ep -= (arm_ep > arm6_ep ? da : -da), da = 0;
  5953. SetAnimationArm(anim_arm_ep, arm_ep);
  5954. }
  5955.  
  5956. if (da && (arm_sp != arm6_Bp)) { // zero wrist pitch
  5957. if (da >= fabs(arm_sp - arm6_Bp)) // finished
  5958. arm_sp = arm6_Bp, da -= fabs(arm_sp - arm6_Bp);
  5959. else
  5960. arm_sp -= (arm_sp > arm6_Bp ? da : -da), da = 0;
  5961. SetAnimationArm(anim_arm_sp, arm_sp);
  5962. }
  5963.  
  5964. if (da && (arm_sy != arm6_By)) { // zero wrist yitch
  5965. if (da >= fabs(arm_sy - arm6_By)) // finished
  5966. arm_sy = arm6_By, da -= fabs(arm_sy - arm6_By);
  5967. else
  5968. arm_sy -= (arm_sy > arm6_By ? da : -da), da = 0;
  5969. SetAnimationArm(anim_arm_sy, arm_sy);
  5970. }
  5971.  
  5972.  
  5973.  
  5974. center_arm_t = t0;
  5975. if (da) {
  5976. rmsexecute = 0;; // finished stowing
  5977. HWND hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS);
  5978. if (hDlg) EnableWindow(GetDlgItem(hDlg, IDC_GRAPPLE), FALSE);
  5979.  
  5980. }
  5981.  
  5982.  
  5983.  
  5984. }
  5985. //store 3
  5986.  
  5987. if ((rmsexecute == 1) && (recallstored == 3) && (Armtilt_proc == 1)) {
  5988. //sprintf(oapiDebugString(), "arm_wr_stored %2.2f arm_wr %2.2f ", arm_wr_stored1, arm_wr);
  5989. double t0 = oapiGetSimTime();
  5990. double dt = t0 - center_arm_t; // time step
  5991. double da = ARM_OPERATING_SPEED*dt; // total rotation angle
  5992. if (da && (arm_wr != arm6_Ar)) { // wrist roll not the stored value
  5993. if (da >= fabs(arm_wr - arm6_Ar)) //
  5994. arm_wr = arm6_Ar, da -= fabs(arm_wr - arm6_Ar);
  5995. else
  5996. arm_wr -= (arm_wr > arm6_Ar ? da : -da), da = 0;
  5997. // sprintf(oapiDebugString(), "arm_wr_stored %2.2f arm_wr %2.2f arm_speed %2.2f ", arm_wr_stored1, arm_wr,ARM_OPERATING_SPEED);
  5998.  
  5999.  
  6000. SetAnimationArm(anim_arm_wr, arm_wr);
  6001. }
  6002.  
  6003. if (da && (arm_wy != arm6_Ay)) { // zero wrist yaw
  6004. if (da >= fabs(arm_wy - arm6_Ay)) // finished
  6005. arm_wy = arm6_Ay, da -= fabs(arm_wy - arm6_Ay);
  6006. else
  6007. arm_wy -= (arm_wy > arm6_Ay ? da : -da), da = 0;
  6008. SetAnimationArm(anim_arm_wy, arm_wy);
  6009. }
  6010.  
  6011.  
  6012. if (da && (arm_wp != arm6_Ap)) { // wrist pitch not stored value
  6013. if (da >= fabs(arm_wp - arm6_Ap)) // finished
  6014. arm_wp = arm6_Ap, da -= fabs(arm_wp - arm6_Ap);
  6015. else
  6016. arm_wp -= (arm_wp > arm6_Ap ? da : -da), da = 0;
  6017. SetAnimationArm(anim_arm_wp, arm_wp);
  6018. }
  6019.  
  6020. if (da && (arm_ep != arm6_ep)) { // zero wrist pitch
  6021. if (da >= fabs(arm_ep - arm6_ep)) // finished
  6022. arm_ep = arm6_ep, da -= fabs(arm_ep - arm6_ep);
  6023. else
  6024. arm_ep -= (arm_ep > arm6_ep ? da : -da), da = 0;
  6025. SetAnimationArm(anim_arm_ep, arm_ep);
  6026. }
  6027. if (da && (arm_ep != arm6_ep)) { // zero wrist pitch
  6028. if (da >= fabs(arm_ep - arm6_ep)) // finished
  6029. arm_ep = arm6_ep, da -= fabs(arm_ep - arm6_ep);
  6030. else
  6031. arm_ep -= (arm_ep > arm6_ep ? da : -da), da = 0;
  6032. SetAnimationArm(anim_arm_ep, arm_ep);
  6033. }
  6034.  
  6035. if (da && (arm_sp != arm6_Bp)) { // zero wrist pitch
  6036. if (da >= fabs(arm_sp - arm6_Bp)) // finished
  6037. arm_sp = arm6_Bp, da -= fabs(arm_sp - arm6_Bp);
  6038. else
  6039. arm_sp -= (arm_sp > arm6_Bp ? da : -da), da = 0;
  6040. SetAnimationArm(anim_arm_sp, arm_sp);
  6041. }
  6042.  
  6043. if (da && (arm_sy != arm6_By)) { // zero wrist yitch
  6044. if (da >= fabs(arm_sy - arm6_By)) // finished
  6045. arm_sy = arm6_By, da -= fabs(arm_sy - arm6_By);
  6046. else
  6047. arm_sy -= (arm_sy > arm6_By ? da : -da), da = 0;
  6048. SetAnimationArm(anim_arm_sy, arm_sy);
  6049. }
  6050.  
  6051.  
  6052. center_arm_t = t0;
  6053. if (da) {
  6054. rmsexecute = 0;; // finished stowing
  6055. HWND hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS);
  6056. if (hDlg) EnableWindow(GetDlgItem(hDlg, IDC_GRAPPLE), FALSE);
  6057.  
  6058. }
  6059.  
  6060.  
  6061.  
  6062. }
  6063. //4
  6064.  
  6065.  
  6066. if ((rmsexecute == 1) && (recallstored == 4) && (Armtilt_proc == 1)) {
  6067. //sprintf(oapiDebugString(), "arm_wr_stored %2.2f arm_wr %2.2f ", arm_wr_stored1, arm_wr);
  6068. double t0 = oapiGetSimTime();
  6069. double dt = t0 - center_arm_t; // time step
  6070. double da = ARM_OPERATING_SPEED*dt; // total rotation angle
  6071. if (da && (arm_wr != arm6_Ar)) { // wrist roll not the stored value
  6072. if (da >= fabs(arm_wr - arm6_Ar)) //
  6073. arm_wr = arm6_Ar, da -= fabs(arm_wr - arm6_Ar);
  6074. else
  6075. arm_wr -= (arm_wr > arm6_Ar ? da : -da), da = 0;
  6076. // sprintf(oapiDebugString(), "arm_wr_stored %2.2f arm_wr %2.2f arm_speed %2.2f ", arm_wr_stored1, arm_wr,ARM_OPERATING_SPEED);
  6077.  
  6078.  
  6079. SetAnimationArm(anim_arm_wr, arm_wr);
  6080. }
  6081.  
  6082. if (da && (arm_wy != arm6_Ay)) { // zero wrist yaw
  6083. if (da >= fabs(arm_wy - arm6_Ay)) // finished
  6084. arm_wy = arm6_Ay, da -= fabs(arm_wy - arm6_Ay);
  6085. else
  6086. arm_wy -= (arm_wy > arm6_Ay ? da : -da), da = 0;
  6087. SetAnimationArm(anim_arm_wy, arm_wy);
  6088. }
  6089.  
  6090.  
  6091. if (da && (arm_wp != arm6_Ap)) { // wrist pitch not stored value
  6092. if (da >= fabs(arm_wp - arm6_Ap)) // finished
  6093. arm_wp = arm6_Ap, da -= fabs(arm_wp - arm6_Ap);
  6094. else
  6095. arm_wp -= (arm_wp > arm6_Ap ? da : -da), da = 0;
  6096. SetAnimationArm(anim_arm_wp, arm_wp);
  6097. }
  6098.  
  6099. if (da && (arm_ep != arm6_ep)) { // zero wrist pitch
  6100. if (da >= fabs(arm_ep - arm6_ep)) // finished
  6101. arm_ep = arm6_ep, da -= fabs(arm_ep - arm6_ep);
  6102. else
  6103. arm_ep -= (arm_ep > arm6_ep ? da : -da), da = 0;
  6104. SetAnimationArm(anim_arm_ep, arm_ep);
  6105. }
  6106. if (da && (arm_ep != arm6_ep)) { // zero wrist pitch
  6107. if (da >= fabs(arm_ep - arm6_ep)) // finished
  6108. arm_ep = arm6_ep, da -= fabs(arm_ep - arm6_ep);
  6109. else
  6110. arm_ep -= (arm_ep > arm6_ep ? da : -da), da = 0;
  6111. SetAnimationArm(anim_arm_ep, arm_ep);
  6112. }
  6113.  
  6114. if (da && (arm_sp != arm6_Bp)) { // zero wrist pitch
  6115. if (da >= fabs(arm_sp - arm6_Bp)) // finished
  6116. arm_sp = arm6_Bp, da -= fabs(arm_sp - arm6_Bp);
  6117. else
  6118. arm_sp -= (arm_sp > arm6_Bp ? da : -da), da = 0;
  6119. SetAnimationArm(anim_arm_sp, arm_sp);
  6120. }
  6121.  
  6122. if (da && (arm_sy != arm6_By)) { // zero wrist yitch
  6123. if (da >= fabs(arm_sy - arm6_By)) // finished
  6124. arm_sy = arm6_By, da -= fabs(arm_sy - arm6_By);
  6125. else
  6126. arm_sy -= (arm_sy > arm6_By ? da : -da), da = 0;
  6127. SetAnimationArm(anim_arm_sy, arm_sy);
  6128. }
  6129.  
  6130.  
  6131. center_arm_t = t0;
  6132. if (da) {
  6133. rmsexecute = 0;; // finished stowing
  6134. HWND hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS);
  6135. if (hDlg) EnableWindow(GetDlgItem(hDlg, IDC_GRAPPLE), FALSE);
  6136.  
  6137. }
  6138.  
  6139.  
  6140.  
  6141. }
  6142. if ((rmsexecute == 1) && (Armtilt_proc == 1) && (recallstored !=8)){
  6143.  
  6144. //sprintf(oapiDebugString(), "arm_wr_stored %2.2f arm_wr %2.2f ", arm_wr_stored1, arm_wr);
  6145. double t0 = oapiGetSimTime();
  6146. double dt = t0 - center_arm_t; // time step
  6147. double da = ARM_OPERATING_SPEED*dt; // total rotation angle
  6148. if (da && (arm_wr != arm6_Ar)) { // wrist roll not the stored value
  6149. if (da >= fabs(arm_wr - arm6_Ar)) //
  6150. arm_wr = arm6_Ar, da -= fabs(arm_wr - arm6_Ar);
  6151. else
  6152. arm_wr -= (arm_wr > arm6_Ar ? da : -da), da = 0;
  6153. // sprintf(oapiDebugString(), "arm_wr_stored %2.2f arm_wr %2.2f arm_speed %2.2f ", arm_wr_stored1, arm_wr,ARM_OPERATING_SPEED);
  6154.  
  6155.  
  6156. SetAnimationArm(anim_arm_wr, arm_wr);
  6157. }
  6158.  
  6159. if (da && (arm_wy != arm6_Ay)) { // zero wrist yaw
  6160. if (da >= fabs(arm_wy - arm6_Ay)) // finished
  6161. arm_wy = arm6_Ay, da -= fabs(arm_wy - arm6_Ay);
  6162. else
  6163. arm_wy -= (arm_wy > arm6_Ay ? da : -da), da = 0;
  6164. SetAnimationArm(anim_arm_wy, arm_wy);
  6165. }
  6166.  
  6167.  
  6168. if (da && (arm_wp != arm6_Ap)) { // wrist pitch not stored value
  6169. if (da >= fabs(arm_wp - arm6_Ap)) // finished
  6170. arm_wp = arm6_Ap, da -= fabs(arm_wp - arm6_Ap);
  6171. else
  6172. arm_wp -= (arm_wp > arm6_Ap ? da : -da), da = 0;
  6173. SetAnimationArm(anim_arm_wp, arm_wp);
  6174. }
  6175.  
  6176. if (da && (arm_ep != arm6_ep)) { // zero wrist pitch
  6177. if (da >= fabs(arm_ep - arm6_ep)) // finished
  6178. arm_ep = arm6_ep, da -= fabs(arm_ep - arm6_ep);
  6179. else
  6180. arm_ep -= (arm_ep > arm6_ep ? da : -da), da = 0;
  6181. SetAnimationArm(anim_arm_ep, arm_ep);
  6182. }
  6183. if (da && (arm_ep != arm6_ep)) { // zero wrist pitch
  6184. if (da >= fabs(arm_ep - arm6_ep)) // finished
  6185. arm_ep = arm6_ep, da -= fabs(arm_ep - arm6_ep);
  6186. else
  6187. arm_ep -= (arm_ep > arm6_ep ? da : -da), da = 0;
  6188. SetAnimationArm(anim_arm_ep, arm_ep);
  6189. }
  6190.  
  6191. if (da && (arm_sp != arm6_Bp)) { // zero wrist pitch
  6192. if (da >= fabs(arm_sp - arm6_Bp)) // finished
  6193. arm_sp = arm6_Bp, da -= fabs(arm_sp - arm6_Bp);
  6194. else
  6195. arm_sp -= (arm_sp > arm6_Bp ? da : -da), da = 0;
  6196. SetAnimationArm(anim_arm_sp, arm_sp);
  6197. }
  6198.  
  6199. if (da && (arm_sy != arm6_By)) { // zero wrist yitch
  6200. if (da >= fabs(arm_sy - arm6_By)) // finished
  6201. arm_sy = arm6_By, da -= fabs(arm_sy - arm6_By);
  6202. else
  6203. arm_sy -= (arm_sy > arm6_By ? da : -da), da = 0;
  6204. SetAnimationArm(anim_arm_sy, arm_sy);
  6205. }
  6206.  
  6207.  
  6208.  
  6209.  
  6210. center_arm_t = t0;
  6211. if (da) {
  6212. rmsexecute = 0;; // finished stowing
  6213. HWND hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS);
  6214. if (hDlg) EnableWindow(GetDlgItem(hDlg, IDC_GRAPPLE), FALSE);
  6215.  
  6216. }
  6217. }
  6218.  
  6219.  
  6220. if (rmsexecute == 1) {
  6221. if (center_arm)
  6222. {
  6223. double t1 = oapiGetSimTime();
  6224. double dt1 = t1 - center_arm_time; // time step
  6225. double da1 = ARM_OPERATING_SPEED*dt1; // total rotation angle
  6226.  
  6227. // work from the wrist down to the shoulder
  6228. if (da1 && (arm_wr != 0.5))
  6229. { // zero wrist roll
  6230. if (da1 >= fabs(arm_wr - wrstart)) // finished
  6231. arm_wr = wrstart, da1 -= fabs(arm_wr - wrstart);
  6232. else
  6233. arm_wr -= (arm_wr > wrstart ? da1 : -da1), da1 = 0;
  6234. SetAnimationArm(anim_arm_wr, arm_wr);
  6235. }
  6236. //sprintf(oapiDebugString(), "arm_wr %2.2f da1 %f dt1 %f t1 %f centert1 %f armspeeded %f", arm_wr, da1, dt1, t1, center_arm_time, ARM_OPERATING_SPEED);
  6237.  
  6238.  
  6239. if (da1 && (arm_wy != wystart)) { // zero wrist yaw
  6240. if (da1 >= fabs(arm_wy - wystart)) // finished
  6241. arm_wy = wystart, da1 -= fabs(arm_wy - wystart);
  6242. else
  6243. arm_wy -= (arm_wy > wystart ? da1 : -da1), da1 = 0;
  6244. SetAnimationArm(anim_arm_wy, arm_wy);
  6245. }
  6246. sprintf(oapiDebugString(), "arm_wr %2.2f arm_wy %2.2f da1 %f dt1 %f t1 %f centert1 %f armspeeded %f", arm_wr, arm_wy, da1, dt1, t1, center_arm_time, ARM_OPERATING_SPEED);
  6247. if (da1 && (arm_wp != wpstart)) { // zero wrist pitch
  6248. if (da1 >= fabs(arm_wp - wpstart)) // finished
  6249. arm_wp = wpstart, da1 -= fabs(arm_wp - wpstart);
  6250. else
  6251. arm_wp -= (arm_wp > wpstart ? da1 : -da1), da1 = 0;
  6252. SetAnimationArm(anim_arm_wp, arm_wp);
  6253. }
  6254. if (da1 && arm_ep) { // zero elbow pitch
  6255. if (da1 >= arm_ep) // finished
  6256. arm_ep = 0.0, da1 -= arm_ep;
  6257. else
  6258. arm_ep -= da1, da1 = 0;
  6259. SetAnimationArm(anim_arm_ep, arm_ep);
  6260. }
  6261. if (da1 && (arm_sy != 0.5)) { // zero shoulder yaw
  6262. if (da1 >= fabs(arm_sy - 0.5)) // finished
  6263. arm_sy = 0.5, da1 -= fabs(arm_sy - 0.5);
  6264. else
  6265. arm_sy -= (arm_sy > 0.5 ? da1 : -da1), da1 = 0;
  6266. SetAnimationArm(anim_arm_sy, arm_sy);
  6267. }
  6268. if (da1 && arm_sp) { // zero shoulder pitch
  6269. if (da1 >= arm_sp) // finished
  6270. arm_sp = 0.0, da1 -= arm_sp;
  6271. else
  6272. arm_sp -= da1, da1 = 0;
  6273. SetAnimationArm(anim_arm_sp, arm_sp);
  6274. }
  6275.  
  6276. //sprintf(oapiDebugString(), "arm_sy %2.2f armM_sy %2.2f da1 %2.2f dt %2.2f", arm_sy, arm_sp, da1, dt);
  6277. center_arm_time = t1;
  6278. if (da1) {
  6279.  
  6280. center_arm = false; // finished stowing
  6281. rmsexecute = 0;
  6282. HWND hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS);
  6283. if (hDlg) EnableWindow(GetDlgItem(hDlg, IDC_GRAPPLE), TRUE);
  6284. }
  6285. }
  6286. }
  6287.  
  6288. */
  6289. if (center_arm) SeqSSRMS();
  6290. // ***** Stow RMS arm *****
  6291.  
  6292. if (rmsexecute == 1) {
  6293. double t0 = oapiGetSimTime();
  6294. double dt = t0 - center_arm_t; // time step
  6295. double da1 = ARM_OPERATING_SPEED * dt; // total rotation angle
  6296.  
  6297. // work from the wrist down to the shoulder
  6298. if (da1 && (arm_wr != 0.5)) { // zero wrist roll
  6299. if (da1 >= fabs(arm_wr - 0.5)) // finished
  6300. arm_wr = 0.5, da1 -= fabs(arm_wr - 0.5);
  6301. else
  6302. arm_wr -= (arm_wr > 0.5 ? da1 : -da1), da1 = 0;
  6303. SetAnimationArm(anim_arm_wr, arm_wr);
  6304. }
  6305. //sprintf(oapiDebugString(), "arm_wr %2.2f da11 %f dt1 %f t1 %f centert1 %f armspeeded %f", arm_wr, da1, center_arm_t, ARM_OPERATING_SPEED);
  6306. if (da1 && (arm_wy != 0.5)) { // zero wrist yaw
  6307. if (da1 >= fabs(arm_wy - 0.5)) // finished
  6308. arm_wy = 0.5, da1 -= fabs(arm_wy - 0.5);
  6309. else
  6310. arm_wy -= (arm_wy > 0.5 ? da1 : -da1), da1 = 0;
  6311. SetAnimationArm(anim_arm_wy, arm_wy);
  6312. }
  6313. if (da1 && (arm_wp != 0.5)) { // zero wrist pitch
  6314. if (da1 >= fabs(arm_wp - 0.5)) // finished
  6315. arm_wp = 0.5, da1 -= fabs(arm_wp - 0.5);
  6316. else
  6317. arm_wp -= (arm_wp > 0.5 ? da1 : -da1), da1 = 0;
  6318. SetAnimationArm(anim_arm_wp, arm_wp);
  6319. }
  6320. if (da1 && arm_ep) { // zero elbow pitch
  6321. if (da1 >= arm_ep) // finished
  6322. arm_ep = 0.0, da1 -= arm_ep;
  6323. else
  6324. arm_ep -= da1, da1 = 0;
  6325. SetAnimationArm(anim_arm_ep, arm_ep);
  6326. }
  6327. if (da1 && (arm_sy != 0.5)) { // zero shoulder yaw
  6328. if (da1 >= fabs(arm_sy - 0.5)) // finished
  6329. arm_sy = 0.5, da1 -= fabs(arm_sy - 0.5);
  6330. else
  6331. arm_sy -= (arm_sy > 0.5 ? da1 : -da1), da1 = 0;
  6332. SetAnimationArm(anim_arm_sy, arm_sy);
  6333. }
  6334. if (da1 && arm_sp) { // zero shoulder pitch
  6335. if (da1 >= arm_sp) // finished
  6336. arm_sp = 0.0, da1 -= arm_sp;
  6337. else
  6338. arm_sp -= da1, da1 = 0;
  6339. SetAnimationArm(anim_arm_sp, arm_sp);
  6340. }
  6341. center_arm_t = t0;
  6342. if (da1) {
  6343. center_arm = false; // finished stowing
  6344. rmsexecute = 0;
  6345. HWND hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS);
  6346. if (hDlg) EnableWindow(GetDlgItem(hDlg, IDC_GRAPPLE), TRUE);
  6347. }
  6348. }
  6349.  
  6350. if (arm_moved) {
  6351. SetAttachmentParams(rms_attach, arm_tip[0], arm_tip[1] - arm_tip[0], arm_tip[2] - arm_tip[0]);
  6352. arm_moved = false;
  6353. }
  6354. if (arm_scheduled) {
  6355. arm_scheduled = false;
  6356. arm_moved = true;
  6357. }
  6358.  
  6359. xp0 = arm_tip[1] - arm_tip[0]; normalise(xp0);
  6360. xr0 = arm_tip[2] - arm_tip[0]; normalise(xr0);
  6361. SetAttachmentParams(rms_attach, arm_tip[0], xp0, xr0);
  6362.  
  6363.  
  6364. if (arm_moved) {
  6365. xp0 = arm_tip[1] - arm_tip[0]; normalise(xp0);
  6366. xr0 = arm_tip[2] - arm_tip[0]; normalise(xr0);
  6367. SetAttachmentParams(rms_attach, arm_tip[0], xp0, xr0);
  6368.  
  6369. //if (arm_moved) {
  6370. // SetAttachmentParams(rms_attach, arm_tip[0], arm_tip[1] - arm_tip[0], arm_tip[2] - arm_tip[0]);
  6371. arm_moved = false;
  6372. }
  6373. if (arm_scheduled) {
  6374. arm_scheduled = false;
  6375. arm_moved = true;
  6376. }
  6377. //MOVE OBSS ATTACHMENT
  6378. if (OBSS_proc > 0 && OBSS_proc < 1) {
  6379. SetAttachmentParams(OBSS_attach, armobss_tip[0], armobss_tip[1] - armobss_tip[0], armobss_tip[2] - armobss_tip[0]);
  6380. //
  6381. }
  6382.  
  6383. if (flood1_status == 1)
  6384. {
  6385. spotlight5->Activate(true);
  6386. spot_beacon[4].active = true;
  6387. }
  6388.  
  6389. if (flood2_status == 1)
  6390. {
  6391. spotlight6->Activate(true);
  6392. spot_beacon[5].active = true;
  6393. }
  6394.  
  6395. if (flood1_status == 0)
  6396. {
  6397. spotlight5->Activate(false);
  6398. spot_beacon[4].active = false;
  6399. }
  6400.  
  6401. if (flood2_status == 0)
  6402. {
  6403. spotlight6->Activate(false);
  6404. spot_beacon[5].active = false;
  6405. }
  6406.  
  6407. if (flood3_status == 1)
  6408. {
  6409. spotlight3->Activate(true);
  6410. spot_beacon[2].active = true;
  6411. }
  6412.  
  6413. if (flood4_status == 1)
  6414. {
  6415. spotlight4->Activate(true);
  6416. spot_beacon[3].active = true;
  6417. }
  6418.  
  6419. if (flood3_status == 0)
  6420. {
  6421. spotlight3->Activate(false);
  6422. spot_beacon[2].active = false;
  6423. }
  6424.  
  6425. if (flood4_status == 0)
  6426. {
  6427. spotlight4->Activate(false);
  6428. spot_beacon[3].active = false;
  6429. }
  6430. //
  6431. if (flood5_status == 1)
  6432. {
  6433. spotlight1->Activate(true);
  6434. spot_beacon[0].active = true;
  6435. }
  6436.  
  6437. if (flood6_status == 1)
  6438. {
  6439. spotlight2->Activate(true);
  6440. spot_beacon[1].active = true;
  6441. }
  6442.  
  6443. if (flood5_status == 0)
  6444. {
  6445. spotlight1->Activate(false);
  6446. spot_beacon[0].active = false;
  6447. }
  6448.  
  6449. if (flood6_status == 0)
  6450. {
  6451. spotlight2->Activate(false);
  6452. spot_beacon[1].active = false;
  6453. }
  6454. if (docklight_status == 0)
  6455. {
  6456. spotlightDOCK->Activate(false);
  6457. spot_beacon[7].active = false;
  6458. }
  6459. if (docklight_status == 1)
  6460. {
  6461. spotlightDOCK->Activate(true);
  6462. spot_beacon[7].active = true;
  6463. }
  6464.  
  6465. if (docklightdim_status == 0)
  6466. {
  6467. //double intensity = 0.0(no light) to 1.0(full light)
  6468. spotlightDOCK->SetIntensity(1.0);
  6469. }
  6470. if (docklightdim_status == 1)
  6471. {
  6472. //double intensity = 0.0(no light) to 1.0(full light)
  6473. spotlightDOCK->SetIntensity(.5);
  6474. }
  6475. if (docklightbright_status == 0)
  6476. {
  6477. //double intensity = 0.0(no light) to 1.0(full light)
  6478. spotlightDOCK->SetIntensity(.5);
  6479. }
  6480. if (docklightbright_status == 1)
  6481. {
  6482. //double intensity = 0.0(no light) to 1.0(full light)
  6483. spotlightDOCK->SetIntensity(1.0);
  6484. }
  6485.  
  6486. if (aft_light_status == 1)
  6487. {
  6488.  
  6489.  
  6490. spotlight7->Activate(true);
  6491.  
  6492.  
  6493.  
  6494. spot_beacon[6].active = true;
  6495.  
  6496. }
  6497.  
  6498. else if (aft_light_status == 0)
  6499. {
  6500.  
  6501. spotlight7->Activate(false);
  6502.  
  6503.  
  6504.  
  6505. spot_beacon[6].active = false;
  6506.  
  6507. }
  6508. if (rmslight_status == 1)
  6509. {
  6510.  
  6511.  
  6512. spotlightRMS->Activate(true);
  6513. spot_beacon[8].active = true;
  6514.  
  6515. }
  6516.  
  6517. else if (rmslight_status == 0)
  6518. {
  6519.  
  6520. spotlightRMS->Activate(false);
  6521. spot_beacon[8].active = false;
  6522.  
  6523. }
  6524. if (ODS == 0){ //ODS is not present
  6525. if (EXT_status >= HATCH_RAISING) {
  6526. double da = simdt * .1;
  6527. if (EXT_status == HATCH_RAISING) {
  6528. if (EXT_proc > 0.0) EXT_proc = max(0.0, EXT_proc - da);
  6529. else EXT_status = HATCH_UP;
  6530. }
  6531. else {
  6532. if (EXT_proc < 1.0) EXT_proc = min(1.0, EXT_proc + da);
  6533. else EXT_status = HATCH_DOWN;
  6534. }
  6535. SetAnimation(anim_extdoor, EXT_proc);
  6536. }
  6537. }
  6538. if (ODS == 1){//ODS is present
  6539. if (EXT_status >= HATCH_RAISING) {
  6540. double da = simdt * .1;
  6541. if (EXT_status == HATCH_RAISING) {
  6542. if (EXT_proc > 0.0) EXT_proc = max(0.0, EXT_proc - da);
  6543. else EXT_status = HATCH_UP;
  6544. }
  6545. else {
  6546. if (EXT_proc < 1.0) EXT_proc = min(1.0, EXT_proc + da);
  6547. else EXT_status = HATCH_DOWN;
  6548. }
  6549. SetAnimation(anim_extodsdoor, EXT_proc);
  6550. }
  6551. }
  6552.  
  6553. if (ODS == 1){//ODS is present
  6554. //SetDockParams(dockpos, _V(0, 1, 0), _V(0, 0, -1));
  6555. if (DOCKRING_status >= HATCH_RAISING) {
  6556. double da = simdt * .1;
  6557. if (DOCKRING_status == HATCH_RAISING) {
  6558. if (DOCKRING_proc > 0.0) DOCKRING_proc = max(0.0, DOCKRING_proc - da);
  6559. else DOCKRING_status = HATCH_UP;
  6560. }
  6561. else {
  6562. if (DOCKRING_proc < 1.0) DOCKRING_proc = min(1.0, DOCKRING_proc + da);
  6563. else DOCKRING_status = HATCH_DOWN;
  6564. }
  6565.  
  6566. SetAnimation(anim_DOCKRING, DOCKRING_proc);
  6567.  
  6568. }
  6569. }
  6570.  
  6571. if (EXTAIRLOCK == 1){//ODS is present
  6572. if (EXT_status >= HATCH_RAISING) {
  6573. double da = simdt * .1;
  6574. if (EXT_status == HATCH_RAISING) {
  6575. if (EXT_proc > 0.0) EXT_proc = max(0.0, EXT_proc - da);
  6576. else EXT_status = HATCH_UP;
  6577. }
  6578. else {
  6579. if (EXT_proc < 1.0) EXT_proc = min(1.0, EXT_proc + da);
  6580. else EXT_status = HATCH_DOWN;
  6581. }
  6582. SetAnimation(anim_EXTAIRLOCK, EXT_proc);
  6583. }
  6584. }
  6585. mfd1pwr = (oapiGetMFDMode(MFD_RIGHT));
  6586. mfd0pwr = (oapiGetMFDMode(MFD_LEFT));
  6587. mfd2pwr = (oapiGetMFDMode(MFD_USER1));
  6588. mfdApwr = (oapiGetMFDMode(MFD_USER2));
  6589.  
  6590. //sprintf(oapiDebugString(), "%d ", mfd1pwr);
  6591. if (mfd1pwr >0) SetAnimation(anim_mfd2, 1);//right
  6592. if (mfd1pwr == 0) SetAnimation(anim_mfd2, 0);//right
  6593. if (mfd0pwr > 0) SetAnimation(anim_mfd1, 1);
  6594. if (mfd0pwr == 0) SetAnimation(anim_mfd1, 0);
  6595. if (mfd2pwr > 0) SetAnimation(anim_mfd0, 1);
  6596. if (mfd2pwr == 0) SetAnimation(anim_mfd0, 0);
  6597. if (mfdApwr > 0) SetAnimation(anim_mfdAFT, 0);
  6598. if (mfdApwr == 0) SetAnimation(anim_mfdAFT, 1);
  6599.  
  6600. if (DRAGCHUTE == 0){ //drag chute is presented and not deployed initial set at Chute_proc =1.0
  6601. if (CHUTE_status >= HATCH_RAISING) {
  6602. double da = simdt * .8;
  6603. if (CHUTE_status == HATCH_RAISING) {
  6604. if (CHUTE_proc > 0.0) CHUTE_proc = max(0.0, CHUTE_proc - da);
  6605. else CHUTE_status = HATCH_UP;
  6606. }
  6607.  
  6608. if (CHUTE_status == HATCH_UP) DRAGCHUTEDEPLOYED = 1;
  6609. SetAnimation(anim_CHUTE, CHUTE_proc);
  6610. SetAnimation(anim_dragdeploy, 1);
  6611. }
  6612.  
  6613.  
  6614. if ((DRAGCHUTE == 0) && (CHUTE_proc < 0.2)) {//drag chute present and started to open
  6615. CreateVariableDragElement(&CHUTE_proc, 22.5, _V(0, 4.5, -12.03));
  6616. }
  6617.  
  6618. //obss tilt
  6619. if (OBSS_status >= HATCH_RAISING) {
  6620. double da = simdt * .1;
  6621. if (OBSS_status == HATCH_RAISING) {
  6622. if (OBSS_proc > 0.0) OBSS_proc = max(0.0, OBSS_proc - da);
  6623. else OBSS_status = HATCH_UP;
  6624. }
  6625. else {
  6626. if (OBSS_proc < 1.0) OBSS_proc = min(1.0, OBSS_proc + da);
  6627. else OBSS_status = HATCH_DOWN;
  6628. }
  6629.  
  6630. SetAnimation(anim_MPMOBSS, OBSS_proc);
  6631.  
  6632. }
  6633. }
  6634. if (ssmestow_status >= HATCH_RAISING) {
  6635. double da = simdt * .1;
  6636. if (ssmestow_status == HATCH_RAISING) {
  6637. if (ssmestow_proc > 0.0) ssmestow_proc = max(0.0, ssmestow_proc - da);
  6638. else ssmestow_status = HATCH_UP;
  6639. }
  6640. else {
  6641. if (ssmestow_proc < 1.0) ssmestow_proc = min(1.0, ssmestow_proc + da);
  6642. else ssmestow_status = HATCH_DOWN;
  6643. }
  6644.  
  6645. SetAnimation(anim_ssmestow, ssmestow_proc);
  6646.  
  6647. }
  6648. //ADTA
  6649. if (ADTA_status >= HATCH_RAISING) {
  6650. double da = simdt * .1;
  6651. if (ADTA_status == HATCH_RAISING) {
  6652. if (ADTA_proc > 0.0) ADTA_proc = max(0.0, ADTA_proc - da);
  6653. else ADTA_status = HATCH_UP;
  6654. }
  6655. else {
  6656. if (ADTA_proc < 1.0) ADTA_proc = min(1.0, ADTA_proc + da);
  6657. else ADTA_status = HATCH_DOWN;
  6658. }
  6659. SetAnimation(anim_ADTA, ADTA_proc);
  6660. }
  6661.  
  6662. //ExternalTankHatch tilt
  6663. if (PETD_status >= HATCH_RAISING) {
  6664. double da = simdt * .1;
  6665. if (PETD_status == HATCH_RAISING) {
  6666.  
  6667. if (PETD_proc > 0.0) PETD_proc = max(0.0, PETD_proc - da);
  6668. else PETD_status = HATCH_UP;
  6669. }
  6670. else {
  6671.  
  6672. if (PETD_proc < 1.0) PETD_proc = min(1.0, PETD_proc + da);
  6673. else PETD_status = HATCH_DOWN;
  6674. }
  6675.  
  6676.  
  6677. SetAnimation(anim_PETD, PETD_proc);
  6678.  
  6679.  
  6680. }
  6681.  
  6682. //ExternalTankHatch tilt
  6683. if (SETD_status >= HATCH_RAISING) {
  6684. double da = simdt * .1;
  6685. if (SETD_status == HATCH_RAISING) {
  6686. if (SETD_proc > 0.0) SETD_proc = max(0.0, SETD_proc - da);
  6687.  
  6688. else SETD_status = HATCH_UP;
  6689. }
  6690. else {
  6691. if (SETD_proc < 1.0) SETD_proc = min(1.0, SETD_proc + da);
  6692.  
  6693. else SETD_status = HATCH_DOWN;
  6694. }
  6695.  
  6696. SetAnimation(anim_SETD, SETD_proc);
  6697.  
  6698.  
  6699.  
  6700. }
  6701.  
  6702.  
  6703. if (plop->BayDoorStatus.pos >= 1.0){
  6704. if (Armtilt_status >= HATCH_RAISING) {
  6705. double da = simdt * .1;
  6706. if (Armtilt_status == HATCH_RAISING) {
  6707. if (Armtilt_proc > 0.0) Armtilt_proc = max(0.0, Armtilt_proc - da);
  6708. else Armtilt_status = HATCH_UP;
  6709. }
  6710. else {
  6711. if (Armtilt_proc < 1.0) Armtilt_proc = min(1.0, Armtilt_proc + da);
  6712. else Armtilt_status = HATCH_DOWN;
  6713. }
  6714. SetAnimation(anim_MPM, Armtilt_proc);
  6715. }
  6716. }
  6717. double airspeed = GetAirspeed();
  6718. double groundspeed = GetGroundspeed();
  6719.  
  6720. if (DRAGCHUTE == 0) {
  6721. SetMeshVisibilityMode(mesh_DRAGCHUITEHUD, MESHVIS_VC);
  6722. }
  6723.  
  6724.  
  6725.  
  6726. if ((DRAGCHUTE == 0)&&(airspeed <= CHUTE_DEPLOY_SPEED) && (airspeed > CHUTE_JETTISON_SPEED) && GroundContact() && (DRAGCHUTEDEPLOYED == 0)) {
  6727. SetMeshVisibilityMode(mesh_DRAGCHUTE, MESHVIS_ALWAYS);
  6728. SetAnimation(anim_chutejett, 1);
  6729. RevertDragchute();
  6730. }
  6731. // sprintf_s(oapiDebugString(), 255, "ft_pad_att1: %f %f %f, pl10_ofs.x,pl10_ofs.y,pl10_ofs.z");
  6732. GetAttachmentParams(ft_pad_att, ft_pad_att_pos, (ft_pad_att_dir), ft_pad_att_rot);
  6733. GetAttachmentParams(ft_pad_att1, ft_pad_att1_pos, (ft_pad_att1_dir), ft_pad_att1_rot);
  6734. GetAttachmentParams(ft_pad_att2, ft_pad_att2_pos, (ft_pad_att2_dir), ft_pad_att2_rot);
  6735. GetAttachmentParams(ft_pad_att3, ft_pad_att3_pos, (ft_pad_att3_dir), ft_pad_att3_rot);
  6736. //sprintf(oapiDebugString(), "ft_pad_att_posx %2.2f ft_pad_att_posy %2.2f ft_pad_att_posz %2.2f eva1 %d", ft_pad_att_pos.x, ft_pad_att_pos.y, ft_pad_att_pos.z,EVA1);
  6737.  
  6738.  
  6739. if (geararmed == 1)
  6740. {
  6741. SetAnimation(anim_LEFTGEARARMON, 1);
  6742. SetAnimation(anim_LEFTGEARARMOFF, 1);
  6743. SetAnimation(anim_RIGHTGEARARMON, 1);
  6744. SetAnimation(anim_RIGHTGEARARMOFF, 1);
  6745. }
  6746.  
  6747.  
  6748.  
  6749.  
  6750.  
  6751. if (GetAttachmentStatus(ft_pad_att) == NULL) SetAttachmentParams(ft_pad_att, ft_pad_att_pos, ft_pad_att_dir, ft_pad_att_rot); // not attached so save the parameters
  6752. if (GetAttachmentStatus(ft_pad_att1) == NULL) SetAttachmentParams(ft_pad_att1, ft_pad_att1_pos, ft_pad_att1_dir, ft_pad_att1_rot); // not attached so save the parameters
  6753. if (GetAttachmentStatus(ft_pad_att2) == NULL) SetAttachmentParams(ft_pad_att2, ft_pad_att2_pos, ft_pad_att2_dir, ft_pad_att2_rot); // not attached so save the parameters
  6754. if (GetAttachmentStatus(ft_pad_att3) == NULL) SetAttachmentParams(ft_pad_att3, ft_pad_att3_pos, ft_pad_att3_dir, ft_pad_att3_rot); // not attached so save the parameters
  6755.  
  6756. if ((airspeed < CHUTE_JETTISON_SPEED) && (DRAGCHUTE == 0) && (DRAGCHUTEDEPLOYED == 1)) SetMeshVisibilityMode(mesh_DRAGCHUTE, MESHVIS_NEVER);;
  6757.  
  6758. if (CAM == 3)SetMeshVisibilityMode(mesh_vc, MESHVIS_NEVER);
  6759. if (CAM == 5)SetMeshVisibilityMode(mesh_vc, MESHVIS_NEVER);
  6760. if (CAM == 9)SetMeshVisibilityMode(mesh_vc, MESHVIS_NEVER);
  6761.  
  6762. if (CAM == 2)SetMeshVisibilityMode(mesh_vc, MESHVIS_NEVER);
  6763. if (CAM == 4)SetMeshVisibilityMode(mesh_vc, MESHVIS_NEVER);
  6764. if (CAM == 1)SetMeshVisibilityMode(mesh_vc, MESHVIS_NEVER);
  6765. if (CAM == 6)SetMeshVisibilityMode(mesh_vc, MESHVIS_NEVER);
  6766. if (CAM == 7)SetMeshVisibilityMode(mesh_vc, MESHVIS_NEVER);
  6767. if (CAM == 2)SetMeshVisibilityMode(mesh_cockpit, MESHVIS_VC | MESHVIS_EXTPASS | MESHVIS_EXTERNAL);
  6768. if (CAM == 3)SetMeshVisibilityMode(mesh_cockpit, MESHVIS_VC | MESHVIS_EXTPASS | MESHVIS_EXTERNAL);
  6769.  
  6770. if (CAM == 6)SetMeshVisibilityMode(mesh_cockpit, MESHVIS_VC | MESHVIS_EXTPASS | MESHVIS_EXTERNAL);
  6771. if (CAM == 7)SetMeshVisibilityMode(mesh_cockpit, MESHVIS_VC | MESHVIS_EXTPASS | MESHVIS_EXTERNAL);
  6772. if ((CAM == 1) || (CAM == 4) || (CAM == 5) || (CAM == 8) || (CAM == 0))SetMeshVisibilityMode(mesh_cockpit, MESHVIS_EXTERNAL);
  6773. if (CAM == 0)SetMeshVisibilityMode(mesh_vc, MESHVIS_VC);
  6774.  
  6775. if (CAM == 6){//elbow view
  6776.  
  6777. VECTOR3 dir = camRMSElbowLoc[1] - camRMSElbowLoc[0];
  6778. if (Eq(dotp(dir, _V(0, -1, 0)), 1.0, 1e-4)) dir = _V(1.74532924314e-4, -0.999999984769, 0.0);
  6779. else if (Eq(dotp(dir, _V(0, 1, 0)), 1.0, 1e-4)) dir = _V(1.74532924314e-4, 0.999999984769, 0.0);
  6780. VECTOR3 orbiter_cam_rot = crossp(crossp(dir, _V(0, 1, 0)), dir);
  6781. orbiter_cam_rot /= length(orbiter_cam_rot);
  6782. if (orbiter_cam_rot.y < 0) orbiter_cam_rot = -orbiter_cam_rot;
  6783. double angle = SignedAngle(orbiter_cam_rot, camRMSElbowLoc[2] - camRMSElbowLoc[0], dir);
  6784. SetCameraDefaultDirection(dir, angle);
  6785. SetCameraOffset(camRMSElbowLoc[0]);
  6786. oapiCameraSetCockpitDir(0.0, 0.0);
  6787. //sprintf_s(oapiDebugString(), 255, "Rot Vec: %f %f %f cam dir: %f %f %f dir: %f %f %f Angle: %f %f length: %f", orbiter_cam_rot.x, orbiter_cam_rot.y, orbiter_cam_rot.z, camRMSElbowLoc[1].x - camRMSElbowLoc[0].x, camRMSElbowLoc[2].y - camRMSElbowLoc[0].y, camRMSElbowLoc[2].z - camRMSElbowLoc[0].z, dir.x, dir.y, dir.z, angle, angle*DEG, length(dir));
  6788.  
  6789. }
  6790. if (CAM == 7){ //ee view
  6791. // calculate rotation angle for EE cam
  6792. VECTOR3 dir = arm_tip[1] - arm_tip[0];
  6793. // if camera is pointing straight up or down, make it slightly offset from (0,1,0) vector
  6794. if (Eq(dotp(dir, _V(0, -1, 0)), 1.0, 1e-4)) dir = _V(1.74532924314e-4, -0.999999984769, 0.0);
  6795. else if (Eq(dotp(dir, _V(0, 1, 0)), 1.0, 1e-4)) dir = _V(1.74532924314e-4, 0.999999984769, 0.0);
  6796. VECTOR3 orbiter_cam_rot = crossp(crossp(dir, _V(0, 1, 0)), dir);
  6797. orbiter_cam_rot /= length(orbiter_cam_rot);
  6798. if (orbiter_cam_rot.y < 0) orbiter_cam_rot = -orbiter_cam_rot;
  6799. double angle = SignedAngle(orbiter_cam_rot, arm_tip[2] - arm_tip[0], dir);
  6800.  
  6801. //sprintf_s(oapiDebugString(), 255, "Rot Vec: %f %f %f dir: %f %f %f dot_prod: %f Angle: %f %f", orbiter_cam_rot.x, orbiter_cam_rot.y, orbiter_cam_rot.z, dir.x, dir.y, dir.z, dot_prod, angle, angle*DEG);
  6802. //sprintf_s(oapiDebugString(), 255, "Rot Vec: %f %f %f cam dir: %f %f %f dir: %f %f %f Angle: %f %f length: %f", orbiter_cam_rot.x, orbiter_cam_rot.y, orbiter_cam_rot.z, arm_tip[2].x - arm_tip[0].x, arm_tip[2].y - arm_tip[0].y, arm_tip[2].z - arm_tip[0].z, dir.x, dir.y, dir.z, angle, angle*DEG, length(dir));
  6803. //sprintf_s(oapiDebugString(), 255, "dot_prod: %f Angle: %f %f", dot_prod, angle, angle*DEG);
  6804.  
  6805. SetCameraOffset(arm_tip[3]);
  6806. //STS()->SetCameraDefaultDirection (arm_tip[1]-arm_tip[0], 0.0);
  6807. SetCameraDefaultDirection(dir, angle);
  6808. oapiCameraSetCockpitDir(0.0, 0.0);
  6809. }
  6810.  
  6811.  
  6812. if (CAM == 8) {
  6813.  
  6814. SetCameraDefaultDirection(_V(0, 1, 0));
  6815. SetCameraOffset(DOCKCAM);
  6816. // sprintf(oapiDebugString(), "armtip3x %2.2f armtip3y %2.2f armtip3z %2.2f", arm_tip[5].x, arm_tip[5].y, arm_tip[5].z);
  6817.  
  6818. oapiCameraSetCockpitDir(0, 0);
  6819. }
  6820. if (USEIUS == 1){
  6821. double da = simdt * .01;
  6822. if (tilt == 1)tiltvalue = .4915; //first step
  6823. if (tilt == 3)tiltvalue = 1.0; //2nd step
  6824.  
  6825.  
  6826. if (tilt == 1) ius_proc = (ius_proc + da);//move up
  6827. if (tilt == 2) ius_proc = (ius_proc - da);//move down
  6828. if (tilt == 4) ius_proc = (ius_proc + da);//move up
  6829. if ((tilt == 1) && (ius_proc > tiltvalue))tilt = 3; //reaches limit so 1st stop
  6830. if ((tilt == 4) && (ius_proc > tiltvalue))tilt = 5; //reaches limit so 2nd stop
  6831. if ((tilt == 2) && (ius_proc < 0))tilt = 0; //reaches limit so stop
  6832. if (ius_proc < 0)ius_proc = 0;
  6833. if (ius_proc >1.0)ius_proc = 1.0;
  6834.  
  6835. SetAnimation(anim_ius, ius_proc);
  6836.  
  6837. if (ius_proc == 0)tilt = 0;
  6838.  
  6839. xp1 = arm1_tip[1] - arm1_tip[0]; normalise(xp1);
  6840. xr1 = arm1_tip[2] - arm1_tip[0]; normalise(xr1);
  6841. DIR = _V(0, sin(ius_proc), cos(ius_proc));
  6842.  
  6843. SetAttachmentParams(sat_attach4, pl4_ofs, DIR, pl4_rot);//ase
  6844. SetAttachmentParams(sat_attach, pl1_ofs, DIR, pl1_rot);//ius
  6845. //sets new attachment rotation values for saving
  6846. pl1_dir.x = DIR.x;
  6847. pl4_dir.x = DIR.x;
  6848. pl1_dir.y = DIR.y;
  6849. pl4_dir.y = DIR.y;
  6850. pl1_dir.z = DIR.z;
  6851. pl4_dir.z = DIR.z;
  6852.  
  6853.  
  6854.  
  6855.  
  6856. /*
  6857.  
  6858.  
  6859.  
  6860.  
  6861. //tilt of ase/IUS
  6862. //sprintf(oapiDebugString(), " tipx %f tipy %f tipz %f tipz %d tipVALUE %f", arm1_tip[1].x, arm1_tip[1].y, arm1_tip[1].z,tilt,tiltvalue);
  6863.  
  6864. if (tilt == 1)tiltvalue = .5; //first step
  6865. if (tilt == 3)tiltvalue = 1.0; //2nd step
  6866. //phi = phi + .001;//move up second step
  6867. if (tilt == 1) phi = (phi + .00039);//move up
  6868. if (tilt == 2) phi = (phi - .00039);//move down
  6869. if (tilt == 4) phi = (phi + .00039);//move up
  6870. if ((tilt == 1) && (phi > tiltvalue))tilt = 3; //reaches limit so 1st stop
  6871. if ((tilt == 4) && (phi > tiltvalue))tilt = 5; //reaches limit so 2nd stop
  6872. if ((tilt == 2) && (phi < 0))tilt = 0; //reaches limit so stop
  6873. if (phi < 0)phi = 0;
  6874. if (phi >1.0)phi = 1.0;
  6875. xp1 = arm1_tip[1] - arm1_tip[0]; normalise(xp1);
  6876. xr1 = arm1_tip[2] - arm1_tip[0]; normalise(xr1);
  6877. //if ((tilt == 1) || (tilt == 2) || (tilt == 4))phi = ANGULAR_VEL *simt; //move ase attachment and ius
  6878. DIR = _V(0, sin(phi), cos(phi));
  6879.  
  6880. SetAttachmentParams(sat_attach4, pl4_ofs, DIR, pl4_rot);//ase
  6881. SetAttachmentParams(sat_attach, pl1_ofs, DIR, pl1_rot);//ius
  6882. //sets new attachment rotation values for saving
  6883. pl1_dir.x = DIR.x;
  6884. pl4_dir.x = DIR.x;
  6885. pl1_dir.y = DIR.y;
  6886. pl4_dir.y = DIR.y;
  6887. pl1_dir.z = DIR.z;
  6888. pl4_dir.z = DIR.z;
  6889. */
  6890. }
  6891. if (SPIN1 == 1){//spintable#1
  6892.  
  6893. if ((spintable == 1) || (spintable == 3) || (spintable == 4)){
  6894.  
  6895. SPINACC = 5 * 360 / 60;
  6896.  
  6897. spintable_vel = spintable_vel + SPINACC*simdt;
  6898. spintable_phi = spintable_phi + spintable_vel*simdt;
  6899. int multiplier = ((int)spintable_phi) / 360;
  6900.  
  6901. if (spintable_vel > (50 * 360 / 60))(spintable_vel = (50 * 360 / 60)); //limit spped
  6902. if (spintable_vel == (50 * 360 / 60)) spintable = 3;//speed achieved
  6903. spintable_phi = spintable_phi - (double)multiplier * 360;
  6904. MATRIX3 spintable_rotmat = rotm(_V(0, 1, 0), spintable_phi*RAD);
  6905. SetAttachmentParams(sat_attach, pl1_ofs, _V(spintable_rotmat.m21, spintable_rotmat.m22, spintable_rotmat.m23), _V(spintable_rotmat.m31, spintable_rotmat.m32, spintable_rotmat.m33));
  6906.  
  6907.  
  6908. ATTACHMENTHANDLE ah = GetAttachmentHandle(false, 0);
  6909. OBJHANDLE hChild = GetAttachmentStatus(ah);
  6910. if (oapiIsVessel(hChild)) { // something is attached!
  6911. VESSEL *v = oapiGetVesselInterface(hChild);
  6912. // sprintf(oapiDebugString(), "%s is attached",
  6913. // v->GetName());
  6914. }
  6915. }
  6916.  
  6917.  
  6918. if (spintable == 4){ // satellite release so slow spintable to 0
  6919. spintable_vel = spintable_vel - SPINACC*simdt;
  6920. if (spintable_vel < 0)spintable_vel = 0;
  6921. }
  6922.  
  6923. }
  6924.  
  6925.  
  6926.  
  6927.  
  6928. if (SPIN2 == 1){//spintable#2
  6929. if ((spintable1 == 1) || (spintable1 == 3) || (spintable1 == 4)){
  6930.  
  6931. SPINACC1 = 5 * 360 / 60;
  6932.  
  6933. spintable1_vel = spintable1_vel + SPINACC1*simdt;
  6934. spintable1_phi = spintable1_phi + spintable1_vel*simdt;
  6935. int multiplier1 = ((int)spintable1_phi) / 360;
  6936.  
  6937. if (spintable1_vel > (50 * 360 / 60))(spintable1_vel = (50 * 360 / 60)); //limit spped
  6938. if (spintable1_vel == (50 * 360 / 60)) spintable1 = 3;//speed achieved
  6939. spintable1_phi = spintable1_phi - (double)multiplier1 * 360;
  6940. MATRIX3 spintable1_rotmat = rotm(_V(0, 1, 0), spintable1_phi*RAD);
  6941. SetAttachmentParams(sat_attach2, pl2_ofs, _V(spintable1_rotmat.m21, spintable1_rotmat.m22, spintable1_rotmat.m23), _V(spintable1_rotmat.m31, spintable1_rotmat.m32, spintable1_rotmat.m33));
  6942.  
  6943.  
  6944. ATTACHMENTHANDLE ah = GetAttachmentHandle(false, 0);
  6945. OBJHANDLE hChild = GetAttachmentStatus(ah);
  6946. if (oapiIsVessel(hChild)) { // something is attached!
  6947. VESSEL *v = oapiGetVesselInterface(hChild);
  6948. // sprintf(oapiDebugString(), "%s is attached",
  6949. // v->GetName());
  6950. }
  6951. }
  6952.  
  6953.  
  6954.  
  6955.  
  6956. }
  6957.  
  6958.  
  6959.  
  6960. if (SPIN4 == 1){//spintable#2
  6961. if ((spintable4 == 1) || (spintable4 == 3) || (spintable4 == 4)){
  6962.  
  6963. SPINACC4 = 5 * 360 / 60;
  6964.  
  6965. spintable4_vel = spintable4_vel + SPINACC4*simdt;
  6966. spintable4_phi = spintable4_phi + spintable4_vel*simdt;
  6967. int multiplier4 = ((int)spintable4_phi) / 360;
  6968.  
  6969. if (spintable4_vel > (50 * 360 / 60))(spintable4_vel = (50 * 360 / 60)); //limit spped
  6970. if (spintable4_vel == (50 * 360 / 60)) spintable4 = 3;//speed achieved
  6971. spintable4_phi = spintable4_phi - (double)multiplier4 * 360;
  6972. MATRIX3 spintable4_rotmat = rotm(_V(0, 1, 0), spintable4_phi*RAD);
  6973. SetAttachmentParams(sat_attach3, pl3_ofs, _V(spintable4_rotmat.m21, spintable4_rotmat.m22, spintable4_rotmat.m23), _V(spintable4_rotmat.m31, spintable4_rotmat.m32, spintable4_rotmat.m33));
  6974.  
  6975. ATTACHMENTHANDLE ah = GetAttachmentHandle(false, 0);
  6976. OBJHANDLE hChild = GetAttachmentStatus(ah);
  6977. if (oapiIsVessel(hChild)) { // something is attached!
  6978. VESSEL *v = oapiGetVesselInterface(hChild);
  6979. // sprintf(oapiDebugString(), "%s is attached",
  6980. // v->GetName());
  6981. }
  6982. }
  6983.  
  6984.  
  6985. if (spintable4 == 4){ // satellite release so slow spintable to 0
  6986. spintable4_vel = spintable4_vel - SPINACC4*simdt;
  6987. if (spintable4_vel < 0)spintable4_vel = 0;
  6988. }
  6989.  
  6990. }
  6991.  
  6992.  
  6993. //mfd1pwr = (oapiGetMFDMode(MFD_RIGHT));
  6994.  
  6995.  
  6996. // if (mfd1pwr==1) SetAnimation(anim_mfd1, 1);
  6997. // if (mfd1pwr == 0) SetAnimation(anim_mfd1, 0);
  6998.  
  6999. if (SPIN5 == 1){//spintable#2
  7000. if ((spintable5 == 1) || (spintable5 == 3) || (spintable5 == 4)){
  7001.  
  7002. SPINACC5 = 5 * 360 / 60;
  7003.  
  7004. spintable5_vel = spintable5_vel + SPINACC5*simdt;
  7005. spintable5_phi = spintable5_phi + spintable5_vel*simdt;
  7006. int multiplier5 = ((int)spintable5_phi) / 360;
  7007.  
  7008. if (spintable5_vel > (50 * 360 / 60))(spintable5_vel = (50 * 360 / 60)); //limit spped
  7009. if (spintable5_vel == (50 * 360 / 60)) spintable5 = 3;//speed achieved
  7010. spintable5_phi = spintable5_phi - (double)multiplier5 * 360;
  7011. MATRIX3 spintable5_rotmat = rotm(_V(0, 1, 0), spintable5_phi*RAD);
  7012. SetAttachmentParams(sat_attach4, pl4_ofs, _V(spintable5_rotmat.m21, spintable5_rotmat.m22, spintable5_rotmat.m23), _V(spintable5_rotmat.m31, spintable5_rotmat.m32, spintable5_rotmat.m33));
  7013.  
  7014. ATTACHMENTHANDLE ah = GetAttachmentHandle(false, 0);
  7015. OBJHANDLE hChild = GetAttachmentStatus(ah);
  7016. if (oapiIsVessel(hChild)) { // something is attached!
  7017. VESSEL *v = oapiGetVesselInterface(hChild);
  7018. // sprintf(oapiDebugString(), "%s is attached",
  7019. // v->GetName());
  7020. }
  7021. }
  7022.  
  7023.  
  7024. if (spintable5 == 4){ // satellite release so slow spintable to 0
  7025. spintable5_vel = spintable5_vel - SPINACC5*simdt;
  7026. if (spintable5_vel < 0)spintable5_vel = 0;
  7027. }
  7028.  
  7029. }
  7030. //CAM MOVEMENT
  7031. for (int i = 0; i < 4; i++) {
  7032. if (bPLBCamPanLeft_Man) {
  7033. camYaw[PBCAMERA] = max(-MAX_PLB_CAM_PAN, camYaw[PBCAMERA] - CAMRATE*simdt);
  7034. cameraMoved = true;
  7035. bPLBCamPanLeft_Man = false;
  7036. }
  7037. else if (bPLBCamPanRight_Man) {
  7038. camYaw[PBCAMERA] = min(MAX_PLB_CAM_PAN, camYaw[PBCAMERA] + CAMRATE*simdt);
  7039. cameraMoved = true;
  7040. bPLBCamPanRight_Man = false;
  7041. }
  7042.  
  7043. if (bPLBCamTiltDown_Man) {
  7044. camPitch[PBCAMERA] = max(-MAX_PLB_CAM_TILT, camPitch[PBCAMERA] - CAMRATE*simdt);
  7045. cameraMoved = true;
  7046. bPLBCamTiltDown_Man = false;
  7047. }
  7048. else if (bPLBCamTiltUp_Man) {
  7049. camPitch[PBCAMERA] = min(MAX_PLB_CAM_TILT, camPitch[PBCAMERA] + CAMRATE*simdt);
  7050. cameraMoved = true;
  7051. bPLBCamTiltUp_Man = false;
  7052. }
  7053. //
  7054. if (bPLBCamTiltDown_Man) {
  7055. camPitch[PBCAMERA] = max(-MAX_PLB_CAM_TILT, camPitch[PBCAMERA] - CAMRATE*simdt);
  7056. cameraMoved = true;
  7057. bPLBCamTiltDown_Man = false;
  7058. }
  7059. else if (bPLBCamTiltUp_Man) {
  7060. camPitch[PBCAMERA] = min(MAX_PLB_CAM_TILT, camPitch[PBCAMERA] + CAMRATE*simdt);
  7061. cameraMoved = true;
  7062. bPLBCamTiltUp_Man = false;
  7063. }
  7064. }
  7065.  
  7066.  
  7067. if (ElbowCamPanLeft) {
  7068. camRMSElbow[PAN] = max(camRMSElbow[PAN] - CAMRATE*simdt, -MAX_PLB_CAM_PAN);
  7069. camera_moved = true;
  7070. ElbowCamPanLeft = false;
  7071. }
  7072. else if (ElbowCamPanRight) {
  7073. camRMSElbow[PAN] = min(camRMSElbow[PAN] + CAMRATE*simdt, MAX_PLB_CAM_PAN);
  7074. camera_moved = true;
  7075. ElbowCamPanRight = false;
  7076. }
  7077. if (ElbowCamTiltDown) {
  7078. camRMSElbow[TILT] = max(camRMSElbow[TILT] - CAMRATE*simdt, -MAX_PLB_CAM_TILT);
  7079. camera_moved = true;
  7080. ElbowCamTiltDown = false;
  7081. }
  7082. else if (ElbowCamTiltUp) {
  7083. camRMSElbow[TILT] = min(camRMSElbow[TILT] + CAMRATE*simdt, MAX_PLB_CAM_TILT);
  7084. camera_moved = true;
  7085. ElbowCamTiltUp = false;
  7086. }
  7087.  
  7088.  
  7089.  
  7090.  
  7091. if (cameraMoved) {
  7092. SetAnimationCameras();
  7093. cameraMoved = false;
  7094. }
  7095.  
  7096. if (cameraMFD[0] || cameraMFD[1] || cameraMFD[2])
  7097. {
  7098. VECTOR3 dir = camRMSElbowLoc[1] - camRMSElbowLoc[0];
  7099.  
  7100. if (Eq(dotp(dir, _V(0, -1, 0)), 1.0, 1e-4)) dir = _V(1.74532924314e-4, -0.999999984769, 0.0);
  7101. else if (Eq(dotp(dir, _V(0, 1, 0)), 1.0, 1e-4)) dir = _V(1.74532924314e-4, 0.999999984769, 0.0);
  7102.  
  7103. VECTOR3 orbiter_cam_rot = crossp(crossp(dir, _V(0, 1, 0)), dir);
  7104. orbiter_cam_rot /= length(orbiter_cam_rot);
  7105. if (orbiter_cam_rot.y < 0) orbiter_cam_rot = -orbiter_cam_rot;
  7106.  
  7107. double angle = -SignedAngle(orbiter_cam_rot, camRMSElbowLoc[2] - camRMSElbowLoc[0], dir);
  7108.  
  7109. cameraData[6].pos = camRMSElbowLoc[0];
  7110. cameraData[6].pitchAngle = -(atan2(sqrt(dir.z * dir.z + dir.x * dir.x), dir.y) - PI05) * DEG;
  7111. cameraData[6].yawAngle = (atan2(dir.z, dir.x) - PI05) * DEG;
  7112. cameraData[6].rotAngle = angle * DEG;
  7113.  
  7114. dir = arm_tip[1] - arm_tip[0];
  7115. // if camera is pointing straight up or down, make it slightly offset from (0,1,0) vector
  7116. if (Eq(dotp(dir, _V(0, -1, 0)), 1.0, 1e-4)) dir = _V(1.74532924314e-4, -0.999999984769, 0.0);
  7117. else if (Eq(dotp(dir, _V(0, 1, 0)), 1.0, 1e-4)) dir = _V(1.74532924314e-4, 0.999999984769, 0.0);
  7118.  
  7119. orbiter_cam_rot = crossp(crossp(dir, _V(0, 1, 0)), dir);
  7120. orbiter_cam_rot /= length(orbiter_cam_rot);
  7121. if (orbiter_cam_rot.y < 0) orbiter_cam_rot = -orbiter_cam_rot;
  7122.  
  7123. angle = -SignedAngle(orbiter_cam_rot, arm_tip[2] - arm_tip[0], dir);
  7124.  
  7125. cameraData[7].pos = arm_tip[3];
  7126. cameraData[7].pitchAngle = -(atan2(sqrt(dir.z * dir.z + dir.x * dir.x), dir.y) - PI05) * DEG;
  7127. cameraData[7].yawAngle = (atan2(dir.z, dir.x) - PI05) * DEG;
  7128. cameraData[7].rotAngle = angle * DEG;
  7129.  
  7130. if (cameraMFD[0])
  7131. {
  7132. cameraMFD[0]->SetCameraData(6, cameraData[6]);
  7133. cameraMFD[0]->SetCameraData(7, cameraData[7]);
  7134. }
  7135.  
  7136. if (cameraMFD[1])
  7137. {
  7138. cameraMFD[1]->SetCameraData(6, cameraData[6]);
  7139. cameraMFD[1]->SetCameraData(7, cameraData[7]);
  7140. }
  7141.  
  7142. if (cameraMFD[2])
  7143. {
  7144. cameraMFD[2]->SetCameraData(6, cameraData[6]);
  7145. cameraMFD[2]->SetCameraData(7, cameraData[7]);
  7146. }
  7147. }
  7148. //sprintf(oapiDebugString(), "MASS0 %5.3f MASS1 %5.3f MASS2 %5.3f MASS3 %5.3f pmassa %d pmassb %d pmassc %d pmassd %d", MASS0, MASS1, MASS2, MASS3, PMASS0, PMASS1, PMASS2, PMASS3);
  7149. //met
  7150.  
  7151. MET += simdt;
  7152.  
  7153.  
  7154. //getgmt
  7155. double fMJD = oapiGetSimMJD();
  7156.  
  7157. //SiameseCat edit: calculate GMT; leap year calculation accurate from 1970 to 2097 (I think)
  7158. //41317 = 1.1.1972
  7159. double fSimGMT = (fmod(fMJD - 41317, 365)) * 86400.0; //MJD 40952 == Jan. 1, 1970, 00:00:00
  7160. int Days = (int)(fMJD - 41317.0);
  7161. int leap_days = Days / 1460 + 1;
  7162. fSimGMT -= leap_days * 86400.0; //compensate for leap years
  7163.  
  7164. //sprintf(oapiDebugString(), "MET M: %d T: %d G: %d GMT: %0.4f ", METmode, Testmode, GMTmode, fSimGMT);
  7165.  
  7166. //met
  7167. timenew = floor(MET);
  7168. days = timenew / (24 * 3600);
  7169.  
  7170. timenew = timenew % (24 * 3600);
  7171. hours = timenew / 3600;
  7172.  
  7173.  
  7174. timenew %= 3600;
  7175. minutes = timenew / 60;
  7176.  
  7177. timenew %= 60;
  7178. seconds = timenew;
  7179.  
  7180. //gmt
  7181. fSimGMT = fSimGMT + simdt;
  7182. sGMTMillis = (short)fmod(fSimGMT * 1000.0, 1000.0);
  7183.  
  7184. lTime = (long)fSimGMT;
  7185. sGMTSeconds = lTime % 60;
  7186. lTime /= 60;
  7187. sGMTMinutes = lTime % 60;
  7188. lTime /= 60;
  7189. sGMTHours = lTime % 24;
  7190. lTime /= 24;
  7191. sGMTDays = lTime % 400 + 1;
  7192.  
  7193.  
  7194.  
  7195. if (METmode == 1)
  7196. {
  7197. // timenew = floor(MET);
  7198. // days = timenew / (24 * 3600);
  7199.  
  7200. // timenew = timenew % (24 * 3600);
  7201. // hours = timenew / 3600;
  7202.  
  7203.  
  7204. // timenew %= 3600;
  7205. // minutes = timenew / 60;
  7206.  
  7207. // timenew %= 60;
  7208. // seconds = timenew;
  7209.  
  7210.  
  7211.  
  7212. AFTtimer_state[8] = days / 100;//days1
  7213. AFTtimer_state[7] = (days / 10) % 10;//days2
  7214. AFTtimer_state[6] = days % 10;//days3
  7215. AFTtimer_state[5] = hours / 10;
  7216. AFTtimer_state[4] = hours % 10;
  7217. AFTtimer_state[3] = minutes / 10;
  7218. AFTtimer_state[2] = minutes % 10;
  7219. AFTtimer_state[1] = seconds / 10;
  7220. AFTtimer_state[0] = seconds % 10;
  7221. }
  7222.  
  7223. else if (Testmode == 1)
  7224. {
  7225.  
  7226. AFTtimer_state[8] = 8;//days1
  7227. AFTtimer_state[7] = 8;//days2
  7228. AFTtimer_state[6] = 8;//days3
  7229. AFTtimer_state[5] = 8;
  7230. AFTtimer_state[4] = 8;
  7231. AFTtimer_state[3] = 8;
  7232. AFTtimer_state[2] = 8;
  7233. AFTtimer_state[1] = 8;
  7234. AFTtimer_state[0] = 8;
  7235. }
  7236.  
  7237. else if (GMTmode == 1)
  7238. {
  7239.  
  7240. //fSimGMT = fSimGMT + simdt;
  7241. // sGMTMillis = (short)fmod(fSimGMT * 1000.0, 1000.0);
  7242.  
  7243. // lTime = (long)fSimGMT;
  7244. // sGMTSeconds = lTime % 60;
  7245. // lTime /= 60;
  7246. // sGMTMinutes = lTime % 60;
  7247. // lTime /= 60;
  7248. // sGMTHours = lTime % 24;
  7249. // lTime /= 24;
  7250. // sGMTDays = lTime % 400 + 1;
  7251.  
  7252. AFTtimer_state[8] = sGMTDays / 100;
  7253. AFTtimer_state[7] = (sGMTDays / 10) % 10;
  7254. AFTtimer_state[6] = sGMTDays % 10;
  7255. AFTtimer_state[5] = sGMTHours / 10;
  7256. AFTtimer_state[4] = sGMTHours % 10;
  7257. AFTtimer_state[3] = sGMTMinutes / 10;
  7258. AFTtimer_state[2] = sGMTMinutes % 10;
  7259. AFTtimer_state[1] = sGMTSeconds / 10;
  7260. AFTtimer_state[0] = sGMTSeconds % 10;
  7261. }
  7262.  
  7263.  
  7264.  
  7265. if (FMETmode == 1)
  7266. {
  7267. // timenew = floor(MET);
  7268. // days = timenew / (24 * 3600);
  7269.  
  7270. // timenew = timenew % (24 * 3600);
  7271. // hours = timenew / 3600;
  7272.  
  7273.  
  7274. // timenew %= 3600;
  7275. // minutes = timenew / 60;
  7276.  
  7277. // timenew %= 60;
  7278. // seconds = timenew;
  7279.  
  7280. Ftimer_state[8] = days / 100;//days1
  7281. Ftimer_state[7] = (days / 10) % 10;//days2
  7282. Ftimer_state[6] = days % 10;//days3
  7283. Ftimer_state[5] = hours / 10;
  7284. Ftimer_state[4] = hours % 10;
  7285. Ftimer_state[3] = minutes / 10;
  7286. Ftimer_state[2] = minutes % 10;
  7287. Ftimer_state[1] = seconds / 10;
  7288. Ftimer_state[0] = seconds % 10;
  7289.  
  7290.  
  7291. }
  7292.  
  7293.  
  7294. else if (FTestmode == 1)
  7295. {
  7296.  
  7297. Ftimer_state[8] = 8;//days1
  7298. Ftimer_state[7] = 8;//days2
  7299. Ftimer_state[6] = 8;//days3
  7300. Ftimer_state[5] = 8;
  7301. Ftimer_state[4] = 8;
  7302. Ftimer_state[3] = 8;
  7303. Ftimer_state[2] = 8;
  7304. Ftimer_state[1] = 8;
  7305. Ftimer_state[0] = 8;
  7306. }
  7307.  
  7308.  
  7309.  
  7310. else if (FGMTmode == 1)
  7311. {
  7312.  
  7313. // fSimGMT = fSimGMT + simdt;
  7314. // sGMTMillis = (short)fmod(fSimGMT * 1000.0, 1000.0);
  7315.  
  7316. // lTime = (long)fSimGMT;
  7317. // sGMTSeconds = lTime % 60;
  7318. // lTime /= 60;
  7319. // sGMTMinutes = lTime % 60;
  7320. // lTime /= 60;
  7321. // sGMTHours = lTime % 24;
  7322. // lTime /= 24;
  7323. // sGMTDays = lTime % 400 + 1;
  7324.  
  7325. Ftimer_state[8] = sGMTDays / 100;
  7326. Ftimer_state[7] = (sGMTDays / 10) % 10;
  7327. Ftimer_state[6] = sGMTDays % 10;
  7328. Ftimer_state[5] = sGMTHours / 10;
  7329. Ftimer_state[4] = sGMTHours % 10;
  7330. Ftimer_state[3] = sGMTMinutes / 10;
  7331. Ftimer_state[2] = sGMTMinutes % 10;
  7332. Ftimer_state[1] = sGMTSeconds / 10;
  7333. Ftimer_state[0] = sGMTSeconds % 10;
  7334. }
  7335.  
  7336. //front eventimer
  7337.  
  7338. // run timer
  7339. if (TimerReset == 1)
  7340. {
  7341. time = 0;
  7342. clk = 0.0;
  7343. }
  7344. else if (TimerSet == 1)
  7345. {
  7346. time = Minutes1set + (Minutes2set * 10) + (Minutes3set * 60) + (Minutes4set * 600);
  7347.  
  7348.  
  7349. // time = (int)Minutes_1.IsSet() + (2 * (int)Minutes_2.IsSet()) + (4 * (int)Minutes_4.IsSet()) + (8 * (int)Minutes_8.IsSet()) +
  7350. // (10 * (int)Minutes_10.IsSet()) + (20 * (int)Minutes_20.IsSet()) + (40 * (int)Minutes_40.IsSet());
  7351. // time *= 60;
  7352. // time += (int)Seconds_1.IsSet() + (2 * (int)Seconds_2.IsSet()) + (4 * (int)Seconds_4.IsSet()) + (8 * (int)Seconds_8.IsSet()) +
  7353. // (10 * (int)Seconds_10.IsSet()) + (20 * (int)Seconds_20.IsSet()) + (40 * (int)Seconds_40.IsSet());
  7354.  
  7355. TimerSet = 0;
  7356. }
  7357.  
  7358. else if (TimerStart ==1 )
  7359.  
  7360. {
  7361.  
  7362. clk += oapiGetSimStep();
  7363. int dt = static_cast<int>(clk);
  7364. clk -= dt;//CLK-DTtime -= dt
  7365. //sprintf(oapiDebugString(), "running time DTTIME: %d CLOCKTIME: %f ", dt, clk);
  7366.  
  7367. if (up)
  7368. {
  7369. time += dt;
  7370. if (time >= 3600) time -= 3600;// overflow at 60mins
  7371. }
  7372. else
  7373. {
  7374. time -= dt;
  7375. if (time <= 0)// reached 0, now count up
  7376. {
  7377. //time = -time;
  7378. time = 0;
  7379. }
  7380. }
  7381. }
  7382. else clk = 0.0;
  7383.  
  7384.  
  7385.  
  7386.  
  7387.  
  7388.  
  7389.  
  7390.  
  7391.  
  7392.  
  7393.  
  7394.  
  7395.  
  7396.  
  7397.  
  7398.  
  7399.  
  7400.  
  7401.  
  7402.  
  7403.  
  7404.  
  7405. // output
  7406. if (ETest == 1)
  7407. {
  7408. Etimer_state[3] = 8;
  7409. Etimer_state[2] = 8;
  7410. Etimer_state[1] = 8;
  7411. Etimer_state[0] = 8;
  7412.  
  7413. }
  7414. else
  7415. {
  7416.  
  7417. short sTimerMinutes = time / 60;
  7418. short sTimerSeconds = time % 60;
  7419.  
  7420. Etimer_state[3] = sTimerMinutes / 10;
  7421. Etimer_state[2] = sTimerMinutes % 10;
  7422. Etimer_state[1] = sTimerSeconds / 10;
  7423. Etimer_state[0] = sTimerSeconds % 10;
  7424. }
  7425.  
  7426. //aft eventimer
  7427.  
  7428. // run timer
  7429. if (TimerResetAFT == 1)
  7430. {
  7431. timeAFT = 0;
  7432. clkAFT = 0.0;
  7433. }
  7434. else if (TimerSetAFT == 1)
  7435. {
  7436. timeAFT = Minutes1setAFT + (Minutes2setAFT * 10) + (Minutes3setAFT * 60) + (Minutes4setAFT * 600);
  7437. //sprintf(oapiDebugString(), "timersetE: %f ", clkAFT);
  7438.  
  7439. // time = (int)Minutes_1.IsSet() + (2 * (int)Minutes_2.IsSet()) + (4 * (int)Minutes_4.IsSet()) + (8 * (int)Minutes_8.IsSet()) +
  7440. // (10 * (int)Minutes_10.IsSet()) + (20 * (int)Minutes_20.IsSet()) + (40 * (int)Minutes_40.IsSet());
  7441. // time *= 60;
  7442. // time += (int)Seconds_1.IsSet() + (2 * (int)Seconds_2.IsSet()) + (4 * (int)Seconds_4.IsSet()) + (8 * (int)Seconds_8.IsSet()) +
  7443. // (10 * (int)Seconds_10.IsSet()) + (20 * (int)Seconds_20.IsSet()) + (40 * (int)Seconds_40.IsSet());
  7444.  
  7445. TimerSetAFT = 0;
  7446. }
  7447.  
  7448. else if (TimerStartAFT == 1)
  7449.  
  7450. {
  7451.  
  7452. clkAFT += oapiGetSimStep();
  7453. int dtAFT = static_cast<int>(clkAFT);
  7454. clkAFT -= dtAFT;//CLK-DTtime -= dt
  7455.  
  7456.  
  7457. if (upAFT)
  7458. {
  7459. //sprintf(oapiDebugString(), "running timeup DTTIME: %d CLOCKTIME: %f ", dtAFT, clkAFT);
  7460. timeAFT += dtAFT;
  7461. if (timeAFT >= 3600) timeAFT -= 3600;// overflow at 60mins
  7462. }
  7463. else
  7464. {
  7465. //sprintf(oapiDebugString(), "running timedown DTTIME: %d CLOCKTIME: %f ", dtAFT, clkAFT);
  7466. timeAFT -= dtAFT;
  7467. if (timeAFT <= 0)// reached 0, now count up
  7468. {
  7469. //time = -time;
  7470. timeAFT = 0;
  7471. }
  7472. }
  7473. }
  7474. else clkAFT = 0.0;
  7475.  
  7476.  
  7477.  
  7478.  
  7479.  
  7480.  
  7481.  
  7482.  
  7483.  
  7484.  
  7485.  
  7486.  
  7487.  
  7488.  
  7489.  
  7490.  
  7491.  
  7492.  
  7493.  
  7494.  
  7495.  
  7496.  
  7497. // output
  7498. if (ETestAFT == 1)
  7499. {
  7500. EtimerAFT_state[3] = 8;
  7501. EtimerAFT_state[2] = 8;
  7502. EtimerAFT_state[1] = 8;
  7503. EtimerAFT_state[0] = 8;
  7504.  
  7505. }
  7506. else
  7507. {
  7508.  
  7509. short sTimerMinutes = timeAFT / 60;
  7510. short sTimerSeconds = timeAFT % 60;
  7511.  
  7512. EtimerAFT_state[3] = sTimerMinutes / 10;
  7513. EtimerAFT_state[2] = sTimerMinutes % 10;
  7514. EtimerAFT_state[1] = sTimerSeconds / 10;
  7515. EtimerAFT_state[0] = sTimerSeconds % 10;
  7516. }
  7517.  
  7518. //if (firstStep) {
  7519. // firstStep = false;
  7520.  
  7521. //}
  7522.  
  7523. //kuelevation
  7524. char cbuf[8];
  7525. //sprintf_s(cbuf, 8, "%05.1f", fabs(elevation));
  7526. //sprintf(oapiDebugString(), "%05.1f %05.1f", fabs(elevation), KURATE);
  7527. //if (elevation > 90) elevation = 90.0;
  7528. //if (elevation < -90) elevation = -90.0;
  7529.  
  7530. // if ((KUEL == 2)&&(elevation<90)) elevation = elevation + KURATE;
  7531. // if ((KUEL == 1) && (elevation > -90)) elevation = elevation - KURATE;
  7532.  
  7533.  
  7534. /*
  7535. for (int i = 3, j = 0; i >= 0; i--, j++)
  7536. {
  7537. if (cbuf[j] == '.') j++;
  7538.  
  7539. next_state[i] = cbuf[j] - 48 + _7SD_STATE_NUM0_DOTOFF;
  7540. }
  7541.  
  7542. next_state[1] -= _7SD_STATE_NUM0_DOTON;
  7543.  
  7544. if (elevation > 0) next_state[4] = _7SD_STATE_SIGN2PLUS;
  7545. else if (elevation < 0) next_state[4] = _7SD_STATE_SIGN2MINUS;
  7546. else next_state[4] = _7SD_STATE_SIGN2OFF;
  7547.  
  7548. */
  7549.  
  7550.  
  7551. //SetAnimation(anim_HUDpower, 1);
  7552.  
  7553.  
  7554. //sprintf(oapiDebugString(), "%d ", currentHudMode);
  7555.  
  7556. if (ADTA_proc==1)SetAnimation(anim_ATDADeploy, 1);
  7557. if (ADTA_proc == 0)SetAnimation(anim_ATDADeploy, 0);
  7558.  
  7559. if (currentHudMode==0)SetAnimation(anim_HUDpower, 1);//hud is oo
  7560. if (currentHudMode != 0)SetAnimation(anim_HUDpower, 0);//hud is off
  7561.  
  7562.  
  7563. if (flood2_status == 0)SetAnimation(anim_floodportaft, 1);
  7564. if (flood2_status == 1)SetAnimation(anim_floodportaft, 0);
  7565.  
  7566. if (flood1_status == 0)SetAnimation(anim_floodstbdaft, 1);
  7567. if (flood1_status == 1)SetAnimation(anim_floodstbdaft, 0);
  7568.  
  7569. if (flood4_status == 0)SetAnimation(anim_floodportmid, 1);
  7570. if (flood4_status == 1)SetAnimation(anim_floodportmid, 0);
  7571.  
  7572. if (flood3_status == 0)SetAnimation(anim_floodstbdmid, 1);
  7573. if (flood3_status == 1)SetAnimation(anim_floodstbdmid, 0);
  7574.  
  7575. if (flood6_status == 0)SetAnimation(anim_floodportfwd, 1);
  7576. if (flood6_status == 1)SetAnimation(anim_floodportfwd, 0);
  7577.  
  7578. if (flood5_status == 0)SetAnimation(anim_floodstbdfwd, 1);
  7579. if (flood5_status == 1)SetAnimation(anim_floodstbdfwd, 0);
  7580.  
  7581. if (aft_light_status == 0)SetAnimation(anim_fwdlight, 0);
  7582. if (aft_light_status == 1)SetAnimation(anim_fwdlight, 1);
  7583.  
  7584.  
  7585. if (docklight_status == 1)SetAnimation(anim_docklight, .5);
  7586. if (docklight_status == 2)SetAnimation(anim_docklight, 0);
  7587. if (docklight_status == 0)SetAnimation(anim_docklight, 1);
  7588.  
  7589.  
  7590.  
  7591. if ((flood1_status == 0) || (flood2_status == 0) || (flood3_status == 0) || (flood4_status == 0) || (flood5_status == 0) || (flood6_status == 0))SetAnimation(anim_floodon, 1);
  7592. if ((flood1_status == 1) || (flood2_status == 1) || (flood3_status == 1) || (flood4_status == 1) || (flood5_status == 1) || (flood6_status == 1))SetAnimation(anim_floodon, 0);
  7593.  
  7594. if (ADTA_proc <= 0)SetAnimation(anim_ATDADeploy, 0);
  7595. if (ADTA_proc >= 1)SetAnimation(anim_ATDADeploy, 1);
  7596.  
  7597.  
  7598. RCSQTY = ((fuelmass/ ORBITER_MAX_PROPELLANT_MASS)*100);
  7599. fuelmass = GetPropellantMass(ph_oms);
  7600. if (RCSQTY = 100)RCSQTY = 99;
  7601.  
  7602. //RCS
  7603. if ( GetThrusterGroupLevel(THGROUP_ATT_PITCHUP)>0)SetAnimation(anim_pitchup, 1);
  7604. else SetAnimation(anim_pitchup, 0);
  7605. if (GetThrusterGroupLevel(THGROUP_ATT_PITCHDOWN) > 0)SetAnimation(anim_pitchdown, 1);
  7606. else SetAnimation(anim_pitchdown, 0);
  7607.  
  7608. if (GetThrusterGroupLevel(THGROUP_ATT_BANKLEFT) > 0)SetAnimation(anim_rollleft, 1);
  7609. else SetAnimation(anim_rollleft, 0);
  7610. if (GetThrusterGroupLevel(THGROUP_ATT_BANKRIGHT) > 0)SetAnimation(anim_rollright, 1);
  7611. else SetAnimation(anim_rollright, 0);
  7612.  
  7613. if (GetThrusterGroupLevel(THGROUP_ATT_YAWLEFT) > 0)SetAnimation(anim_yawleft, 1);
  7614. else SetAnimation(anim_yawleft, 0);
  7615. if (GetThrusterGroupLevel(THGROUP_ATT_YAWRIGHT) > 0)SetAnimation(anim_yawright, 1);
  7616. else SetAnimation(anim_yawright, 0);
  7617. }
  7618. // --------------------------------------------------------------
  7619. // Respond to playback event
  7620. // --------------------------------------------------------------
  7621. bool Atlantis::clbkPlaybackEvent (double simt, double event_t, const char *event_type, const char *event)
  7622. {
  7623. if (!_stricmp (event_type, "JET")) {
  7624. if (!_stricmp (event, "SRB")) {
  7625. bManualSeparate = true;
  7626. return true;
  7627. }
  7628. else if (!_stricmp (event, "ET")) {
  7629. bManualSeparate = true;
  7630. return true;
  7631. }
  7632. } else if (!_stricmp (event_type, "STATUS")) {
  7633.  
  7634. } else if (!_stricmp (event_type, "CARGODOOR")) {
  7635. if (!_stricmp(event, "OPEN")) plop->SetDoorAction (AnimState::OPENING, true);
  7636. else if (!_stricmp(event, "CLOSE")) plop->SetDoorAction (AnimState::CLOSING, true);
  7637. else if (!_stricmp(event, "ISOPEN")) plop->SetDoorAction (AnimState::OPEN, true);
  7638. else if (!_stricmp(event, "ISCLOSED")) plop->SetDoorAction (AnimState::CLOSED, true);
  7639. return true;
  7640. } else if (!_stricmp (event_type, "GEAR")) {
  7641. OperateLandingGear (!_stricmp (event, "UP") ? AnimState::CLOSING : AnimState::OPENING);
  7642. return true;
  7643. }
  7644. else if (!_stricmp (event_type,"SPEEDBRAKE")) {
  7645. OperateSpeedbrake (!_stricmp (event, "CLOSE") ? AnimState::CLOSING : AnimState::OPENING);
  7646. return true;
  7647. }
  7648. else if (!_stricmp (event_type, "KUBAND")) {
  7649. plop->SetKuAntennaAction (!_stricmp (event, "CLOSE") ? AnimState::CLOSING : AnimState::OPENING);
  7650. return true;
  7651. }
  7652.  
  7653. return false;
  7654. }
  7655.  
  7656. // --------------------------------------------------------------
  7657. // Atlantis mesh loaded
  7658. // --------------------------------------------------------------
  7659. void Atlantis::clbkVisualCreated (VISHANDLE _vis, int refcount)
  7660. {
  7661. if (refcount > 1) return; // we don't support more than one visual per object
  7662. vis = _vis;
  7663.  
  7664. // make sure the RMS AND OBSS attachment point is in sync with the animation state of the visual
  7665.  
  7666. xp0 = arm_tip[1] - arm_tip[0]; normalise(xp0);
  7667. xr0 = arm_tip[2] - arm_tip[0]; normalise(xr0);
  7668. SetAttachmentParams(rms_attach, arm_tip[0], xp0, xr0);
  7669.  
  7670.  
  7671. //SetAttachmentParams (rms_attach, arm_tip[0], arm_tip[1]-arm_tip[0], arm_tip[2]-arm_tip[0]);
  7672. SetAttachmentParams(OBSS_attach, armobss_tip[0], armobss_tip[1] - armobss_tip[0], armobss_tip[2] - armobss_tip[0]);
  7673.  
  7674. }
  7675.  
  7676. // --------------------------------------------------------------
  7677. // Atlantis mesh discarded
  7678. // --------------------------------------------------------------
  7679. void Atlantis::clbkVisualDestroyed (VISHANDLE _vis, int refcount)
  7680. {
  7681. if (vis == _vis) vis = NULL;
  7682. }
  7683.  
  7684. // --------------------------------------------------------------
  7685. // Update mesh animation state
  7686. // --------------------------------------------------------------
  7687. void Atlantis::clbkAnimate (double simt)
  7688. {
  7689. UpdateMesh ();
  7690. }
  7691. void Atlantis::RedrawPanel_MFDButton(SURFHANDLE surf, int mfd)
  7692. {
  7693.  
  7694. // oapi::Font* font3 = oapiCreateFont(-11, true, "Arial");
  7695. //g_Param.font[0] = CreateFont (-11, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 0, "Arial");
  7696. oapi::Sketchpad* skp = oapiGetSketchpad(surf);
  7697. //skp->SetTextColor(BBGGRR)
  7698. skp->SetFont(Atlantis::font3);
  7699. skp->SetTextColor(0x00FF00);
  7700. skp->SetTextAlign(oapi::Sketchpad::CENTER);
  7701.  
  7702.  
  7703.  
  7704.  
  7705.  
  7706.  
  7707.  
  7708.  
  7709. if (oapiGetMFDMode(mfd) == MFD_NONE) {
  7710. RECT r = { 0, 0, 255, 13 };
  7711.  
  7712. //skp->Rectangle(0, 0, 255, 13);
  7713. //skp->SetBrush(gBlackBrush); // Enable shape filling
  7714. auto Old = skp->SetPen(NULL); // Disable outline
  7715. skp->Rectangle(0, 0, 255, 13);
  7716. skp->SetBrush(NULL); // Disable shape filling
  7717. skp->SetPen(Old);
  7718. }
  7719. else { // MFD powered on
  7720.  
  7721. const char* label;
  7722. int x = 24;
  7723. for (int bt = 0; bt < 5; bt++) {
  7724. if (label = oapiMFDButtonLabel(mfd, bt)) {
  7725. skp->Text(x, 1, label, strlen(label));
  7726. x += 42;
  7727. }
  7728. else break;
  7729. }
  7730. skp->Text(234, 1, "PG", 2);
  7731.  
  7732. }
  7733.  
  7734. oapiReleaseSketchpad(skp);
  7735. }
  7736.  
  7737.  
  7738. //}
  7739. // --------------------------------------------------------------
  7740. // Respond to MFD mode change
  7741. // --------------------------------------------------------------
  7742. void Atlantis::clbkMFDMode (int mfd, int mode)
  7743. {
  7744. oapiVCTriggerRedrawArea (-1, AID_CDR1_BUTTONS+mfd-MFD_LEFT);
  7745. }
  7746.  
  7747. // --------------------------------------------------------------
  7748. // Respond to RCS mode change
  7749. // --------------------------------------------------------------
  7750. void Atlantis::clbkRCSMode (int mode)
  7751. {
  7752. SetADCtrlMode (mode ? 0 : 7);
  7753. // turn off aerodynamic control surfaces if RCS is enabled
  7754. }
  7755.  
  7756. // --------------------------------------------------------------
  7757. // Load generic glass cockpit mode
  7758. // --------------------------------------------------------------
  7759. bool Atlantis::clbkLoadGenericCockpit ()
  7760. {
  7761. //SetCameraOffset (_V(-0.67,2.55,14.0));
  7762. //SetCameraDefaultDirection (_V(0,0,1));
  7763. return true;
  7764. }
  7765.  
  7766. // --------------------------------------------------------------
  7767. // register VC buttons for the 2 commander MFDs
  7768. // (accessible from commander position only)
  7769. // --------------------------------------------------------------
  7770. void Atlantis::RegisterVC_CdrMFD ()
  7771. {
  7772. // activate MFD function buttons
  7773. oapiVCSetAreaClickmode_Quadrilateral(AID_CDR1_BUTTONS, _V(-.338, 2.1229, 14.705), _V(-.157, 2.1229, 14.705), _V(-.338, 2.1097, 14.702), _V(-.157, 2.1097, 14.402));
  7774. //oapiVCSetAreaClickmode_Quadrilateral(AID_CDR2_BUTTONS, _V(-0.6546, 2.0091, 14.65), _V(-0.4736, 2.0091, 14.65), _V(-0.6546, 1.9881, 14.65), _V(-0.4736, 1.9881, 14.65));
  7775. //_V(-.338, 2.1229, 14.705), _V(-.157, 2.1229, 14.705), _V(-.338, 2.1097, 14.702), _V(-.157, 2.1097, 14.402));
  7776. // D. Beachy: register+activate MFD power buttons
  7777. const double powerButtonRadius = 0.01; // radius of power button on each MFD
  7778. oapiVCRegisterArea (AID_CDR1_PWR, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY);
  7779. // oapiVCRegisterArea (AID_CDR2_PWR, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY);
  7780. oapiVCSetAreaClickmode_Spherical(AID_CDR1_PWR, _V(-0.110675, 1.801403 , 14.44215), powerButtonRadius);
  7781. // oapiVCSetAreaClickmode_Spherical(AID_CDR2_PWR, _V(-0.680, 2.0107, 14.65), powerButtonRadius);
  7782. // register+activate MFD brightness buttons
  7783. oapiVCRegisterArea (AID_CDR1_BRT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY);
  7784. //oapiVCRegisterArea (AID_CDR2_BRT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY);
  7785. oapiVCSetAreaClickmode_Quadrilateral(AID_CDR1_BRT, _V(-0.373, 2.1138, 14.691), _V(-0.340, 2.1138, 14.691), _V(-0.373, 2.0777, 14.683), _V(-0.340, 2.0777, 14.683));
  7786. //oapiVCSetAreaClickmode_Quadrilateral(AID_CDR2_BRT, _V(-0.459, 2.0221, 14.649), _V(-0.444, 2.0221, 14.649), _V(-0.459, 2.0063, 14.645), _V(-0.444, 2.0063, 14.645));
  7787. oapiVCRegisterArea(AID_FRTMINUTE2UP, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7788. oapiVCSetAreaClickmode_Spherical(AID_FRTMINUTE2UP, _V(-0.008, 1.72, 14.368), powerButtonRadius);
  7789. oapiVCRegisterArea(AID_FRTMINUTE2DWN, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7790. oapiVCSetAreaClickmode_Spherical(AID_FRTMINUTE2DWN, _V(-0.008, 1.692, 14.344), powerButtonRadius);
  7791. oapiVCRegisterArea(AID_FRTMINUTE1UP, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7792. oapiVCSetAreaClickmode_Spherical(AID_FRTMINUTE1UP, _V(0.014, 1.7185, 14.368), powerButtonRadius);
  7793.  
  7794. oapiVCRegisterArea(AID_FRTMINUTE1DWN, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7795. oapiVCSetAreaClickmode_Spherical(AID_FRTMINUTE1DWN, _V(0.014, 1.692, 14.344), powerButtonRadius);
  7796.  
  7797. oapiVCRegisterArea(AID_FRTSECOND1DWN, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7798. oapiVCSetAreaClickmode_Spherical(AID_FRTSECOND1DWN, _V(0.059, 1.692, 14.344), powerButtonRadius);
  7799.  
  7800. oapiVCRegisterArea(AID_FRTSECOND2DWN, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7801. oapiVCSetAreaClickmode_Spherical(AID_FRTSECOND2DWN, _V(0.037, 1.692, 14.344), powerButtonRadius);
  7802.  
  7803. oapiVCRegisterArea(AID_FRTSECOND1UP, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7804. oapiVCSetAreaClickmode_Spherical(AID_FRTSECOND1UP, _V(0.059, 1.7185, 14.368), powerButtonRadius);
  7805.  
  7806. oapiVCRegisterArea(AID_FRTSECOND2UP, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7807. oapiVCSetAreaClickmode_Spherical(AID_FRTSECOND2UP, _V(0.037, 1.7185, 14.368), powerButtonRadius);
  7808.  
  7809. //FRONTTIMER
  7810. oapiVCRegisterArea(AID_FRTEVENTSET, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  7811. oapiVCRegisterArea(AID_FRTEVENTRESET, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  7812. oapiVCSetAreaClickmode_Spherical(AID_FRTEVENTSET, _V(.102, 1.692, 14.338), .01);//-1.0401, 2.8382, 12.443
  7813. oapiVCSetAreaClickmode_Spherical(AID_FRTEVENTRESET, _V(.102, 1.682, 14.327), .01);//-1.0401, 2.8382, 12.443
  7814. oapiVCRegisterArea(AID_FRTEVENTSTART, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  7815. oapiVCRegisterArea(AID_FRTEVENTSTOP, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  7816. oapiVCSetAreaClickmode_Spherical(AID_FRTEVENTSTART, _V(-.074, 1.694, 14.34), .01);//-1.0401, 2.8382, 12.443
  7817. oapiVCSetAreaClickmode_Spherical(AID_FRTEVENTSTOP, _V(-.074, 1.682, 14.324), .01);//-1.0401, 2.8382, 12.443
  7818. oapiVCRegisterArea(AID_FRTEVENTUP, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7819. oapiVCRegisterArea(AID_FRTEVENTDOWN, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7820. oapiVCRegisterArea(AID_FRTEVENTTEST, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  7821. oapiVCSetAreaClickmode_Spherical(AID_FRTEVENTUP, _V(-.105, 1.694, 14.34), .01);//-1.0401, 2.8382, 12.443
  7822. oapiVCSetAreaClickmode_Spherical(AID_FRTEVENTDOWN, _V(-.105, 1.687, 12.433), .01);//-1.0401, 2.8382, 12.443
  7823. oapiVCSetAreaClickmode_Spherical(AID_FRTEVENTTEST, _V(-.105, 1.679, 14.324), .01);//-1.0401, 2.8382, 12.443
  7824.  
  7825. }
  7826.  
  7827. // --------------------------------------------------------------
  7828. // register VC buttons for the 2 pilot MFDs
  7829. // (accessible from pilot position only)
  7830. // --------------------------------------------------------------
  7831. void Atlantis::RegisterVC_PltMFD ()
  7832. {
  7833. // activate MFD function buttons
  7834. oapiVCSetAreaClickmode_Quadrilateral(AID_PLT1_BUTTONS, _V(.157, 2.1229, 14.705), _V(.338, 2.1229, 14.705), _V(.157, 2.1097, 14.702), _V(.338, 2.1097, 14.402));
  7835. // oapiVCSetAreaClickmode_Quadrilateral (AID_PLT2_BUTTONS, _V(0.7461,2.0091,14.65), _V(0.9271,2.0091,14.65), _V(0.7461,1.9881,14.65), _V(0.9271,1.9881,14.65));
  7836.  
  7837. // D. Beachy: register+activate MFD power buttons
  7838. const double powerButtonRadius = 0.01; // radius of power button on each MFD
  7839. oapiVCRegisterArea (AID_PLT1_PWR, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY);
  7840. // oapiVCRegisterArea (AID_PLT2_PWR, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY);
  7841. oapiVCSetAreaClickmode_Spherical(AID_PLT1_PWR, _V(0.069895, 1.801834, 14.44158), powerButtonRadius);
  7842. // oapiVCSetAreaClickmode_Spherical(AID_PLT2_PWR, _V(0.720, 2.0147, 14.65), powerButtonRadius);
  7843.  
  7844. oapiVCRegisterArea(AID_FRTMINUTE2UP, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7845. oapiVCSetAreaClickmode_Spherical(AID_FRTMINUTE2UP, _V(-0.008, 1.72, 14.368), powerButtonRadius);
  7846. oapiVCRegisterArea(AID_FRTMINUTE2DWN, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7847. oapiVCSetAreaClickmode_Spherical(AID_FRTMINUTE2DWN, _V(-0.008, 1.692, 14.344), powerButtonRadius);
  7848. oapiVCRegisterArea(AID_FRTMINUTE1UP, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7849. oapiVCSetAreaClickmode_Spherical(AID_FRTMINUTE1UP, _V(0.014, 1.7185, 14.368), powerButtonRadius);
  7850.  
  7851. oapiVCRegisterArea(AID_FRTMINUTE1DWN, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7852. oapiVCSetAreaClickmode_Spherical(AID_FRTMINUTE1DWN, _V(0.014, 1.692, 14.344), powerButtonRadius);
  7853.  
  7854. oapiVCRegisterArea(AID_FRTSECOND1DWN, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7855. oapiVCSetAreaClickmode_Spherical(AID_FRTSECOND1DWN, _V(0.059, 1.692, 14.344), powerButtonRadius);
  7856.  
  7857. oapiVCRegisterArea(AID_FRTSECOND2DWN, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7858. oapiVCSetAreaClickmode_Spherical(AID_FRTSECOND2DWN, _V(0.037, 1.692, 14.344), powerButtonRadius);
  7859.  
  7860. oapiVCRegisterArea(AID_FRTSECOND1UP, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7861. oapiVCSetAreaClickmode_Spherical(AID_FRTSECOND1UP, _V(0.059, 1.7185, 14.368), powerButtonRadius);
  7862.  
  7863. oapiVCRegisterArea(AID_FRTSECOND2UP, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7864. oapiVCSetAreaClickmode_Spherical(AID_FRTSECOND2UP, _V(0.037, 1.7185, 14.368), powerButtonRadius);
  7865.  
  7866.  
  7867.  
  7868. // register+activate MFD brightness buttons
  7869. oapiVCRegisterArea (AID_PLT1_BRT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY);
  7870. // oapiVCRegisterArea (AID_PLT2_BRT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY);
  7871. oapiVCSetAreaClickmode_Quadrilateral(AID_PLT1_BRT, _V(.111, 2.1138, 14.691), _V(0.157, 2.1138, 14.691), _V(.111, 2.0777, 14.683), _V(0.157, 2.0777, 14.683));
  7872. //oapiVCSetAreaClickmode_Quadrilateral(AID_PLT2_BRT, _V(0.941, 2.0221, 14.649), _V(0.956, 2.0221, 14.649), _V(0.941, 1.9881, 14.65), _V(0.956, 1.9881, 14.65));
  7873. //FRONTTIMER
  7874. oapiVCRegisterArea(AID_FRTEVENTSET, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  7875. oapiVCRegisterArea(AID_FRTEVENTRESET, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  7876. oapiVCSetAreaClickmode_Spherical(AID_FRTEVENTSET, _V(.102, 1.692, 14.338), .01);//-1.0401, 2.8382, 12.443
  7877. oapiVCSetAreaClickmode_Spherical(AID_FRTEVENTRESET, _V(.102, 1.682, 14.327), .01);//-1.0401, 2.8382, 12.443
  7878. oapiVCRegisterArea(AID_FRTEVENTSTART, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  7879. oapiVCRegisterArea(AID_FRTEVENTSTOP, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  7880. oapiVCSetAreaClickmode_Spherical(AID_FRTEVENTSTART, _V(-.074, 1.694, 14.34), .01);//-1.0401, 2.8382, 12.443
  7881. oapiVCSetAreaClickmode_Spherical(AID_FRTEVENTSTOP, _V(-.074, 1.682, 14.324), .01);//-1.0401, 2.8382, 12.443
  7882. oapiVCRegisterArea(AID_FRTEVENTUP, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7883. oapiVCRegisterArea(AID_FRTEVENTDOWN, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7884. oapiVCRegisterArea(AID_FRTEVENTTEST, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  7885. oapiVCSetAreaClickmode_Spherical(AID_FRTEVENTUP, _V(-.105, 1.694, 14.34), .01);//-1.0401, 2.8382, 12.443
  7886. oapiVCSetAreaClickmode_Spherical(AID_FRTEVENTDOWN, _V(-.105, 1.687, 12.433), .01);//-1.0401, 2.8382, 12.443
  7887. oapiVCSetAreaClickmode_Spherical(AID_FRTEVENTTEST, _V(-.105, 1.679, 14.324), .01);//-1.0401, 2.8382, 12.443
  7888. //FRONT MET
  7889. oapiVCRegisterArea(AID_METTIMERGMT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7890. oapiVCRegisterArea(AID_METTIMERMET, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7891. oapiVCRegisterArea(AID_METTIMERTEST, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  7892. oapiVCSetAreaClickmode_Spherical(AID_METTIMERGMT, _V(.512, 2.722, 14.294), .01);//-1.0401, 2.8382, 12.443
  7893. oapiVCSetAreaClickmode_Spherical(AID_METTIMERMET, _V(.512, 2.714, 14.294), .01);//-1.0401, 2.8382, 12.443
  7894. oapiVCSetAreaClickmode_Spherical(AID_METTIMERTEST, _V(.512, 2.704, 14.294), .01);//-1.0401, 2.8382, 12.443
  7895. }
  7896.  
  7897. // --------------------------------------------------------------
  7898. // register VC buttons for the 5 MFDs on the central panel
  7899. // (accessible from commander and pilot positions)
  7900. // --------------------------------------------------------------
  7901. void Atlantis::RegisterVC_CntMFD ()
  7902. {
  7903. // activate MFD function buttons
  7904. oapiVCSetAreaClickmode_Quadrilateral(AID_MFD1_BUTTONS, _V(-0.090, 1.8744, 14.634), _V(0.090, 1.8744, 14.634), _V(-0.090, 1.8652, 14.633), _V(0.090, 1.8652, 14.633));
  7905.  
  7906.  
  7907. // D. Beachy: register+activate MFD power buttons
  7908. const double powerButtonRadius = 0.01; // radius of power button on each MFD
  7909. oapiVCRegisterArea (AID_MFD1_PWR, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY);
  7910.  
  7911. oapiVCSetAreaClickmode_Spherical(AID_MFD1_PWR, _V(-0.02039 , 1.801834 , 14.44179), powerButtonRadius);
  7912.  
  7913.  
  7914. // register+activate MFD brightness buttons
  7915. oapiVCRegisterArea (AID_MFD1_BRT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY);
  7916.  
  7917. oapiVCSetAreaClickmode_Quadrilateral(AID_MFD1_BRT, _V(-0.143, 1.8647, 14.63), _V(-0.090, 1.8647, 14.63), _V(-0.143, 1.8297, 14.62), _V(-0.090, 1.8297, 14.62));
  7918.  
  7919. // oapiVCRegisterArea(AID_FRTMINUTE2UP, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7920. // oapiVCSetAreaClickmode_Spherical(AID_FRTMINUTE2UP, _V(-0.008, 1.7185, 14.368), powerButtonRadius);
  7921.  
  7922. // oapiVCRegisterArea(AID_FRTMINUTE2DWN, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7923. // oapiVCSetAreaClickmode_Spherical(AID_FRTMINUTE2DWN, _V(-0.008, 1.69, 14.368), powerButtonRadius);
  7924.  
  7925. }
  7926.  
  7927. // --------------------------------------------------------------
  7928. // register VC buttons for the aft MFD at the starbord panel
  7929. // (accessible from payload control position only)
  7930. // --------------------------------------------------------------
  7931. void Atlantis::RegisterVC_AftMFD()
  7932. {
  7933. //SURFHANDLE tex1 = oapiGetTextureHandle(hOrbiterVCMesh, 20);
  7934. //oapiVCRegisterArea(AID_MFDA_BUTTONS, _R(0, 127, 255, 140), PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_LBPRESSED | PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1);
  7935.  
  7936. // SURFHANDLE tex1 = oapiGetTextureHandle (hOrbiterVCMesh, 20);
  7937. // activate MFD function buttons
  7938. oapiVCSetAreaClickmode_Quadrilateral(AID_MFDSIDE_BUTTONS, _V(1.4005, 2.2204, 13.465), _V(1.4005, 2.2189, 13.282), _V(1.3931, 2.2195, 13.465), _V(1.3931, 2.1426, 13.282));
  7939.  
  7940. //oapiVCSetAreaClickmode_Quadrilateral(AID_CCTV1_BUTTONS, _V(-.876, 2.92, 12.284), _V(-.876, 2.92, 12.395), _V(-.876, 2.910, 12.284), _V(-.876, 2.910, 12.395));
  7941. oapiVCSetAreaClickmode_Quadrilateral(AID_CCTV2_BUTTONS, _V(-0.98, 2.702, 12.419), _V(-0.877, 2.702, 12.316), _V(-0.98, 2.694, 12.42), _V(-0.877, 2.694, 12.318));
  7942. oapiVCSetAreaClickmode_Quadrilateral(AID_CCTV1_BUTTONS, _V(-1.011, 2.909, 12.39062), _V(-0.904, 2.909, 12.285), _V(-1.01, 2.901, 12.392), _V(-0.903, 2.901, 12.288));
  7943. // oapiVCSetAreaClickmode_Quadrilateral(AID_CCTV1_BUTTONS, _V(-.906, 2.905935, 12.39062), _V(-1.009214, 2.906741, 12.285), _V(-0.903, 2.913594, 12.392), _V(-1.007, 2.914401, 12.288));
  7944. //-0.956014 2.914348 12.3912 -0.956014 2.906688 12.39282 -0.956014 2.913542 12.28598 -0.956014 2.905882 12.2876 -1.009228 2.914146 12.2876
  7945. //oapiVCSetAreaClickmode_Quadrilateral(AID_CCTV1_BUTTONS, _V(-1.0, 2.9, 12.392), _V(-.9, 2.5, 12.288), _V(-1.0, 2.9, 12.392), _V(-.9, 2.5, 12.288)); 2.905935 2.913594
  7946. // D. Beachy: register+activate MFD power buttons
  7947. const double powerButtonRadius = 0.01; // radius of power button on each MFD
  7948. oapiVCRegisterArea(AID_MFDSIDE_PWR, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7949.  
  7950. oapiVCRegisterArea(AID_MFDSIDE_PWR, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7951. oapiVCSetAreaClickmode_Spherical(AID_MFDSIDE_PWR, _V(1.2789, 2.138, 13.33), powerButtonRadius);
  7952.  
  7953. oapiVCSetAreaClickmode_Spherical(AID_CCTV1_PWR, _V(-1.05952, 3.050369, 12.416), .01);//-1.079, 3.0613, 12.412
  7954. oapiVCSetAreaClickmode_Spherical(AID_CCTV2_PWR, _V(-1.034025, 2.838804, 12.433), .01);//-1.0401, 2.8382, 12.443
  7955.  
  7956.  
  7957. //
  7958. //oapiVCRegisterArea(AID_MFDA_BRT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBPRESSED | PANEL_MOUSE_ONREPLAY);
  7959. //oapiVCSetAreaClickmode_Quadrilateral(AID_MFDA_BRT, _V(1.3817, 2.2164, 13.489), _V(1.3809, 2.2164, 13.463), _V(1.3634, 2.2148, 13.489), _V(1.3634, 2.2118, 13.461));
  7960. //atlantis
  7961.  
  7962. //oapiVCRegisterArea (AID_MFDA_BRT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY);
  7963. //oapiVCSetAreaClickmode_Quadrilateral(AID_MFDA_BRT, _V(1.4024, 2.2675, 13.6736), _V(1.4024, 2.2675, 13.6586), _V(1.3893, 2.2590, 13.6736), _V(1.3893, 2.2590, 13.6586));
  7964.  
  7965. oapiVCRegisterArea(AID_MFDSIDE_BRT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBPRESSED | PANEL_MOUSE_ONREPLAY);
  7966. oapiVCSetAreaClickmode_Quadrilateral(AID_MFDSIDE_BRT, _V(1.3853, 2.2171, 13.48), _V(1.3853, 2.2171, 13.463), _V(1.3726, 2.2076, 13.48), _V(1.3724, 2.2076, 13.463));
  7967.  
  7968.  
  7969. oapiVCRegisterArea(AID_CCTV1_PWR, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7970. oapiVCRegisterArea(AID_CCTV2_PWR, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7971. oapiVCRegisterArea(AID_AFTMETTIMERGMT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7972. oapiVCRegisterArea(AID_AFTMETTIMERMET, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7973. oapiVCRegisterArea(AID_AFTMETTIMERTEST, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  7974.  
  7975. oapiVCRegisterArea(AID_FLOODON, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7976. oapiVCRegisterArea(AID_FLOODOFF, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7977. oapiVCRegisterArea(AID_AFTPORTFLOODON, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7978. oapiVCRegisterArea(AID_AFTPORTFLOODOFF, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7979. oapiVCRegisterArea(AID_AFTSTBDFLOODON, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7980. oapiVCRegisterArea(AID_AFTSTBDFLOODOFF, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7981.  
  7982. oapiVCRegisterArea(AID_MIDPORTFLOODON, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7983. oapiVCRegisterArea(AID_MIDPORTFLOODOFF, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7984. oapiVCRegisterArea(AID_MIDSTBDFLOODON, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7985. oapiVCRegisterArea(AID_MIDSTBDFLOODOFF, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7986.  
  7987. oapiVCRegisterArea(AID_FWDPORTFLOODON, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7988. oapiVCRegisterArea(AID_FWDPORTFLOODOFF, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7989. oapiVCRegisterArea(AID_FWDSTBDFLOODON, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7990. oapiVCRegisterArea(AID_FWDSTBDFLOODOFF, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7991.  
  7992. oapiVCRegisterArea(AID_AFTFLOODON, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7993. oapiVCRegisterArea(AID_AFTFLOODOFF, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7994.  
  7995. oapiVCRegisterArea(AID_DOCKFLOODOFF, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7996. oapiVCRegisterArea(AID_DOCKFLOODDIM, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7997. oapiVCRegisterArea(AID_DOCKFLOODBRIGHT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  7998.  
  7999.  
  8000.  
  8001. //EVENT_TIMER
  8002. oapiVCRegisterArea(AID_AFTEVENTSET, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  8003. oapiVCRegisterArea(AID_AFTEVENTRESET, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  8004.  
  8005. oapiVCRegisterArea(AID_AFTEVENTSTART, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  8006. oapiVCRegisterArea(AID_AFTEVENTSTOP, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  8007.  
  8008. oapiVCRegisterArea(AID_AFTEVENTUP, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  8009. oapiVCRegisterArea(AID_AFTEVENTDOWN, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  8010. oapiVCRegisterArea(AID_AFTEVENTTEST, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  8011. oapiVCRegisterArea(AID_PANELA2TEST, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  8012. oapiVCRegisterArea(AID_PANELA2SCALEX1, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  8013. oapiVCRegisterArea(AID_PANELA2SCALEX10, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  8014.  
  8015.  
  8016.  
  8017. oapiVCSetAreaClickmode_Spherical(AID_AFTMETTIMERGMT, _V(-.822, 2.8815, 12.262), .01);//-1.0401, 2.8382, 12.443
  8018. oapiVCSetAreaClickmode_Spherical(AID_AFTMETTIMERMET, _V(-.822, 2.8699, 12.262), .01);//-1.0401, 2.8382, 12.443
  8019. oapiVCSetAreaClickmode_Spherical(AID_AFTMETTIMERTEST, _V(-.822, 2.8577, 12.262), .01);//-1.0401, 2.8382, 12.443
  8020.  
  8021. oapiVCSetAreaClickmode_Spherical(AID_AFTEVENTSET, _V(.351, 2.449, 12.313), .01);//-1.0401, 2.8382, 12.443
  8022. oapiVCSetAreaClickmode_Spherical(AID_AFTEVENTRESET, _V(.351, 2.429, 12.313), .01);//-1.0401, 2.8382, 12.443
  8023.  
  8024.  
  8025. oapiVCSetAreaClickmode_Spherical(AID_AFTEVENTSTART, _V(.376, 2.448, 12.313), .01);//-1.0401, 2.8382, 12.443
  8026. oapiVCSetAreaClickmode_Spherical(AID_AFTEVENTSTOP, _V(.376, 2.426, 12.313), .01);//-1.0401, 2.8382, 12.443
  8027.  
  8028. oapiVCSetAreaClickmode_Spherical(AID_AFTEVENTUP, _V(.408, 2.449, 12.313), .01);//-1.0401, 2.8382, 12.443
  8029. oapiVCSetAreaClickmode_Spherical(AID_AFTEVENTDOWN, _V(.408, 2.437, 12.313), .01);//-1.0401, 2.8382, 12.443
  8030. oapiVCSetAreaClickmode_Spherical(AID_AFTEVENTTEST, _V(.408, 2.426, 12.313), .01);//-1.0401, 2.8382, 12.443
  8031. oapiVCSetAreaClickmode_Spherical(AID_PANELA2RR, _V(0, 3.197, 12.23), .01);//-1.0401, 2.8382, 12.443
  8032. oapiVCSetAreaClickmode_Spherical(AID_PANELA2TEST, _V(0, 3.179, 12.23), .01);//-1.0401, 2.8382, 12.443
  8033. oapiVCSetAreaClickmode_Spherical(AID_PANELA2SCALEX10, _V(0, 3.111, 12.23), .01);//-1.0401, 2.8382, 12.443
  8034. oapiVCSetAreaClickmode_Spherical(AID_PANELA2SCALEX1, _V(0, 3.142, 12.23), .01);//-1.0401, 2.8382, 12.443
  8035.  
  8036. oapiVCSetAreaClickmode_Spherical(AID_AFTSTBDFLOODON, _V(0.22196, 2.704 , 12.23508), .01);//-1.079, 3.0613, 12.412 0.22196 2.694968 12.23508
  8037. oapiVCSetAreaClickmode_Spherical(AID_AFTSTBDFLOODOFF, _V(0.22196, 2.69, 12.23508), .01);//-1.079, 3.0613, 12.412
  8038.  
  8039. oapiVCSetAreaClickmode_Spherical(AID_AFTPORTFLOODON, _V(0.176, 2.704, 12.23508), .01);//-1.079, 3.0613, 12.412 0.22196 2.694968 12.23508
  8040. oapiVCSetAreaClickmode_Spherical(AID_AFTPORTFLOODOFF, _V(0.176, 2.69, 12.23508), .01);//-1.079, 3.0613, 12.412
  8041.  
  8042. oapiVCSetAreaClickmode_Spherical(AID_MIDSTBDFLOODON, _V(0.22196, 2.643, 12.252), .01);//-1.079, 3.0613, 12.412 0.22196 2.694968 12.23508
  8043. oapiVCSetAreaClickmode_Spherical(AID_MIDSTBDFLOODOFF, _V(0.22196, 2.631, 12.252), .01);//-1.079, 3.0613, 12.412
  8044.  
  8045. oapiVCSetAreaClickmode_Spherical(AID_MIDPORTFLOODON, _V(0.176, 2.643, 12.252), .01);//-1.079, 3.0613, 12.412 0.22196 2.694968 12.23508
  8046. oapiVCSetAreaClickmode_Spherical(AID_MIDPORTFLOODOFF, _V(0.176, 2.631, 12.252), .01);//-1.079, 3.0613, 12.412
  8047.  
  8048. oapiVCSetAreaClickmode_Spherical(AID_FWDSTBDFLOODON, _V(0.22196, 2.579, 12.273), .01);//-1.079, 3.0613, 12.412 0.22196 2.694968 12.23508
  8049. oapiVCSetAreaClickmode_Spherical(AID_FWDSTBDFLOODOFF, _V(0.22196, 2.566, 12.273), .01);//-1.079, 3.0613, 12.412
  8050.  
  8051. oapiVCSetAreaClickmode_Spherical(AID_FWDPORTFLOODON, _V(0.176, 2.579, 12.273), .01);//-1.079, 3.0613, 12.412 0.22196 2.694968 12.23508
  8052. oapiVCSetAreaClickmode_Spherical(AID_FWDPORTFLOODOFF, _V(0.176, 2.566, 12.273), .01);//-1.079, 3.0613, 12.412
  8053.  
  8054.  
  8055. oapiVCSetAreaClickmode_Spherical(AID_FLOODON, _V(0.43404, 2.785, 12.21263), .01);//-1.079, 3.0613, 12.412
  8056. oapiVCSetAreaClickmode_Spherical(AID_FLOODOFF, _V(0.43404, 2.763, 12.21263), .01);//-1.079, 3.0613, 12.412
  8057.  
  8058.  
  8059. oapiVCSetAreaClickmode_Spherical(AID_AFTFLOODON, _V(0.176, 2.524, 12.28897), .01);//-1.079, 3.0613, 12.412
  8060. oapiVCSetAreaClickmode_Spherical(AID_AFTFLOODOFF, _V(0.176, 2.511, 12.28897), .01);//-1.079, 3.0613, 12.412
  8061.  
  8062. oapiVCSetAreaClickmode_Spherical(AID_DOCKFLOODDIM, _V(0.22196, 2.517118, 12.28912), .01);//-1.079, 3.0613, 12.412
  8063. oapiVCSetAreaClickmode_Spherical(AID_DOCKFLOODOFF, _V(0.22196, 2.512, 12.28912), .01);//-1.079, 3.0613, 12.412
  8064. oapiVCSetAreaClickmode_Spherical(AID_DOCKFLOODBRIGHT, _V(0.22196, 2.527, 12.28912), .01);//-1.079, 3.0613, 12.412
  8065.  
  8066.  
  8067. oapiVCRegisterArea(AID_AFTMINUTE2UP, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  8068. oapiVCSetAreaClickmode_Spherical(AID_AFTMINUTE2UP, _V(.405, 2.515002, 12.28757), powerButtonRadius);
  8069. oapiVCRegisterArea(AID_AFTMINUTE2DWN, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  8070. oapiVCSetAreaClickmode_Spherical(AID_AFTMINUTE2DWN, _V(.405, 2.48366, 12.29915), powerButtonRadius);
  8071. oapiVCRegisterArea(AID_AFTMINUTE1UP, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  8072. oapiVCSetAreaClickmode_Spherical(AID_AFTMINUTE1UP, _V(0.382, 2.515002, 12.28757), powerButtonRadius);
  8073.  
  8074. oapiVCRegisterArea(AID_AFTMINUTE1DWN, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  8075. oapiVCSetAreaClickmode_Spherical(AID_AFTMINUTE1DWN, _V(0.382, 2.48366, 12.29915), powerButtonRadius);
  8076.  
  8077. oapiVCRegisterArea(AID_AFTSECOND1DWN, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  8078. oapiVCSetAreaClickmode_Spherical(AID_AFTSECOND1DWN, _V(0.335, 2.48, 12.28757), powerButtonRadius);
  8079.  
  8080. oapiVCRegisterArea(AID_AFTSECOND1UP, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  8081. oapiVCSetAreaClickmode_Spherical(AID_AFTSECOND1UP, _V(0.335, 2.515002, 12.28757), powerButtonRadius);
  8082.  
  8083.  
  8084. oapiVCRegisterArea(AID_AFTSECOND2DWN, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  8085. oapiVCSetAreaClickmode_Spherical(AID_AFTSECOND2DWN, _V(0.359, 2.48366, 12.29915), powerButtonRadius);
  8086.  
  8087. oapiVCRegisterArea(AID_AFTSECOND2UP, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  8088. oapiVCSetAreaClickmode_Spherical(AID_AFTSECOND2UP, _V(0.359, 2.515002, 12.28757), powerButtonRadius);
  8089.  
  8090. oapiVCRegisterArea(AID_PANELA2PWRON, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  8091. oapiVCSetAreaClickmode_Spherical(AID_PANELA2PWRON, _V(1.283, 2.709, 12.147), .01);//-1.079, 3.0613, 12.412
  8092.  
  8093. oapiVCRegisterArea(AID_PANELA2PWROFF, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  8094. oapiVCSetAreaClickmode_Spherical(AID_PANELA2PWROFF, _V(1.283, 2.698, 12.147), .01);//-1.079, 3.0613, 12.412
  8095. //KU
  8096. oapiVCRegisterArea(AID_KUAZIMUTHLEFT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  8097. oapiVCSetAreaClickmode_Spherical(AID_KUAZIMUTHLEFT, _V(1.139, 2.88, 12.147), powerButtonRadius);
  8098.  
  8099. oapiVCRegisterArea(AID_KUAZIMUTHRIGHT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  8100. oapiVCSetAreaClickmode_Spherical(AID_KUAZIMUTHRIGHT, _V(1.155, 2.88, 12.147), powerButtonRadius);
  8101.  
  8102. oapiVCRegisterArea(AID_KUELUP, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  8103. oapiVCSetAreaClickmode_Spherical(AID_KUELUP, _V(1.102, 2.89, 12.147), powerButtonRadius);
  8104.  
  8105. oapiVCRegisterArea(AID_KUELDOWN, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_ONREPLAY);
  8106. oapiVCSetAreaClickmode_Spherical(AID_KUELDOWN, _V(1.102, 2.87, 12.147), powerButtonRadius);
  8107.  
  8108. oapiVCRegisterArea(AID_KURATESLOW, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  8109. oapiVCSetAreaClickmode_Spherical(AID_KURATESLOW, _V(1.069, 2.87, 12.147), powerButtonRadius);
  8110.  
  8111. oapiVCRegisterArea(AID_KURATEFAST, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  8112. oapiVCSetAreaClickmode_Spherical(AID_KURATEFAST, _V(1.069, 2.89, 12.147), powerButtonRadius);
  8113.  
  8114. // register+activate aft MFD function buttons
  8115. // SURFHANDLE tex1 = oapiGetTextureHandle (hOrbiterVCMesh, 14);
  8116. // oapiVCRegisterArea (AID_MFDA_BUTTONS, _R(0,127,255,140), PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1);
  8117. // oapiVCSetAreaClickmode_Quadrilateral(AID_MFDA_BUTTONS, _V(.773, 3.0252, 12.376), _V(.600, 3.0133, 12.306), _V(.776, 3.0065, 12.376), _V(.600, 2.2452, 12.306));
  8118.  
  8119. // register+activate MFD power button
  8120. // const double powerButtonRadius = 0.0075; // radius of power button on each MFD
  8121. // oapiVCRegisterArea (AID_MFDA_PWR, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_ONREPLAY);
  8122. // oapiVCSetAreaClickmode_Spherical(AID_MFDA_PWR, _V(0.791, 3.0327, 12.392), powerButtonRadius);
  8123.  
  8124. // register+activate MFD brightness buttons
  8125. // oapiVCRegisterArea (AID_MFDA_BRT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY);
  8126. // oapiVCSetAreaClickmode_Quadrilateral(AID_MFDA_BRT, _V(.591, 3.0318, 12.308), _V(.567, 3.0263, 12.297), _V(.593, 3.0146, 12.309), _V(.568, 3.008, 12.295));
  8127. }
  8128. void Atlantis::RegistergearleftVC()
  8129. {
  8130. SURFHANDLE tkbk_texL = oapiGetTextureHandle(hOrbiterVCMesh, 13);
  8131. const double powerButtonRadius = 0.01; // radius of power button on each MFD
  8132. // oapiVCRegisterArea(AID_LANDINGGEARLEFT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN);
  8133. // oapiVCSetAreaClickmode_Quadrilateral(AID_LANDINGGEARLEFT, _V(-.957, 2.04, 14.7), _V(-.957, 1.84, 14.6), _V(-.752, 2.04, 14.7), _V(-.752, 1.84, 14.6));
  8134.  
  8135. // register the complete panel for mouse events
  8136. // oapiVCRegisterArea(AID_LANDINGGEARLEFT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN);
  8137. // oapiVCSetAreaClickmode_Quadrilateral(AID_LANDINGGEARLEFT, _V(1.35, 2.197, 12.456), _V(1.35, 2.197, 12.144), _V(1.0868, 2.0174, 12.456), _V(1.0868, 2.0174, 12.144));
  8138. oapiVCRegisterArea(AID_LANDINGGEARARM, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  8139. oapiVCSetAreaClickmode_Spherical(AID_LANDINGGEARARM, _V(-.9249141, 1.941366, 14.6538), powerButtonRadius);
  8140. oapiVCRegisterArea(AID_LANDINGGEARDN, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  8141. oapiVCSetAreaClickmode_Spherical(AID_LANDINGGEARDN, _V(-.889, 1.941366, 14.6538), powerButtonRadius);
  8142.  
  8143. oapiVCRegisterArea(AID_LANDINGGEARARMRIGHT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  8144. oapiVCSetAreaClickmode_Spherical(AID_LANDINGGEARARMRIGHT, _V(.492, 1.937, 14.6538), powerButtonRadius);
  8145. oapiVCRegisterArea(AID_LANDINGGEARDNRIGHT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_ONREPLAY);
  8146. oapiVCSetAreaClickmode_Spherical(AID_LANDINGGEARDNRIGHT, _V(.535, 1.937, 14.6538), powerButtonRadius);
  8147. }
  8148. // --------------------------------------------------------------
  8149. // Load virtual cockpit mode
  8150. // --------------------------------------------------------------
  8151. bool Atlantis::clbkLoadVC (int id)
  8152. {
  8153.  
  8154. static VCHUDSPEC huds = { // common HUD specs
  8155. mesh_vc, // nmesh
  8156. GRP_VIRTUAL_HUD, // ngroup
  8157. {0,0,0}, // hudcnt (to be filled)
  8158. 0.176558 // size
  8159. };
  8160. //static VCMFDSPEC mfds = {
  8161. // mesh_vc, 0
  8162. //};
  8163. static EXTMFDSPEC mfds = { // common MFD specs
  8164. {0,0,0,0}, // pos
  8165. mesh_vc, // nmesh
  8166. 0, // ngroup (to be filled)
  8167. MFD_SHOWMODELABELS, // flag
  8168. 5, 0, // nbt1, nbt2
  8169. 512/6, 512/7 // bt_yofs, bt_ydist
  8170. };
  8171. static const int mfdgrp[6] = {
  8172.  
  8173. GRP_CDR1A_VC, GRP_PLT1A_VC, GRP_MFD1A_VC,GRP_MFD_SIDE_VC, GRP_MFDCCTV1_VC, GRP_MFDCCTV2_VC
  8174.  
  8175. };
  8176. //SetClipRadius(.1);
  8177. bool ok = false;
  8178.  
  8179. // register MFD function buttons
  8180. // this needs to be done globally, so that the labels are correctly updated from all VC positions
  8181. //SURFHANDLE tex1 = oapiGetTextureHandle (hOrbiterVCMesh, 14);
  8182. SURFHANDLE tex1 = oapiGetTextureHandle(hOrbiterVCMesh, 19);
  8183. // commander MFD function buttons
  8184. //oapiVCRegisterArea(AID_CDR1_BUTTONS, _R(0, 29, 255, 42), PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_LBPRESSED | PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1);
  8185. // pilot MFD function buttons
  8186. //oapiVCRegisterArea(AID_PLT1_BUTTONS, _R(0, 57, 255, 70), PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_LBPRESSED | PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1);
  8187. oapiVCRegisterArea(AID_PLT1_BUTTONS, _R(0, 29, 255, 42), PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_LBPRESSED | PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1);
  8188. oapiVCRegisterArea(AID_CDR1_BUTTONS, _R(0, 1, 255, 14), PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_LBPRESSED | PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1);
  8189. //oapiVCRegisterArea(AID_PLT1_BUTTONS, _R(0, 15, 255, 28), PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_LBPRESSED | PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1);
  8190. oapiVCRegisterArea(AID_MFD1_BUTTONS, _R(0, 85, 255, 98), PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_LBPRESSED | PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1);
  8191. oapiVCRegisterArea(AID_MFDSIDE_BUTTONS, _R(0, 127, 255, 140), PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_LBPRESSED | PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1);
  8192. oapiVCRegisterArea(AID_CCTV1_BUTTONS, _R(0, 99, 255, 112), PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_LBPRESSED | PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1);
  8193. oapiVCRegisterArea(AID_CCTV2_BUTTONS, _R(0, 113, 255, 126), PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN | PANEL_MOUSE_LBUP | PANEL_MOUSE_LBPRESSED | PANEL_MOUSE_ONREPLAY, PANEL_MAP_BACKGROUND, tex1);
  8194.  
  8195. SURFHANDLE const tex3 = oapiGetTextureHandle(hOrbiterVCMesh, 44); //aft met
  8196. oapiVCRegisterArea(AID_METTIME, _R(0, 0, 512, 512), PANEL_REDRAW_USER, PANEL_MOUSE_IGNORE, PANEL_MAP_BACKGROUND, tex3);
  8197. SURFHANDLE const tex5 = oapiGetTextureHandle(hOrbiterVCMesh, 45);//afttimer
  8198. oapiVCRegisterArea(AID_EVENTTIME, _R(0, 0, 256, 256), PANEL_REDRAW_USER, PANEL_MOUSE_IGNORE, PANEL_MAP_BACKGROUND, tex5);
  8199.  
  8200. SURFHANDLE const tex4 = oapiGetTextureHandle(hOrbiterVCMesh, 43);//frontmet
  8201. oapiVCRegisterArea(AID_EVENT1TIME, _R(0, 0, 256, 256), PANEL_REDRAW_USER, PANEL_MOUSE_IGNORE, PANEL_MAP_BACKGROUND, tex4);
  8202. SURFHANDLE const tex6 = oapiGetTextureHandle(hOrbiterVCMesh, 46);//fronttimer
  8203. oapiVCRegisterArea(AID_EVENTAFTTIME, _R(0, 0, 256, 256), PANEL_REDRAW_USER, PANEL_MOUSE_IGNORE, PANEL_MAP_BACKGROUND, tex6);
  8204.  
  8205. SURFHANDLE const tex7 = oapiGetTextureHandle(hOrbiterVCMesh, 58);//panela2
  8206. oapiVCRegisterArea(AID_PANELA2, _R(0, 0, 512, 512), PANEL_REDRAW_USER, PANEL_MOUSE_IGNORE, PANEL_MAP_BACKGROUND, tex7);
  8207.  
  8208. SURFHANDLE const tex8 = oapiGetTextureHandle(hOrbiterVCMesh, 84); //rcsqty
  8209. oapiVCRegisterArea(AID_RCSQTY, _R(0, 0, 256, 256), PANEL_REDRAW_USER, PANEL_MOUSE_IGNORE, PANEL_MAP_BACKGROUND, tex8);
  8210.  
  8211.  
  8212. if (firstStep) id= VCCAM;// if firststep then load vc camera position
  8213. //sprintf(oapiDebugString(), "%d %d", id, VCCAM);
  8214.  
  8215. // Get the VC Mode.
  8216. VCCAM = id;
  8217. //sprintf(oapiDebugString(), "%d ", id);
  8218. firstStep = false;
  8219. switch (id) {
  8220. case 0: // commander position
  8221. SetCameraOffset(_V(-0.67, 2.55, 13.8));
  8222. SetCameraDefaultDirection(_V(0, 0, 1));
  8223. SetCameraMovement(_V(0, 0, 0.3), 0, 0, _V(-0.3, 0, 0), 75 * RAD, -5 * RAD, _V(0.3, 0, 0), -20 * RAD, -27 * RAD);
  8224. huds.hudcnt = _V(-0.671257, 2.523535, 14.969);
  8225. oapiVCSetNeighbours(-1, 1, -1, 2);
  8226.  
  8227. RegistergearleftVC();
  8228.  
  8229. RegisterVC_CdrMFD(); // activate commander MFD controls
  8230. RegisterVC_CntMFD(); // activate central panel MFD controls
  8231. vccameracase = 0;
  8232. VCCAM = 0;
  8233.  
  8234.  
  8235.  
  8236.  
  8237.  
  8238.  
  8239. ok = true;
  8240. break;
  8241.  
  8242. case 1: // pilot position
  8243. SetCameraOffset(_V(0.67, 2.55, 13.8));
  8244. SetCameraDefaultDirection(_V(0, 0, 1));
  8245. SetCameraMovement(_V(0, 0, 0.3), 0, 0, _V(-0.3, 0, 0), 20 * RAD, -27 * RAD, _V(0.3, 0, 0), -75 * RAD, -5 * RAD);
  8246. huds.hudcnt = _V(0.671257, 2.523535, 14.969);
  8247. oapiVCSetNeighbours(0, -1, -1, 2);
  8248. RegistergearleftVC();
  8249. RegisterVC_PltMFD(); // activate pilot MFD controls
  8250. RegisterVC_CntMFD(); // activate central panel MFD controls
  8251. vccameracase = 1;
  8252. VCCAM = 1;
  8253.  
  8254.  
  8255.  
  8256.  
  8257.  
  8258. ok = true;
  8259. break;
  8260. case 2: // payload view position
  8261. SetCameraOffset(_V(0.35, 3.055, 12.73));
  8262. SetCameraDefaultDirection(_V(0, 0, -1));
  8263. SetCameraMovement(_V(0, -0.1, -0.1), 0, 80.0 * RAD, _V(0.3, -0.3, 0.15), 60.0 * RAD, -50.0 * RAD, _V(-0.8, 0, 0), 0, 0);
  8264. oapiVCSetNeighbours(1, 5, -1, 3);
  8265.  
  8266. RegisterVC_AftMFD(); // activate aft MFD controls
  8267. plop->RegisterVC(); // register panel R13L interface
  8268. ok = true;
  8269. vccameracase = 2;
  8270. VCCAM = 2;
  8271. break;
  8272.  
  8273. case 3: // payload view position
  8274. SetCameraOffset(_V(0.75, 2.855, 12.83));
  8275. SetCameraDefaultDirection(_V(0, 0, -1));
  8276. SetCameraMovement(_V(0, -0.1, -0.1), 0, 80.0*RAD, _V(0.3, -0.3, 0.15), 60.0*RAD, -50.0*RAD, _V(-0.8, 0, 0), 0, 0);
  8277. oapiVCSetNeighbours(1, 4, -1, 3);
  8278.  
  8279. RegisterVC_AftMFD(); // activate aft MFD controls
  8280. plop->RegisterVC(); // register panel R13L interface
  8281. ok = true;
  8282. vccameracase = 2;
  8283.  
  8284. VCCAM = 3;
  8285.  
  8286.  
  8287.  
  8288. break;
  8289. case 4: // payload view position
  8290. //SetCameraOffset(_V(0.45, 3.02, 12.50));
  8291. SetCameraOffset(_V(0.45, 3.02, 12.50));
  8292. SetCameraDefaultDirection(_V(0, 0, -1));
  8293. SetCameraMovement(_V(0, -0.1, -0.1), 0, 80.0*RAD, _V(0.3, -0.3, 0.15), 60.0*RAD, -50.0*RAD, _V(-0.8, 0, 0), 0, 0);
  8294. oapiVCSetNeighbours(1, 5, -1, 0);
  8295.  
  8296. RegisterVC_AftMFD(); // activate aft MFD controls
  8297. plop->RegisterVC(); // register panel R13L interface
  8298. ok = true;
  8299. vccameracase = 2;
  8300.  
  8301. VCCAM = 4;
  8302.  
  8303.  
  8304.  
  8305. break;
  8306. case 5: // payload view position
  8307. SetCameraOffset(_V(-0.45, 3.055, 12.43));
  8308. SetCameraDefaultDirection(_V(0, 0, -1));
  8309. SetCameraMovement(_V(0, -0.1, -0.1), 0, 80.0*RAD, _V(0.3, -0.3, 0.15), 60.0*RAD, -50.0*RAD, _V(-0.8, 0, 0), 0, 0);
  8310. oapiVCSetNeighbours(2, 6, -1, 0);
  8311.  
  8312. RegisterVC_AftMFD(); // activate aft MFD controls
  8313. plop->RegisterVC(); // register panel R13L interface
  8314. vccameracase = 2;
  8315. VCCAM = 5;
  8316. ok = true;
  8317. break;
  8318. case 6: // payload view position
  8319. SetCameraOffset(_V(-0.65, 2.90, 12.644));
  8320. SetCameraDefaultDirection(_V(-.7, -.1, -.7));
  8321. SetCameraMovement(_V(0, -0.1, -0.1), 0, 80.0*RAD, _V(0.3, -0.3, 0.15), 60.0*RAD, -50.0*RAD, _V(-0.8, 0, 0), 0, 0);
  8322. oapiVCSetNeighbours(5, 0, 0, 0);
  8323.  
  8324. RegisterVC_AftMFD(); // activate aft MFD controls
  8325. plop->RegisterVC(); // register panel R13L interface
  8326. vccameracase = 2;
  8327. VCCAM = 6;
  8328. ok = true;
  8329. break;
  8330. }
  8331.  
  8332. if (ok) {
  8333. // register the HUDs (synced)
  8334. oapiVCRegisterHUD(&huds);
  8335. // register all MFD displays
  8336. for (int i = 0; i < 6; i++) {
  8337. mfds.ngroup = mfdgrp[i];
  8338. oapiRegisterMFD(MFD_LEFT + i, &mfds);
  8339. }
  8340. // update panel R13L
  8341. plop->UpdateVC();
  8342. }
  8343. return ok;
  8344. }
  8345.  
  8346. void Atlantis::panelswitch()
  8347. {
  8348.  
  8349. switchtimer = (switchtimer + 1);// count up
  8350. sprintf(oapiDebugString(), "timer M: %d ", switchtimer);
  8351.  
  8352. if (switchtimer > 10)switchtimer = 0; // if timer reaches point reset timer
  8353. if (switchtimer == 0)return;//return since timer reached end
  8354.  
  8355. }
  8356.  
  8357.  
  8358.  
  8359. // --------------------------------------------------------------
  8360. // Respond to virtual cockpit mouse event
  8361. // --------------------------------------------------------------
  8362. bool Atlantis::clbkVCMouseEvent(int id, int event, VECTOR3& p)
  8363. {
  8364. static bool counting = false;
  8365. static double t0 = 0.0;
  8366.  
  8367. switch (id) {
  8368. // handle MFD selection buttons
  8369. case AID_CDR1_BUTTONS:
  8370. case AID_PLT1_BUTTONS:
  8371. case AID_MFD1_BUTTONS:
  8372. case AID_MFDSIDE_BUTTONS: {
  8373. int mfd = id - AID_CDR1_BUTTONS + MFD_LEFT;
  8374. int bt = (int)(p.x * 5.99);
  8375. if (bt < 5) oapiProcessMFDButton(mfd, bt, event);
  8376. else {
  8377. if (event & PANEL_MOUSE_LBDOWN) {
  8378. t0 = oapiGetSysTime();
  8379. counting = true;
  8380. }
  8381. else if ((event & PANEL_MOUSE_LBUP) && counting) {
  8382. oapiSendMFDKey(mfd, OAPI_KEY_F2);
  8383. counting = false;
  8384. }
  8385. else if ((event & PANEL_MOUSE_LBPRESSED) && counting && (oapiGetSysTime() - t0 >= 1.0)) {
  8386. oapiSendMFDKey(mfd, OAPI_KEY_F1);
  8387. counting = false;
  8388. }
  8389. }
  8390. } return true;
  8391.  
  8392. // D. Beachy: handle power buttons
  8393. case AID_CDR1_PWR:
  8394. case AID_PLT1_PWR:
  8395. case AID_MFD1_PWR:
  8396. case AID_MFDSIDE_PWR: {
  8397. int mfd = id - AID_CDR1_PWR + MFD_LEFT;
  8398. oapiSendMFDKey(mfd, OAPI_KEY_ESCAPE);
  8399. } return true;
  8400.  
  8401. // handle MFD brightness buttons
  8402. case AID_CDR1_BRT:
  8403. case AID_PLT1_BRT:
  8404. case AID_MFD1_BRT:
  8405. case AID_MFDSIDE_BRT:
  8406.  
  8407.  
  8408.  
  8409. {
  8410. static double t0, brt0;
  8411. static bool up;
  8412. int mfd = id - AID_CDR1_BRT;
  8413. if (event & PANEL_MOUSE_LBDOWN) {
  8414. up = (p.x >= 0.5);
  8415. t0 = oapiGetSysTime();
  8416. brt0 = mfdbright[mfd];
  8417. }
  8418. else if (event & PANEL_MOUSE_LBPRESSED) {
  8419. double dt = oapiGetSysTime() - t0;
  8420. double brt, dbrt = dt * 0.2;
  8421. if (up) brt = min(1.0, brt0 + dbrt);
  8422. else brt = max(0.25, brt0 - dbrt);
  8423. mfdbright[mfd] = brt;
  8424. if (vis) {
  8425. MATERIAL mat;
  8426. memset(&mat, 0, sizeof(MATERIAL));
  8427. mat.emissive.r = mat.emissive.g = mat.emissive.b = (float)brt;
  8428. mat.emissive.a = 1.0f;
  8429. DEVMESHHANDLE hMesh = GetDevMesh(vis, mesh_vc);
  8430. oapiSetMaterial(hMesh, 20 + mfd, &mat);
  8431. }
  8432. }
  8433. } return false;
  8434.  
  8435. // handle panel R13L events (payload bay operations)
  8436. case AID_R13L:
  8437. return plop->VCMouseEvent(id, event, p);
  8438. }
  8439. return false;
  8440.  
  8441. }
  8442. void Atlantis::Revertextdoor(void) {
  8443. EXT_status = ((EXT_status == HATCH_UP || EXT_status == HATCH_RAISING) ?
  8444. HATCH_LOWERING : HATCH_RAISING);
  8445. }
  8446. void Atlantis::RevertDockingRing(void) {
  8447. DOCKRING_status = ((DOCKRING_status == HATCH_UP || DOCKRING_status == HATCH_RAISING) ?
  8448. HATCH_LOWERING : HATCH_RAISING);
  8449. }
  8450. void Atlantis::RevertDragchute(void) {
  8451. CHUTE_status = ((CHUTE_status == HATCH_UP || CHUTE_status == HATCH_RAISING) ?
  8452. HATCH_LOWERING : HATCH_RAISING);
  8453. }
  8454. void Atlantis::OBSStilt(void) {
  8455. OBSS_status = ((OBSS_status == HATCH_UP || OBSS_status == HATCH_RAISING) ?
  8456. HATCH_LOWERING : HATCH_RAISING);
  8457. }
  8458. void Atlantis::Armtilt(void) {
  8459. Armtilt_status = ((Armtilt_status == HATCH_UP || Armtilt_status == HATCH_RAISING) ?
  8460. HATCH_LOWERING : HATCH_RAISING);
  8461. }
  8462. void Atlantis::RevertIUS(void) {
  8463. ius_status = ((ius_status == HATCH_UP || ius_status == HATCH_RAISING) ?
  8464. HATCH_LOWERING : HATCH_RAISING);
  8465. }
  8466. void Atlantis::RevertPETD(void) {
  8467. PETD_status = ((PETD_status == HATCH_UP || PETD_status == HATCH_RAISING) ?
  8468. HATCH_LOWERING : HATCH_RAISING);
  8469. }
  8470. void Atlantis::RevertSETD(void) {
  8471. SETD_status = ((SETD_status == HATCH_UP || SETD_status == HATCH_RAISING) ?
  8472. HATCH_LOWERING : HATCH_RAISING);
  8473. }
  8474. void Atlantis::RevertSSMESTOW(void) {
  8475. ssmestow_status = ((ssmestow_status == HATCH_UP || ssmestow_status == HATCH_RAISING) ?
  8476. HATCH_LOWERING : HATCH_RAISING);
  8477. }
  8478. void Atlantis::RevertADTA(void) {
  8479. ADTA_status = ((ADTA_status == HATCH_UP || ADTA_status == HATCH_RAISING) ?
  8480. HATCH_LOWERING : HATCH_RAISING);
  8481. }
  8482. void Atlantis::SetODSDock(void) {
  8483. //DelDock(hDockODS);
  8484. //sprintf(oapiDebugString(), "%0.4f ", ringpos.y);
  8485. //hDockODS = CreateDock(_V(0,2.80,10.14), _V(0, 1, 0), _V(0, 0, -1));
  8486. //SetDockParams(hDockODS, dockpos, _V(0, 1, 0), _V(0, 0, -1));
  8487.  
  8488. }
  8489. // --------------------------------------------------------------
  8490. // Respond to virtual cockpit area redraw request
  8491. // --------------------------------------------------------------
  8492. bool Atlantis::clbkVCRedrawEvent (int id, int event, SURFHANDLE surf)
  8493. {
  8494.  
  8495. switch (id) {
  8496. case AID_CDR1_BUTTONS:
  8497. case AID_PLT1_BUTTONS:
  8498. case AID_MFD1_BUTTONS:
  8499. case AID_MFDSIDE_BUTTONS:
  8500. case AID_CCTV1_BUTTONS:
  8501. case AID_CCTV2_BUTTONS: {
  8502. int mfd = id - AID_CDR1_BUTTONS + MFD_LEFT;
  8503. RedrawPanel_MFDButton(surf, mfd);
  8504. } return true;
  8505.  
  8506. case AID_LANDINGGEARARM:
  8507. {
  8508.  
  8509. geararmed = 1;//gear is armed
  8510. } return true;
  8511.  
  8512. case AID_LANDINGGEARDN:
  8513. {
  8514. if (geararmed == 1) {//gear is armed
  8515. SetAnimation(anim_LEFTGEARTALKBACK, .5);//move talkback to barber pole
  8516. SetAnimation(anim_RIGHTGEARTALKBACK, .5);//move talkback to barber pole
  8517. if (gear_proc == 0)RevertLandingGear();//move gear
  8518.  
  8519. }
  8520. } return true;
  8521.  
  8522. case AID_LANDINGGEARARMRIGHT:
  8523. {
  8524.  
  8525. geararmed = 1;//gear is armed
  8526. } return true;
  8527.  
  8528. case AID_LANDINGGEARDNRIGHT:
  8529. {
  8530. if (geararmed == 1) {//gear is armed
  8531. SetAnimation(anim_LEFTGEARTALKBACK, .5);//move talkback to barber pole
  8532. SetAnimation(anim_RIGHTGEARTALKBACK, .5);//move talkback to barber pole
  8533. if (gear_proc == 0)RevertLandingGear();//move gear
  8534.  
  8535. }
  8536. } return true;
  8537. //afttimer
  8538. case AID_AFTMETTIMERGMT:
  8539. {
  8540. GMTmode = 1;
  8541. METmode = 0;
  8542. Testmode = 0;
  8543. SetAnimation(anim_AFTMETTIMER, 0);
  8544. //SetAnimation(anim_mfd2, 0);
  8545. } return true;
  8546. case AID_AFTMETTIMERMET:
  8547. {
  8548. METmode = 1;
  8549. Testmode = 0;
  8550. GMTmode = 0;
  8551. SetAnimation(anim_AFTMETTIMER, .5);
  8552. //SetAnimation(anim_mfd2, 0);
  8553. } return true;
  8554. case AID_AFTMETTIMERTEST:
  8555. {
  8556. if (event & PANEL_MOUSE_LBDOWN) {
  8557. Testmode = 1;
  8558. METmode = 0;
  8559. GMTmode = 0;
  8560. SetAnimation(anim_AFTMETTIMER, 1);
  8561. }
  8562. if (event & PANEL_MOUSE_LBUP) {
  8563. SetAnimation(anim_AFTMETTIMER, .5);
  8564. Testmode = 0;
  8565. METmode = 1;
  8566. GMTmode = 0;
  8567. }
  8568. //SetAnimation(anim_mfd2, 0);
  8569. } return true;
  8570. //FRONTMET
  8571. //
  8572. case AID_METTIMERGMT:
  8573. {
  8574. FGMTmode = 1;
  8575. FMETmode = 0;
  8576. FTestmode = 0;
  8577. SetAnimation(anim_FRTMET, 1);
  8578. //SetAnimation(anim_mfd2, 0);
  8579. } return true;
  8580. case AID_METTIMERMET:
  8581. {
  8582. FMETmode = 1;
  8583. FTestmode = 0;
  8584. FGMTmode = 0;
  8585. SetAnimation(anim_FRTMET, .5);
  8586. //SetAnimation(anim_mfd2, 0);
  8587. } return true;
  8588. case AID_METTIMERTEST:
  8589. {
  8590. if (event & PANEL_MOUSE_LBDOWN) {
  8591. FTestmode = 1;
  8592. FMETmode = 0;
  8593. FGMTmode = 0;
  8594. SetAnimation(anim_FRTMET, 0);
  8595. }
  8596. if (event & PANEL_MOUSE_LBUP) {
  8597. SetAnimation(anim_FRTMET, .5);
  8598. FTestmode = 0;
  8599. FMETmode = 1;
  8600. FGMTmode = 0;
  8601. }
  8602.  
  8603. } return true;
  8604.  
  8605.  
  8606.  
  8607.  
  8608.  
  8609. default:
  8610. if (id >= AID_R13L_MIN && id <= AID_R13L_MAX)
  8611. return plop->VCRedrawEvent(id, event, surf);
  8612. break;
  8613. }
  8614. return false;
  8615. }
  8616.  
  8617.  
  8618. // --------------------------------------------------------------
  8619. // Respond to a HUD redraw request
  8620. // --------------------------------------------------------------
  8621. bool Atlantis::clbkDrawHUD(int mode, const HUDPAINTSPEC *hps, oapi::Sketchpad *skp)
  8622. {
  8623. {
  8624. // draw the default HUD
  8625. VESSEL4::clbkDrawHUD(mode, hps, skp);
  8626. int cx = hps->CX, cy = hps->CY;
  8627.  
  8628. // show OMS thrust marker
  8629. if (status >= 3) {
  8630. int omsy = cy + (int)(15.0*hps->Scale);
  8631. int dx = (int)(1.0*hps->Scale);
  8632. skp->Line(cx - 2 * dx, omsy, cx + 2 * dx, omsy);
  8633. skp->Line(cx, omsy - dx, cx, omsy + dx);
  8634. }
  8635.  
  8636. if (wheelbrake == 1){
  8637. char cbuf[255];
  8638. sprintf(cbuf, "WHEEL BRAKE APPLIED");
  8639. skp->Text(hps->W / 3, hps->H / 10, cbuf, strlen(cbuf));
  8640.  
  8641.  
  8642. }
  8643. if (wheelbrake == 0){
  8644. char cbuf[255];
  8645. sprintf(cbuf, "");
  8646. skp->Text(hps->W / 3, hps->H / 10, cbuf, strlen(cbuf));
  8647.  
  8648.  
  8649. }
  8650. if (DRAGCHUTEDEPLOYED == 1){
  8651. char cbuf[255];
  8652. sprintf(cbuf, "CHUTE DEPLOYED");
  8653. skp->Text(hps->W / 3, hps->H / 10, cbuf, strlen(cbuf));
  8654.  
  8655.  
  8656. }
  8657. if (gear_proc >.9){
  8658. char cbuf[255];
  8659. sprintf(cbuf, "GEAR Down");
  8660. skp->Text(hps->W / 3, hps->H / 5, cbuf, strlen(cbuf));
  8661.  
  8662.  
  8663. }
  8664. {
  8665. // char cbuf[255];
  8666. // if (whicheva == 0)sprintf(cbuf, "EVA1 selected");
  8667. // if (whicheva == 1)sprintf(cbuf, "EVA2 selected");
  8668. // if (whicheva == 2)sprintf(cbuf, "EVA3 selected");
  8669. // if (whicheva == 3)sprintf(cbuf, "EVA4 selected");
  8670. // skp->Text(hps->W / 4, hps->H / 6, cbuf, strlen(cbuf));
  8671.  
  8672.  
  8673. }
  8674.  
  8675. /*
  8676. //ius stuff
  8677.  
  8678. if (USEIUS == 1){
  8679. char cbuf[255];
  8680. //tilt of ase/IUS
  8681. //sprintf(oapiDebugString(), " tipx %f tipy %f tipz %f", arm1_tip[1].x, arm1_tip[1].y, arm1_tip[1].z);
  8682.  
  8683. // if (tilt == 1)tiltvalue = .6; //first step
  8684. // if (tilt == 3)tiltvalue = 1.0; //2nd step
  8685. //phi = phi + .001;//move up second step
  8686. // if (tilt == 1) phi = (phi + .001);//move up
  8687. // if (tilt == 2) phi = (phi - .001);//move down
  8688. // if (tilt == 4) phi = (phi + .001);//move down
  8689.  
  8690. sprintf(cbuf, "IUS STATUS "); //degree of ase tilt
  8691. skp->Text(hps->W / 3, hps->H / 5.5, cbuf, strlen(cbuf));
  8692.  
  8693. sprintf(cbuf, "TILT TABLE %0.0f ", phi / .017); //degree of ase tilt
  8694. skp->Text(hps->W / 3, hps->H / 5, cbuf, strlen(cbuf));
  8695. /*
  8696. if ((tilt == 1) && (phi < tiltvalue)){
  8697.  
  8698. sprintf(cbuf, "IUS moving to first stop");
  8699. skp->Text(hps->W / 3, hps->H / 5, cbuf, strlen(cbuf));
  8700. }
  8701. if (tilt == 3) {
  8702.  
  8703. sprintf(cbuf, "IUS at first stop");
  8704. skp->Text(hps->W / 3, hps->H / 5, cbuf, strlen(cbuf));
  8705. }
  8706. if ((tilt == 4) && (phi < tiltvalue)) {
  8707.  
  8708. sprintf(cbuf, "IUS moving to second stop");
  8709. skp->Text(hps->W / 3, hps->H / 5, cbuf, strlen(cbuf));
  8710. }
  8711.  
  8712.  
  8713. if (phi == tiltvalue) {//ius tilt at max
  8714.  
  8715. sprintf(cbuf, "ENJ ENH");
  8716. skp->Text(hps->W / 3, hps->H / 4.5, cbuf, strlen(cbuf));
  8717. }
  8718.  
  8719. //sprintf(oapiDebugString(), " phi %f tiltvalue %f", phi, tiltvalue);
  8720.  
  8721. //if (tilt == 5) {
  8722.  
  8723. // sprintf(cbuf, "IUS ready to deploy");
  8724. // skp->Text(hps->W / 3, hps->H / 5, cbuf, strlen(cbuf));
  8725. //}
  8726.  
  8727. //if (GetAttachmentStatus(sat_attach)==NULL)//ius deployed so clear ius info
  8728. // sprintf(cbuf, " ");
  8729. //skp->Text(hps->W / 3, hps->H / 4.5, cbuf, strlen(cbuf));
  8730. }
  8731.  
  8732. if (SPIN3 == 1){
  8733. char cbuf[255];
  8734. //tilt of ase/IUS
  8735. //sprintf(oapiDebugString(), " tipx %f tipy %f tipz %f", arm1_tip[1].x, arm1_tip[1].y, arm1_tip[1].z);
  8736.  
  8737. // if (tilt == 1)tiltvalue = .6; //first step
  8738. // if (tilt == 3)tiltvalue = 1.0; //2nd step
  8739. //phi = phi + .001;//move up second step
  8740. // if (tilt == 1) phi = (phi + .001);//move up
  8741. // if (tilt == 2) phi = (phi - .001);//move down
  8742. // if (tilt == 4) phi = (phi + .001);//move down
  8743.  
  8744. sprintf(cbuf, "ENJ ENH"); //degree of ase tilt
  8745. skp->Text(hps->W / 3, hps->H / 5.5, cbuf, strlen(cbuf));
  8746.  
  8747.  
  8748. }
  8749.  
  8750.  
  8751. */
  8752.  
  8753.  
  8754.  
  8755.  
  8756.  
  8757. //show speedbrake status
  8758. int d = hps->Markersize / 2;
  8759. spbrkx = ((spdb_proc*-10) + 5);
  8760. //int spbrkx = (spdb_proc +int (10.0*hps->Scale));
  8761. //if (spdb_proc == 0)spbrkx = 5;
  8762. //if (spdb_proc == 1)spbrkx = -5;
  8763. //if (spdb_proc == .5)spbrkx = 0;
  8764. //if (spdb_proc == .25)spbrkx = 2.5;
  8765. //if (spdb_proc == .75)spbrkx = -2.5;
  8766.  
  8767. //sprintf(oapiDebugString(), "spbrkx %f spdb_proc %7.2f ", SpeedFactor, arm_ep);
  8768.  
  8769. skp->Line(cx - d * -5, cy + d * 22, cx - d*-5, cy + d * 23);
  8770. skp->Line(cx - d * -5, cy + d * 23, cx - d * 5, cy + d * 23);//bottom line
  8771. skp->Line(cx - d * -4, cy + d * 22, cx - d*-4, cy + d * 23);
  8772. skp->Line(cx - d * -3, cy + d * 22, cx - d*-3, cy + d * 23);
  8773. skp->Line(cx - d * -2, cy + d * 22, cx - d*-2, cy + d * 23);
  8774. skp->Line(cx - d * -1, cy + d * 22, cx - d*-1, cy + d * 23);
  8775. skp->Line(cx - d * 0, cy + d * 22, cx - d * 0, cy + d * 23);
  8776. skp->Line(cx - d * 1, cy + d * 22, cx - d * 1, cy + d * 23);
  8777. skp->Line(cx - d * 2, cy + d * 22, cx - d * 2, cy + d * 23);
  8778. skp->Line(cx - d * 3, cy + d * 22, cx - d * 3, cy + d * 23);
  8779. skp->Line(cx - d * 4, cy + d * 22, cx - d * 4, cy + d * 23);
  8780. skp->Line(cx - d * 5, cy + d * 22, cx - d * 5, cy + d * 23);
  8781.  
  8782.  
  8783.  
  8784. //skp->Rectangle(cx - d * -5, cy + d * 22, cx - d*-4, cy + d * 23);
  8785.  
  8786. //skp->Rectangle(cx - d * -4, cy + d * 22, cx - d*-3, cy + d * 23);
  8787. //skp->Rectangle(cx - d * -3, cy + d * 22, cx - d*-2, cy + d * 23);
  8788.  
  8789. //skp->Rectangle(cx - d * -2, cy + d * 22, cx - d*-1, cy + d * 23);
  8790.  
  8791. //skp->Rectangle(cx - d * -1, cy + d * 22, cx - 0 , cy + d * 23);
  8792. //skp->Rectangle(cx - d * 0, cy + d * 22, cx - d, cy + d * 23);
  8793.  
  8794. //skp->Rectangle(cx - d * 3, cy + d * 22, cx - d * 2, cy + d * 23);
  8795. //skp->Rectangle(cx - d * 2, cy + d * 22, cx - d*1 , cy + d * 23);
  8796. //skp->Rectangle(cx - d * 4, cy + d * 22, cx - d *3, cy + d * 23);
  8797. //skp->Rectangle(cx - d * 5, cy + d * 22, cx - d * 4, cy + d * 23);
  8798.  
  8799. skp->Line(cx - d*spbrkx - 6, cy + d * 21, cx - d*spbrkx + 6, cy + d * 21);
  8800. skp->Line(cx - d*spbrkx - 6, cy + d * 21, cx - d*spbrkx, cy + d * 23);
  8801. skp->Line(cx - d*spbrkx + 6, cy + d * 21, cx - d*spbrkx, cy + d * 23);
  8802. //skp->Line(cx - d*spbrkx-6, cy + d * 21.5, cx - d*spbrkx, cy + d * 22);
  8803.  
  8804.  
  8805. // show RCS mode
  8806. if (status >= 3 && oapiCockpitMode() == COCKPIT_VIRTUAL) {
  8807. switch (GetAttitudeMode()) {
  8808. case RCS_ROT:
  8809. skp->Text(0, hps->H - 13, "RCS ROT", 7);
  8810. break;
  8811. case RCS_LIN:
  8812. skp->Text(0, hps->H - 13, "RCS_LIN", 7);
  8813. break;
  8814. }
  8815. }
  8816. arm6_ByHUD = ((arm6_By - systart)*-360); //anim state to degrees
  8817. arm6_BpHUD = ((arm6_Bp - spstart) * 147);
  8818. arm6_epHUD = ((arm6_ep - epstart) * -162);
  8819. arm6_ApHUD = ((arm6_Ap - wpstart) * 240);
  8820. arm6_AyHUD = ((arm6_Ay - wystart) * 240);
  8821. arm6_ArHUD = ((arm6_Ar -wrstart) * 894);
  8822. arm_syHUD = ((arm_sy - systart)*-360);
  8823. arm_spHUD = ((arm_sp - spstart) * 147);
  8824. arm_epHUD = ((arm_ep - epstart)*-162);
  8825. arm_wpHUD = ((arm_wp - wpstart) * 240);
  8826. arm_wyHUD = ((arm_wy - wystart) * 240);
  8827. arm_wrHUD = ((arm_wr - wrstart) * 894);
  8828. if (rmshud == 1){//show rms screen
  8829. char cbuf[255];
  8830. sprintf(cbuf, " SY SP EP WP WY WR");
  8831. skp->Text(hps->W / 35, hps->H / 4.7, cbuf, strlen(cbuf));
  8832. sprintf(cbuf, "%7.1f %7.1f %7.1f %7.1f %7.1f %7.1f (current)", arm_syHUD, arm_spHUD,arm_epHUD, arm_wpHUD, arm_wyHUD, arm_wrHUD);
  8833. skp->Text(hps->W / 35, (hps->H / 8.2) + (2.8*hps->Markersize), cbuf, strlen(cbuf));
  8834.  
  8835. sprintf(cbuf, "%7.1f %7.1f %7.1f %7.1f %7.1f %7.1f TGT", arm6_ByHUD, arm6_BpHUD, arm6_epHUD, arm6_ApHUD, arm6_AyHUD, arm6_ArHUD);
  8836. skp->Text(hps->W / 35, (hps->H / 4.8) + (hps->Markersize), cbuf, strlen(cbuf));
  8837.  
  8838. sprintf(cbuf, "%7.1f %7.1f %7.1f %7.1f %7.1f %7.1f ERR", arm_syHUD - arm6_ByHUD, arm_spHUD - arm6_BpHUD,
  8839. arm_epHUD - arm6_epHUD, arm_wpHUD - arm6_ApHUD, arm_wyHUD - arm6_AyHUD, arm_wrHUD - arm6_ArHUD);
  8840. skp->Text(hps->W / 35, (hps->H / 4.8) + (1.5*hps->Markersize), cbuf, strlen(cbuf));
  8841.  
  8842. //
  8843. /*
  8844. char cbuf[255];
  8845. sprintf(cbuf, " SY SP EP WP WY WR");
  8846. skp->Text(hps->W / 35, hps->H / 4.8, cbuf, strlen(cbuf));
  8847. sprintf(cbuf, "(current)%7.1f %7.1f %7.1f %7.1f %7.1f %7.1f", arm_syHUD, arm_spHUD, arm_epHUD, arm_wpHUD, arm_wyHUD, arm_wrHUD);
  8848. skp->Text(hps->W / 35, (hps->H / 8.2) + (2.8*hps->Markersize), cbuf, strlen(cbuf));
  8849.  
  8850. sprintf(cbuf, "TGT %7.1f %7.1f %7.1f %7.1f %7.1f %7.1f ", arm6_ByHUD, arm6_BpHUD, arm6_epHUD, arm6_ApHUD, arm6_AyHUD, arm6_ArHUD);
  8851. skp->Text(hps->W / 35, (hps->H / 4.8) + (hps->Markersize), cbuf, strlen(cbuf));
  8852.  
  8853. sprintf(cbuf, "ERR %7.1f %7.1f %7.1f %7.1f %7.1f %7.1f ", (arm_syHUD - arm6_ByHUD), (arm_spHUD - arm6_BpHUD), (arm_epHUD - arm6_epHUD), (arm_wpHUD - arm6_ApHUD), (arm_wyHUD - arm6_AyHUD), (arm_wrHUD - arm6_ArHUD));
  8854. ;
  8855. skp->Text(hps->W / 35, (hps->H / 4.8) + (1.5*hps->Markersize), cbuf, strlen(cbuf));
  8856.  
  8857. */
  8858. // position/attitude
  8859. sprintf(cbuf, " X Y Z ");
  8860. skp->Text(hps->W / 35, hps->H / 10 + (4.7*hps->Markersize), cbuf, strlen(cbuf));
  8861. sprintf(cbuf, " %+5.0f %+5.0f %+5.0f ", arm_tip[0].x, arm_tip[0].y, arm_tip[0].z);
  8862. skp->Text(hps->W / 35, hps->H / 10 + (5.2*hps->Markersize), cbuf, strlen(cbuf));
  8863.  
  8864.  
  8865.  
  8866. if (Armtilt_proc == 0) sprintf(cbuf, "ARM Latched");
  8867. if ((Armtilt_proc > 0) && (Armtilt_proc <1))sprintf(cbuf, "ARM Transition");
  8868. if (Armtilt_proc == 1) sprintf(cbuf, "ARM Deployed");
  8869. skp->Text(hps->W / 35, (hps->H / 5) + (2.8*hps->Markersize), cbuf, strlen(cbuf));
  8870.  
  8871.  
  8872.  
  8873.  
  8874. if (rmsspeed == 0) sprintf(cbuf, "ARM Speed =1");
  8875. if (rmsspeed == 1) sprintf(cbuf, "ARM Speed =2");
  8876. if (rmsspeed == 2) sprintf(cbuf, "ARM Speed =3");
  8877. if (rmsspeed == 3) sprintf(cbuf, "ARM Speed =4");
  8878. if (rmsspeed == 4) sprintf(cbuf, "ARM Speed =5");
  8879. if (rmsspeed == 5) sprintf(cbuf, "ARM Speed =10");
  8880. skp->Text(hps->W / 35, (hps->H / 3) + (.2*hps->Markersize), cbuf, strlen(cbuf));
  8881.  
  8882.  
  8883.  
  8884. if (arm1set) sprintf(cbuf, "1");
  8885. skp->Text(hps->W / 35, (hps->H / 5) + (4*hps->Markersize), cbuf, strlen(cbuf));
  8886. if (arm2set) sprintf(cbuf, "1 2");
  8887. skp->Text(hps->W / 35, (hps->H / 5) + (4*hps->Markersize), cbuf, strlen(cbuf));
  8888. if (arm3set) sprintf(cbuf, "1 2 3");
  8889. skp->Text(hps->W / 35, (hps->H / 5) + (4*hps->Markersize), cbuf, strlen(cbuf));
  8890. if (arm4set) sprintf(cbuf, "1 2 3 4");
  8891. skp->Text(hps->W / 35, (hps->H / 5) + (4*hps->Markersize), cbuf, strlen(cbuf));
  8892.  
  8893. if (GRAB == 1)
  8894. {
  8895. skp->SetTextColor(0x0066FF66);
  8896. char abuf[256];
  8897. sprintf(abuf, "Distance to attachment %0.4f", distattach);
  8898. skp->Text(hps->W / 35, (hps->H / 5) + (5 * hps->Markersize), abuf, strlen(abuf));
  8899. }
  8900.  
  8901. if (GRAB == 0) {
  8902. skp->SetTextColor(0x0066FF66);
  8903. char abuf[256];
  8904. sprintf(abuf, " ");
  8905. skp->Text(hps->W / 35, (hps->H / 5) + (5 * hps->Markersize), abuf, strlen(abuf));
  8906. }
  8907.  
  8908.  
  8909. }
  8910.  
  8911.  
  8912.  
  8913.  
  8914.  
  8915.  
  8916. return true;
  8917. }
  8918.  
  8919.  
  8920. }
  8921. VECTOR3 Atlantis::CalcAnimationFKArm() {
  8922. //Do forward kinematics to get the current position of the wrist joint
  8923. double current_phi_s = linterp(0, shoulder_min, 1, shoulder_max, arm_sp);
  8924. double current_phi_e = linterp(0, elbow_min, 1, elbow_max, arm_ep);
  8925. double current_beta_s = linterp(0, -180, 1, 180, arm_sy);
  8926. double current_phi_l = current_phi_s - current_phi_e;
  8927. double rho_e = lu*cos(RAD*current_phi_s);
  8928. double z_e = lu*sin(RAD*current_phi_s);
  8929. double rho_w = rho_e + ll*cos(RAD*current_phi_l);
  8930. double z_w = z_e + ll*sin(RAD*current_phi_l);
  8931. double x_w = rho_w*cos(RAD*current_beta_s);
  8932. double y_w = rho_w*sin(RAD*current_beta_s);
  8933. // sprintf(oapiDebugString(),"ll %f lu %f arm_sy %f beta_s %f arm_sp %f phi_s %f arm_ep %f phi_e %f FK %f,%f,%f",ll,lu,arm_sy,current_beta_s,arm_sp,current_phi_s,arm_ep,current_phi_e,x_w,y_w,z_w);
  8934. return _V(x_w, y_w, z_w);
  8935. }
  8936.  
  8937. void Atlantis::SetAnimationIKArm(VECTOR3 arm_wrist_dpos) {
  8938. arm_wrist_pos = CalcAnimationFKArm();
  8939. //Candidate position. Calculate the joints on it...
  8940. VECTOR3 arm_wrist_cpos = arm_wrist_pos + arm_wrist_dpos;
  8941. double r = length(arm_wrist_cpos);
  8942. double beta_s = DEG*atan2(arm_wrist_cpos.y, arm_wrist_cpos.x);
  8943. double rho = sqrt(arm_wrist_cpos.x*arm_wrist_cpos.x + arm_wrist_cpos.y*arm_wrist_cpos.y);
  8944. double cos_phibar_e = (r*r - lu*lu - ll*ll) / (-2 * lu*ll);
  8945. if (fabs(cos_phibar_e)>1) return;//Can't reach new point with the elbow
  8946. double phi_e = 180 - DEG*acos(cos_phibar_e);
  8947. double cos_phi_s2 = (ll*ll - lu*lu - r*r) / (-2 * lu*r);
  8948. if (fabs(cos_phi_s2)>1) return; //Can't reach with shoulder
  8949. double phi_s = DEG*(atan2(arm_wrist_cpos.z, rho) + acos(cos_phi_s2));
  8950. double anim_phi_s = linterp(shoulder_min, 0, shoulder_max, 1, phi_s);
  8951. double anim_phi_e = linterp(elbow_min, 0, elbow_max, 1, phi_e);
  8952. double anim_beta_s = linterp(-180, 0, 180, 1, beta_s);
  8953. if (anim_beta_s<0 || anim_beta_s>1) return;
  8954. if (anim_phi_s<0 || anim_phi_s>1) return;
  8955. if (anim_phi_e<0 || anim_phi_e>1) return;
  8956. //but only keep it and set the joints if no constraints are violated.
  8957.  
  8958. //Limited IK on the wrist
  8959. double new_phi_l = phi_s - phi_e;
  8960. double current_phi_w = linterp(0, wrist_min, 1, wrist_max, arm_wp);
  8961. double current_phi_s = linterp(0, shoulder_min, 1, shoulder_max, arm_sp);
  8962. double current_phi_e = linterp(0, elbow_min, 1, elbow_max, arm_ep);
  8963. double current_beta_s = linterp(0, -180, 1, 180, arm_sy);
  8964. double current_phi_l = current_phi_s - current_phi_e;
  8965. double new_phi_w = current_phi_w - new_phi_l + current_phi_l;
  8966. double anim_phi_w = linterp(wrist_min, 0, wrist_max, 1, new_phi_w);
  8967. arm_sy = anim_beta_s;
  8968. SetAnimationArm(anim_arm_sy, arm_sy);
  8969. arm_sp = anim_phi_s;
  8970. SetAnimationArm(anim_arm_sp, arm_sp);
  8971. arm_ep = anim_phi_e;
  8972. SetAnimationArm(anim_arm_ep, arm_ep);
  8973. arm_wp = anim_phi_w;
  8974. SetAnimationArm(anim_arm_wp, arm_wp);
  8975. arm_wrist_pos = arm_wrist_cpos;
  8976. }
  8977.  
  8978. // --------------------------------------------------------------
  8979. // Keyboard interface handler (buffered key events)
  8980. // --------------------------------------------------------------
  8981. int Atlantis::clbkConsumeBufferedKey(DWORD key, bool down, char *kstate)
  8982. {
  8983. if (!down) return 0; // only process keydown events
  8984.  
  8985. if (KEYMOD_SHIFT(kstate)) {
  8986.  
  8987. switch (key) {
  8988. case OAPI_KEY_B: //turn lights on/off
  8989. {
  8990. // if (light_status == 0) light_status = 1;
  8991. // else if (light_status == 1) light_status = 0;
  8992. // return 1;
  8993. }
  8994. case OAPI_KEY_F: //armseq
  8995. {
  8996. ARMSEQ();
  8997. }
  8998. case OAPI_KEY_F6:{
  8999.  
  9000.  
  9001. DetachChild(sat_attach, 1.0);
  9002.  
  9003. return 1;
  9004. }
  9005.  
  9006. case OAPI_KEY_E:
  9007. {
  9008. Revertextdoor();
  9009. //case OAPI_KEY_B: // deploy/retract speedbrake
  9010. // if (!Playback()) RevertSpeedbrake();
  9011. return 1;
  9012. }
  9013. case OAPI_KEY_0:
  9014. {
  9015. spdb_off = 1;
  9016. spdb_on = 0;
  9017. RevertSpeedbrake();
  9018. return 1;
  9019. }
  9020. case OAPI_KEY_9:
  9021. {
  9022. spdb_off = 0;
  9023. spdb_on = 1;
  9024. RevertSpeedbrake();
  9025. return 1;
  9026. }
  9027. case OAPI_KEY_V:
  9028.  
  9029. {
  9030.  
  9031. CAM = 6;//elbow
  9032. //SelectCockpitView(CAM);
  9033. SetAnimationCameras();
  9034. return 1;
  9035.  
  9036. }
  9037.  
  9038. //rmshud
  9039. case OAPI_KEY_J:
  9040.  
  9041. {
  9042. if (rmshud == 0) rmshud = 1;
  9043. else (rmshud = 0);
  9044. return 1;
  9045. }
  9046.  
  9047.  
  9048. case OAPI_KEY_Z:
  9049.  
  9050. {
  9051. CAM = 8; //SelectCockpitView(CAM);
  9052. SetAnimationCameras(); SelectCockpitView(CAM);
  9053. return 1;
  9054. }
  9055. case OAPI_KEY_X: //Armtilt
  9056. {
  9057. Armtilt();
  9058.  
  9059. return 1;
  9060. }
  9061. case OAPI_KEY_S: //RMS speed
  9062. {
  9063. if (rmsspeed == 0) rmsspeed = 1;
  9064.  
  9065.  
  9066. else if (rmsspeed == 1) rmsspeed = 2;
  9067.  
  9068.  
  9069. else if (rmsspeed == 2) rmsspeed = 3;
  9070.  
  9071.  
  9072. else if (rmsspeed == 3) rmsspeed = 4;
  9073.  
  9074.  
  9075. else if (rmsspeed == 4) rmsspeed = 5;
  9076.  
  9077.  
  9078. else if (rmsspeed == 5) rmsspeed = 0;
  9079.  
  9080.  
  9081. return 1;
  9082.  
  9083. }
  9084. }
  9085. }
  9086. else if (KEYMOD_CONTROL(kstate)) {
  9087. switch (key) {
  9088. case OAPI_KEY_SPACE: // open RMS control dialog
  9089. oapiOpenDialogEx(g_Param.hDLL, IDD_CTRL, Atlantis_DlgProc, 0, this);
  9090. return 1;
  9091. case OAPI_KEY_B: // deploy/retract speedbrake
  9092. if (!Playback()) RevertSpeedbrake();
  9093. return 1;
  9094. case OAPI_KEY_8: // stop rms
  9095. //rmsexecute = 0;
  9096. return 1;
  9097. case OAPI_KEY_COMMA: // speed brake
  9098. spdb_auto = 1;
  9099. return 1;
  9100. case OAPI_KEY_J: // deploy/retract External Tank Hatch
  9101. RevertSETD();
  9102. RevertPETD();
  9103. return 1;
  9104. case OAPI_KEY_7: // deploy/stow SSME
  9105. RevertSSMESTOW();
  9106. return 1;
  9107. case OAPI_KEY_U: // deploy/store Ku-band antenna
  9108. if (!Playback()) plop->RevertKuAntennaAction();
  9109. return 1;
  9110. case OAPI_KEY_G: // deploy/retract speedbrake
  9111. geararmed = 1;
  9112. return 1;
  9113.  
  9114. case OAPI_KEY_L: // deploy/store Ku-band antenna
  9115. { if (!Playback())
  9116.  
  9117. (plop->MechPwr[0] = plop->MP_ON) || (plop->MechPwr[1] = plop->MP_ON);//if power is off turn power on.
  9118. { // check both systems are set correctly
  9119. (plop->MechPwr[0] = plop->MP_ON) || (plop->MechPwr[1] = plop->MP_ON);//if power is off turn power on.
  9120. (plop->RadiatorCtrl[0] = plop->RC_DEPLOY);
  9121. (plop->RadiatorCtrl[1] = plop->RC_DEPLOY);
  9122. //if plop->(action == AnimState::CLOSING && RadiatorCtrl[i] != RC_STOW) return;
  9123. }
  9124.  
  9125.  
  9126.  
  9127. }
  9128. case OAPI_KEY_5: //Armtilt
  9129. {
  9130. RevertADTA();
  9131.  
  9132. return 1;
  9133. }
  9134. case OAPI_KEY_X: //Armtilt
  9135. {
  9136. OBSStilt();
  9137.  
  9138. return 1;
  9139. }
  9140. case OAPI_KEY_6: //arminput
  9141. {
  9142. ARMINPUT();
  9143.  
  9144. return 1;
  9145. }
  9146. case OAPI_KEY_V:
  9147.  
  9148. {
  9149.  
  9150. CAM = 7;//eecamera
  9151. //SelectCockpitView(CAM);
  9152. SetAnimationCameras();
  9153. return 1;
  9154. }
  9155.  
  9156.  
  9157. }
  9158. }
  9159. else if (KEYMOD_ALT(kstate)) {
  9160. switch (key) {
  9161. case OAPI_KEY_B: //turn aft lights on/off
  9162. {
  9163. // if (aft_light_status == 0) aft_light_status = 1;
  9164. // else if (aft_light_status == 1) aft_light_status = 0;
  9165. // return 1;
  9166. }
  9167. case OAPI_KEY_1:
  9168. {
  9169. // ReleaseDragchute();
  9170. center_arm = false;
  9171. return 1;
  9172. }
  9173. case OAPI_KEY_2:
  9174. {
  9175. // ReleaseDragchute();
  9176. center_arm = true;
  9177. return 1;
  9178. }
  9179.  
  9180. case OAPI_KEY_J:
  9181. {
  9182. // ReleaseDragchute();
  9183. // IUS_check = IUS_UP;
  9184. return 1;
  9185. }
  9186. }
  9187. }
  9188. else { // unmodified keys
  9189. switch (key) {
  9190. case OAPI_KEY_G: // "Landing gear"
  9191. if (geararmed == 1) {
  9192. SetAnimation(anim_LEFTGEARTALKBACK, .5);//move talkback to barber pole
  9193. SetAnimation(anim_RIGHTGEARTALKBACK, .5);//move talkback to barber pole
  9194. if (!Playback()) RevertLandingGear();
  9195. }
  9196. return 1;
  9197. case OAPI_KEY_J: // "Jettison"
  9198. //if (!Playback()) bManualSeparate = true;
  9199. return 1;
  9200. case OAPI_KEY_K: // "Cargo bay doors"
  9201. if (!Playback()) plop->RevertDoorAction();
  9202. return 1;
  9203. case OAPI_KEY_8:
  9204. ToggleGrapple();
  9205. return 1;
  9206. case OAPI_KEY_COMMA:
  9207. spdb_plus=1;
  9208. return 1;
  9209. case OAPI_KEY_PERIOD:
  9210. spdb_minus = 1;
  9211. return 1;
  9212. case OAPI_KEY_9:
  9213. //center_arm = true;
  9214. FULLINPUT();
  9215. return 1;
  9216.  
  9217. case OAPI_KEY_B:
  9218. {
  9219. if (wheelbrake == 0){
  9220. SetWheelbrakeLevel(1, 0);
  9221. wheelbrake = 1;
  9222. }
  9223. else {
  9224. wheelbrake = 0;
  9225. SetWheelbrakeLevel(0, 0);
  9226. }
  9227. return 1;
  9228. }
  9229.  
  9230.  
  9231.  
  9232.  
  9233.  
  9234.  
  9235.  
  9236.  
  9237.  
  9238. case OAPI_KEY_1:
  9239.  
  9240. {
  9241. CAM = 1;
  9242. //SelectCockpitView(CAM);
  9243. SetAnimationCameras();
  9244. return 1;
  9245. }
  9246. case OAPI_KEY_2:
  9247.  
  9248. {
  9249. CAM = 2;
  9250. //SelectCockpitView(CAM);
  9251. SetAnimationCameras();
  9252. return 1;
  9253. }
  9254. case OAPI_KEY_3:
  9255.  
  9256. {
  9257. CAM = 3;
  9258. //SelectCockpitView(CAM);
  9259. SetAnimationCameras();
  9260. return 1;
  9261. }
  9262. case OAPI_KEY_4:
  9263.  
  9264. {
  9265. CAM = 4;
  9266. //SelectCockpitView(CAM);
  9267. SetAnimationCameras();
  9268. return 1;
  9269. }
  9270. case OAPI_KEY_5:
  9271.  
  9272. {
  9273. CAM = 5;
  9274. //SelectCockpitView(CAM);
  9275. SetAnimationCameras();
  9276. return 1;
  9277. }
  9278.  
  9279.  
  9280. case OAPI_KEY_V:
  9281.  
  9282. {
  9283. CAM = 0;
  9284.  
  9285. vccameracase = 4;
  9286.  
  9287. //SelectCockpitView(CAM);
  9288. SetAnimationCameras();
  9289.  
  9290. return 1;
  9291. }
  9292.  
  9293.  
  9294.  
  9295.  
  9296.  
  9297.  
  9298. }
  9299. }
  9300. return 0;
  9301. }
  9302.  
  9303. // ==============================================================
  9304. // API callback interface
  9305. // ==============================================================
  9306.  
  9307. // --------------------------------------------------------------
  9308. // Module initialisation
  9309. // --------------------------------------------------------------
  9310. DLLCLBK void InitModule (HINSTANCE hModule)
  9311. {
  9312. g_Param.hDLL = hModule;
  9313. oapiRegisterCustomControls (hModule);
  9314. g_Param.tkbk_label = oapiCreateSurface (LOADBMP (IDB_TKBKLABEL));
  9315.  
  9316. // allocate GDI resources
  9317. g_Param.font[0] = CreateFont (-11, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 0, "Arial");
  9318. g_Param.font[1] = CreateFont(70, 0, 0, 0, 000, 0, 0, 0, 0, 0, 0, 0, 0, "Arial");
  9319. g_Param.font[2] = CreateFont(40, 0, 0, 0, 0, 000, 0, 0, 0, 0, 0, 0, 0, "Seven Segment");
  9320. g_Param.font[3] = CreateFont(70, 0, 0, 0, 000, 0, 0, 0, 0, 0, 0, 0, 0, "Arial");
  9321. g_Param.font[4] = CreateFont(50, 0, 0, 0, 0, 000, 0, 0, 0, 0, 0, 0, 0, "Seven Segment");
  9322. g_Param.font[5] = CreateFont(25, 0, 0, 0, 0, 000, 0, 0, 0, 0, 0, 0, 0, "Seven Segment");
  9323.  
  9324.  
  9325.  
  9326. }
  9327.  
  9328. DLLCLBK void ExitModule (HINSTANCE hModule)
  9329. {
  9330. oapiUnregisterCustomControls (hModule);
  9331. oapiDestroySurface (g_Param.tkbk_label);
  9332.  
  9333. // deallocate GDI resources
  9334. DeleteObject (g_Param.font[0]);
  9335.  
  9336. }
  9337.  
  9338. // --------------------------------------------------------------
  9339. // Vessel initialisation
  9340. // --------------------------------------------------------------
  9341. DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel)
  9342. {
  9343. return new Atlantis (hvessel, flightmodel);
  9344. }
  9345.  
  9346. // --------------------------------------------------------------
  9347. // Vessel cleanup
  9348. // --------------------------------------------------------------
  9349. DLLCLBK void ovcExit (VESSEL *vessel)
  9350. {
  9351. if (vessel) delete (Atlantis*)vessel;
  9352. oapiReleaseFont(Atlantis::font3);
  9353. }
  9354.  
  9355. // ==============================================================
  9356. // Message callback function for Atlantis control dialog box
  9357. // ==============================================================
  9358.  
  9359. BOOL CALLBACK Atlantis_DlgProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  9360. {
  9361. Atlantis *sts = (uMsg == WM_INITDIALOG ? (Atlantis*)lParam : (Atlantis*)oapiGetDialogContext (hWnd));
  9362. // pointer to vessel instance was passed as dialog context
  9363.  
  9364. switch (uMsg) {
  9365. case WM_COMMAND:
  9366. switch (LOWORD(wParam)) {
  9367. case IDCANCEL:
  9368. oapiCloseDialog(hWnd);
  9369. return TRUE;
  9370. //case IDC_ASCENTAP:
  9371. // sts->CreateAscentAPDlg();
  9372. // break;
  9373. case IDC_PLBAYOP:
  9374. sts->plop->OpenDialog();
  9375. break;
  9376.  
  9377. case IDC_RMSOP:
  9378. oapiOpenDialogEx(g_Param.hDLL, IDD_RMS, RMS_DlgProc, 0, sts);
  9379. (sts->RMSDIALOG = 2);
  9380. break;
  9381. case IDC_LIGHT3:
  9382. oapiOpenDialogEx(g_Param.hDLL, IDD_PAYLOAD1, EVA_DlgProc, 0, sts);
  9383. break;
  9384.  
  9385.  
  9386. case IDC_LIGHT:
  9387. oapiOpenDialogEx(g_Param.hDLL, IDD_LIGHT, LIGHT_DlgProc, 0, sts);
  9388. break;
  9389.  
  9390. case IDC_LIGHT2:
  9391. oapiOpenDialogEx(g_Param.hDLL, IDD_PAYLOAD, PAYLOADOPERATION_DlgProc, 0, sts);
  9392. break;
  9393. }
  9394. break;
  9395. }
  9396. return oapiDefDialogProc (hWnd, uMsg, wParam, lParam);
  9397. }
  9398.  
  9399. // ==============================================================
  9400. // Message callback function for RMS control dialog box
  9401. // ==============================================================
  9402.  
  9403. BOOL CALLBACK RMS_DlgProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  9404. {
  9405.  
  9406. Atlantis *sts = (uMsg == WM_INITDIALOG ? (Atlantis*)lParam : (Atlantis*)oapiGetDialogContext (hWnd));
  9407. // pointer to vessel instance was passed as dialog context
  9408.  
  9409. const double step = 0.05*RAD;
  9410. static double t0;
  9411. double t1;
  9412. HICON hIcon;
  9413. HWND hDlg;
  9414. switch (uMsg) {
  9415. case WM_INITDIALOG:
  9416. hIcon = LoadIcon (g_Param.hDLL, MAKEINTRESOURCE(IDI_UP));
  9417. SendDlgItemMessage (hWnd, IDC_WRIST_PITCHUP, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
  9418. SendDlgItemMessage (hWnd, IDC_ELBOW_PITCHUP, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
  9419. SendDlgItemMessage (hWnd, IDC_SHOULDER_PITCHUP, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
  9420. hIcon = LoadIcon (g_Param.hDLL, MAKEINTRESOURCE(IDI_DOWN));
  9421. SendDlgItemMessage (hWnd, IDC_WRIST_PITCHDOWN, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
  9422. SendDlgItemMessage (hWnd, IDC_ELBOW_PITCHDOWN, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
  9423. SendDlgItemMessage (hWnd, IDC_SHOULDER_PITCHDOWN, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
  9424. hIcon = LoadIcon (g_Param.hDLL, MAKEINTRESOURCE(IDI_LEFT));
  9425. SendDlgItemMessage (hWnd, IDC_WRIST_YAWLEFT, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
  9426. SendDlgItemMessage (hWnd, IDC_SHOULDER_YAWLEFT, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
  9427. hIcon = LoadIcon (g_Param.hDLL, MAKEINTRESOURCE(IDI_RIGHT));
  9428. SendDlgItemMessage (hWnd, IDC_WRIST_YAWRIGHT, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
  9429. SendDlgItemMessage (hWnd, IDC_SHOULDER_YAWRIGHT, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
  9430. hIcon = LoadIcon (g_Param.hDLL, MAKEINTRESOURCE(IDI_RRIGHT));
  9431. SendDlgItemMessage (hWnd, IDC_WRIST_ROLLRIGHT, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
  9432. hIcon = LoadIcon (g_Param.hDLL, MAKEINTRESOURCE(IDI_RLEFT));
  9433. SendDlgItemMessage (hWnd, IDC_WRIST_ROLLLEFT, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
  9434. SendDlgItemMessage (hWnd, IDC_SHOWGRAPPLE, BM_SETCHECK, oapiGetShowGrapplePoints() ? BST_CHECKED:BST_UNCHECKED, 0);
  9435. SetWindowText (GetDlgItem (hWnd, IDC_GRAPPLE), sts->SatGrappled() ? "Release" : "Grapple");
  9436. EnableWindow (GetDlgItem (hWnd, IDC_STOW), sts->SatGrappled() ? FALSE : TRUE);
  9437. SetWindowText (GetDlgItem (hWnd, IDC_PAYLOAD), sts->SatStowed() ? "Release" : "Arrest");
  9438. EnableWindow (GetDlgItem (hWnd, IDC_PAYLOAD), sts->SatStowed() ? TRUE:FALSE);
  9439. SetWindowText(GetDlgItem(hWnd, IDC_PAYLOAD2), sts->SatStowed2() ? "Release" : "Arrest");
  9440. EnableWindow(GetDlgItem(hWnd, IDC_PAYLOAD2), sts->SatStowed2() ? TRUE : FALSE);
  9441. SetWindowText(GetDlgItem(hWnd, IDC_PAYLOAD3), sts->SatStowed3() ? "Release" : "Arrest");
  9442. EnableWindow(GetDlgItem(hWnd, IDC_PAYLOAD3), sts->SatStowed3() ? TRUE : FALSE);
  9443. SetTimer (hWnd, 1, 100, NULL);
  9444. t0 = oapiGetSimTime();
  9445. return FALSE;
  9446. case WM_DESTROY:
  9447. KillTimer (hWnd, 1);
  9448. return 0;
  9449. case WM_TIMER:
  9450. if (wParam == 1) {
  9451. t1 = oapiGetSimTime();
  9452. if (SendDlgItemMessage (hWnd, IDC_SHOULDER_YAWLEFT, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9453. sts->arm_sy = min(1.0, sts->arm_sy + (t1 - t0)*sts->ARM_OPERATING_SPEED);
  9454. sts->SetAnimationArm (sts->anim_arm_sy, sts->arm_sy);
  9455.  
  9456.  
  9457.  
  9458.  
  9459.  
  9460.  
  9461. } else if (SendDlgItemMessage (hWnd, IDC_SHOULDER_YAWRIGHT, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9462. sts->arm_sy = max(0.0, sts->arm_sy - (t1 - t0)*sts->ARM_OPERATING_SPEED);
  9463. sts->SetAnimationArm (sts->anim_arm_sy, sts->arm_sy);
  9464. } else if (SendDlgItemMessage (hWnd, IDC_SHOULDER_PITCHUP, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9465. sts->arm_sp = min(1.0, sts->arm_sp + (t1 - t0)*sts->ARM_OPERATING_SPEED);
  9466. sts->SetAnimationArm (sts->anim_arm_sp, sts->arm_sp);
  9467. } else if (SendDlgItemMessage (hWnd, IDC_SHOULDER_PITCHDOWN, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9468. sts->arm_sp = max(0.0, sts->arm_sp - (t1 - t0)*sts->ARM_OPERATING_SPEED);
  9469. sts->SetAnimationArm (sts->anim_arm_sp, sts->arm_sp);
  9470. } else if (SendDlgItemMessage (hWnd, IDC_ELBOW_PITCHUP, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9471. sts->arm_ep = max(0.0, sts->arm_ep - (t1 - t0)*sts->ARM_OPERATING_SPEED);
  9472. sts->SetAnimationArm (sts->anim_arm_ep, sts->arm_ep);
  9473. } else if (SendDlgItemMessage (hWnd, IDC_ELBOW_PITCHDOWN, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9474. sts->arm_ep = min(1.0, sts->arm_ep + (t1 - t0)*sts->ARM_OPERATING_SPEED);
  9475. sts->SetAnimationArm (sts->anim_arm_ep, sts->arm_ep);
  9476. } else if (SendDlgItemMessage (hWnd, IDC_WRIST_PITCHUP, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9477. sts->arm_wp = min(1.0, sts->arm_wp + (t1 - t0)*sts->ARM_OPERATING_SPEED);
  9478. sts->SetAnimationArm (sts->anim_arm_wp, sts->arm_wp);
  9479. } else if (SendDlgItemMessage (hWnd, IDC_WRIST_PITCHDOWN, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9480. sts->arm_wp = max(0.0, sts->arm_wp - (t1 - t0)*sts->ARM_OPERATING_SPEED);
  9481. sts->SetAnimationArm (sts->anim_arm_wp, sts->arm_wp);
  9482. } else if (SendDlgItemMessage (hWnd, IDC_WRIST_YAWRIGHT, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9483. sts->arm_wy = min(1.0, sts->arm_wy + (t1 - t0)*sts->ARM_OPERATING_SPEED);
  9484. sts->SetAnimationArm (sts->anim_arm_wy, sts->arm_wy);
  9485. } else if (SendDlgItemMessage (hWnd, IDC_WRIST_YAWLEFT, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9486. sts->arm_wy = max(0.0, sts->arm_wy - (t1 - t0)*sts->ARM_OPERATING_SPEED);
  9487. sts->SetAnimationArm (sts->anim_arm_wy, sts->arm_wy);
  9488. } else if (SendDlgItemMessage (hWnd, IDC_WRIST_ROLLLEFT, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9489. sts->arm_wr = max(0.0, sts->arm_wr - (t1 - t0)*sts->ARM_OPERATING_SPEED);
  9490. sts->SetAnimationArm (sts->anim_arm_wr, sts->arm_wr);
  9491. }
  9492. else if (SendDlgItemMessage(hWnd, IDC_WRIST_ROLLRIGHT, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9493. sts->arm_wr = min(1.0, sts->arm_wr + (t1 - t0)*sts->ARM_OPERATING_SPEED);
  9494. sts->SetAnimationArm(sts->anim_arm_wr, sts->arm_wr);
  9495. }
  9496. //ik
  9497.  
  9498. else if (SendDlgItemMessage(hWnd, IDC_TRANS_PX, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9499. sts->SetAnimationIKArm(_V(+1, 0, 0)*(t1 - t0)*sts->ARM_OPERATING_SPEED);
  9500. }
  9501. else if (SendDlgItemMessage(hWnd, IDC_TRANS_PY, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9502. sts->SetAnimationIKArm(_V(0, +1, 0)*(t1 - t0)*sts->ARM_OPERATING_SPEED);
  9503. }
  9504. else if (SendDlgItemMessage(hWnd, IDC_TRANS_PZ, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9505. sts->SetAnimationIKArm(_V(0, 0, +1)*(t1 - t0)*sts->ARM_OPERATING_SPEED);
  9506. }
  9507. else if (SendDlgItemMessage(hWnd, IDC_TRANS_MX, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9508. sts->SetAnimationIKArm(_V(-1, 0, 0)*(t1 - t0)*sts->ARM_OPERATING_SPEED);
  9509. }
  9510. else if (SendDlgItemMessage(hWnd, IDC_TRANS_MY, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9511. sts->SetAnimationIKArm(_V(0, -1, 0)*(t1 - t0)*sts->ARM_OPERATING_SPEED);
  9512. }
  9513. else if (SendDlgItemMessage(hWnd, IDC_TRANS_MZ, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9514. sts->SetAnimationIKArm(_V(0, 0, -1)*(t1 - t0)*sts->ARM_OPERATING_SPEED);
  9515. }
  9516. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  9517. if (sts->rmslight_status == 1){
  9518.  
  9519. SetWindowText(GetDlgItem(hDlg, IDC_SPEED2), "LIGHT ON");
  9520. //EnableWindow(GetDlgItem(hDlg, IDC_STOW), TRUE);
  9521.  
  9522.  
  9523. }
  9524. if (sts->rmslight_status == 0){
  9525.  
  9526. SetWindowText(GetDlgItem(hDlg, IDC_SPEED2), "LIGHT OFF");
  9527. //EnableWindow(GetDlgItem(hDlgsts->rmslight_status = 0;
  9528.  
  9529. }
  9530. }
  9531.  
  9532.  
  9533.  
  9534. if (SendDlgItemMessage(hWnd, IDC_SPEED2, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9535. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  9536. if (sts->rmslight_status == 0){
  9537.  
  9538. SetWindowText(GetDlgItem(hDlg, IDC_SPEED2), "LIGHT ON");
  9539.  
  9540. sts->rmslight_status = 1;
  9541.  
  9542. }
  9543. else if (sts->rmslight_status == 1){
  9544.  
  9545. SetWindowText(GetDlgItem(hDlg, IDC_SPEED2), "LIGHT OFF");
  9546.  
  9547. sts->rmslight_status = 0;
  9548.  
  9549. }
  9550.  
  9551. }
  9552. }
  9553.  
  9554.  
  9555.  
  9556. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  9557.  
  9558. if (sts->rmsspeed == 0){
  9559.  
  9560. SetWindowText(GetDlgItem(hDlg, IDC_SPEED), "Speed 1");
  9561.  
  9562. }
  9563. else if (sts->rmsspeed == 1){
  9564.  
  9565. SetWindowText(GetDlgItem(hDlg, IDC_SPEED), "Speed 2");
  9566.  
  9567. }
  9568. else if (sts->rmsspeed == 2){
  9569.  
  9570. SetWindowText(GetDlgItem(hDlg, IDC_SPEED), "Speed 3");
  9571.  
  9572. }
  9573. else if (sts->rmsspeed == 3){
  9574.  
  9575. SetWindowText(GetDlgItem(hDlg, IDC_SPEED), "Speed 4");
  9576.  
  9577. }
  9578. else if (sts->rmsspeed == 4){
  9579.  
  9580. SetWindowText(GetDlgItem(hDlg, IDC_SPEED), "Speed 5");
  9581.  
  9582. }
  9583. else if (sts->rmsspeed == 5){
  9584.  
  9585. SetWindowText(GetDlgItem(hDlg, IDC_SPEED), "Speed 10");
  9586.  
  9587. }
  9588. }
  9589.  
  9590.  
  9591.  
  9592. if (SendDlgItemMessage(hWnd, IDC_SPEED, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9593. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  9594. if (sts->rmsspeed == 0){
  9595.  
  9596. // SetWindowText(GetDlgItem(hDlg, IDC_SPEED), "Speed 2");
  9597.  
  9598. sts->rmsspeed = 1;
  9599. sts->ARM_OPERATING_SPEED = .01;
  9600. }
  9601. else if (sts->rmsspeed == 1){
  9602.  
  9603. // SetWindowText(GetDlgItem(hDlg, IDC_SPEED), "Speed 3");
  9604.  
  9605. sts->rmsspeed = 2;
  9606. sts->ARM_OPERATING_SPEED = .02;
  9607. }
  9608. else if (sts->rmsspeed == 2){
  9609.  
  9610. // SetWindowText(GetDlgItem(hDlg, IDC_SPEED), "Speed 4");
  9611.  
  9612. sts->rmsspeed = 3;
  9613. sts->ARM_OPERATING_SPEED = .03;
  9614. }
  9615. else if (sts->rmsspeed == 3){
  9616.  
  9617. // SetWindowText(GetDlgItem(hDlg, IDC_SPEED), "Speed 5");
  9618.  
  9619. sts->rmsspeed = 4;
  9620. sts->ARM_OPERATING_SPEED = .04;
  9621. }
  9622. else if (sts->rmsspeed == 4){
  9623.  
  9624. // SetWindowText(GetDlgItem(hDlg, IDC_SPEED), "Speed 10");
  9625.  
  9626. sts->rmsspeed = 5;
  9627. sts->ARM_OPERATING_SPEED = .1;
  9628. }
  9629. else if (sts->rmsspeed == 5){
  9630.  
  9631. // SetWindowText(GetDlgItem(hDlg, IDC_SPEED), "Speed 1");
  9632.  
  9633. sts->rmsspeed = 0;
  9634. sts->ARM_OPERATING_SPEED = .01;
  9635. }
  9636. }
  9637. }
  9638.  
  9639.  
  9640.  
  9641. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  9642.  
  9643. if (sts->Armtilt_proc >=1)
  9644. SetWindowText(GetDlgItem(hDlg, IDC_SPEED3), "Arm Deployed");
  9645.  
  9646. if (sts->Armtilt_proc <=0)
  9647. SetWindowText(GetDlgItem(hDlg, IDC_SPEED3), "Arm Latch");
  9648. if ((sts->Armtilt_proc >0) && (sts->Armtilt_proc <1))
  9649. SetWindowText(GetDlgItem(hDlg, IDC_SPEED3), "////////");
  9650.  
  9651.  
  9652.  
  9653. if (sts->OBSS_proc >= 1)
  9654. SetWindowText(GetDlgItem(hDlg, IDC_SPEED4), "Arm Deployed");
  9655.  
  9656. if (sts->OBSS_proc <= 0)
  9657. SetWindowText(GetDlgItem(hDlg, IDC_SPEED4), "Arm Latch");
  9658. if ((sts->OBSS_proc >0) && (sts->OBSS_proc <1))
  9659. SetWindowText(GetDlgItem(hDlg, IDC_SPEED4), "////////");
  9660.  
  9661.  
  9662.  
  9663.  
  9664. }
  9665.  
  9666.  
  9667.  
  9668.  
  9669.  
  9670.  
  9671.  
  9672.  
  9673. if (SendDlgItemMessage(hWnd, IDC_SPEED3, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9674. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  9675. sts->Armtilt();
  9676.  
  9677. }
  9678. }
  9679.  
  9680. if (SendDlgItemMessage(hWnd, IDC_SPEED4, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9681. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  9682. sts->OBSStilt();
  9683.  
  9684. }
  9685. }
  9686.  
  9687. if (SendDlgItemMessage(hWnd, IDC_STORE1, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9688. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  9689.  
  9690.  
  9691. sts->SAVEA();
  9692. }
  9693. }
  9694. if (SendDlgItemMessage(hWnd, IDC_STORE2, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9695. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  9696.  
  9697.  
  9698. sts->SAVEB();
  9699. }
  9700. }
  9701. if (SendDlgItemMessage(hWnd, IDC_STORE3, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9702. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  9703.  
  9704.  
  9705. sts->SAVEC();
  9706. }
  9707. }
  9708. if (SendDlgItemMessage(hWnd, IDC_STORE4, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9709. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  9710.  
  9711.  
  9712. sts->SAVED();
  9713. }
  9714. }
  9715. if (sts->arm1set)EnableWindow(GetDlgItem(hWnd, IDC_RECALL1), TRUE);
  9716. else EnableWindow(GetDlgItem(hWnd, IDC_RECALL1), FALSE);
  9717. if (sts->arm2set)EnableWindow(GetDlgItem(hWnd, IDC_RECALL2), TRUE);
  9718. else EnableWindow(GetDlgItem(hWnd, IDC_RECALL2), FALSE);
  9719. if (sts->arm3set)EnableWindow(GetDlgItem(hWnd, IDC_RECALL3), TRUE);
  9720. else EnableWindow(GetDlgItem(hWnd, IDC_RECALL3), FALSE);
  9721. if (sts->arm4set )EnableWindow(GetDlgItem(hWnd, IDC_RECALL4), TRUE);
  9722. else EnableWindow(GetDlgItem(hWnd, IDC_RECALL4), FALSE);
  9723. //EnableWindow(GetDlgItem(hWnd, IDC_GRAPPLE), FALSE);
  9724.  
  9725.  
  9726. if (SendDlgItemMessage(hWnd, IDC_RECALL1, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9727. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  9728. sts->LOADA();
  9729.  
  9730. }
  9731. }
  9732. if (SendDlgItemMessage(hWnd, IDC_RECALL2, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9733. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  9734. sts->LOADB();
  9735.  
  9736. }
  9737. }
  9738. if (SendDlgItemMessage(hWnd, IDC_RECALL3, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9739. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  9740. sts->LOADC();
  9741.  
  9742. }
  9743. }
  9744. if (SendDlgItemMessage(hWnd, IDC_RECALL4, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9745. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  9746. sts->LOADD();
  9747.  
  9748. }
  9749. }
  9750. if (SendDlgItemMessage(hWnd, IDC_SPEED10, BM_GETSTATE, 0, 0) & BST_PUSHED) {//halt
  9751. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  9752. sts->center_arm = false;
  9753. sts->rmsexecute = 0;
  9754. }
  9755. }
  9756.  
  9757. if (SendDlgItemMessage(hWnd, IDC_SEQ, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9758. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  9759. sts->center_arm_t = oapiGetSimTime();
  9760. sts->ARMSEQ();
  9761.  
  9762. }
  9763. }
  9764.  
  9765. if (SendDlgItemMessage(hWnd, IDC_SEL, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9766. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  9767. sts->ARMINPUT();
  9768.  
  9769. }
  9770. }
  9771. if (SendDlgItemMessage(hWnd, IDC_ALL, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9772. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  9773. sts->FULLINPUT();
  9774.  
  9775. }
  9776. }
  9777.  
  9778.  
  9779.  
  9780.  
  9781.  
  9782. t0 = t1;
  9783. }
  9784. if (!sts->center_arm) EnableWindow (GetDlgItem (hWnd, IDC_GRAPPLE), TRUE);
  9785. break;
  9786. case WM_COMMAND:
  9787. switch (LOWORD(wParam)) {
  9788. case IDCANCEL:
  9789. oapiCloseDialog (hWnd);
  9790. sts->RMSDIALOG = 0;
  9791. return TRUE;
  9792. case IDC_STOW:
  9793. // if (sts->center_arm = !sts->center_arm) {
  9794. // sts->center_arm_time = oapiGetSimTime();
  9795. // sts->rmsexecute = 1;
  9796. //sts->stow_time = oapiGetSimTime();
  9797. //sts->center_arm_t = oapiGetSimTime();
  9798. //sts->STOW();
  9799. // EnableWindow (GetDlgItem (hWnd, IDC_GRAPPLE), FALSE);
  9800. // }
  9801. if (sts->center_arm = !sts->center_arm) {
  9802. sts->center_arm_t = oapiGetSimTime();
  9803. sts->rmsexecute = 1;
  9804. EnableWindow(GetDlgItem(hWnd, IDC_GRAPPLE), FALSE);
  9805. }
  9806. return 0;
  9807. case IDC_SPEED9://execute new rms arm position
  9808. //if (sts->rmsexecute == 0) {
  9809. // sts->rmsexecute = 1;
  9810. // sts->center_arm_t = oapiGetSimTime();
  9811.  
  9812. //}
  9813.  
  9814. return 0;
  9815.  
  9816. case IDC_GRAPPLE:
  9817. sts->ToggleGrapple();
  9818. return 0;
  9819. case IDC_PAYLOAD:
  9820. sts->ToggleArrest1();
  9821. return 0;
  9822. case IDC_PAYLOAD2:
  9823. sts->ToggleArrest2();
  9824. return 0;
  9825. case IDC_PAYLOAD3:
  9826. sts->ToggleArrest3();
  9827. return 0;
  9828. case IDC_GRAPPLE2:
  9829. sts->ToggleGrappleOBSS();
  9830. return 0;
  9831. case IDC_SHOWGRAPPLE:
  9832. oapiSetShowGrapplePoints (SendDlgItemMessage (hWnd, IDC_SHOWGRAPPLE, BM_GETCHECK, 0, 0) == BST_CHECKED ? true : false);
  9833. return 0;
  9834. }
  9835. break;
  9836. }
  9837. return oapiDefDialogProc (hWnd, uMsg, wParam, lParam);
  9838. }
  9839. BOOL CALLBACK LIGHT_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  9840. {
  9841.  
  9842. Atlantis *sts = (uMsg == WM_INITDIALOG ? (Atlantis*)lParam : (Atlantis*)oapiGetDialogContext(hWnd));
  9843. // pointer to vessel instance was passed as dialog context
  9844.  
  9845. const double step = 0.05*RAD;
  9846. static double t0;
  9847. double t2;
  9848. HICON hIcon;
  9849. HWND hDlg;
  9850. char cbuf[256];
  9851. int i;
  9852. //sprintf (cbuf, "Atlantis %s: Payload Bay Operation", sts->GetName());
  9853.  
  9854. //oapiSetSwitchState(GetDlgItem(hWnd, IDC_FLOOD1), FLOODLIGHT1 == FLOOD_ON ? 0 : FLOODLIGHT1 == FLOOD_OFF ? 1 : 2, true);
  9855.  
  9856. switch (uMsg) {
  9857. case WM_INITDIALOG:
  9858. hIcon = LoadIcon(g_Param.hDLL, MAKEINTRESOURCE(IDI_UP));
  9859. SendDlgItemMessage(hWnd, IDC_CAM_PITCHUP, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
  9860. hIcon = LoadIcon(g_Param.hDLL, MAKEINTRESOURCE(IDI_DOWN));
  9861. SendDlgItemMessage(hWnd, IDC_CAM_PITCHDOWN, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
  9862. hIcon = LoadIcon(g_Param.hDLL, MAKEINTRESOURCE(IDI_LEFT));
  9863. SendDlgItemMessage(hWnd, IDC_CAM_YAWLEFT, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
  9864. hIcon = LoadIcon(g_Param.hDLL, MAKEINTRESOURCE(IDI_RIGHT));
  9865. SendDlgItemMessage(hWnd, IDC_CAM_YAWRIGHT, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
  9866. //UpdateDialog1(hWnd);
  9867.  
  9868. SetTimer(hWnd, 1, 100, NULL);
  9869. t0 = oapiGetSimTime();
  9870. return FALSE;
  9871. case WM_DESTROY:
  9872. KillTimer(hWnd, 1);
  9873. return 0;
  9874. case WM_TIMER:
  9875. {
  9876. t2 = oapiGetSimTime();
  9877.  
  9878.  
  9879.  
  9880. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  9881. if (sts->flood1_status == 1) {
  9882.  
  9883. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD1), "LIGHT ON");
  9884.  
  9885.  
  9886.  
  9887. }
  9888. if (sts->flood1_status == 0) {
  9889.  
  9890. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD1), "LIGHT OFF");
  9891.  
  9892.  
  9893. }
  9894. }
  9895.  
  9896.  
  9897.  
  9898. if (SendDlgItemMessage(hWnd, IDC_FLOOD1, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9899. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  9900. if (sts->flood1_status == 0) {
  9901.  
  9902. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD1), "LIGHT ON");
  9903.  
  9904. sts->flood1_status = 1;
  9905.  
  9906. }
  9907. else if (sts->flood1_status == 1) {
  9908.  
  9909. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD1), "LIGHT OFF");
  9910.  
  9911. sts->flood1_status = 0;
  9912.  
  9913. }
  9914.  
  9915. }
  9916. }
  9917.  
  9918. //LIGHT2
  9919. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  9920. if (sts->flood2_status == 1) {
  9921.  
  9922. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD2), "LIGHT ON");
  9923.  
  9924.  
  9925.  
  9926. }
  9927. if (sts->flood2_status == 0) {
  9928.  
  9929. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD2), "LIGHT OFF");
  9930.  
  9931.  
  9932. }
  9933. }
  9934.  
  9935.  
  9936.  
  9937. if (SendDlgItemMessage(hWnd, IDC_FLOOD2, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9938. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  9939. if (sts->flood2_status == 0) {
  9940.  
  9941. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD2), "LIGHT ON");
  9942.  
  9943. sts->flood2_status = 1;
  9944.  
  9945. }
  9946. else if (sts->flood2_status == 1) {
  9947.  
  9948. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD2), "LIGHT OFF");
  9949.  
  9950. sts->flood2_status = 0;
  9951.  
  9952. }
  9953.  
  9954. }
  9955. }
  9956.  
  9957. //light3/4
  9958. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  9959. if (sts->flood3_status == 1) {
  9960.  
  9961. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD3), "LIGHT ON");
  9962.  
  9963.  
  9964.  
  9965. }
  9966. if (sts->flood3_status == 0) {
  9967.  
  9968. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD3), "LIGHT OFF");
  9969.  
  9970.  
  9971. }
  9972. }
  9973.  
  9974.  
  9975.  
  9976. if (SendDlgItemMessage(hWnd, IDC_FLOOD3, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  9977. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  9978. if (sts->flood3_status == 0) {
  9979.  
  9980. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD3), "LIGHT ON");
  9981.  
  9982. sts->flood3_status = 1;
  9983.  
  9984. }
  9985. else if (sts->flood3_status == 1) {
  9986.  
  9987. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD3), "LIGHT OFF");
  9988.  
  9989. sts->flood3_status = 0;
  9990.  
  9991. }
  9992.  
  9993. }
  9994. }
  9995.  
  9996. //LIGHT4
  9997. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  9998. if (sts->flood4_status == 1) {
  9999.  
  10000. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD4), "LIGHT ON");
  10001.  
  10002.  
  10003.  
  10004. }
  10005. if (sts->flood4_status == 0) {
  10006.  
  10007. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD4), "LIGHT OFF");
  10008.  
  10009.  
  10010. }
  10011. }
  10012.  
  10013.  
  10014.  
  10015. if (SendDlgItemMessage(hWnd, IDC_FLOOD4, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10016. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10017. if (sts->flood4_status == 0) {
  10018.  
  10019. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD4), "LIGHT ON");
  10020.  
  10021. sts->flood4_status = 1;
  10022.  
  10023. }
  10024. else if (sts->flood4_status == 1) {
  10025.  
  10026. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD4), "LIGHT OFF");
  10027.  
  10028. sts->flood4_status = 0;
  10029.  
  10030. }
  10031.  
  10032. }
  10033. }
  10034. //light5/6
  10035. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10036. if (sts->flood5_status == 1) {
  10037.  
  10038. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD5), "LIGHT ON");
  10039.  
  10040.  
  10041.  
  10042. }
  10043. if (sts->flood5_status == 0) {
  10044.  
  10045. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD5), "LIGHT OFF");
  10046.  
  10047. }
  10048. }
  10049.  
  10050.  
  10051.  
  10052. if (SendDlgItemMessage(hWnd, IDC_FLOOD5, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10053. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10054. if (sts->flood5_status == 0) {
  10055.  
  10056. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD5), "LIGHT ON");
  10057.  
  10058. sts->flood5_status = 1;
  10059.  
  10060. }
  10061. else if (sts->flood5_status == 1) {
  10062.  
  10063. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD5), "LIGHT OFF");
  10064.  
  10065. sts->flood5_status = 0;
  10066.  
  10067. }
  10068.  
  10069. }
  10070. }
  10071.  
  10072. //LIGHT4
  10073. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10074. if (sts->flood6_status == 1) {
  10075.  
  10076. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD6), "LIGHT ON");
  10077.  
  10078.  
  10079.  
  10080. }
  10081. if (sts->flood6_status == 0) {
  10082.  
  10083. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD6), "LIGHT OFF");
  10084.  
  10085. }
  10086. }
  10087.  
  10088.  
  10089.  
  10090. if (SendDlgItemMessage(hWnd, IDC_FLOOD6, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10091. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10092. if (sts->flood6_status == 0) {
  10093.  
  10094. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD6), "LIGHT ON");
  10095.  
  10096. sts->flood6_status = 1;
  10097.  
  10098. }
  10099. else if (sts->flood6_status == 1) {
  10100.  
  10101. SetWindowText(GetDlgItem(hDlg, IDC_FLOOD6), "LIGHT OFF");
  10102.  
  10103. sts->flood6_status = 0;
  10104.  
  10105. }
  10106.  
  10107. }
  10108. }//dock
  10109. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10110. if (sts->docklight_status == 1){
  10111.  
  10112. SetWindowText(GetDlgItem(hDlg, IDC_DOCKDIM), "DIM");
  10113.  
  10114.  
  10115.  
  10116. }
  10117. if (sts->docklight_status == 2) {
  10118.  
  10119. SetWindowText(GetDlgItem(hDlg, IDC_DOCKDIM), "BRIGHT");
  10120.  
  10121.  
  10122.  
  10123. }
  10124. if (sts->docklight_status == 0){
  10125.  
  10126. SetWindowText(GetDlgItem(hDlg, IDC_DOCKDIM), "LIGHT OFF");
  10127.  
  10128. }
  10129. }
  10130.  
  10131.  
  10132.  
  10133. if (SendDlgItemMessage(hWnd, IDC_DOCKDIM, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10134. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10135. if (sts->docklight_status == 1) {
  10136.  
  10137. SetWindowText(GetDlgItem(hDlg, IDC_DOCKDIM), "DIM");
  10138.  
  10139.  
  10140.  
  10141. }
  10142. if (sts->docklight_status == 2) {
  10143.  
  10144. SetWindowText(GetDlgItem(hDlg, IDC_DOCKDIM), "BRIGHT");
  10145.  
  10146.  
  10147.  
  10148. }
  10149. if (sts->docklight_status == 0) {
  10150.  
  10151. SetWindowText(GetDlgItem(hDlg, IDC_DOCKDIM), "LIGHT OFF");
  10152.  
  10153. }
  10154. }
  10155. }
  10156.  
  10157. //forebulkhead
  10158. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10159. if (sts->aft_light_status == 1){
  10160.  
  10161. SetWindowText(GetDlgItem(hDlg, IDC_FOREL1), "LIGHT ON");
  10162. //EnableWindow(GetDlgItem(hDlg, IDC_STOW), TRUE);
  10163.  
  10164.  
  10165. }
  10166. if (sts->aft_light_status == 0){
  10167.  
  10168. SetWindowText(GetDlgItem(hDlg, IDC_FOREL1), "LIGHT OFF");
  10169.  
  10170. }
  10171. }
  10172.  
  10173.  
  10174.  
  10175. if (SendDlgItemMessage(hWnd, IDC_FOREL1, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10176. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10177. if (sts->aft_light_status == 0){
  10178.  
  10179. SetWindowText(GetDlgItem(hDlg, IDC_FOREL1), "LIGHT ON");
  10180.  
  10181. sts->aft_light_status = 1;
  10182.  
  10183. }
  10184. else if (sts->aft_light_status == 1){
  10185.  
  10186. SetWindowText(GetDlgItem(hDlg, IDC_FOREL1), "LIGHT OFF");
  10187.  
  10188. sts->aft_light_status = 0;
  10189.  
  10190. }
  10191.  
  10192. }
  10193. }
  10194. //CAMERA
  10195.  
  10196.  
  10197.  
  10198.  
  10199.  
  10200.  
  10201. if (SendDlgItemMessage(hWnd, IDC_HIGHRATE, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10202. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10203. {
  10204. sts->CAMRATE = 12;
  10205.  
  10206. }
  10207.  
  10208.  
  10209. }
  10210. }
  10211. if (SendDlgItemMessage(hWnd, IDC_LOWRATE, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10212. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10213. {
  10214. sts->CAMRATE = .12;
  10215.  
  10216. }
  10217.  
  10218.  
  10219. }
  10220. }
  10221. if (SendDlgItemMessage(hWnd, IDC_CAM_A, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10222. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10223. {
  10224. sts->CAM = 1;
  10225. sts->SetAnimationCameras();
  10226. }
  10227.  
  10228.  
  10229. }
  10230. }
  10231.  
  10232. if (SendDlgItemMessage(hWnd, IDC_CAM_B, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10233. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10234. {
  10235. sts->CAM = 2;
  10236. sts->SetAnimationCameras();
  10237. }
  10238.  
  10239.  
  10240. }
  10241. }
  10242. if (SendDlgItemMessage(hWnd, IDC__CAM_C, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10243. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10244. {
  10245. sts->CAM = 3;
  10246. sts->SetAnimationCameras();
  10247. }
  10248.  
  10249.  
  10250. }
  10251. }
  10252. if (SendDlgItemMessage(hWnd, IDC__CAM_D, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10253. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10254. {
  10255. sts->CAM = 4;
  10256. sts->SetAnimationCameras();
  10257. }
  10258.  
  10259.  
  10260. }
  10261. }
  10262.  
  10263. if (SendDlgItemMessage(hWnd, IDC__CAM_K, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10264. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10265. {
  10266. sts->CAM = 5;
  10267. sts->SetAnimationCameras();
  10268. }
  10269.  
  10270.  
  10271. }
  10272. }
  10273. if (SendDlgItemMessage(hWnd, IDC__CAM_ET, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10274. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10275. {
  10276. sts->CAM = 9;
  10277. sts->SetAnimationCameras();
  10278. }
  10279.  
  10280.  
  10281. }
  10282. }
  10283. if (SendDlgItemMessage(hWnd, IDC__CAM_ELB, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10284. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10285. {
  10286. sts->CAM = 6;
  10287. sts->SetAnimationCameras();
  10288. }
  10289.  
  10290.  
  10291. }
  10292. }
  10293. if (SendDlgItemMessage(hWnd, IDC_CAM_END, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10294. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10295. {
  10296. sts->CAM = 7;
  10297. sts->SetAnimationCameras();
  10298. }
  10299.  
  10300.  
  10301. }
  10302. }
  10303. if (SendDlgItemMessage(hWnd, IDC_CAM_COCKPIT, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10304. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10305. {
  10306. sts->CAM = 0;
  10307. sts->SetAnimationCameras();
  10308. }
  10309.  
  10310.  
  10311. }
  10312. }
  10313. if (SendDlgItemMessage(hWnd, IDC_CAM_DOCK, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10314. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_LIGHT)) {
  10315. {
  10316. sts->CAM = 8;
  10317. sts->SetAnimationCameras();
  10318. }
  10319.  
  10320.  
  10321. }
  10322. }
  10323. if (SendDlgItemMessage(hWnd, IDC_CAM_YAWLEFT, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10324. //if (sts->CAM == 1){
  10325. // sts->camYaw[sts->CAM_A] = min(sts->MAX_PLB_CAM_PAN, sts->camYaw[sts->CAM_A] - sts->CAMRATE);
  10326. //}
  10327. sts->bPLBCamPanLeft_Man = true;
  10328. sts->ElbowCamPanLeft = true;
  10329. sts->cameraMoved = true;
  10330. sts->SetAnimationCameras();
  10331. }
  10332. else if (SendDlgItemMessage(hWnd, IDC_CAM_YAWRIGHT, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10333. sts->bPLBCamPanRight_Man = true;
  10334. sts->ElbowCamPanRight = true;
  10335. sts->cameraMoved = true;
  10336. sts->SetAnimationCameras();
  10337. }
  10338. if (SendDlgItemMessage(hWnd, IDC_CAM_PITCHUP, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10339. //if (sts->CAM == 1){
  10340. // sts->camYaw[sts->CAM_A] = min(sts->MAX_PLB_CAM_PAN, sts->camYaw[sts->CAM_A] - sts->CAMRATE);
  10341. //}
  10342. sts->bPLBCamTiltUp_Man = true;
  10343. sts->ElbowCamTiltUp = true;
  10344. sts->cameraMoved = true;
  10345. sts->SetAnimationCameras();
  10346. }
  10347. else if (SendDlgItemMessage(hWnd, IDC_CAM_PITCHDOWN, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10348. sts->bPLBCamTiltDown_Man = true;
  10349. sts->ElbowCamTiltDown = true;
  10350. sts->cameraMoved = true;
  10351. sts->SetAnimationCameras();
  10352. }
  10353.  
  10354. t0 = t2;
  10355. }
  10356.  
  10357. break;
  10358. case WM_COMMAND:
  10359. switch (LOWORD(wParam)) {
  10360. case IDCANCEL:
  10361. oapiCloseDialog(hWnd);
  10362. return TRUE;
  10363.  
  10364. break;
  10365. }
  10366. }
  10367. return oapiDefDialogProc(hWnd, uMsg, wParam, lParam);
  10368. }
  10369.  
  10370. //payloadbayoperation
  10371. BOOL CALLBACK PAYLOADOPERATION_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  10372. {
  10373.  
  10374. Atlantis *sts = (uMsg == WM_INITDIALOG ? (Atlantis*)lParam : (Atlantis*)oapiGetDialogContext(hWnd));
  10375. // pointer to vessel instance was passed as dialog context
  10376.  
  10377. const double step = 0.05*RAD;
  10378. static double t0;
  10379. double t3;
  10380. HICON hIcon;
  10381. HWND hDlg;
  10382. char cbuf[256];
  10383. int i;
  10384. //sprintf (cbuf, "Atlantis %s: Payload Bay Operation", sts->GetName());
  10385.  
  10386. //oapiSetSwitchState(GetDlgItem(hWnd, IDC_FLOOD1), FLOODLIGHT1 == FLOOD_ON ? 0 : FLOODLIGHT1 == FLOOD_OFF ? 1 : 2, true);
  10387.  
  10388. switch (uMsg) {
  10389. case WM_INITDIALOG:
  10390.  
  10391. //UpdateDialog1(hWnd);
  10392.  
  10393. SetTimer(hWnd, 1, 100, NULL);
  10394. t0 = oapiGetSimTime();
  10395. return FALSE;
  10396. case WM_DESTROY:
  10397. KillTimer(hWnd, 1);
  10398. return 0;
  10399. case WM_TIMER:
  10400. {
  10401.  
  10402. t3 = oapiGetSimTime();
  10403.  
  10404. char cbuf1[256];
  10405.  
  10406. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_PAYLOAD)) {
  10407. sprintf(cbuf1, "%0.0f", (sts->ius_proc / .016949));
  10408. SetWindowText(GetDlgItem(hDlg, IDC_IUSANGLE), cbuf1);
  10409.  
  10410. char cbuf2[256];
  10411. char cbuf3[256];
  10412. sprintf(cbuf2, "%0.0f", sts->spintable_vel*60/360);
  10413. SetWindowText(GetDlgItem(hDlg, IDC_IUSANGLE2), cbuf2);
  10414. sprintf(cbuf3, "%0.0f", sts->spintable1_vel * 60 / 360);
  10415. SetWindowText(GetDlgItem(hDlg, IDC_IUSANGLE3), cbuf3);
  10416. sprintf(cbuf2, "%0.0f", sts->spintable4_vel * 60 / 360);
  10417. SetWindowText(GetDlgItem(hDlg, IDC_IUSANGLE4), cbuf2);
  10418. sprintf(cbuf3, "%0.0f", sts->spintable5_vel * 60 / 360);
  10419. SetWindowText(GetDlgItem(hDlg, IDC_IUSANGLE5), cbuf3);
  10420.  
  10421. if (sts->SPIN1 == 1){
  10422. if (sts->spintable != 3)
  10423. SetWindowText(GetDlgItem(hDlg, IDC_IUSRELEASE2), "////////");
  10424. else
  10425. SetWindowText(GetDlgItem(hDlg, IDC_IUSRELEASE2), "SPIN RELEASE");
  10426.  
  10427. }
  10428. if (sts->SPIN2 == 1){
  10429. if (sts->spintable1 != 3)SetWindowText(GetDlgItem(hDlg, IDC_IUSRELEASE3), "////////");
  10430. else SetWindowText(GetDlgItem(hDlg, IDC_IUSRELEASE3), "SPIN RELEASE");
  10431. }
  10432. if (sts->SPIN4 == 1){
  10433. if (sts->spintable4 != 3) SetWindowText(GetDlgItem(hDlg, IDC_IUSRELEASE5), "////////");
  10434. else
  10435. SetWindowText(GetDlgItem(hDlg, IDC_IUSRELEASE5), "SPIN RELEASE");
  10436. }
  10437. if (sts->SPIN5 == 1){
  10438. if (sts->spintable5 != 3) SetWindowText(GetDlgItem(hDlg, IDC_IUSRELEASE6), "////////");
  10439. else SetWindowText(GetDlgItem(hDlg, IDC_IUSRELEASE6), "SPIN RELEASE");
  10440. }
  10441. if (sts->USEIUS == 1){
  10442. if (sts->ius_proc < 1.0)
  10443. SetWindowText(GetDlgItem(hDlg, IDC_IUSRELEASE), "////////");
  10444. if (sts->ius_proc == 1.0)
  10445. SetWindowText(GetDlgItem(hDlg, IDC_IUSRELEASE), "IUS RELEASE");
  10446. }
  10447. }
  10448.  
  10449. if (sts->USEIUS == 1){
  10450. if (SendDlgItemMessage(hWnd, IDC_IUSUP2, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10451. if (sts->tilt == 0) sts->tilt = 1;
  10452. else if (sts->tilt ==3) sts->tilt = 4;
  10453. else if ((sts->tilt == 2) && (sts->ius_proc<.4915))sts->tilt = 1;
  10454. else if ((sts->tilt == 2) && (sts->ius_proc >= .4915))sts->tilt = 4;
  10455. // SetWindowText(GetDlgItem(hDlg, IDC_IUSANGLE), "Speed 1");
  10456. // oapiSetShowGrapplePoints(SendDlgItemMessage(hWnd, IDC_SHOWGRAPPLE, BM_GETCHECK, 0, 0) == BST_CHECKED ? true : false);
  10457. //sts->flood6_status = 1;
  10458.  
  10459.  
  10460.  
  10461.  
  10462.  
  10463.  
  10464.  
  10465.  
  10466. }
  10467. if (SendDlgItemMessage(hWnd, IDC_IUSDOWN, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10468. sts->tilt = 2;
  10469.  
  10470.  
  10471. }
  10472.  
  10473. if (SendDlgItemMessage(hWnd, IDC_IUSRELEASE, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10474. if (sts->ius_proc == 1.0)
  10475. sts->DetachChild(sts->sat_attach, .35);//ius is at max value so release
  10476. // sts->DetachChild(sts->sat_attach, 1.0);//ius is at max value so release
  10477. }
  10478. }
  10479. if (sts->SPIN1 == 1){
  10480. if (SendDlgItemMessage(hWnd, IDC_IUSUP, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10481. if (sts->spintable == 0) sts->spintable = 1;
  10482.  
  10483. }
  10484. if (SendDlgItemMessage(hWnd, IDC_IUSRELEASE2, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10485. if (sts->spintable == 3) {
  10486. sts->spintable = 4;
  10487. OBJHANDLE hChild = sts->GetAttachmentStatus(sts->sat_attach);
  10488. sts->DetachChild(sts->sat_attach, 1.0);
  10489. if (oapiIsVessel(hChild)) {
  10490. VESSEL *vChild = oapiGetVesselInterface(hChild);
  10491. VECTOR3 avel;
  10492. avel.data[0] = 0;
  10493. avel.data[1] = 0;
  10494. avel.data[2] = 300 * RAD;
  10495. vChild->SetAngularVel(avel);
  10496. }
  10497. }
  10498. }
  10499. }
  10500.  
  10501. if (sts->SPIN2 == 1){
  10502. if (SendDlgItemMessage(hWnd, IDC_IUSUP3, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10503. if (sts->spintable1 == 0) sts->spintable1 = 1;
  10504.  
  10505. }
  10506. if (SendDlgItemMessage(hWnd, IDC_IUSRELEASE3, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10507. if (sts->spintable1 == 3) {
  10508. sts->spintable1 = 4;
  10509. OBJHANDLE hChild1 = sts->GetAttachmentStatus(sts->sat_attach2);
  10510. sts->DetachChild(sts->sat_attach2, 1.0);
  10511. if (oapiIsVessel(hChild1)) {
  10512. VESSEL *vChild1 = oapiGetVesselInterface(hChild1);
  10513. VECTOR3 avel;
  10514. avel.data[0] = 0;
  10515. avel.data[1] = 0;
  10516. avel.data[2] = 300 * RAD;
  10517. vChild1->SetAngularVel(avel);
  10518. }
  10519. }
  10520. }
  10521. }
  10522. //
  10523. if (sts->SPIN4 == 1){
  10524. if (SendDlgItemMessage(hWnd, IDC_IUSUP4, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10525. if (sts->spintable4 == 0) sts->spintable4 = 1;
  10526.  
  10527. }
  10528. if (SendDlgItemMessage(hWnd, IDC_IUSRELEASE5, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10529. if (sts->spintable4 == 3) {
  10530. sts->spintable4 = 4;
  10531. OBJHANDLE hChild4 = sts->GetAttachmentStatus(sts->sat_attach3);
  10532. sts->DetachChild(sts->sat_attach3, 1.0);
  10533. if (oapiIsVessel(hChild4)) {
  10534. VESSEL *vChild4 = oapiGetVesselInterface(hChild4);
  10535. VECTOR3 avel;
  10536. avel.data[0] = 0;
  10537. avel.data[1] = 0;
  10538. avel.data[2] = 300 * RAD;
  10539. vChild4->SetAngularVel(avel);
  10540. }
  10541. }
  10542. }
  10543. }
  10544. if (sts->SPIN5 == 1){
  10545. if (SendDlgItemMessage(hWnd, IDC_IUSUP5, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10546. if (sts->spintable5 == 0) sts->spintable5 = 1;
  10547.  
  10548. }
  10549. if (SendDlgItemMessage(hWnd, IDC_IUSRELEASE6, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10550. if (sts->spintable5 == 3) {
  10551. sts->spintable5 = 4;
  10552. OBJHANDLE hChild5 = sts->GetAttachmentStatus(sts->sat_attach4);
  10553. sts->DetachChild(sts->sat_attach4, 1.0);
  10554. if (oapiIsVessel(hChild5)) {
  10555. VESSEL *vChild5 = oapiGetVesselInterface(hChild5);
  10556. VECTOR3 avel;
  10557. avel.data[0] = 0;
  10558. avel.data[1] = 0;
  10559. avel.data[2] = 300 * RAD;
  10560. vChild5->SetAngularVel(avel);
  10561. }
  10562. }
  10563. }
  10564. }
  10565. if (sts->SPIN3 == 1){
  10566. if (SendDlgItemMessage(hWnd, IDC_IUSRELEASE4, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10567. OBJHANDLE hChild3 = sts->GetAttachmentStatus(sts->sat_attach3);
  10568. sts->DetachChild(sts->sat_attach3, 1.0);
  10569. if (oapiIsVessel(hChild3)) {
  10570. VESSEL *vChild3 = oapiGetVesselInterface(hChild3);
  10571. VECTOR3 avel;
  10572. avel.data[1] = 0;
  10573. avel.data[0] = 0;
  10574. avel.data[2] = -100 * RAD;
  10575. vChild3->SetAngularVel(avel);
  10576. }
  10577. }
  10578. }
  10579. if (sts->SPIN0 == 1){
  10580. if (SendDlgItemMessage(hWnd, IDC_IUSRELEASE4, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10581. OBJHANDLE hChild3 = sts->GetAttachmentStatus(sts->sat_attach3);
  10582. sts->DetachChild(sts->sat_attach3, .2);
  10583. if (oapiIsVessel(hChild3)) {
  10584. VESSEL *vChild3 = oapiGetVesselInterface(hChild3);
  10585. VECTOR3 avel;
  10586. avel.data[1] = 0;
  10587. avel.data[0] = 0;
  10588. avel.data[2] = 12 * RAD;
  10589. vChild3->SetAngularVel(avel);
  10590. }
  10591. }
  10592. }
  10593. //}
  10594.  
  10595.  
  10596. t0 = t3;
  10597. }
  10598.  
  10599. break;
  10600. case WM_COMMAND:
  10601. switch (LOWORD(wParam)) {
  10602. case IDCANCEL:
  10603. oapiCloseDialog(hWnd);
  10604. return TRUE;
  10605.  
  10606. break;
  10607. }
  10608. }
  10609. return oapiDefDialogProc(hWnd, uMsg, wParam, lParam);
  10610. }
  10611. BOOL CALLBACK EVA_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  10612. {
  10613.  
  10614. Atlantis *sts = (uMsg == WM_INITDIALOG ? (Atlantis*)lParam : (Atlantis*)oapiGetDialogContext(hWnd));
  10615. // pointer to vessel instance was passed as dialog context
  10616.  
  10617. const double step = 0.05*RAD;
  10618. static double t5;
  10619. double t1;
  10620. HICON hIcon;
  10621. HWND hDlg;
  10622. switch (uMsg) {
  10623. case WM_INITDIALOG:
  10624.  
  10625. SetWindowText(GetDlgItem(hWnd, IDC_TETHER1), sts->EVA1TETHER() ? "Release" : "Tether");
  10626. SetWindowText(GetDlgItem(hWnd, IDC_TETHER2), sts->EVA2TETHER() ? "Release" : "Tether");
  10627. SetWindowText(GetDlgItem(hWnd, IDC_TETHER3), sts->EVA3TETHER() ? "Release" : "Tether");
  10628. SetWindowText(GetDlgItem(hWnd, IDC_TETHER4), sts->EVA4TETHER() ? "Release" : "Tether");
  10629. SetTimer(hWnd, 1, 100, NULL);
  10630. t5 = oapiGetSimTime();
  10631. return FALSE;
  10632. case WM_DESTROY:
  10633. KillTimer(hWnd, 1);
  10634. return 0;
  10635. case WM_TIMER:
  10636. {
  10637. //AttachChild(hMMU, ft_pad_att3, hAttWFC);
  10638. if (SendDlgItemMessage(hWnd, IDC_EVA1, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10639. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_PAYLOAD1)) {
  10640. sts->SpawnEVA();
  10641. //sts->ToggleArrest1();
  10642. }
  10643. }
  10644. if (SendDlgItemMessage(hWnd, IDC_EVA2, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10645. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_PAYLOAD1)) {
  10646. sts->SpawnEVA1();
  10647.  
  10648. }
  10649. }
  10650. if (SendDlgItemMessage(hWnd, IDC_EVA3, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10651. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_PAYLOAD1)) {
  10652. sts->SpawnEVA2();
  10653.  
  10654. }
  10655. }
  10656. if (SendDlgItemMessage(hWnd, IDC_EVA4, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10657. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_PAYLOAD1)) {
  10658. sts->SpawnEVA3();
  10659.  
  10660. }
  10661. }
  10662.  
  10663.  
  10664. if (SendDlgItemMessage(hWnd, IDC_EVA5, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10665. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_PAYLOAD1)) {
  10666. if (sts->EXT_proc == 1)sts->ENTER_EVA1();
  10667. //sts->ToggleArrest1();
  10668. }
  10669. }
  10670.  
  10671. if (SendDlgItemMessage(hWnd, IDC_EVA6, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10672. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_PAYLOAD1)) {
  10673. if (sts->EXT_proc == 1)sts->ENTER_EVA2();
  10674. //sts->ToggleArrest1();
  10675. }
  10676. }
  10677. if (SendDlgItemMessage(hWnd, IDC_EVA7, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10678. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_PAYLOAD1)) {
  10679. if (sts->EXT_proc == 1)sts->ENTER_EVA3();
  10680. //sts->ToggleArrest1();
  10681. }
  10682. }
  10683.  
  10684. if (SendDlgItemMessage(hWnd, IDC_EVA8, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10685. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_PAYLOAD1)) {
  10686. if (sts->EXT_proc == 1)sts->ENTER_EVA4();
  10687. //sts->ToggleArrest1();
  10688. }
  10689. }
  10690.  
  10691.  
  10692. if (SendDlgItemMessage(hWnd, IDC_AIRLOCK, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10693. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_PAYLOAD1)) {
  10694. sts->Revertextdoor();
  10695.  
  10696. }
  10697. }
  10698.  
  10699.  
  10700.  
  10701. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_PAYLOAD1)) {
  10702.  
  10703. if (sts->EXT_proc >= 1)
  10704. SetWindowText(GetDlgItem(hDlg, IDC_AIRLOCK), "Hatch Open");
  10705.  
  10706. if (sts->EXT_proc <= 0)
  10707. SetWindowText(GetDlgItem(hDlg, IDC_AIRLOCK), "Hatch Closed");
  10708. if ((sts->EXT_proc >0) && (sts->EXT_proc <1))
  10709. SetWindowText(GetDlgItem(hDlg, IDC_AIRLOCK), "////////");
  10710.  
  10711.  
  10712.  
  10713.  
  10714.  
  10715.  
  10716.  
  10717.  
  10718. }
  10719.  
  10720.  
  10721.  
  10722.  
  10723.  
  10724.  
  10725.  
  10726.  
  10727. if (SendDlgItemMessage(hWnd, IDC_AIRLOCK, BM_GETSTATE, 0, 0) & BST_PUSHED) {
  10728. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_RMS)) {
  10729. sts->Revertextdoor();
  10730.  
  10731. }
  10732. }
  10733. t1 = t5;
  10734. }
  10735.  
  10736. break;
  10737. case WM_COMMAND:
  10738. switch (LOWORD(wParam)) {
  10739. case IDCANCEL:
  10740. oapiCloseDialog(hWnd);
  10741. return TRUE;
  10742. case IDC_TETHER1:
  10743. sts->TETHER1();
  10744. return 0;
  10745. case IDC_TETHER2:
  10746. sts->TETHER2();
  10747. return 0;
  10748. break;
  10749. case IDC_TETHER3:
  10750. sts->TETHER3();
  10751. return 0;
  10752. break;
  10753. case IDC_TETHER4:
  10754. sts->TETHER4();
  10755. return 0;
  10756. break;
  10757. }
  10758. }
  10759. return oapiDefDialogProc(hWnd, uMsg, wParam, lParam);
  10760. }
  10761.  
  10762. void Atlantis::LOADA()
  10763. {
  10764.  
  10765. arm6_By = arm1_By;
  10766. arm6_Bp = arm1_Bp;
  10767. arm6_ep = arm1_ep;
  10768. arm6_Ap = arm1_Ap;
  10769. arm6_Ay = arm1_Ay;
  10770. arm6_Ar = arm1_Ar;
  10771. recallstored = 1;
  10772. }
  10773. void Atlantis::LOADB()
  10774. {
  10775.  
  10776. arm6_By = arm2_By;
  10777. arm6_Bp = arm2_Bp;
  10778. arm6_ep = arm2_ep;
  10779. arm6_Ap = arm2_Ap;
  10780. arm6_Ay = arm2_Ay;
  10781. arm6_Ar = arm2_Ar;
  10782. recallstored = 2;
  10783. }
  10784. void Atlantis::LOADC()
  10785. {
  10786.  
  10787. arm6_By = arm3_By;
  10788. arm6_Bp = arm3_Bp;
  10789. arm6_ep = arm3_ep;
  10790. arm6_Ap = arm3_Ap;
  10791. arm6_Ay = arm3_Ay;
  10792. arm6_Ar = arm3_Ar;
  10793. recallstored = 3;
  10794. }
  10795. void Atlantis::LOADD()
  10796. {
  10797.  
  10798. arm6_By = arm4_By;
  10799. arm6_Bp = arm4_Bp;
  10800. arm6_ep = arm4_ep;
  10801. arm6_Ap = arm4_Ap;
  10802. arm6_Ay = arm4_Ay;
  10803. arm6_Ar = arm4_Ar;
  10804. recallstored = 4;
  10805. }
  10806. void Atlantis::SAVEA()
  10807. {
  10808.  
  10809. arm1_By = arm_sy;
  10810. arm1_Bp = arm_sp;
  10811. arm1_ep = arm_ep;
  10812. arm1_Ap = arm_wp;
  10813. arm1_Ay = arm_wy;
  10814. arm1_Ar = arm_wr;
  10815. arm1set = true;
  10816.  
  10817. }
  10818. void Atlantis::SAVEB()
  10819. {
  10820.  
  10821. arm2_By = arm_sy;
  10822. arm2_Bp = arm_sp;
  10823. arm2_ep = arm_ep;
  10824. arm2_Ap = arm_wp;
  10825. arm2_Ay = arm_wy;
  10826. arm2_Ar = arm_wr;
  10827. arm2set = true;
  10828.  
  10829. }
  10830. void Atlantis::SAVEC()
  10831. {
  10832.  
  10833. arm3_By = arm_sy;
  10834. arm3_Bp = arm_sp;
  10835. arm3_ep = arm_ep;
  10836. arm3_Ap = arm_wp;
  10837. arm3_Ay = arm_wy;
  10838. arm3_Ar = arm_wr;
  10839. arm3set = true;
  10840.  
  10841. }
  10842. void Atlantis::SAVED()
  10843. {
  10844.  
  10845. arm4_By = arm_sy;
  10846. arm4_Bp = arm_sp;
  10847. arm4_ep = arm_ep;
  10848. arm4_Ap = arm_wp;
  10849. arm4_Ay = arm_wy;
  10850. arm4_Ar = arm_wr;
  10851. arm4set = true;
  10852.  
  10853. }
  10854. void Atlantis::CheckFlags()
  10855. {
  10856. if (arm1set && arm1_By == 0.0 && arm1_Bp == 0.0
  10857. && arm1_ep == 0.0 && arm1_Ar == 0.0 && arm1_Ay == 0.0
  10858. && arm1_Ap == 0.0) arm1set = false;
  10859. if (arm2set && arm2_By == 0.0 && arm2_Bp == 0.0
  10860. && arm2_ep == 0.0 && arm2_Ar == 0.0 && arm2_Ay == 0.0
  10861. && arm2_Ap == 0.0) arm2set = false;
  10862. if (arm3set && arm3_By == 0.0 && arm3_Bp == 0.0
  10863. && arm3_ep == 0.0 && arm3_Ar == 0.0 && arm3_Ay == 0.0
  10864. && arm3_Ap == 0.0) arm3set = false;
  10865. if (arm4set && arm4_By == 0.0 && arm4_Bp == 0.0
  10866. && arm4_ep == 0.0 && arm4_Ar == 0.0 && arm4_Ay == 0.0
  10867. && arm4_Ap == 0.0) arm4set = false;
  10868. if (arm5set && arm5_By == 0.0 && arm5_Bp == 0.0
  10869. && arm5_ep == 0.0 && arm5_Ar == 0.0 && arm5_Ay == 0.0
  10870. && arm5_Ap == 0.0) arm5set = false;
  10871. }
  10872. // ==============================================================
  10873. bool Atlantis::ItemChange(char *rstr)
  10874. {
  10875. int ItemValue;
  10876. sscanf(rstr, "%d", &ItemValue);
  10877. DetermineArmSeq(ItemValue);
  10878. center_arm = true;
  10879. Seqindex = 0;
  10880. Seqfinished = false;
  10881.  
  10882. return true;
  10883. }
  10884. // ==============================================================
  10885. void Atlantis::DetermineArmSeq(int ItemValue)
  10886. {
  10887. armseq[0] = int(ItemValue / 1e6);
  10888. ItemValue = ItemValue - (armseq[0] * 1e6);
  10889. armseq[1] = int(ItemValue / 1e5);
  10890. ItemValue = ItemValue - (armseq[1] * 1e5);
  10891. armseq[2] = int(ItemValue / 1e4);
  10892. ItemValue = ItemValue - (armseq[2] * 1e4);
  10893. armseq[3] = int(ItemValue / 1e3);
  10894. ItemValue = ItemValue - (armseq[3] * 1e3);
  10895. armseq[4] = int(ItemValue / 1e2);
  10896. ItemValue = ItemValue - (armseq[4] * 1e2);
  10897. armseq[5] = int(ItemValue / 1e1);
  10898. ItemValue = ItemValue - (armseq[5] * 1e1);
  10899. armseq[6] = int(ItemValue);
  10900. }
  10901. // ==============================================================
  10902. void Atlantis::SeqSSRMS()
  10903. {
  10904. if (Seqfinished == true){
  10905. Seqfinished = false;
  10906. armseq[Seqindex] = 0;
  10907. Seqindex += 1;
  10908. }
  10909.  
  10910. if (Seqindex > 6) center_arm = false;
  10911. if (center_arm){
  10912. // sprintf(oapiDebugString(), "armtip3x %2.2f armtip3y %2.2f Seqindex %2.2f", arm_tip[5].x, arm_tip[5].y, Seqindex);
  10913. PosSSRMS(Seqindex);
  10914. }
  10915. }
  10916. // ==============================================================
  10917. void Atlantis::PosSSRMS(int i)
  10918. {
  10919. //double t0 = oapiGetSimTime();
  10920. double dt = oapiGetSimStep(); // time step//double dt = t0 - center_arm_t; // time step
  10921. double da = ARM_OPERATING_SPEED*dt ;; // total rotation angle
  10922.  
  10923. //double dt = oapiGetSimStep(); // time step
  10924. //double da = JOINT_ROTATION_SPEED * dt * SpeedFactor; // total rotation angle
  10925.  
  10926.  
  10927.  
  10928.  
  10929.  
  10930.  
  10931. //sprintf(oapiDebugString(), "arm_sy %2.2f armM_sy %2.2f da %2.2f", arm_sy, armM_By, da);
  10932. switch (armseq[i])
  10933. {
  10934. case 1:
  10935.  
  10936.  
  10937.  
  10938. if ((arm_sy != armM_By)) {
  10939.  
  10940. if (da >= fabs(arm_sy - armM_By)) // finished
  10941. arm_sy = armM_By, da -= fabs(arm_sy - armM_By),Seqfinished = true;
  10942. else
  10943. arm_sy -= (arm_sy > armM_By ? da : -da), da = 0;
  10944. SetAnimationArm(anim_arm_sy, arm_sy);
  10945. }
  10946. else {
  10947. Seqfinished = true;
  10948. }
  10949. break;
  10950.  
  10951.  
  10952.  
  10953. case 2:
  10954.  
  10955.  
  10956. // sprintf(oapiDebugString(), "arm_sy %2.2f armM_sy %2.2f da %2.2f", arm_sy, armM_By, da);
  10957.  
  10958. if ((arm_sp != armM_Bp)) { // zero wrist yitch
  10959. if (da >= fabs(arm_sp - armM_Bp)) // finished
  10960. arm_sp = armM_Bp, da -= fabs(arm_sp - armM_Bp), Seqfinished = true;
  10961. else
  10962. arm_sp -= (arm_sp > armM_Bp ? da : -da), da = 0;
  10963. SetAnimationArm(anim_arm_sp, arm_sp);
  10964. }
  10965. else {
  10966. Seqfinished = true;
  10967. }
  10968. break;
  10969.  
  10970. case 3:
  10971.  
  10972.  
  10973. // sprintf(oapiDebugString(), "arm_sy %2.2f armM_sy %2.2f da %2.2f", arm_sy, armM_By, da);
  10974.  
  10975. if ((arm_ep != armM_ep)) { // zero wrist yitch
  10976. if (da >= fabs(arm_ep - armM_ep)) // finished
  10977. arm_ep = armM_ep, da -= fabs(arm_ep - armM_ep), Seqfinished = true;
  10978. else
  10979. arm_ep -= (arm_ep > armM_ep ? da : -da), da = 0;
  10980. SetAnimationArm(anim_arm_ep, arm_ep);
  10981. }
  10982. else {
  10983. Seqfinished = true;
  10984. }
  10985. break;
  10986.  
  10987.  
  10988. case 4:
  10989.  
  10990.  
  10991. // sprintf(oapiDebugString(), "arm_sy %2.2f armM_sy %2.2f da %2.2f", arm_sy, armM_By, da);
  10992.  
  10993. if ((arm_wp != armM_Ap)) { // zero wrist yitch
  10994. if (da >= fabs(arm_wp - armM_Ap)) // finished
  10995. arm_wp = armM_Ap, da -= fabs(arm_wp - armM_Ap), Seqfinished = true;
  10996. else
  10997. arm_wp -= (arm_wp > armM_Ap ? da : -da), da = 0;
  10998. SetAnimationArm(anim_arm_wp, arm_wp);
  10999. }
  11000. else {
  11001. Seqfinished = true;
  11002. }
  11003. break;
  11004.  
  11005. case 5:
  11006.  
  11007.  
  11008. // sprintf(oapiDebugString(), "arm_sy %2.2f armM_sy %2.2f da %2.2f", arm_sy, armM_By, da);
  11009.  
  11010. if ((arm_wy != armM_Ay)) { // zero wrist yitch
  11011. if (da >= fabs(arm_wy - armM_Ay)) // finished
  11012. arm_wy = armM_Ay, da -= fabs(arm_wy - armM_Ay), Seqfinished = true;
  11013. else
  11014. arm_wy -= (arm_wy > armM_Ay ? da : -da), da = 0;
  11015. SetAnimationArm(anim_arm_wy, arm_wy);
  11016. }
  11017. else {
  11018. Seqfinished = true;
  11019. }
  11020. break;
  11021.  
  11022. case 6:
  11023.  
  11024.  
  11025. // sprintf(oapiDebugString(), "arm_sy %2.2f armM_sy %2.2f da %2.2f", arm_sy, armM_By, da);
  11026.  
  11027. if ((arm_wr != armM_Ar)) { // zero wrist yitch
  11028. if (da >= fabs(arm_wr - armM_Ar)) // finished
  11029. arm_wr = armM_Ar, da -= fabs(arm_wr - armM_Ar), Seqfinished = true;
  11030. else
  11031. arm_wr -= (arm_wr > armM_Ar ? da : -da), da = 0;
  11032. SetAnimationArm(anim_arm_wr, arm_wr);
  11033. }
  11034. else {
  11035. Seqfinished = true;
  11036. }
  11037. break;
  11038. case 7:
  11039. if (((arm_sy != armM_By))|| ((arm_sp != armM_Bp))|| ((arm_ep != armM_ep))|| ((arm_wp != armM_Ap))|| ((arm_wy != armM_Ay))|| ((arm_wr != armM_Ar))){
  11040. if (da >= fabs(arm_sy - armM_By)) // finished
  11041. arm_sy = armM_By, da -= fabs(arm_sy - armM_By);
  11042. else
  11043. arm_sy -= (arm_sy > armM_By ? da : -da), da = 0;
  11044. SetAnimationArm(anim_arm_sy, arm_sy);
  11045.  
  11046. if (da >= fabs(arm_sp - armM_Bp)) // finished
  11047. arm_sp = armM_Bp, da -= fabs(arm_sp - armM_Bp);
  11048. else
  11049. arm_sp -= (arm_sp > armM_Bp ? da : -da), da = 0;
  11050. SetAnimationArm(anim_arm_sp, arm_sp);
  11051.  
  11052. if (da >= fabs(arm_ep - armM_ep)) // finished
  11053. arm_ep = armM_ep, da -= fabs(arm_ep - armM_ep);
  11054. else
  11055. arm_ep -= (arm_ep > armM_ep ? da : -da), da = 0;
  11056. SetAnimationArm(anim_arm_sp, arm_sp);
  11057.  
  11058. if (da >= fabs(arm_wp - armM_Ap)) // finished
  11059. arm_wp = armM_Ap, da -= fabs(arm_wp - armM_Ap);
  11060. else
  11061. arm_wp -= (arm_wp > armM_Ap ? da : -da), da = 0;
  11062. SetAnimationArm(anim_arm_wp, arm_wp);
  11063.  
  11064. if (da >= fabs(arm_wy - armM_Ay)) // finished
  11065. arm_wy = armM_Ay, da -= fabs(arm_wy - armM_Ay);
  11066. else
  11067. arm_wy -= (arm_wy > armM_Ay ? da : -da), da = 0;
  11068. SetAnimationArm(anim_arm_wy, arm_wy);
  11069.  
  11070. if (da >= fabs(arm_wr - armM_Ar)) // finished
  11071. arm_wr = armM_Ar, da -= fabs(arm_wr - armM_Ar);
  11072. else
  11073. arm_wr -= (arm_wr > armM_Ar ? da : -da), da = 0;
  11074. SetAnimationArm(anim_arm_wr, arm_wr);
  11075. }
  11076. else {
  11077.  
  11078. Seqfinished = true;
  11079. }
  11080.  
  11081.  
  11082. break;
  11083. case 0:
  11084. Seqfinished = true;
  11085. break;
  11086. }
  11087. }
  11088. bool IteminputJoint(void *id, char *str, void *data)
  11089. {
  11090. return ((Atlantis*)data)->ItemChangeJoint(str);
  11091. }
  11092. // ==============================================================
  11093. bool Atlantis::ItemChangeJoint(char *rstr)
  11094. {
  11095. int JointValue;
  11096. double JointAmt;
  11097. sscanf(rstr, "%d%lf", &JointValue, &JointAmt);
  11098. if (JointAmt > 270.0) JointAmt = 270.0;
  11099. if (JointAmt < -270.0) JointAmt = -270.0;
  11100. switch (JointValue){
  11101. //sprintf(oapiDebugString(), "JointValue %d JointAmt %2.2f ", JointValue, JointAmt);
  11102.  
  11103. case 1:
  11104. arm6_By = (((JointAmt - 0)/-360)+.5);
  11105. break;
  11106. case 2:
  11107. arm6_Bp = (((JointAmt - 0) / 147) + 0.0136);
  11108. break;
  11109. case 3:
  11110. //- epstart) * -162);
  11111. arm6_ep = (((JointAmt - 0) / -162) + epstart);
  11112. break;
  11113. case 4:
  11114. arm6_Ap = (((JointAmt - 0) / 240) + wpstart);
  11115. break;
  11116. case 5:
  11117. arm6_Ay = (((JointAmt - 0) / 240) + wystart);
  11118. break;
  11119. case 6:
  11120. arm6_Ar = (((JointAmt - 0) / 894) + wrstart);
  11121. break;
  11122. }
  11123. return true;
  11124. }
  11125. void Atlantis::ARMINPUT()
  11126. {
  11127. oapiOpenInputBox("Joint (1-6) and Value (degrees)", IteminputJoint, 0, 20, (void*)this);
  11128. }
  11129. bool FullinputJoint(void *id, char *str, void *data)
  11130. {
  11131. return ((Atlantis*)data)->FullChangeJoint(str);
  11132. }
  11133. // ==============================================================
  11134. bool Atlantis::FullChangeJoint(char *rstr)
  11135. {
  11136. sscanf(rstr, "%lf%lf%lf%lf%lf%lf", &arm6_By, &arm6_Bp, &arm6_ep, &arm6_Ap, &arm6_Ay, &arm6_Ar);
  11137. arm6_By = (((arm6_By - 0) / -360) + .5);
  11138. arm6_Bp = (((arm6_Bp - 0) / 147) + 0.0136);
  11139. arm6_ep = (((arm6_ep - 0) / -162) + epstart);
  11140. arm6_Ap = (((arm6_Ap - 0) / 240) + wpstart);
  11141. arm6_Ay = (((arm6_Ay - 0) / 240) + wystart);
  11142. arm6_Ar = (((arm6_Ar - 0) / 894) + wrstart);
  11143. return true;
  11144. }
  11145. void Atlantis::FULLINPUT()
  11146. {
  11147. oapiOpenInputBox("SY SP EP WP WY WR", FullinputJoint, 0, 60, (void*)this);
  11148. }
  11149. bool Iteminput(void *id, char *str, void *data)
  11150. {
  11151. return ((Atlantis*)data)->ItemChange(str);
  11152. }
  11153. void Atlantis::ARMSEQ()
  11154. {
  11155.  
  11156. armM_Bp = arm6_Bp;
  11157. armM_By = arm6_By;
  11158. armM_ep = arm6_ep;
  11159. armM_Ap = arm6_Ap;
  11160. armM_Ay = arm6_Ay;
  11161. armM_Ar = arm6_Ar;
  11162. oapiOpenInputBox("ARM SEQ", Iteminput, 0, 20, (void*)this);
  11163.  
  11164. }
  11165. void Atlantis::STOW()
  11166. {}
  11167.  
  11168. void Atlantis::TETHER2(void)
  11169.  
  11170. {
  11171. if (EVA2 == 1){
  11172.  
  11173.  
  11174. HWND hDlg;
  11175. OBJHANDLE hV = GetAttachmentStatus(ft_pad_att1);
  11176.  
  11177. if (hV) { // release satellite
  11178.  
  11179. // ATTACHMENTHANDLE hAtt = CanArrest();
  11180. // DetachChild(ft_pad_att1);
  11181. // if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_PAYLOAD1)) {
  11182. // SetWindowText(GetDlgItem(hDlg, IDC_TETHER2), "TETHER");
  11183.  
  11184. // }
  11185. // check whether the object being ungrappled is ready to be clamped into the payload bay
  11186. // if (hAtt) {
  11187. // AttachChild(hV, sat_attach, hAtt);
  11188. // if (hDlg) {
  11189. // SetWindowText(GetDlgItem(hDlg, IDC_PAYLOAD), "Purge");
  11190. // EnableWindow(GetDlgItem(hDlg, IDC_PAYLOAD), TRUE);
  11191. // }
  11192. //}
  11193.  
  11194. #ifdef UNDEF
  11195. VECTOR3 pos, dir, rot, gbay, gpos;
  11196. GetAttachmentParams(sat_attach, pos, dir, rot);
  11197. Local2Global(pos, gbay);
  11198. VESSEL *v = oapiGetVesselInterface(hV);
  11199. DWORD nAttach = v->AttachmentCount(true);
  11200. for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points
  11201. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  11202. v->GetAttachmentParams(hAtt, pos, dir, rot);
  11203. v->Local2Global(pos, gpos);
  11204. if (dist(gpos, gbay) < MAX_GRAPPLING_DIST) {
  11205. AttachChild(hV, sat_attach, hAtt);
  11206. return;
  11207. }
  11208. }
  11209. #endif
  11210.  
  11211. }
  11212. else { // grapple satellite
  11213.  
  11214. VECTOR3 gpos, grms, pos, dir, rot;
  11215. Local2Global(arm_tip[0], grms); // global position of RMS tip
  11216. // sprintf(oapiDebugString(), "dist %2.2f ", dist(gpos, grms));
  11217. // Search the complete vessel list for a grappling candidate.
  11218. // Not very scalable ...
  11219. for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
  11220. OBJHANDLE hV = oapiGetVesselByIndex(i);
  11221. if (hV == GetHandle()) continue; // we don't want to grapple ourselves ...
  11222. // oapiGetGlobalPos(hV, &gpos);
  11223. //sprintf(oapiDebugString(), "dist %2.2f size %2.2f ", dist(gpos, grms), oapiGetSize(hV));
  11224. // if (dist(gpos, grms) < oapiGetSize(hV)) { // in range
  11225. VESSEL *v = oapiGetVesselInterface(hV);
  11226. DWORD nAttach = v->AttachmentCount(true);
  11227.  
  11228. for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points of the candidate
  11229. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  11230. const char *id = v->GetAttachmentId(hAtt);
  11231. //sprintf(oapiDebugString(), "dist %2.2f ", dist(gpos, grms));
  11232. if (strncmp(id, "FTEVA2", 6)) continue; // attachment point compatible go to next step
  11233. //v->GetAttachmentParams(hAtt, pos, dir, rot);
  11234. //v->Local2Global(pos, gpos);
  11235. //sprintf(oapiDebugString(), "dist %2.2f ", dist(gpos, grms));
  11236.  
  11237. // check whether satellite is currently clamped into payload bay
  11238. //if (hV == GetAttachmentStatus(sat_attach))
  11239. // DetachChild(sat_attach);
  11240.  
  11241. AttachChild(hV, ft_pad_att1, hAtt);
  11242. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_PAYLOAD1)) {
  11243. // SetWindowText(GetDlgItem(hDlg, IDC_TETHER2), "Release");
  11244.  
  11245.  
  11246. return;
  11247. //}
  11248. }
  11249. }
  11250. }
  11251.  
  11252. }
  11253. }
  11254. }
  11255. void Atlantis::TETHER1(void)
  11256. {
  11257. if (EVA1 == 1){
  11258.  
  11259. HWND hDlg;
  11260. OBJHANDLE hV = GetAttachmentStatus(ft_pad_att);
  11261.  
  11262. if (hV) { // release satellite
  11263.  
  11264. //ATTACHMENTHANDLE hAtt = CanArrest();
  11265. //DetachChild(ft_pad_att);
  11266. //if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_PAYLOAD1)) {
  11267. // SetWindowText(GetDlgItem(hDlg, IDC_TETHER1), "TETHER");
  11268.  
  11269. //}
  11270. // check whether the object being ungrappled is ready to be clamped into the payload bay
  11271. // if (hAtt) {
  11272. // AttachChild(hV, sat_attach, hAtt);
  11273. // if (hDlg) {
  11274. // SetWindowText(GetDlgItem(hDlg, IDC_PAYLOAD), "Purge");
  11275. // EnableWindow(GetDlgItem(hDlg, IDC_PAYLOAD), TRUE);
  11276. // }
  11277. //}
  11278.  
  11279. #ifdef UNDEF
  11280. VECTOR3 pos, dir, rot, gbay, gpos;
  11281. GetAttachmentParams(sat_attach, pos, dir, rot);
  11282. Local2Global(pos, gbay);
  11283. VESSEL *v = oapiGetVesselInterface(hV);
  11284. DWORD nAttach = v->AttachmentCount(true);
  11285. for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points
  11286. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  11287. v->GetAttachmentParams(hAtt, pos, dir, rot);
  11288. v->Local2Global(pos, gpos);
  11289. if (dist(gpos, gbay) < MAX_GRAPPLING_DIST) {
  11290. AttachChild(hV, sat_attach, hAtt);
  11291. return;
  11292. }
  11293. }
  11294. #endif
  11295.  
  11296. }
  11297. else { // grapple satellite
  11298.  
  11299. VECTOR3 gpos, grms, pos, dir, rot;
  11300. Local2Global(arm_tip[0], grms); // global position of RMS tip
  11301. // sprintf(oapiDebugString(), "dist %2.2f ", dist(gpos, grms));
  11302. // Search the complete vessel list for a grappling candidate.
  11303. // Not very scalable ...
  11304. for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
  11305. OBJHANDLE hV = oapiGetVesselByIndex(i);
  11306. if (hV == GetHandle()) continue; // we don't want to grapple ourselves ...
  11307. // oapiGetGlobalPos(hV, &gpos);
  11308. //sprintf(oapiDebugString(), "dist %2.2f size %2.2f ", dist(gpos, grms), oapiGetSize(hV));
  11309. // if (dist(gpos, grms) < oapiGetSize(hV)) { // in range
  11310. VESSEL *v = oapiGetVesselInterface(hV);
  11311. DWORD nAttach = v->AttachmentCount(true);
  11312.  
  11313. for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points of the candidate
  11314. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  11315. const char *id = v->GetAttachmentId(hAtt);
  11316. //sprintf(oapiDebugString(), "dist %2.2f ", dist(gpos, grms));
  11317. if (strncmp(id, "FTEVA1", 6)) continue; // attachment point compatible go to next step
  11318. //v->GetAttachmentParams(hAtt, pos, dir, rot);
  11319. //v->Local2Global(pos, gpos);
  11320. //sprintf(oapiDebugString(), "dist %2.2f ", dist(gpos, grms));
  11321.  
  11322. // check whether satellite is currently clamped into payload bay
  11323. //if (hV == GetAttachmentStatus(sat_attach))
  11324. // DetachChild(sat_attach);
  11325.  
  11326. AttachChild(hV, ft_pad_att, hAtt);
  11327. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_PAYLOAD1)) {
  11328. // SetWindowText(GetDlgItem(hDlg, IDC_TETHER1), "Release");
  11329.  
  11330.  
  11331. return;
  11332. //}
  11333. }
  11334. }
  11335. }
  11336.  
  11337. }
  11338. }
  11339. }
  11340. void Atlantis::TETHER3(void)
  11341.  
  11342. {
  11343. if (EVA3 == 1){
  11344.  
  11345.  
  11346. HWND hDlg;
  11347. OBJHANDLE hV = GetAttachmentStatus(ft_pad_att2);
  11348.  
  11349. if (hV) { // release satellite
  11350.  
  11351. //ATTACHMENTHANDLE hAtt = CanArrest();
  11352. //DetachChild(ft_pad_att2);
  11353. // if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_PAYLOAD1)) {
  11354. // SetWindowText(GetDlgItem(hDlg, IDC_TETHER3), "TETHER");
  11355.  
  11356. // }
  11357. // check whether the object being ungrappled is ready to be clamped into the payload bay
  11358. // if (hAtt) {
  11359. // AttachChild(hV, sat_attach, hAtt);
  11360. // if (hDlg) {
  11361. // SetWindowText(GetDlgItem(hDlg, IDC_PAYLOAD), "Purge");
  11362. // EnableWindow(GetDlgItem(hDlg, IDC_PAYLOAD), TRUE);
  11363. // }
  11364. //}
  11365.  
  11366. #ifdef UNDEF
  11367. VECTOR3 pos, dir, rot, gbay, gpos;
  11368. GetAttachmentParams(sat_attach, pos, dir, rot);
  11369. Local2Global(pos, gbay);
  11370. VESSEL *v = oapiGetVesselInterface(hV);
  11371. DWORD nAttach = v->AttachmentCount(true);
  11372. for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points
  11373. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  11374. v->GetAttachmentParams(hAtt, pos, dir, rot);
  11375. v->Local2Global(pos, gpos);
  11376. if (dist(gpos, gbay) < MAX_GRAPPLING_DIST) {
  11377. AttachChild(hV, sat_attach, hAtt);
  11378. return;
  11379. }
  11380. }
  11381. #endif
  11382.  
  11383. }
  11384. else { // grapple satellite
  11385.  
  11386. VECTOR3 gpos, grms, pos, dir, rot;
  11387. Local2Global(arm_tip[0], grms); // global position of RMS tip
  11388. // sprintf(oapiDebugString(), "dist %2.2f ", dist(gpos, grms));
  11389. // Search the complete vessel list for a grappling candidate.
  11390. // Not very scalable ...
  11391. for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
  11392. OBJHANDLE hV = oapiGetVesselByIndex(i);
  11393. if (hV == GetHandle()) continue; // we don't want to grapple ourselves ...
  11394. // oapiGetGlobalPos(hV, &gpos);
  11395. //sprintf(oapiDebugString(), "dist %2.2f size %2.2f ", dist(gpos, grms), oapiGetSize(hV));
  11396. // if (dist(gpos, grms) < oapiGetSize(hV)) { // in range
  11397. VESSEL *v = oapiGetVesselInterface(hV);
  11398. DWORD nAttach = v->AttachmentCount(true);
  11399.  
  11400. for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points of the candidate
  11401. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  11402. const char *id = v->GetAttachmentId(hAtt);
  11403. //sprintf(oapiDebugString(), "dist %2.2f ", dist(gpos, grms));
  11404. if (strncmp(id, "FTEVA3", 6)) continue; // attachment point compatible go to next step
  11405. //v->GetAttachmentParams(hAtt, pos, dir, rot);
  11406. //v->Local2Global(pos, gpos);
  11407. //sprintf(oapiDebugString(), "dist %2.2f ", dist(gpos, grms));
  11408.  
  11409. // check whether satellite is currently clamped into payload bay
  11410. //if (hV == GetAttachmentStatus(sat_attach))
  11411. // DetachChild(sat_attach);
  11412.  
  11413. AttachChild(hV, ft_pad_att2, hAtt);
  11414. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_PAYLOAD1)) {
  11415. // SetWindowText(GetDlgItem(hDlg, IDC_TETHER3), "Release");
  11416.  
  11417.  
  11418. return;
  11419. //}
  11420. }
  11421. }
  11422. }
  11423.  
  11424. }
  11425. }
  11426. }
  11427. void Atlantis::TETHER4(void)
  11428.  
  11429. {
  11430. if (EVA4 == 1){
  11431.  
  11432.  
  11433. HWND hDlg;
  11434. OBJHANDLE hV = GetAttachmentStatus(ft_pad_att1);
  11435.  
  11436. if (hV) { // release satellite
  11437.  
  11438. // ATTACHMENTHANDLE hAtt = CanArrest();
  11439. // DetachChild(ft_pad_att3);
  11440. // if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_PAYLOAD1)) {
  11441. // SetWindowText(GetDlgItem(hDlg, IDC_TETHER4), "TETHER");
  11442.  
  11443. // }
  11444. // check whether the object being ungrappled is ready to be clamped into the payload bay
  11445. // if (hAtt) {
  11446. // AttachChild(hV, sat_attach, hAtt);
  11447. // if (hDlg) {
  11448. // SetWindowText(GetDlgItem(hDlg, IDC_PAYLOAD), "Purge");
  11449. // EnableWindow(GetDlgItem(hDlg, IDC_PAYLOAD), TRUE);
  11450. // }
  11451. //}
  11452.  
  11453. #ifdef UNDEF
  11454. VECTOR3 pos, dir, rot, gbay, gpos;
  11455. GetAttachmentParams(sat_attach, pos, dir, rot);
  11456. Local2Global(pos, gbay);
  11457. VESSEL *v = oapiGetVesselInterface(hV);
  11458. DWORD nAttach = v->AttachmentCount(true);
  11459. for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points
  11460. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  11461. v->GetAttachmentParams(hAtt, pos, dir, rot);
  11462. v->Local2Global(pos, gpos);
  11463. if (dist(gpos, gbay) < MAX_GRAPPLING_DIST) {
  11464. AttachChild(hV, sat_attach, hAtt);
  11465. return;
  11466. }
  11467. }
  11468. #endif
  11469.  
  11470. }
  11471. else { // grapple satellite
  11472.  
  11473. VECTOR3 gpos, grms, pos, dir, rot;
  11474. Local2Global(arm_tip[0], grms); // global position of RMS tip
  11475. // sprintf(oapiDebugString(), "dist %2.2f ", dist(gpos, grms));
  11476. // Search the complete vessel list for a grappling candidate.
  11477. // Not very scalable ...
  11478. for (DWORD i = 0; i < oapiGetVesselCount(); i++) {
  11479. OBJHANDLE hV = oapiGetVesselByIndex(i);
  11480. if (hV == GetHandle()) continue; // we don't want to grapple ourselves ...
  11481. // oapiGetGlobalPos(hV, &gpos);
  11482. //sprintf(oapiDebugString(), "dist %2.2f size %2.2f ", dist(gpos, grms), oapiGetSize(hV));
  11483. // if (dist(gpos, grms) < oapiGetSize(hV)) { // in range
  11484. VESSEL *v = oapiGetVesselInterface(hV);
  11485. DWORD nAttach = v->AttachmentCount(true);
  11486.  
  11487. for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points of the candidate
  11488. ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle(true, j);
  11489. const char *id = v->GetAttachmentId(hAtt);
  11490. //sprintf(oapiDebugString(), "dist %2.2f ", dist(gpos, grms));
  11491. if (strncmp(id, "FTEVA4", 6)) continue; // attachment point compatible go to next step
  11492. //v->GetAttachmentParams(hAtt, pos, dir, rot);
  11493. //v->Local2Global(pos, gpos);
  11494. //sprintf(oapiDebugString(), "dist %2.2f ", dist(gpos, grms));
  11495.  
  11496. // check whether satellite is currently clamped into payload bay
  11497. //if (hV == GetAttachmentStatus(sat_attach))
  11498. // DetachChild(sat_attach);
  11499.  
  11500. AttachChild(hV, ft_pad_att3, hAtt);
  11501. if (hDlg = oapiFindDialog(g_Param.hDLL, IDD_PAYLOAD1)) {
  11502. //SetWindowText(GetDlgItem(hDlg, IDC_TETHER4), "Release");
  11503.  
  11504.  
  11505. return;
  11506. //}
  11507. }
  11508. }
  11509. }
  11510.  
  11511. }
  11512. }
  11513. }
  11514. void Atlantis::SetAnimationCameras() {
  11515. // FRONT LEFT
  11516. double anim_yaw = linterp(-170, 0, 170, 1, camYaw[CAM_A]);
  11517. SetAnimation(anim_camFLyaw, anim_yaw);
  11518.  
  11519. double anim_pitch = linterp(-170, 0, 170, 1, camPitch[CAM_A]);
  11520. SetAnimation(anim_camFLpitch, anim_pitch);
  11521.  
  11522. // FRONT RIGHT
  11523. anim_yaw = linterp(-170, 0, 170, 1, camYaw[CAM_D]);
  11524. SetAnimation(anim_camFRyaw, anim_yaw);
  11525.  
  11526. anim_pitch = linterp(-170, 0, 170, 1, camPitch[CAM_D]);
  11527. SetAnimation(anim_camFRpitch, anim_pitch);
  11528.  
  11529. // BACK LEFT
  11530. anim_yaw = linterp(-170, 0, 170, 1, camYaw[CAM_B]);
  11531. SetAnimation(anim_camBLyaw, anim_yaw);
  11532.  
  11533. anim_pitch = linterp(-170, 0, 170, 1, camPitch[CAM_B]);
  11534. SetAnimation(anim_camBLpitch, anim_pitch);
  11535.  
  11536. // BACK RIGHT
  11537. anim_yaw = linterp(-170, 0, 170, 1, camYaw[CAM_C]);
  11538. SetAnimation(anim_camBRyaw, anim_yaw);
  11539.  
  11540. anim_pitch = linterp(-170, 0, 170, 1, camPitch[CAM_C]);
  11541. SetAnimation(anim_camBRpitch, anim_pitch);
  11542. //rms elbow
  11543.  
  11544. double anim = linterp(-MAX_PLB_CAM_PAN, 0, MAX_PLB_CAM_PAN, 1, camRMSElbow[PAN]);
  11545. SetAnimation(anim_camRMSElbow[PAN], anim);
  11546. anim = linterp(-MAX_PLB_CAM_TILT, 0, MAX_PLB_CAM_TILT, 1, camRMSElbow[TILT]);
  11547. SetAnimation(anim_camRMSElbow[TILT], anim);
  11548. //sprintf(oapiDebugString(), "YAW %f ", anim);
  11549.  
  11550. //if (oapiCameraInternal() && VCMode >= VC_PLBCAMFL && VCMode <= VC_PLBCAMFR) {
  11551. double a = 0.0;
  11552. double b = 0.0;
  11553. double c = 0.0;
  11554.  
  11555. if (CAM == 3){
  11556. PBCAMERA = 2;
  11557. a = ((-camYaw[CAM_C] - 90)*RAD);
  11558. b = ((camPitch[CAM_C] - 90)*RAD);
  11559. //SetCameraOffset(_V(-1.850, 1.8, 11.750));
  11560. //sprintf(oapiDebugString(), "phi %d YAW %f ", PBCAMERA, a);
  11561. SetCameraOffset(plbCamPos[2]);
  11562. SetCameraDefaultDirection(_V(cos(a)*sin(b), cos(b), sin(a)*sin(b)), c);
  11563. oapiCameraSetCockpitDir(0.0, 0.0);
  11564. //sprintf(oapiDebugString(), "YAW %f PITCH %f", a, b);
  11565. }
  11566. if (CAM == 4){
  11567. PBCAMERA = 3;
  11568. a = ((-camYaw[CAM_D] + 90)*RAD);
  11569. b = ((camPitch[CAM_D] - 90)*RAD);
  11570. //SetCameraOffset(_V(-2.2, 1.8, -6.250));
  11571. SetCameraOffset(plbCamPos[3]);
  11572. SetCameraDefaultDirection(_V(cos(a)*sin(b), cos(b), sin(a)*sin(b)), c);
  11573. oapiCameraSetCockpitDir(0.0, 0.0);
  11574. //sprintf(oapiDebugString(), "YAW %f PITCH %f", a, b);
  11575. }
  11576. if (CAM == 1){
  11577. PBCAMERA = 0;
  11578. a = ((-camYaw[CAM_A] + 90)*RAD);
  11579. b = ((camPitch[CAM_A] - 90)*RAD);
  11580. //SetCameraOffset(_V(2.2, 1.8, -6.250));
  11581. SetCameraOffset(plbCamPos[0]);
  11582. SetCameraDefaultDirection(_V(cos(a)*sin(b), cos(b), sin(a)*sin(b)), c);
  11583. oapiCameraSetCockpitDir(0.0, 0.0);
  11584. //sprintf(oapiDebugString(), "YAW %f PITCH %f c %f", a,b,c);
  11585. }
  11586. if (CAM == 2){
  11587. PBCAMERA = 1;
  11588. a = ((-camYaw[CAM_B] - 90)*RAD);
  11589. b = ((camPitch[CAM_B] - 90)*RAD);
  11590. //SetCameraOffset(_V(1.850, 1.8, 11.750));
  11591. SetCameraOffset(plbCamPos[1]);
  11592. SetCameraDefaultDirection(_V(cos(a)*sin(b), cos(b), sin(a)*sin(b)), c);
  11593. oapiCameraSetCockpitDir(0.0, 0.0);
  11594. //sprintf(oapiDebugString(), "YAW %f PITCH %f", a, b);
  11595. }
  11596. if (b > 0.0) c = 180.0 * RAD;
  11597. if (CAM == 0) {
  11598.  
  11599. SetCameraDefaultDirection(_V(0, 0, 1));
  11600. SetCameraOffset(_V(-0.67, 2.55, 14.4));
  11601. oapiCameraSetCockpitDir(0, 0);
  11602. }
  11603. if (CAM == 5){
  11604. SetCameraDefaultDirection(_V(0, 1, 0));
  11605. SetCameraOffset(KEELCAM);
  11606. oapiCameraSetCockpitDir(0, 0);
  11607. };
  11608. if (CAM == 9) {
  11609. SetCameraDefaultDirection(_V(0, -1, 0));
  11610. SetCameraOffset(ETCAM);
  11611. oapiCameraSetCockpitDir(0, 0);
  11612. };
  11613. if (CAM == 8) {
  11614.  
  11615. SetCameraDefaultDirection(_V(0, 1, 0));
  11616. SetCameraOffset(DOCKCAM);
  11617. // sprintf(oapiDebugString(), "armtip3x %2.2f armtip3y %2.2f armtip3z %2.2f", arm_tip[5].x, arm_tip[5].y, arm_tip[5].z);
  11618.  
  11619. oapiCameraSetCockpitDir(0, 0);
  11620. }
  11621. if (CAM == 6){//elbow view
  11622. PBCAMERA = 5;
  11623. VECTOR3 dir = camRMSElbowLoc[1] - camRMSElbowLoc[0];
  11624. if (Eq(dotp(dir, _V(0, -1, 0)), 1.0, 1e-4)) dir = _V(1.74532924314e-4, -0.999999984769, 0.0);
  11625. else if (Eq(dotp(dir, _V(0, 1, 0)), 1.0, 1e-4)) dir = _V(1.74532924314e-4, 0.999999984769, 0.0);
  11626. VECTOR3 orbiter_cam_rot = crossp(crossp(dir, _V(0, 1, 0)), dir);
  11627. orbiter_cam_rot /= length(orbiter_cam_rot);
  11628. if (orbiter_cam_rot.y < 0) orbiter_cam_rot = -orbiter_cam_rot;
  11629. double angle = SignedAngle(orbiter_cam_rot, camRMSElbowLoc[2] - camRMSElbowLoc[0], dir);
  11630. SetCameraDefaultDirection(dir, angle);
  11631. SetCameraOffset(camRMSElbowLoc[0]);
  11632. oapiCameraSetCockpitDir(0.0, 0.0);
  11633. //sprintf_s(oapiDebugString(), 255, "Rot Vec: %f %f %f cam dir: %f %f %f dir: %f %f %f Angle: %f %f length: %f", orbiter_cam_rot.x, orbiter_cam_rot.y, orbiter_cam_rot.z, camRMSElbowLoc[1].x - camRMSElbowLoc[0].x, camRMSElbowLoc[2].y - camRMSElbowLoc[0].y, camRMSElbowLoc[2].z - camRMSElbowLoc[0].z, dir.x, dir.y, dir.z, angle, angle*DEG, length(dir));
  11634.  
  11635. }
  11636. if (CAM == 7){ //ee view
  11637. // calculate rotation angle for EE cam
  11638. VECTOR3 dir = arm_tip[1] - arm_tip[0];
  11639. // if camera is pointing straight up or down, make it slightly offset from (0,1,0) vector
  11640. if (Eq(dotp(dir, _V(0, -1, 0)), 1.0, 1e-4)) dir = _V(1.74532924314e-4, -0.999999984769, 0.0);
  11641. else if (Eq(dotp(dir, _V(0, 1, 0)), 1.0, 1e-4)) dir = _V(1.74532924314e-4, 0.999999984769, 0.0);
  11642. VECTOR3 orbiter_cam_rot = crossp(crossp(dir, _V(0, 1, 0)), dir);
  11643. orbiter_cam_rot /= length(orbiter_cam_rot);
  11644. if (orbiter_cam_rot.y < 0) orbiter_cam_rot = -orbiter_cam_rot;
  11645. double angle = SignedAngle(orbiter_cam_rot, arm_tip[2] - arm_tip[0], dir);
  11646.  
  11647. //sprintf_s(oapiDebugString(), 255, "Rot Vec: %f %f %f dir: %f %f %f dot_prod: %f Angle: %f %f", orbiter_cam_rot.x, orbiter_cam_rot.y, orbiter_cam_rot.z, dir.x, dir.y, dir.z, dot_prod, angle, angle*DEG);
  11648. //sprintf_s(oapiDebugString(), 255, "Rot Vec: %f %f %f cam dir: %f %f %f dir: %f %f %f Angle: %f %f length: %f", orbiter_cam_rot.x, orbiter_cam_rot.y, orbiter_cam_rot.z, arm_tip[2].x - arm_tip[0].x, arm_tip[2].y - arm_tip[0].y, arm_tip[2].z - arm_tip[0].z, dir.x, dir.y, dir.z, angle, angle*DEG, length(dir));
  11649. //sprintf_s(oapiDebugString(), 255, "dot_prod: %f Angle: %f %f", dot_prod, angle, angle*DEG);
  11650.  
  11651. SetCameraOffset(arm_tip[3]);
  11652. //STS()->SetCameraDefaultDirection (arm_tip[1]-arm_tip[0], 0.0);
  11653. SetCameraDefaultDirection(dir, angle);
  11654. oapiCameraSetCockpitDir(0.0, 0.0);
  11655. }
  11656.  
  11657.  
  11658. //SetCameraOffset(orbiter_ofs + plbCamPos[VCMode - VC_PLBCAMFL]);
  11659. //SetCameraDefaultDirection(_V(cos(a)*sin(b), cos(b), sin(a)*sin(b)), c);
  11660. // oapiCameraSetCockpitDir(0.0, 0.0);
  11661.  
  11662. }
  11663. int Atlantis::clbkGeneric(int msgid, int prm, void* context)
  11664. {
  11665. if (msgid == CAMERA_MFD)
  11666. {
  11667. int index = prm - 3;
  11668.  
  11669. if (index < 0 || index > 2) return 0;
  11670.  
  11671. if (context)
  11672. {
  11673. cameraData[0] = { "Keel Camera", KEELCAM, 90, 0, 0, 40, { true, true, false, true, false } };// keel camera
  11674. cameraData[1] = { "ET Camera", ETCAM, 0, 0, 0, 40, { true, true, false, true, false } };// ET camera
  11675. cameraData[2] = { "Payload Bay Camera A", plbCamPos[0], 0, 180, 0, 40, { true, true, false, true, false } };// payload bay camera 1
  11676. cameraData[3] = { "Payload Bay Camera B", plbCamPos[1], 0, 0, 0, 40, { true, true, false, true, false } };// payload bay camera 2
  11677. cameraData[4] = { "Payload Bay Camera C", plbCamPos[2], 0, 0, 0, 40, { true, true, false, true, false } };// payload bay camera 3
  11678. cameraData[5] = { "Payload Bay Camera D", plbCamPos[3], 0, 180, 0, 40, { true, true, false, true, false } };// payload bay camera 4
  11679. cameraData[6] = { "RMS Elbow Camera", camRMSElbowLoc[0], 0, 180, 0, 40, { true, true, false, true, false } }; // RMS elbow camera
  11680. cameraData[7] = { "RMS EE Camera", arm_tip[3], 0, -90, 0, 40, { true, true, false, false, false } }; // RMS tip camera
  11681. cameraData[8] = { "Dock Camera", DOCKCAM, 90, 90, 90, 40, { true, true, false, false, false } }; // dockcam camera
  11682.  
  11683. cameraMFD[index] = static_cast<CameraMFD*>(context);
  11684.  
  11685. cameraMFD[index]->SetCameraData(0, cameraData[0]);
  11686.  
  11687. if (cameraMFD[index]->CameraDataExist())
  11688. {
  11689. for (int cam = 1; cam <= 8; cam++)
  11690. cameraMFD[index]->SetCameraData(cam, cameraData[cam]);
  11691. }
  11692. else
  11693. {
  11694. for (int cam = 1; cam <= 8; cam++)
  11695. cameraMFD[index]->AddCamera(cam, cameraData[cam]);
  11696. }
  11697.  
  11698. return CAMERA_MFD;
  11699. }
  11700. else cameraMFD[index] = nullptr;
  11701. }
  11702.  
  11703. return 0;
  11704. }
  11705.  
  11706.  
  11707.  
  11708.  
  11709.  
  11710. h:
  11711. // ==============================================================
  11712. // ORBITER MODULE: Atlantis
  11713. // Part of the ORBITER SDK
  11714. // Copyright (C) 2001-2012 Martin Schweiger
  11715. // All rights reserved
  11716. //
  11717. // Atlantis.h
  11718. // Class interface of Atlantis (Space Shuttle) vessel class
  11719. // module and associated subclasses (SRB, tank)
  11720. // ==============================================================
  11721.  
  11722. #ifndef __ATLANTIS_H
  11723. #define __ATLANTIS_H
  11724.  
  11725. #include "orbitersdk.h"
  11726. #include <math.h>
  11727. #include <CameraMFD_API.h>
  11728. //#ifdef ATLANTIS_TANK_MODULE
  11729. //#define TANKFUNC DLLEXPORT
  11730. //#else
  11731. //#define TANKFUNC DLLIMPORT
  11732. //#endif
  11733.  
  11734. //#ifdef ATLANTIS_SRB_MODULE
  11735. //#define SRBFUNC DLLEXPORT
  11736. //#else
  11737. //#define SRBFUNC DLLIMPORT
  11738. //#endif
  11739.  
  11740. // ==========================================================
  11741. // Some Orbiter-related parameters
  11742. // ==========================================================
  11743.  
  11744. const double ORBITER_EMPTY_MASS = 104326.0;
  11745. // Orbiter empty mass [kg]
  11746.  
  11747. //const double MPS2KTS = 1.94384;
  11748. // Orbiter empty mass [kg]
  11749.  
  11750.  
  11751. const double ORBITER_MAX_PROPELLANT_MASS = 21600.0;
  11752. // Amount of fuel the orbiter can hold in internal OMS tanks
  11753.  
  11754. const double ORBITER_MAIN_THRUST = 1668652.0 * 1.25;
  11755. // Vacuum thrust rating per main engine [N] (x3 for total)
  11756. // assuming vacuum thrust is 5/4 liftoff thrust
  11757.  
  11758. const double ORBITER_OMS_THRUST = 26700.0;
  11759. // Vacuum thrust per unit for Orbital Maneuvering System [N] (x2 for total)
  11760.  
  11761. const double ORBITER_RCS_THRUST = 7740.0;
  11762. // Vacuum thrust rating for attitude thrusters (Reaction Control System) [N]
  11763.  
  11764. const double ORBITER_MAIN_ISP0 = 4444.0; // 453s*9.81
  11765. const double ORBITER_MAIN_ISP1 = 3561.0; // 363s*9.81
  11766. // Vacuum and sea-level fuel-specific impulse for orbiter main engines [m/s]
  11767. // using H2/O2 (hydrogen/oxygen)
  11768.  
  11769. const double ORBITER_OMS_ISP0 = 3100;
  11770. const double ORBITER_OMS_ISP1 = 2500;
  11771. // Vacuum and sea-level fuel-specific impulse for Orbital Maneuvering System [m/s]
  11772. // using MMH/N2O4 (monomethyl hydrazine/nitrogen tetroxide)
  11773.  
  11774. const double ORBITER_RCS_ISP0 = 5000.0;
  11775. const double ORBITER_RCS_ISP1 = 4000.0;
  11776. // Vacuum and sea-level fuel-specific impulse for Reaction Control System [m/s]
  11777.  
  11778. const double GEAR_OPERATING_SPEED = 0.3;
  11779. // Opening/closing speed of landing gear (1/sec)
  11780. // => gear cycle ~ 3 sec
  11781.  
  11782. const double DOOR_OPERATING_SPEED = 0.007353;
  11783. // Opening/closing speed of payload bay doors (1/sec)
  11784. // This contains the door opening sequence (63 sec for each door) and an
  11785. // interval of 10 sec between the two door operations
  11786.  
  11787. const double RAD_OPERATING_SPEED = 0.025;
  11788. // Deployment/stowing speed of radiators (1/sec)
  11789. // => radiator cycle = 40 sec
  11790.  
  11791. const double RADLATCH_OPERATING_SPEED = 0.2;
  11792. // Release/engaging speed of radiator latches (1/sec)
  11793. // => radiator latch cycle = 5 sec
  11794.  
  11795. const double KU_OPERATING_SPEED = 0.0435;
  11796. // Deployment speed of the Ku Band antenna (1/sec)
  11797. // cycle is 23 sec
  11798.  
  11799. const double SPEEDBRAKE_OPERATING_SPEED = 0.20284;
  11800. // Deployment speed of the speedbrake (1/sec)
  11801. // cycle is 4.93 sec
  11802.  
  11803. //const double ARM_OPERATING_SPEED = 0.005;
  11804. // RMS arm joint rotation speed (rad/sec)
  11805.  
  11806. const VECTOR3 ORBITER_CS = {234.8,389.1,68.2};
  11807. // Orbiter cross sections (projections into principal axes) [m^2]
  11808.  
  11809. const VECTOR3 ORBITER_CS_GEAR = {10.0,0.0,3.0};
  11810. // Contribution of fully extended landing gear to cross sections
  11811.  
  11812. const double MAX_GRAPPLING_DIST = 4;//.5
  11813. // max distance between RMS tip and grappling point for successful grappling
  11814. const double MAX_GRAPPLING_ANGLE_COS_ERR = 0.02; // max angle between EE and grapple for successful grappling (cosine of angle)
  11815.  
  11816.  
  11817. //ik
  11818. const double ARM_TRANSLATE_SPEED = 0.1;
  11819. // RMS IK translation speed (m/s)
  11820. // ==========================================================
  11821. // Some Tank-related parameters
  11822. // ==========================================================
  11823.  
  11824. //const double TANK_MAX_PROPELLANT_MASS = 719115.0;
  11825. // Main tank propellant mass [kg]
  11826.  
  11827. //const double TANK_EMPTY_MASS = 35425.0;
  11828. // Main tank empty mass
  11829.  
  11830. // ==========================================================
  11831. // Some SRB-related parameters
  11832. // ==========================================================
  11833.  
  11834. //const double SRB_MAX_PROPELLANT_MASS = 502126.0;
  11835. // SRB propellant mass [kg]
  11836.  
  11837. //const double SRB_EMPTY_MASS = 87543.0;
  11838. // SRB empty mass [kg]
  11839.  
  11840. //const double SRB_ISP0 = 3574.68;
  11841. //const double SRB_ISP1 = 2859.74;
  11842. // SRB vacuum and sea-level fuel-specific impulse [m/s]
  11843.  
  11844. //const double SRB_THRUST = 1202020.0*9.81 * 1.25;
  11845. // Mean vacuum SRB thrust per unit [N]
  11846.  
  11847. //const double SRB_THRUST_MAX = 1.7070e+07;
  11848. // Peak vacuum SRB thrust per unit [N]
  11849.  
  11850. //const double MAX_ATT_LAUNCH = 1e5;
  11851. //const double MAX_ROLL_SRB = 2.5e5;
  11852. // Max attitude thrust during launch phase (temporary)
  11853.  
  11854. //const double SRB_STABILISATION_TIME = 4.0;
  11855. // MET: -SRB ignition
  11856.  
  11857. //const double SRB_SEPARATION_TIME = 126.0;
  11858. // MET: SRB separation
  11859.  
  11860. //const double SRB_CUTOUT_TIME = 135.0;
  11861. // MET: engine shutdown
  11862.  
  11863. //const double SRB_GIMBAL_SPEED = 0.5;
  11864.  
  11865. // ==========================================================
  11866. // Thruster reference positions and thrust directions
  11867. // ==========================================================
  11868.  
  11869. const VECTOR3 THRUSTREF_SSME0 = {-1.55,-0.37,-12.5};
  11870. const VECTOR3 THRUSTREF_SSME1 = { 1.55,-0.37,-12.5};
  11871. const VECTOR3 THRUSTREF_SSME2 = { 0.0, 2.7, -12.5};
  11872. const VECTOR3 THRUSTREF_OMSL = { -2.8, 3.5, -13.5 };//-2.6, 3.3, -12.8
  11873. const VECTOR3 THRUSTREF_OMSR = { 2.8, 3.5, -13.5 };//2.6, 3.3, -12.8
  11874. const VECTOR3 THRUSTREF_SRB = { 0.0, 0.0, -20.4};
  11875.  
  11876. const double THRUSTPITCH_LAUNCH = -2.3*RAD;
  11877. const VECTOR3 THRUSTGIMBAL_LAUNCH = {0, sin(THRUSTPITCH_LAUNCH), cos(THRUSTPITCH_LAUNCH)};
  11878.  
  11879. const VECTOR3 THRUSTDIR_OMSL = { 0.10, -0.23, 0.97 };//0.19299542, -0.24495572, 0.95013129
  11880. const VECTOR3 THRUSTDIR_OMSR = { -0.10, -0.23, 0.97 }; //-0.19299542, -0.24495572, 0.95013129
  11881. const VECTOR3 RMS_EE_POS = _V(-2.515, 2.059, -5.5327);
  11882. const VECTOR3 RMS_ELBOW_CAM_POS = _V(-2.65, 2.533, 2.432944);
  11883. const VECTOR3 OBSS_POS = _V(2.45, 2.2, 4.4);
  11884. const VECTOR3 RMS_EE_CAM_POS = _V(-2.429, 2.453, -4.987415);
  11885. //const VECTOR3 RMS_EE_CAM_POS = _V(-1.7, 2.455, -4.5);
  11886. const VECTOR3 RMS_EE_LIGHT_POS = _V(-2.4, 2.5407, -5.0);
  11887. const VECTOR3 RMS_Z_AXIS = _V(0.0, 1.0, 0.0); // axis along which RMS EE camera & light are mounted
  11888. const VECTOR3 RMS_ELBOW_CAM_AXIS = _V(0.422618, 0.906308, 0.0);// 25� tilt inboard
  11889. const double JOINT_ROTATION_SPEED = 1.0;
  11890.  
  11891. const double CHUTE_DEPLOY_SPEED = 165.0 / 1.94384;
  11892. // Speed at which chute is deployed (m/s)
  11893. const double CHUTE_JETTISON_SPEED = 60.0 / 1.94384;
  11894. // Speed at which chute is jettisoned (m/s)
  11895. // ==========================================================
  11896. // Docking port position
  11897. // ==========================================================
  11898.  
  11899. const VECTOR3 ORBITER_DOCKPOS = { -.088, 2.35, 10.166 };// 0.0, 2.40, 10.15
  11900.  
  11901. // ==========================================================
  11902. // panel area identifiers
  11903. // ==========================================================
  11904.  
  11905. // define MFD function buttons
  11906. #define AID_CDR1_BUTTONS 1
  11907. #define AID_PLT1_BUTTONS 2
  11908. #define AID_MFD1_BUTTONS 3
  11909. #define AID_MFDSIDE_BUTTONS 4
  11910. #define AID_CCTV1_BUTTONS 5
  11911. #define AID_CCTV2_BUTTONS 6
  11912.  
  11913. // D. Beachy: define power buttons
  11914. #define AID_CDR1_PWR 7
  11915. #define AID_PLT1_PWR 8
  11916. #define AID_MFD1_PWR 9
  11917. #define AID_MFDSIDE_PWR 10
  11918.  
  11919. #define AID_CCTV1_PWR 11
  11920. #define AID_CCTV2_PWR 12
  11921. // MFD brightness buttons
  11922. #define AID_CDR1_BRT 13
  11923. #define AID_PLT1_BRT 14
  11924. #define AID_MFD1_BRT 15
  11925. #define AID_MFDSIDE_BRT 16
  11926.  
  11927. // Panel R13L (payload bay operations)
  11928. #define AID_R13L_MIN 100
  11929. #define AID_R13L 100
  11930. #define AID_R13L_TKBK1 101
  11931. #define AID_R13L_TKBK2 102
  11932. #define AID_R13L_TKBK3 103
  11933. #define AID_R13L_TKBK4 104
  11934. #define AID_R13L_TKBK5 105
  11935. #define AID_R13L_TKBK6 106
  11936. #define AID_R13L_MAX 120
  11937.  
  11938. typedef struct {
  11939. HINSTANCE hDLL;
  11940. SURFHANDLE tkbk_label;
  11941. HFONT font[1];
  11942. } GDIParams;
  11943. //met
  11944. #define AID_EVENTAFTTIME 114
  11945. #define AID_METTIME 115
  11946. #define AID_EVENTTIME 116
  11947. #define AID_EVENT1TIME 117
  11948. #define AID_AFTMETTIMERGMT 118
  11949. #define AID_AFTMETTIMERMET 119
  11950. #define AID_AFTMETTIMERTEST 121
  11951. #define AID_AFTEVENTTEST 122
  11952. #define AID_AFTEVENTSET 123
  11953. #define AID_AFTEVENTRESET 124
  11954. #define AID_AFTEVENTSTART 125
  11955. #define AID_AFTEVENTSTOP 126
  11956. #define AID_AFTEVENTUP 127
  11957. #define AID_AFTEVENTDOWN 128
  11958. #define AID_FRTMINUTE2UP 129
  11959. #define AID_FRTMINUTE2DWN 130
  11960. #define AID_FRTMETTIMERTEST 131
  11961. #define AID_FRTEVENTTEST 132
  11962. #define AID_FRTEVENTSET 133
  11963. #define AID_FRTEVENTRESET 134
  11964. #define AID_FRTEVENTSTART 135
  11965. #define AID_FRTEVENTSTOP 136
  11966. #define AID_FRTEVENTUP 137
  11967. #define AID_FRTEVENTDOWN 138
  11968. #define AID_FRTMINUTE1UP 139
  11969. #define AID_FRTMINUTE1DWN 140
  11970. #define AID_FRTSECOND1UP 141
  11971. #define AID_FRTSECOND1DWN 142
  11972. #define AID_FRTSECOND2UP 143
  11973. #define AID_FRTSECOND2DWN 144
  11974.  
  11975. #define AID_AFTMINUTE1UP 145
  11976. #define AID_AFTMINUTE1DWN 146
  11977. #define AID_AFTSECOND1UP 147
  11978. #define AID_AFTSECOND1DWN 148
  11979. #define AID_AFTSECOND2UP 149
  11980. #define AID_AFTSECOND2DWN 150
  11981. #define AID_AFTMINUTE2UP 151
  11982. #define AID_AFTMINUTE2DWN 152
  11983.  
  11984. #define AID_METTIMERGMT 153
  11985. #define AID_METTIMERMET 154
  11986. #define AID_METTIMERTEST 155
  11987. #define AID_PANELA2 156
  11988. #define AID_PANELA2SCALEX1 157
  11989. #define AID_PANELA2TEST 158
  11990. #define AID_PANELA2SCALEX10 159
  11991. #define AID_PANELA2RR 160
  11992. #define AID_PANELA2PWRON 161
  11993. #define AID_PANELA2PWROFF 162
  11994. //ku antenna
  11995. #define AID_KUAZIMUTHLEFT 163
  11996. #define AID_KUAZIMUTHRIGHT 164
  11997. #define AID_KUELUP 165
  11998. #define AID_KUELDOWN 166
  11999. #define AID_KURATESLOW 167
  12000. #define AID_KURATEFAST 168
  12001. #define AID_LANDINGGEARLEFT 169
  12002. #define AID_LANDINGGEARRIGHT 170
  12003. #define AID_LANDINGGEARARMRIGHT 171
  12004. #define AID_LANDINGGEARDNRIGHT 172
  12005. #define AID_LANDINGGEARLEFT_TKBK3 173
  12006. #define AID_LANDINGGEARARM 174
  12007. #define AID_LANDINGGEARDN 175
  12008.  
  12009. #define AID_FLOODON 176
  12010. #define AID_FLOODOFF 177
  12011.  
  12012. #define AID_AFTPORTFLOODON 178
  12013. #define AID_AFTPORTFLOODOFF 179
  12014.  
  12015. #define AID_AFTSTBDFLOODON 180
  12016. #define AID_AFTSTBDFLOODOFF 181
  12017.  
  12018. #define AID_MIDPORTFLOODON 182
  12019. #define AID_MIDPORTFLOODOFF 183
  12020.  
  12021. #define AID_MIDSTBDFLOODON 184
  12022. #define AID_MIDSTBDFLOODOFF 185
  12023.  
  12024. #define AID_FWDPORTFLOODON 186
  12025. #define AID_FWDPORTFLOODOFF 187
  12026.  
  12027. #define AID_FWDSTBDFLOODON 188
  12028. #define AID_FWDSTBDFLOODOFF 189
  12029.  
  12030. #define AID_AFTFLOODON 190
  12031. #define AID_AFTFLOODOFF 191
  12032.  
  12033. #define AID_DOCKFLOODDIM 192
  12034. #define AID_DOCKFLOODOFF 193
  12035. #define AID_DOCKFLOODBRIGHT 194
  12036.  
  12037. #define AID_RCSQTY 195
  12038.  
  12039.  
  12040. //class Atlantis_Tank;
  12041. class AscentAPDlg;
  12042.  
  12043. // ==========================================================
  12044. // Interface for derived vessel class: Atlantis
  12045. // ==========================================================
  12046.  
  12047. class Atlantis: public VESSEL4 {
  12048. friend class AscentAP;
  12049. friend class PayloadBayOp;
  12050. friend BOOL CALLBACK RMS_DlgProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  12051. friend BOOL CALLBACK LIGHT_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  12052. friend BOOL CALLBACK PAYLOADOPERATION_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  12053.  
  12054. public:
  12055. AnimState::Action gear_status, spdb_status;
  12056. Atlantis (OBJHANDLE hObj, int fmodel);
  12057. ~Atlantis();
  12058.  
  12059. //AscentAP *AscentAutopilot() { return ascap; }
  12060. //int RegisterAscentApMfd();
  12061. //void CreateAscentAPDlg();
  12062. //void DestroyAscentAPDlg();
  12063.  
  12064. //void SeparateBoosters (double srb_time);
  12065. // Jettison both SRBs from ET
  12066.  
  12067. // void SeparateTank ();
  12068. // Jettison ET from orbiter
  12069.  
  12070. void clbkHUDMode(int mode) { currentHudMode = mode; }
  12071.  
  12072. void GetSSMEGimbalPos (int which, double &pitch, double &yaw);
  12073. void GetSRBGimbalPos (int which, double &pitch, double &yaw);
  12074. void RevertDockingRing(void);
  12075. void ToggleGrapple (void);
  12076. void ToggleGrapple2(void);
  12077. void ToggleGrapple1(void);
  12078. void ToggleGrapple3(void);
  12079. void ToggleGrappleOBSS(void);
  12080.  
  12081.  
  12082. void ToggleArrest (void);
  12083. void ToggleArrest2(void);
  12084. void ToggleArrest1(void);
  12085. void ToggleArrest3(void);
  12086.  
  12087. void TETHER2(void);
  12088. void TETHER1(void);
  12089. void TETHER3(void);
  12090. void TETHER4(void);
  12091. void SetGearParameters (double state);
  12092. void STOW();
  12093. void Jettison ();
  12094. void UpdateMesh ();
  12095. void SetODSDock();
  12096. void SetBayDoorPosition (double pos);
  12097. void SetRadiatorPosition (double pos);
  12098. void SetRadLatchPosition (double pos) {}
  12099. void SetKuAntennaPosition (double pos);
  12100.  
  12101.  
  12102. void SetSSMEPosition (double pos);
  12103. void OperateLandingGear (AnimState::Action action);
  12104. void RevertLandingGear ();
  12105. void OperateSpeedbrake (AnimState::Action action);
  12106. void RevertSpeedbrake ();
  12107. void SetAnimationArm (UINT anim, double state);
  12108. void RevertPETD();
  12109. void RevertSETD();
  12110. void RevertIUS();
  12111. void RevertADTA();
  12112. void RevertSSMESTOW();
  12113. //new
  12114. void SpawnEVA(void);
  12115. void SpawnEVA1(void);
  12116. void SpawnEVA2(void);
  12117. void SpawnEVA3(void);
  12118. ATTACHMENTHANDLE ft_pad_att, ft_pad_att1, ft_pad_att2, ft_pad_att3;
  12119. VECTOR3 attp_pos[12];
  12120. int EVA1,EVA2,EVA3,EVA4;
  12121. //
  12122. double GetSRBThrustLevel (int which);
  12123. // returns the thrust level from left (which=0) or right (which=1)
  12124. // SRB, or 0 if SRB is detached
  12125.  
  12126. void RegisterVC_CdrMFD ();
  12127. void RegisterVC_PltMFD ();
  12128. void RegisterVC_CntMFD ();
  12129. void RegisterVC_AftMFD ();
  12130. void RegistergearleftVC();
  12131. void RedrawPanel_MFDButton (SURFHANDLE surf, int mfd);
  12132. //met
  12133.  
  12134. void RedrawPanel_metmeterstatus(SURFHANDLE surf, int part);
  12135. void RedrawPanel_EVENTstatus(SURFHANDLE surf, int part);
  12136. void RedrawPanel_EVENT1status(SURFHANDLE surf, int part);
  12137. void RedrawPanel_EVENTAFTstatus(SURFHANDLE surf, int part);
  12138. void RedrawPanel_PANELA2status(SURFHANDLE surf, int part);
  12139. void RedrawPanel_PANELRCSstatus(SURFHANDLE surf, int part);
  12140.  
  12141. void panelswitch();
  12142.  
  12143. //mfdcame
  12144. int clbkGeneric(int msgid, int prm, void* context);
  12145.  
  12146. int status; // 0=launch configuration
  12147. // 1=SRB's engaged
  12148. // 2=SRB's separated
  12149. // 3=Tank separated (orbiter only)
  12150.  
  12151. double t0; // reference time: designated liftoff time
  12152. WORD srb_id1, srb_id2;
  12153.  
  12154. double gear_proc; // landing gear deployment state (0=retracted, 1=deployed)
  12155. //double kubd_proc; // Ku-band antenna deployment state (0=retracted, 1=deployed)
  12156. double spdb_proc; // Speedbrake deployment state (0=retracted, 1=deployed)
  12157. double ldoor_drag, rdoor_drag; // drag components from open cargo doors
  12158. bool center_arm;
  12159. bool arm_moved, arm_scheduled, armOBSS_moved;
  12160. double center_arm_t, center_arm_time, stow_time;
  12161. bool do_plat;
  12162. bool do_cargostatic;
  12163. VECTOR3 glatchpos, glatchdir, glatchrot;
  12164. VECTOR3 ofs_sts_sat, ofs_sts_sat1, ofs_sts_sat2, ofs_sts_sat3, ofs_sts_sat4, ofs_sts_sat5, ofs_sts_sat6;
  12165. VECTOR3 cargo_static_ofs;
  12166. VISHANDLE vis; // handle for visual - note: we assume that only one visual per object is created!
  12167. MESHHANDLE hOrbiterDRAGCHUTEHUD,hOrbiterMesh, hOrbiterCockpitMesh, hOrbiterVCMesh, hOrbiterRMS1Mesh, hOrbiterODSMesh, hOrbiterdragchuteMesh, hOrbiterdragchutereleasedMesh, hOrbiterMPMobss, hOrbiterEXTAIRLOCK, hOrbiterKU, hOrbiterSLIDEWIRE, hOrbiterSHUTTLEWIRE, hOrbiterTHERMALCOVER; // mesh handles
  12168. char cargo_static_mesh_name[256];
  12169. ATTACHMENTHANDLE sat_attach, rms_attach, sat_attach2, sat_attach3, sat_attach4, sat_attach5, sat_attach6, sat_attach7, sat_attach8, sat_attach9, sat_attach10, OBSS_attach;
  12170. VECTOR3 arm_tip[6], armobss_tip[3], arm_ius[6];
  12171. VECTOR3 obssdir, dockpos, ringpos,dockpos1;
  12172. double EXT_proc;
  12173. VECTOR3 xp0, xr0;
  12174. // Overloaded callback functions
  12175. void clbkSetClassCaps (FILEHANDLE cfg);
  12176. void clbkSetStateEx (const void *status);
  12177. void clbkLoadStateEx (FILEHANDLE scn, void *vs);
  12178. void clbkSaveState (FILEHANDLE scn);
  12179. void clbkPostCreation ();
  12180. void clbkFocusChanged (bool getfocus, OBJHANDLE hNewVessel, OBJHANDLE hOldVessel);
  12181. void clbkPreStep (double simt, double simdt, double mjd);
  12182. bool clbkPlaybackEvent (double simt, double event_t, const char *event_type, const char *event);
  12183. int clbkConsumeBufferedKey (DWORD key, bool down, char *kstate);
  12184. void clbkVisualCreated (VISHANDLE vis, int refcount);
  12185. void clbkVisualDestroyed (VISHANDLE vis, int refcount);
  12186. void clbkAnimate (double simt);
  12187. void clbkMFDMode (int mfd, int mode);
  12188. void clbkRCSMode (int mode);
  12189. bool clbkLoadGenericCockpit ();
  12190. bool clbkLoadVC (int id);
  12191. bool clbkVCMouseEvent (int id, int event, VECTOR3 &p);
  12192. bool clbkVCRedrawEvent (int id, int event, SURFHANDLE surf);
  12193. bool clbkDrawHUD (int mode, const HUDPAINTSPEC *hps, oapi::Sketchpad *skp);
  12194.  
  12195. bool firstStep; //call functions in first timestep
  12196.  
  12197.  
  12198. //ik
  12199. void SetAnimationIKArm(VECTOR3 arm_wrist_dpos);
  12200. VECTOR3 CalcAnimationFKArm();
  12201.  
  12202. PayloadBayOp *plop; // control and status of payload bay operations
  12203. int RMSSELECT, OBSS1, RMSDIALOG;
  12204. int OV,MIDMODEL,DRAGCHUTE,NOSLIDEWIRE;
  12205. void ENTER_EVA1(void);
  12206. void ENTER_EVA2(void);
  12207. void ENTER_EVA3(void);
  12208. void ENTER_EVA4(void);
  12209. void Revertextdoor(void);
  12210. void RMSspeed(void);
  12211. void Armtilt(void);
  12212. void OBSStilt(void);
  12213. void RevertDragchute(void);
  12214. bool ItemChange(char *rstr);
  12215. bool ItemChangeJoint(char *rstr);
  12216. bool FullChangeJoint(char *rstr);
  12217. double systart, spstart, epstart, wpstart, wrstart, wystart;
  12218. double arm6_AyHUD, arm6_ApHUD, arm6_ArHUD, arm6_epHUD, arm6_BpHUD, arm6_ByHUD, arm_syHUD, arm_spHUD, arm_epHUD, arm_wpHUD, arm_wyHUD, arm_wrHUD;
  12219. bool EVA1TETHER() const { return GetAttachmentStatus(ft_pad_att) != 0; }
  12220. bool EVA2TETHER() const { return GetAttachmentStatus(ft_pad_att1) != 0; }
  12221. bool EVA3TETHER() const { return GetAttachmentStatus(ft_pad_att2) != 0; }
  12222. bool EVA4TETHER() const { return GetAttachmentStatus(ft_pad_att3) != 0; }
  12223. //payload masses
  12224. int PMASS0, PMASS1, PMASS2, PMASS3;//read from scn
  12225. double MASS1, MASS2, MASS3, MASS0; //payload masses
  12226.  
  12227. protected:
  12228. void LoadMeshes();
  12229. // Load the meshes for cockpit and exterior
  12230.  
  12231. void CreateSSME();
  12232. // Initialise the thrusters for the shuttle main engines
  12233.  
  12234. void CreateOMS();
  12235. // Initialise the thrusters for the orbital maneuvering system
  12236.  
  12237. void CreateRCS();
  12238. // Initialise the thrusters for the reaction control system
  12239.  
  12240. void CreateAirfoils();
  12241. // Initialise airfoils, aerodynamic control surfaces and drag elements
  12242.  
  12243. static void VLiftCoeff (double aoa, double M, double Re, double *cl, double *cm, double *cd);
  12244. static void HLiftCoeff (double beta, double M, double Re, double *cl, double *cm, double *cd);
  12245. // airfoil coefficient functions
  12246.  
  12247. void DefineAnimations (void);
  12248. // Initialises all animation objects
  12249. //
  12250. enum hatch_status { HATCH_UP, HATCH_DOWN, HATCH_RAISING, HATCH_LOWERING } EXT_status, Armtilt_status, ODS_status, OBSS_status, CHUTE_status, DOCKRING_status, PETD_status, SETD_status, ius_status, ssmestow_status, ADTA_status;;
  12251. enum SPANELcheck { IUS_UP, IUS_STOP, IUS_DOWN } IUS_check;
  12252.  
  12253. typedef enum { SHOULDER_YAW = 0, SHOULDER_PITCH = 1, ELBOW_PITCH = 2, WRIST_PITCH = 3, WRIST_YAW = 4, WRIST_ROLL = 5 } RMS_JOINT;
  12254. typedef enum { PAN = 0, TILT = 1 } CAMERA_MOTION;
  12255. //
  12256. //
  12257. int mfd1pwr, mfd0pwr, mfd2pwr, mfdApwr,HUDpwr,floodon;
  12258.  
  12259. //
  12260. private:
  12261.  
  12262. oapi::Font *font, *font1, *font2, *font3;
  12263.  
  12264.  
  12265.  
  12266. int currentHudMode; // Stores the current HUD mode | don't forget to initialize at c'tor!
  12267. int getHUDMode() const { return currentHudMode; }
  12268.  
  12269. void SetSSMEGimbal (const VECTOR3 &angle);
  12270. // Set the gimbal positions for the shuttle main engines
  12271.  
  12272. double GetAscentPitchRate (double tgt_pitch);
  12273. // Autopilot function: returns the pitch rate for the specified
  12274. // target pitch during launch phase (until ET separation)
  12275.  
  12276. void AutoGimbal (const VECTOR3 &tgt_rate);
  12277. // Automatic gimbal adjustment for SSME and SRB engines to correct
  12278. // for CG shift, SRB thrust variations, atmospheric effects, etc.
  12279.  
  12280. void AutoRCS (const VECTOR3 &tgt_rate);
  12281. // Automatic RCS control for ascent autopilot
  12282. void Atlantis::SelectCockpitView(int CAM);
  12283. unsigned short SpeedFactor;
  12284. void LaunchClamps();
  12285. bool EnableSSME (bool enable);
  12286. void EnableOMS (bool enable);
  12287. void EnableRCS (bool enable);
  12288. void PosSSRMS(int i);
  12289. void SeqSSRMS();
  12290. void CheckFlags();
  12291. void DetermineArmSeq(int ItemValue);
  12292. void LOADA();
  12293. void LOADB();
  12294. void LOADC();
  12295. void LOADD();
  12296. void SAVEA();
  12297. void SAVEB();
  12298. void SAVEC();
  12299. void SAVED();
  12300. void ARMSEQ();
  12301. void ARMINPUT();
  12302. void FULLINPUT();
  12303.  
  12304. bool SatGrappled() const { return GetAttachmentStatus (rms_attach) != 0; }
  12305. bool SatStowed() const { return GetAttachmentStatus (sat_attach) != 0; }
  12306. bool SatStowed2() const { return GetAttachmentStatus(sat_attach2) != 0; }
  12307. bool SatStowed3() const { return GetAttachmentStatus(sat_attach3) != 0; }
  12308.  
  12309.  
  12310.  
  12311.  
  12312.  
  12313.  
  12314.  
  12315. ANIMATIONCOMPONENT_HANDLE hAC_arm1;
  12316.  
  12317.  
  12318. ATTACHMENTHANDLE CanArrest() const;
  12319. ATTACHMENTHANDLE CanArrest2() const;
  12320. ATTACHMENTHANDLE CanArrest1() const;
  12321. ATTACHMENTHANDLE CanArrest3() const;
  12322. ATTACHMENTHANDLE CanArrestOBSS() const;
  12323.  
  12324.  
  12325. VECTOR3 pl1_ofs, pl2_ofs, pl3_ofs, pl4_ofs, pl5_ofs, pl6_ofs, pl7_ofs, pl8_ofs, pl9_ofs, pl10_ofs, ft_pad_att_pos, ft_pad_att1_pos, ft_pad_att2_pos, ft_pad_att3_pos;
  12326. VECTOR3 pl1_dir, pl2_dir, pl3_dir, pl4_dir, pl5_dir, pl6_dir, pl7_dir, pl8_dir, pl9_dir, pl10_dir, ft_pad_att_dir, ft_pad_att1_dir, ft_pad_att2_dir, ft_pad_att3_dir;
  12327. VECTOR3 pl1_rot, pl2_rot, pl3_rot, pl4_rot, pl5_rot, pl6_rot, pl7_rot, pl8_rot, pl9_rot, pl10_rot, ft_pad_att_rot, ft_pad_att1_rot, ft_pad_att2_rot, ft_pad_att3_rot;
  12328. VECTOR3 pl1_ofs_scn, pl2_ofs_scn, pl3_ofs_scn, pl4_ofs_scn, pl5_ofs_scn, pl6_ofs_scn, pl7_ofs_scn, pl8_ofs_scn, pl9_ofs_scn, pl10_ofs_scn, ft_pad_att_pos_scn, ft_pad_att1_pos_scn, ft_pad_att2_pos_scn, ft_pad_att3_pos_scn;
  12329. VECTOR3 pl1_dir_scn, pl2_dir_scn, pl3_dir_scn, pl4_dir_scn, pl5_dir_scn, pl6_dir_scn, pl7_dir_scn, pl8_dir_scn, pl9_dir_scn, pl10_dir_scn, ft_pad_att_dir_scn, ft_pad_att1_dir_scn, ft_pad_att2_dir_scn, ft_pad_att3_dir_scn;
  12330. VECTOR3 pl1_rot_scn, pl2_rot_scn, pl3_rot_scn, pl4_rot_scn, pl5_rot_scn, pl6_rot_scn, pl7_rot_scn, pl8_rot_scn, pl9_rot_scn, pl10_rot_scn, ft_pad_att_rot_scn, ft_pad_att1_rot_scn, ft_pad_att2_rot_scn, ft_pad_att3_rot_scn;
  12331. VECTOR3 KEELCAM, KEELCAM_scn, ETCAM, ETCAM_scn, DOCKCAM, DOCKCAM_scn;
  12332. AscentAP *ascap; // ascent autopilot
  12333. int ascapMfdId; // ID for ascent autopilot MFD mode
  12334. //Atlantis_Tank *pET; // pointer to ET object (if attached)
  12335. DOCKHANDLE hDockET, hDockODS; // docking connector to ET
  12336.  
  12337. VECTOR3 gimbal_pos; // gimbal settings for pitch,yaw,roll
  12338.  
  12339. UINT anim_door;
  12340. UINT anim_ssmestow;
  12341. UINT anim_ADTA; // handle for cargo door animation
  12342. UINT anim_extodsdoor;
  12343. UINT anim_EXTAIRLOCK;
  12344. UINT anim_extdoor;
  12345. UINT anim_armtwist;
  12346. //RMS Camera rot/direction
  12347. double camRMSElbow[2];
  12348. VECTOR3 camRMSElbowLoc[3];
  12349. UINT anim_camRMSElbow[2];
  12350. UINT anim_joint[6];
  12351. //
  12352.  
  12353. //payloadcam
  12354. // PAYLOAD CAMERAS ANIMATIONS
  12355. UINT anim_camFLyaw; // handle for front-left payload camera yaw animation
  12356. UINT anim_camFLpitch; // handle for front-left payload camera pitch animation
  12357. UINT anim_camFRyaw; // handle for front-right payload camera yaw animation
  12358. UINT anim_camFRpitch; // handle for front-right payload camera pitch animation
  12359. UINT anim_camBLyaw; // handle for back-left payload camera yaw animation
  12360. UINT anim_camBLpitch; // handle for back-left payload camera pitch animation
  12361. UINT anim_camBRyaw; // handle for back-right payload camera yaw animation
  12362. UINT anim_camBRpitch; // handle for back-right payload camera pitch animation
  12363.  
  12364. typedef enum { CAM_A = 0, CAM_B = 1, CAM_C = 2, CAM_D = 3 } PLB_CAM;
  12365. double camYaw[4], camPitch[4];
  12366. VECTOR3 plbCamPos[4];
  12367.  
  12368. // Camera MFD
  12369. CameraMFD* cameraMFD[3];
  12370. CameraMFD::CameraData cameraData[9];
  12371.  
  12372.  
  12373. // Selected camera must be moved at low rate (if false at high rate)
  12374. bool cameraLowRate;
  12375.  
  12376. // If a camera have been moved (used for reposition camera animations)
  12377. bool cameraMoved;
  12378.  
  12379. // Selected camera for control
  12380. int cameraControl; // 0:FL 1:FR 2:BL 3:BR 4:RMS Elbow
  12381.  
  12382. // Sets the camera positions and animations.
  12383. void SetAnimationCameras();
  12384. double MAX_PLB_CAM_PAN, MAX_PLB_CAM_TILT, CAMRATE, anim_yaw, anim_pitch, a, b, c, MIN_PLB_CAM_PAN;
  12385. UINT PLBCamPanLeft[4], PLBCamPanRight[4], PLBCamTiltUp[4], PLBCamTiltDown[4];
  12386. bool bPLBCamPanLeft_Man, bPLBCamPanRight_Man, bPLBCamTiltUp_Man, bPLBCamTiltDown_Man, ElbowCamTiltUp, ElbowCamTiltDown, ElbowCamPanLeft, ElbowCamPanRight;
  12387.  
  12388.  
  12389.  
  12390.  
  12391. //double CalculateCameraRotationAngle(VECTOR3& dir, const VECTOR3& rot);
  12392. //double Cameraangle;
  12393. VECTOR3 Cameraangle;
  12394. NOTEHANDLE nhCameraLabel; // annotation to display current camera view
  12395. double annotationDisplayTime; // counter used to show/hide camera label
  12396. //
  12397. double arm1_Ay, arm1_Ap, arm1_Ar, arm1_ep, arm1_Bp, arm1_By, arm1_Br;
  12398. double arm2_Ay, arm2_Ap, arm2_Ar, arm2_ep, arm2_Bp, arm2_By, arm2_Br;
  12399. double arm3_Ay, arm3_Ap, arm3_Ar, arm3_ep, arm3_Bp, arm3_By, arm3_Br;
  12400. double arm4_Ay, arm4_Ap, arm4_Ar, arm4_ep, arm4_Bp, arm4_By, arm4_Br;
  12401. double arm5_Ay, arm5_Ap, arm5_Ar, arm5_ep, arm5_Bp, arm5_By, arm5_Br;
  12402. double arm6_Ay, arm6_Ap, arm6_Ar, arm6_ep, arm6_Bp, arm6_By, arm6_Br;
  12403. double armM_Ay, armM_Ap, armM_Ar, armM_ep, armM_Bp, armM_By, armM_Br;
  12404.  
  12405. bool arm1set, arm2set, arm3set, arm4set, arm5set;
  12406. int armseq[8];
  12407. int Seqindex;
  12408. bool Seqfinished;
  12409. bool SpeedChange;
  12410. //
  12411. double ARM_OPERATING_SPEED, OBSS_proc, DOCKRING_proc, AIRSPEEDKNOT, spbrkx, SETD_proc, PETD_proc,ssmes_proc,ADTA_proc;
  12412. int ORIGINAL, spdb_on, spdb_off, spdb_plus, spdb_minus, spdb_auto, rmshud ,NOKU,NOWIRE,GRAB;
  12413. bool camera_moved, update_vectors;
  12414. double distattach;
  12415. UINT anim_MPM; // handle for mpm
  12416. UINT anim_MPMOBSS; // handle for mpmOBSS
  12417. //UINT anim_rad;
  12418. // handle for radiator animation
  12419. UINT anim_PRADIATOR;
  12420. UINT anim_SRADIATOR;
  12421. UINT anim_gear; // handle for landing gear animation
  12422. UINT anim_kubd; // handle for Ku-band antenna animation
  12423. UINT anim_elev; // handle for elevator animation
  12424. UINT anim_laileron; // handle for left aileron animation
  12425. UINT anim_raileron; // handle for right aileron animation
  12426. UINT anim_rudder; // handle for rudder animation
  12427. UINT anim_spdb; // handle for speed brake animation
  12428. UINT anim_ssmes;
  12429. UINT anim_CHUTE; // handle for speed brake animation
  12430. // handle for SSME pitch gimbal animation
  12431. UINT mesh_orbiter; // index for orbiter mesh
  12432. UINT mesh_cockpit; // index for cockpit mesh for external view
  12433. UINT mesh_vc; // index for virtual cockpit mesh
  12434. UINT mesh_ODS;
  12435. UINT mesh_RMS1; // index for DEFAULT RMS
  12436. UINT mesh_cargo; // index for cargo
  12437. UINT mesh_platform; // index for payload platform meshFcent
  12438. UINT mesh_DRAGCHUTE; // dragchute mesh
  12439. UINT mesh_DRAGCHUTERELEASED; // dragchute mesh
  12440. UINT mesh_MPMOBSS;
  12441. UINT mesh_EXTAIRLOCK;
  12442. UINT anim_DOCKRING; // dragchute mesh
  12443. UINT anim_bf;//body flap
  12444. UINT anim_SETD;
  12445. UINT anim_PETD;
  12446. UINT anim_mfd1,anim_mfd2,anim_mfd0,anim_mfdAFT;
  12447. UINT mesh_KU, mesh_SLIDEWIRE, mesh_SHUTTLEWIRE, mesh_THERMALCOVER, mesh_DRAGCHUITEHUD;
  12448. UINT anim_AFTMETTIMER, anim_AFTSETRESET, anim_AFTTIMERSTARTSTOP, anim_AFTTIMERUPDOWNTEST, anim_FRTMET, anim_PANELA2TEST, anim_PANELA2SCALE, anim_PANELA2pwr,anim_KUAZ, anim_KUEL, anim_KURATE;
  12449. UINT anim_FRTEVENTMINUTE2, anim_FRTEVENTMINUTE1, anim_FRTEVENTSECOND2, anim_FRTEVENTSECOND1;
  12450. UINT anim_AFTEVENTMINUTE2, anim_AFTEVENTMINUTE1, anim_AFTEVENTSECOND2, anim_AFTEVENTSECOND1;
  12451.  
  12452. UINT anim_FRTSETRESET, anim_FRTTIMERSTARTSTOP, anim_FRTTIMERUPDOWNTEST;
  12453. PROPELLANT_HANDLE ph_oms; // handles for propellant resources
  12454. THRUSTER_HANDLE th_main[3]; // handles for orbiter main engines
  12455. THRUSTER_HANDLE th_oms[2]; // handles for orbiter oms engines
  12456. THGROUP_HANDLE thg_main, thg_oms; // handles for thruster groups
  12457. int CAM, rmsspeed, ODS, DRAGCHUTEDEPLOYED, EXTAIRLOCK;
  12458. // RMS arm animation status
  12459. ANIMATIONCOMPONENT_HANDLE hAC_arm, hAC_sat, hAC_satref;
  12460. MGROUP_TRANSFORM *rms_anim[9], *obss_anim[1],*ius_anim[1];
  12461. MGROUP_TRANSFORM *ssme_anim[3], *ssme_animSTOW[3];
  12462. UINT anim_arm_sy, anim_arm_sp, anim_arm_ep, anim_arm_wp, anim_arm_wy, anim_arm_wr;
  12463.  
  12464. double arm_sy, arm_sp, arm_ep, arm_wp, arm_wy, arm_wr;
  12465. int Shuttlechutereleased, wheelbrake, PBCAMERA ,geararmed;
  12466. double launchelev; // elevation of launch stack on the ground [m]
  12467. UINT anim_rms_ee;
  12468. UINT anim_ius, anim_SLIDEWIRE;
  12469. MGROUP_TRANSFORM *sat_anim, *sat_ref;
  12470.  
  12471. bool bManualSeparate; // flag for user-induced booster or tank separation
  12472. bool reset_sat;
  12473. OBJHANDLE hMMU, hSAT,hMM1;
  12474. bool render_cockpit;
  12475. double mfdbright[4];
  12476. double cockpitbright;
  12477. //
  12478. double Armtilt_proc, CHUTE_proc, olddockpos, rotchange, rotchange1, phi1, rotchange4, rotchange5, ius_proc, SPINACC, SPINACC1, SPINACC4, SPINACC5, ExternalTankHatch_proc, ssmestow_proc;
  12479. //
  12480. double phi, tiltvalue, ANGULAR_VEL, ANGULAR_VEL1, ANGULAR_VEL4, ANGULAR_VEL5, phi2, phi4, phi5;
  12481. double spintable_vel, spintable1_vel, spintable4_vel, spintable5_vel;
  12482. double spintable_phi, spintable1_phi, spintable4_phi, spintable5_phi;
  12483. int USEIUS, tilt, SPIN1, spintable, SPIN2, spintable1, SPIN3, SPIN4, SPIN5, spintable4, spintable5, SPIN0, vccameracase ;
  12484. VECTOR3 arm1_tip[3], arm2_tip[3], arm3_tip[3], arm4_tip[3];
  12485. VECTOR3 xp1, xr1, DIR, ROT, ROT1, xp2, xr2, xp4, xr4, xp5, xr5, ROT4, ROT5;
  12486.  
  12487. NOTEHANDLE hNote;
  12488. // double arm_sy_stored1, arm_sp_stored1, arm_ep_stored1, arm_wp_stored1, arm_wy_stored1, arm_wr_stored1;
  12489. // double arm_sy_stored2, arm_sp_stored2, arm_ep_stored2, arm_wp_stored2, arm_wy_stored2, arm_wr_stored2;
  12490. // double arm_sy_stored3, arm_sp_stored3, arm_ep_stored3, arm_wp_stored3, arm_wy_stored3, arm_wr_stored3;
  12491. // double arm_sy_stored4, arm_sp_stored4, arm_ep_stored4, arm_wp_stored4, arm_wy_stored4, arm_wr_stored4;
  12492.  
  12493.  
  12494. int storerms, recallstored, rmsexecute;
  12495.  
  12496. //IK parameters
  12497. VECTOR3 arm_wrist_pos;
  12498. double lu, ll;
  12499. double shoulder_neutral;
  12500. double shoulder_range, shoulder_min, shoulder_max;
  12501. double elbow_neutral;
  12502. double elbow_range, elbow_min, elbow_max;
  12503. double wrist_neutral;
  12504. double wrist_range, wrist_min, wrist_max;
  12505.  
  12506.  
  12507. SURFHANDLE contrail_tex; // contrail particle texture
  12508.  
  12509. LightEmitter *engine_light;
  12510. double engine_light_level;
  12511. double ATMPRESSURE; //get DYNAMIC pressure for rcs or control surfaces
  12512. //AscentAPDlg *ascentApDlg;
  12513. int aft_light_status, rmslight_status, flood1_status, flood2_status, flood3_status, flood4_status, flood5_status, flood6_status, docklight_status, docklightdim_status, docklightbright_status;
  12514. SpotLight *spotlight1, *spotlight2, *spotlight3, *spotlight4, *spotlight5, *spotlight6, *spotlight7, *spotlightDOCK, *spotlightRMS;
  12515. BEACONLIGHTSPEC spot_beacon[9];
  12516. VECTOR3 beacon_col = _V(0.75, 0.75, 0.75);
  12517.  
  12518.  
  12519. //eva
  12520. char crew1_name[40];
  12521. char crew2_name[40];
  12522. char crew3_name[40];
  12523. char crew4_name[40];
  12524. char crew1_cfg[40];
  12525. char crew2_cfg[40];
  12526. char crew3_cfg[40];
  12527. char crew4_cfg[40];
  12528.  
  12529. char crew1_name_scn[40];
  12530. char crew2_name_scn[40];
  12531. char crew3_name_scn[40];
  12532. char crew4_name_scn[40];
  12533. char crew1_cfg_scn[40];
  12534. char crew2_cfg_scn[40];
  12535. char crew3_cfg_scn[40];
  12536. char crew4_cfg_scn[40];
  12537.  
  12538. int CREW1, CREW2, CREW3, CREW4;
  12539. int VCCAM;
  12540.  
  12541. //met
  12542. //etimer
  12543. short time;
  12544. double clk;
  12545. short timeAFT;
  12546. double clkAFT;
  12547. //bool start;
  12548. bool up;
  12549. bool upAFT;
  12550. int ETest, TimerReset, TimerStart, TimerSet,A2Test;
  12551. int ETestAFT, TimerResetAFT, TimerStartAFT, TimerSetAFT;
  12552. int switchtimer;
  12553. int Etimer_state[10], Minutes1set, Minutes2set, Minutes3set, Minutes4set;
  12554. int EtimerAFT_state[10], Minutes1setAFT, Minutes2setAFT, Minutes3setAFT, Minutes4setAFT;
  12555.  
  12556. UINT MeshMain, METNUMBER;
  12557. //
  12558. double MET, loadedMET, fGMT;
  12559. int AFTtimer_state[10], GMTmode, Testmode, lTime, METmode, sGMTMillis, Ftimer_state[10], FGMTmode, FTestmode, FMETmode;
  12560. int hours1, minutes, minutes1, timenew, seconds, days, hours;
  12561. int sGMTDays, sGMTHours, sGMTSeconds, sGMTMinutes;
  12562. double FRONTMINUTE2_proc, FRONTMINUTE1_proc, FRONTSECOND2_proc, FRONTSECOND1_proc;
  12563. double AFTMINUTE2_proc, AFTMINUTE1_proc, AFTSECOND2_proc, AFTSECOND1_proc;
  12564.  
  12565. //PANELA1/A2
  12566. int PANELa2pwr;
  12567. int KUAZ, KUEL;
  12568. double elevation, KURATE ;
  12569. //UINT anim_kubdAlpha, anim_kubdBeta;
  12570. UINT anim_LEFTGEARARMON, anim_LEFTGEARDN, anim_LEFTGEARTALKBACK, anim_LEFTGEARARMOFF, anim_LEFTGEARUP ;
  12571. UINT anim_RIGHTGEARARMON, anim_RIGHTGEARDN, anim_RIGHTGEARTALKBACK, anim_RIGHTGEARARMOFF, anim_RIGHTGEARUP;
  12572. UINT anim_floodon, anim_floodportaft, anim_floodportmid, anim_floodportfwd, anim_floodstbdaft, anim_floodstbdmid, anim_floodstbdfwd, anim_fwdlight, anim_docklight,anim_HUDpower, anim_ATDADeploy,anim_dragdeploy,anim_chutejett;
  12573. //RCSQUANTITY
  12574. double RCSQTY;
  12575. double fuelmass;
  12576.  
  12577. //rcsindicators
  12578. UINT anim_pitchup, anim_pitchdown, anim_yawleft, anim_yawright, anim_rollleft, anim_rollright;
  12579. //SPI
  12580. UINT anim_BODYFLAPINDICATOR, anim_rudderINDICATOR, anim_speedbrakeINDICATOR, anim_leftelevonINDICATOR, anim_rightelevonINDICATOR;
  12581.  
  12582. UINT anim_AUTOSPDBRAKE, anim_AUTOBDYFLAP;
  12583. };
  12584.  
  12585.  
  12586. #endif // !__ATLANTIS_H
  12587.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement