viewtrans.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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. /* $Header: /Commando/Code/Tools/ViewTrans/viewtrans.cpp 3 7/06/98 6:28p Greg_h $ */
  19. /***********************************************************************************************
  20. *** Confidential - Westwood Studios ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Trnasformation Viewer Utility *
  24. * *
  25. * File Name : VIEWTRANS.CPP *
  26. * *
  27. * Programmer : Greg Hjelstrom *
  28. * *
  29. * Start Date : 02/24/97 *
  30. * *
  31. * Last Update : February 25, 1997 [GH] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * UtilityDlgProc -- Dialog Proc to handle all of the dialog's windows messages *
  36. * TVU::TransViewerUtility -- Constructor *
  37. * TVU::OnInitDialog -- Initializes the custom controls. *
  38. * TVU::BeginEditParams -- Adds the rollup to the control panel *
  39. * TVU::EndEditParams -- Removes the rollup from the panel *
  40. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  41. #include <MAX.H>
  42. #include <UTILAPI.H>
  43. #include "viewtrans.h"
  44. #include "resource.h"
  45. /*****************************************************************************
  46. ** Globals
  47. */
  48. HINSTANCE hInstance;
  49. TransViewerUtility TheUtility;
  50. UtilityClassDesc UtilityDesc;
  51. /***********************************************************************************************
  52. * UtilityDlgProc -- Dialog Proc to handle all of the dialog's windows messages *
  53. * *
  54. * INPUT: *
  55. * *
  56. * OUTPUT: *
  57. * *
  58. * WARNINGS: *
  59. * *
  60. * HISTORY: *
  61. * 02/25/1997 GH : Created. *
  62. *=============================================================================================*/
  63. BOOL CALLBACK UtilityDlgProc(HWND hDlg, UINT message, WPARAM wParam,LPARAM lParam)
  64. {
  65. TransViewerUtility *to = &TheUtility;
  66. // Respond to the message type...
  67. switch (message) {
  68. case WM_INITDIALOG:
  69. // Initialize all our Custom Controls
  70. TheUtility.OnInitDialog(hDlg, lParam);
  71. return TRUE;
  72. case WM_DESTROY:
  73. // Release all our Custom Controls
  74. return FALSE;
  75. case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_MOUSEMOVE:
  76. // Pass these messages on to the RollupMouseMessage method
  77. // to allow 'hand cursor' scrolling with unused area of the
  78. // rollup page.
  79. to->ip->RollupMouseMessage(hDlg, message, wParam, lParam);
  80. break;
  81. case WM_MOUSEACTIVATE:
  82. to->ip->RealizeParamPanel();
  83. return FALSE;
  84. default:
  85. break;
  86. }
  87. return FALSE;
  88. }
  89. /***********************************************************************************************
  90. * TVU::TransViewerUtility -- Constructor *
  91. * *
  92. * INPUT: *
  93. * *
  94. * OUTPUT: *
  95. * *
  96. * WARNINGS: *
  97. * *
  98. * HISTORY: *
  99. * 02/25/1997 GH : Created. *
  100. *=============================================================================================*/
  101. TransViewerUtility::TransViewerUtility(void)
  102. {
  103. iu = NULL;
  104. ip = NULL;
  105. hPanel = NULL;
  106. }
  107. /***********************************************************************************************
  108. * TVU::BeginEditParams -- Adds the rollup to the control panel *
  109. * *
  110. * INPUT: *
  111. * *
  112. * OUTPUT: *
  113. * *
  114. * WARNINGS: *
  115. * *
  116. * HISTORY: *
  117. * 02/25/1997 GH : Created. *
  118. *=============================================================================================*/
  119. void TransViewerUtility::BeginEditParams(Interface *ip, IUtil *iu)
  120. {
  121. this->iu = iu;
  122. this->ip = ip;
  123. // Add the rollup page to the command panel.
  124. hPanel = ip->AddRollupPage(
  125. hInstance,
  126. MAKEINTRESOURCE(IDD_VIEWTRANS),
  127. UtilityDlgProc,
  128. ROLLUP_PAGE_TITLE,
  129. (LPARAM)this);
  130. // update the display
  131. SelectionSetChanged(ip,iu);
  132. }
  133. /***********************************************************************************************
  134. * TVU::EndEditParams -- Removes the rollup from the panel *
  135. * *
  136. * INPUT: *
  137. * *
  138. * OUTPUT: *
  139. * *
  140. * WARNINGS: *
  141. * *
  142. * HISTORY: *
  143. * 02/25/1997 GH : Created. *
  144. *=============================================================================================*/
  145. void TransViewerUtility::EndEditParams(Interface *ip, IUtil *iu)
  146. {
  147. // Delete the rollup page
  148. ip->DeleteRollupPage(hPanel);
  149. // The panel index is only valid within BeginEditParams and
  150. // EndEditParams. Set it to null for safety.
  151. hPanel = NULL;
  152. }
  153. /***********************************************************************************************
  154. * TVU::OnInitDialog -- Initializes the custom controls. *
  155. * *
  156. * INPUT: *
  157. * *
  158. * OUTPUT: *
  159. * *
  160. * WARNINGS: *
  161. * *
  162. * HISTORY: *
  163. * 02/25/1997 GH : Created. *
  164. *=============================================================================================*/
  165. void TransViewerUtility::OnInitDialog(HWND hDlg, LPARAM lParam)
  166. {
  167. }
  168. void TransViewerUtility::SelectionSetChanged(Interface *ip,IUtil *iu)
  169. {
  170. // If there is not one and only one selected, clear
  171. // the display with zeros.
  172. if (ip->GetSelNodeCount() != 1) {
  173. Display_Data(
  174. Matrix3(1),
  175. Matrix3(1),
  176. Point3(0.0f,0.0f,0.0f),
  177. Quat(0.0f,0.0f,0.0f,0.0f),
  178. ScaleValue(Point3(1.0f,1.0f,1.0f))
  179. );
  180. return;
  181. }
  182. // Get all sorts of info about this node!
  183. INode * node = ip->GetSelNode(0);
  184. Matrix3 nodetm = node->GetNodeTM(ip->GetTime());
  185. Matrix3 objtm = node->GetObjectTM(ip->GetTime());
  186. Point3 objoffpos = node->GetObjOffsetPos();
  187. Quat objoffrot = node->GetObjOffsetRot();
  188. ScaleValue objoffscl = node->GetObjOffsetScale();
  189. // display on the panel
  190. Display_Data(nodetm,objtm,objoffpos,objoffrot,objoffscl);
  191. }
  192. void TransViewerUtility::Display_Data
  193. (
  194. Matrix3 &nodetm,
  195. Matrix3 &objtm,
  196. Point3 &objoffpos,
  197. Quat &objoffrot,
  198. ScaleValue &objoffscl
  199. )
  200. {
  201. char string[256];
  202. Point3 vect;
  203. //////////////////////////////////////////
  204. // 3x3 sub-matrix of the ObjectTM
  205. //////////////////////////////////////////
  206. vect = objtm.GetRow(0);
  207. sprintf(string,"%5.3f",vect.x);
  208. SetWindowText(GetDlgItem(hPanel, IDC_OBJTM_0),string);
  209. sprintf(string,"%5.3f",vect.y);
  210. SetWindowText(GetDlgItem(hPanel, IDC_OBJTM_1),string);
  211. sprintf(string,"%5.3f",vect.z);
  212. SetWindowText(GetDlgItem(hPanel, IDC_OBJTM_2),string);
  213. vect = objtm.GetRow(1);
  214. sprintf(string,"%5.3f",vect.x);
  215. SetWindowText(GetDlgItem(hPanel, IDC_OBJTM_3),string);
  216. sprintf(string,"%5.3f",vect.y);
  217. SetWindowText(GetDlgItem(hPanel, IDC_OBJTM_4),string);
  218. sprintf(string,"%5.3f",vect.z);
  219. SetWindowText(GetDlgItem(hPanel, IDC_OBJTM_5),string);
  220. vect = objtm.GetRow(2);
  221. sprintf(string,"%5.3f",vect.x);
  222. SetWindowText(GetDlgItem(hPanel, IDC_OBJTM_6),string);
  223. sprintf(string,"%5.3f",vect.y);
  224. SetWindowText(GetDlgItem(hPanel, IDC_OBJTM_7),string);
  225. sprintf(string,"%5.3f",vect.z);
  226. SetWindowText(GetDlgItem(hPanel, IDC_OBJTM_8),string);
  227. ///////////////////////////////////////////
  228. // Translation portion of the ObjectTM
  229. ///////////////////////////////////////////
  230. vect = objtm.GetTrans();
  231. sprintf(string,"%5.3f",vect.x);
  232. SetWindowText(GetDlgItem(hPanel, IDC_OBJTM_9),string);
  233. sprintf(string,"%5.3f",vect.y);
  234. SetWindowText(GetDlgItem(hPanel, IDC_OBJTM_10),string);
  235. sprintf(string,"%5.3f",vect.z);
  236. SetWindowText(GetDlgItem(hPanel, IDC_OBJTM_11),string);
  237. ///////////////////////////////////////////
  238. // 3x3 sub-matrix of the NodeTM
  239. ///////////////////////////////////////////
  240. vect = objtm.GetRow(0);
  241. sprintf(string,"%5.3f",vect.x);
  242. SetWindowText(GetDlgItem(hPanel, IDC_NODETM_0),string);
  243. sprintf(string,"%5.3f",vect.y);
  244. SetWindowText(GetDlgItem(hPanel, IDC_NODETM_1),string);
  245. sprintf(string,"%5.3f",vect.z);
  246. SetWindowText(GetDlgItem(hPanel, IDC_NODETM_2),string);
  247. vect = objtm.GetRow(1);
  248. sprintf(string,"%5.3f",vect.x);
  249. SetWindowText(GetDlgItem(hPanel, IDC_NODETM_3),string);
  250. sprintf(string,"%5.3f",vect.y);
  251. SetWindowText(GetDlgItem(hPanel, IDC_NODETM_4),string);
  252. sprintf(string,"%5.3f",vect.z);
  253. SetWindowText(GetDlgItem(hPanel, IDC_NODETM_5),string);
  254. vect = objtm.GetRow(2);
  255. sprintf(string,"%5.3f",vect.x);
  256. SetWindowText(GetDlgItem(hPanel, IDC_NODETM_6),string);
  257. sprintf(string,"%5.3f",vect.y);
  258. SetWindowText(GetDlgItem(hPanel, IDC_NODETM_7),string);
  259. sprintf(string,"%5.3f",vect.z);
  260. SetWindowText(GetDlgItem(hPanel, IDC_NODETM_8),string);
  261. ///////////////////////////////////////////
  262. // Translation portion of the NodeTM
  263. ///////////////////////////////////////////
  264. vect = nodetm.GetTrans();
  265. sprintf(string,"%5.3f",vect.x);
  266. SetWindowText(GetDlgItem(hPanel, IDC_NODETM_9),string);
  267. sprintf(string,"%5.3f",vect.y);
  268. SetWindowText(GetDlgItem(hPanel, IDC_NODETM_10),string);
  269. sprintf(string,"%5.3f",vect.z);
  270. SetWindowText(GetDlgItem(hPanel, IDC_NODETM_11),string);
  271. ///////////////////////////////////////////
  272. // Object-Offset translation:
  273. ///////////////////////////////////////////
  274. vect = objoffpos;
  275. sprintf(string,"%5.3f",vect.x);
  276. SetWindowText(GetDlgItem(hPanel, IDC_OBJOFF_TRANS_X),string);
  277. sprintf(string,"%5.3f",vect.y);
  278. SetWindowText(GetDlgItem(hPanel, IDC_OBJOFF_TRANS_Y),string);
  279. sprintf(string,"%5.3f",vect.z);
  280. SetWindowText(GetDlgItem(hPanel, IDC_OBJOFF_TRANS_Z),string);
  281. ///////////////////////////////////////////
  282. // Object-Offset scaling:
  283. ///////////////////////////////////////////
  284. vect = objoffscl.s;
  285. sprintf(string,"%5.3f",vect.x);
  286. SetWindowText(GetDlgItem(hPanel, IDC_OBJOFF_SCALE_X),string);
  287. sprintf(string,"%5.3f",vect.y);
  288. SetWindowText(GetDlgItem(hPanel, IDC_OBJOFF_SCALE_Y),string);
  289. sprintf(string,"%5.3f",vect.z);
  290. SetWindowText(GetDlgItem(hPanel, IDC_OBJOFF_SCALE_Z),string);
  291. ///////////////////////////////////////////
  292. // Object-Offset Quaternion:
  293. ///////////////////////////////////////////
  294. sprintf(string,"%5.3f",objoffrot[0]);
  295. SetWindowText(GetDlgItem(hPanel, IDC_OBJOFF_ROT_X),string);
  296. sprintf(string,"%5.3f",objoffrot[1]);
  297. SetWindowText(GetDlgItem(hPanel, IDC_OBJOFF_ROT_Y),string);
  298. sprintf(string,"%5.3f",objoffrot[2]);
  299. SetWindowText(GetDlgItem(hPanel, IDC_OBJOFF_ROT_Z),string);
  300. sprintf(string,"%5.3f",objoffrot[3]);
  301. SetWindowText(GetDlgItem(hPanel, IDC_OBJOFF_ROT_W),string);
  302. }