MaxFly.cpp 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /**********************************************************************
  19. *<
  20. FILE: MaxFly.cpp
  21. DESCRIPTION: Appwizard generated plugin
  22. CREATED BY:
  23. HISTORY:
  24. *> Copyright (c) 1997, All Rights Reserved.
  25. **********************************************************************/
  26. #include "MaxFly.h"
  27. #define MAXFLY_CLASS_ID Class_ID(0xf1077c8, 0x387a6b66)
  28. const float PITCH_SPEED = 8.0f * 3.1415f / 180.0f;
  29. const float YAW_SPEED = 8.0f * 3.1415f / 180.0f;
  30. const float FLY_SPEED = 5.0f;
  31. class MaxFly : public UtilityObj
  32. {
  33. public:
  34. MaxFly();
  35. ~MaxFly();
  36. void BeginEditParams(Interface *ip,IUtil *iu);
  37. void EndEditParams(Interface *ip,IUtil *iu);
  38. void Init(HWND hWnd);
  39. void Destroy(HWND hWnd);
  40. void DeleteThis() { }
  41. protected:
  42. void Select_Camera(void);
  43. void Pitch_Up(void);
  44. void Pitch_Down(void);
  45. void Yaw_Left(void);
  46. void Yaw_Right(void);
  47. void Fly_Forward(void);
  48. void Fly_Backward(void);
  49. HWND hPanel;
  50. IUtil * iu;
  51. Interface * ip;
  52. friend static BOOL CALLBACK MaxFlyDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  53. };
  54. static MaxFly theMaxFly;
  55. class MaxFlyClassDesc:public ClassDesc2
  56. {
  57. public:
  58. int IsPublic() {return 1;}
  59. void * Create(BOOL loading = FALSE) {return &theMaxFly;}
  60. const TCHAR * ClassName() {return GetString(IDS_CLASS_NAME);}
  61. SClass_ID SuperClassID() {return UTILITY_CLASS_ID;}
  62. Class_ID ClassID() {return MAXFLY_CLASS_ID;}
  63. const TCHAR* Category() {return GetString(IDS_CATEGORY);}
  64. const TCHAR* InternalName() { return _T("MaxFly"); } // returns fixed parsable name (scripter-visible name)
  65. HINSTANCE HInstance() { return hInstance; } // returns owning module handle
  66. };
  67. static MaxFlyClassDesc MaxFlyDesc;
  68. ClassDesc2* GetMaxFlyDesc() {return &MaxFlyDesc;}
  69. static BOOL CALLBACK MaxFlyDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  70. {
  71. switch (msg) {
  72. case WM_INITDIALOG:
  73. theMaxFly.Init(hWnd);
  74. break;
  75. case WM_DESTROY:
  76. theMaxFly.Destroy(hWnd);
  77. break;
  78. case WM_COMMAND:
  79. switch (LOWORD(wParam)) {
  80. case IDC_PITCH_UP_BUTTON: theMaxFly.Pitch_Up(); break;
  81. case IDC_PITCH_DOWN_BUTTON: theMaxFly.Pitch_Down(); break;
  82. case IDC_YAW_LEFT_BUTTON: theMaxFly.Yaw_Left(); break;
  83. case IDC_YAW_RIGHT_BUTTON: theMaxFly.Yaw_Right(); break;
  84. case IDC_FLY_FORWARD_BUTTON: theMaxFly.Fly_Forward(); break;
  85. case IDC_FLY_BACKWARD_BUTTON: theMaxFly.Fly_Backward(); break;
  86. case IDC_SELECT_CAMERA_BUTTON: theMaxFly.Select_Camera(); break;
  87. };
  88. break;
  89. case WM_LBUTTONDOWN:
  90. case WM_LBUTTONUP:
  91. case WM_MOUSEMOVE:
  92. theMaxFly.ip->RollupMouseMessage(hWnd,msg,wParam,lParam);
  93. break;
  94. default:
  95. return FALSE;
  96. }
  97. return TRUE;
  98. }
  99. //--- MaxFly -------------------------------------------------------
  100. MaxFly::MaxFly()
  101. {
  102. iu = NULL;
  103. ip = NULL;
  104. hPanel = NULL;
  105. }
  106. MaxFly::~MaxFly()
  107. {
  108. }
  109. void MaxFly::BeginEditParams(Interface *ip,IUtil *iu)
  110. {
  111. this->iu = iu;
  112. this->ip = ip;
  113. hPanel = ip->AddRollupPage(
  114. hInstance,
  115. MAKEINTRESOURCE(IDD_PANEL),
  116. MaxFlyDlgProc,
  117. GetString(IDS_PARAMS),
  118. 0);
  119. }
  120. void MaxFly::EndEditParams(Interface *ip,IUtil *iu)
  121. {
  122. this->iu = NULL;
  123. this->ip = NULL;
  124. ip->DeleteRollupPage(hPanel);
  125. hPanel = NULL;
  126. }
  127. void MaxFly::Init(HWND hWnd)
  128. {
  129. }
  130. void MaxFly::Destroy(HWND hWnd)
  131. {
  132. }
  133. void MaxFly::Select_Camera(void)
  134. {
  135. }
  136. void MaxFly::Pitch_Up(void)
  137. {
  138. if (ip->GetSelNodeCount() > 0) {
  139. for (int i=0; i<ip->GetSelNodeCount(); i++) {
  140. INode * node = ip->GetSelNode(i);
  141. if (node) {
  142. Matrix3 object_tm = node->GetObjectTM(ip->GetTime());
  143. node->Rotate( ip->GetTime(), // Time
  144. object_tm, // tmAxis
  145. AngAxis(Point3(1,0,0),-PITCH_SPEED), // const AngAxis& val,
  146. TRUE, // BOOL localOrigin=FALSE,
  147. TRUE, // BOOL affectKids=TRUE,
  148. PIV_NONE, // int pivMode=PIV_NONE,
  149. TRUE // BOOL ignoreLocks=FALSE
  150. );
  151. }
  152. }
  153. ip->RedrawViews(ip->GetTime());
  154. }
  155. }
  156. void MaxFly::Pitch_Down(void)
  157. {
  158. if (ip->GetSelNodeCount() > 0) {
  159. for (int i=0; i<ip->GetSelNodeCount(); i++) {
  160. INode * node = ip->GetSelNode(i);
  161. if (node) {
  162. Matrix3 object_tm = node->GetObjectTM(ip->GetTime());
  163. node->Rotate( ip->GetTime(), // Time
  164. object_tm, // tmAxis
  165. AngAxis(Point3(1,0,0),PITCH_SPEED), // const AngAxis& val,
  166. TRUE, // BOOL localOrigin=FALSE,
  167. TRUE, // BOOL affectKids=TRUE,
  168. PIV_NONE, // int pivMode=PIV_NONE,
  169. TRUE // BOOL ignoreLocks=FALSE
  170. );
  171. }
  172. }
  173. ip->RedrawViews(ip->GetTime());
  174. }
  175. }
  176. void MaxFly::Yaw_Left(void)
  177. {
  178. if (ip->GetSelNodeCount() > 0) {
  179. for (int i=0; i<ip->GetSelNodeCount(); i++) {
  180. INode * node = ip->GetSelNode(i);
  181. if (node) {
  182. Matrix3 object_tm = node->GetObjectTM(ip->GetTime());
  183. node->Rotate( ip->GetTime(), // Time
  184. object_tm, // tmAxis
  185. AngAxis(Point3(0,1,0),-YAW_SPEED), // const AngAxis& val,
  186. TRUE, // BOOL localOrigin=FALSE,
  187. TRUE, // BOOL affectKids=TRUE,
  188. PIV_NONE, // int pivMode=PIV_NONE,
  189. TRUE // BOOL ignoreLocks=FALSE
  190. );
  191. }
  192. }
  193. ip->RedrawViews(ip->GetTime());
  194. }
  195. }
  196. void MaxFly::Yaw_Right(void)
  197. {
  198. if (ip->GetSelNodeCount() > 0) {
  199. for (int i=0; i<ip->GetSelNodeCount(); i++) {
  200. INode * node = ip->GetSelNode(i);
  201. if (node) {
  202. Matrix3 object_tm = node->GetObjectTM(ip->GetTime());
  203. node->Rotate( ip->GetTime(), // Time
  204. object_tm, // tmAxis
  205. AngAxis(Point3(0,1,0),+YAW_SPEED), // const AngAxis& val,
  206. TRUE, // BOOL localOrigin=FALSE,
  207. TRUE, // BOOL affectKids=TRUE,
  208. PIV_NONE, // int pivMode=PIV_NONE,
  209. TRUE // BOOL ignoreLocks=FALSE
  210. );
  211. }
  212. }
  213. ip->RedrawViews(ip->GetTime());
  214. }
  215. }
  216. void MaxFly::Fly_Forward(void)
  217. {
  218. if (ip->GetSelNodeCount() > 0) {
  219. for (int i=0; i<ip->GetSelNodeCount(); i++) {
  220. INode * node = ip->GetSelNode(i);
  221. if (node) {
  222. Matrix3 object_tm = node->GetObjectTM(ip->GetTime());
  223. node->Move( ip->GetTime(), // TimeValue t,
  224. object_tm, // const Matrix3& tmAxis,
  225. Point3(0.0f,0.0f,-FLY_SPEED), // const Point3& val,
  226. TRUE, // BOOL localOrigin=FALSE,
  227. TRUE, // BOOL affectKids=TRUE,
  228. PIV_NONE, // int pivMode=PIV_NONE,
  229. TRUE // BOOL ignoreLocks=FALSE
  230. );
  231. }
  232. }
  233. ip->RedrawViews(ip->GetTime());
  234. }
  235. }
  236. void MaxFly::Fly_Backward(void)
  237. {
  238. if (ip->GetSelNodeCount() > 0) {
  239. for (int i=0; i<ip->GetSelNodeCount(); i++) {
  240. INode * node = ip->GetSelNode(i);
  241. if (node) {
  242. Matrix3 object_tm = node->GetObjectTM(ip->GetTime());
  243. node->Move( ip->GetTime(), // TimeValue t,
  244. object_tm, // const Matrix3& tmAxis,
  245. Point3(0.0f,0.0f,FLY_SPEED), // const Point3& val,
  246. TRUE, // BOOL localOrigin=FALSE,
  247. TRUE, // BOOL affectKids=TRUE,
  248. PIV_NONE, // int pivMode=PIV_NONE,
  249. TRUE // BOOL ignoreLocks=FALSE
  250. );
  251. }
  252. }
  253. ip->RedrawViews(ip->GetTime());
  254. }
  255. }