bpick.cpp 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. ** Command & Conquer Generals(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/max2w3d/bpick.cpp 7 1/04/01 11:12a Greg_h $ */
  19. /***********************************************************************************************
  20. *** Confidential - Westwood Studios ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Commando Tools - WWSkin *
  24. * *
  25. * $Archive:: /Commando/Code/Tools/max2w3d/bpick.cpp $*
  26. * *
  27. * $Author:: Greg_h $*
  28. * *
  29. * $Modtime:: 1/04/01 11:12a $*
  30. * *
  31. * $Revision:: 7 $*
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * BonePickerClass::Filter -- determine whether the passed node is suitable *
  36. * BonePickerClass::HitTest -- MAX HitTest method *
  37. * BonePickerClass::Pick -- MAX Pick method *
  38. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  39. #include "bpick.h"
  40. #include "dllmain.h"
  41. #include "resource.h"
  42. /*
  43. ** Global instance of a bone picker :-)
  44. */
  45. BonePickerClass TheBonePicker;
  46. /***********************************************************************************************
  47. * BonePickerClass::Filter -- determine whether the passed node is suitable *
  48. * *
  49. * INPUT: *
  50. * *
  51. * OUTPUT: *
  52. * *
  53. * WARNINGS: *
  54. * *
  55. * HISTORY: *
  56. * 10/26/1997 GH : Created. *
  57. *=============================================================================================*/
  58. BOOL BonePickerClass::Filter(INode *node)
  59. {
  60. if (BoneList == NULL) {
  61. ObjectState os = node->EvalWorldState(0);
  62. if (os.obj) {
  63. return TRUE;
  64. }
  65. } else {
  66. for (int i=0; i<BoneList->Count(); i++) {
  67. if ((*BoneList)[i] == node) return TRUE;
  68. }
  69. }
  70. return FALSE;
  71. }
  72. /***********************************************************************************************
  73. * BonePickerClass::HitTest -- MAX HitTest method *
  74. * *
  75. * INPUT: *
  76. * *
  77. * OUTPUT: *
  78. * *
  79. * WARNINGS: *
  80. * *
  81. * HISTORY: *
  82. * 10/26/1997 GH : Created. *
  83. *=============================================================================================*/
  84. BOOL BonePickerClass::HitTest(IObjParam *ip,HWND hwnd,ViewExp *vpt,IPoint2 m,int flags)
  85. {
  86. if (ip->PickNode(hwnd,m,GetFilter())) {
  87. return TRUE;
  88. } else {
  89. return FALSE;
  90. }
  91. }
  92. /***********************************************************************************************
  93. * BonePickerClass::Pick -- MAX Pick method *
  94. * *
  95. * INPUT: *
  96. * *
  97. * OUTPUT: *
  98. * *
  99. * WARNINGS: *
  100. * *
  101. * HISTORY: *
  102. * 10/26/1997 GH : Created. *
  103. *=============================================================================================*/
  104. BOOL BonePickerClass::Pick(IObjParam *ip,ViewExp *vpt)
  105. {
  106. INode *node = vpt->GetClosestHit();
  107. if (node) {
  108. /*
  109. ** Tell the "owning" skin modifier about the
  110. ** bone which was picked.
  111. */
  112. assert(User);
  113. User->User_Picked_Bone(node);
  114. User = NULL;
  115. BoneList = NULL;
  116. }
  117. return TRUE;
  118. }
  119. BOOL BonePickerClass::filter(INode * inode)
  120. {
  121. return Filter(inode);
  122. }
  123. void BonePickerClass::proc(INodeTab & nodetab)
  124. {
  125. assert(User != NULL);
  126. User->User_Picked_Bones(nodetab);
  127. User = NULL;
  128. BoneList = NULL;
  129. }
  130. TCHAR * BonePickerClass::dialogTitle(void)
  131. {
  132. return Get_String(IDS_PICK_BONE_DIALOG_TITLE);
  133. }
  134. TCHAR * BonePickerClass::buttonText(void)
  135. {
  136. return Get_String(IDS_PICK_BONE_BUTTON_TEXT);
  137. }