MeshPropPage.cpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. // MeshPropPage.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "W3DView.h"
  22. #include "MeshPropPage.h"
  23. #include "RendObj.H"
  24. #include "AssetMgr.H"
  25. #include "Mesh.H"
  26. #include "MeshMdl.H"
  27. #include "w3d_file.h"
  28. #ifdef _DEBUG
  29. #define new DEBUG_NEW
  30. #undef THIS_FILE
  31. static char THIS_FILE[] = __FILE__;
  32. #endif
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CMeshPropPage property page
  35. IMPLEMENT_DYNCREATE(CMeshPropPage, CPropertyPage)
  36. ////////////////////////////////////////////////////////////////
  37. //
  38. // CMeshPropPage
  39. //
  40. CMeshPropPage::CMeshPropPage (const CString &stringMeshName)
  41. : CPropertyPage(CMeshPropPage::IDD)
  42. {
  43. //{{AFX_DATA_INIT(CMeshPropPage)
  44. // NOTE: the ClassWizard will add member initialization here
  45. //}}AFX_DATA_INIT
  46. m_stringMeshName = stringMeshName;
  47. return ;
  48. }
  49. ////////////////////////////////////////////////////////////////
  50. //
  51. // ~CMeshPropPage
  52. //
  53. CMeshPropPage::~CMeshPropPage (void)
  54. {
  55. return ;
  56. }
  57. ////////////////////////////////////////////////////////////////
  58. //
  59. // DoDataExchange
  60. //
  61. void
  62. CMeshPropPage::DoDataExchange (CDataExchange* pDX)
  63. {
  64. CPropertyPage::DoDataExchange(pDX);
  65. //{{AFX_DATA_MAP(CMeshPropPage)
  66. // NOTE: the ClassWizard will add DDX and DDV calls here
  67. //}}AFX_DATA_MAP
  68. return ;
  69. }
  70. BEGIN_MESSAGE_MAP(CMeshPropPage, CPropertyPage)
  71. //{{AFX_MSG_MAP(CMeshPropPage)
  72. ON_WM_CLOSE()
  73. //}}AFX_MSG_MAP
  74. END_MESSAGE_MAP()
  75. /////////////////////////////////////////////////////////////////////////////
  76. // CMeshPropPage message handlers
  77. ////////////////////////////////////////////////////////////////
  78. //
  79. // OnInitDialog
  80. //
  81. BOOL
  82. CMeshPropPage::OnInitDialog (void)
  83. {
  84. // Allow the base class to process this message
  85. CPropertyPage::OnInitDialog();
  86. if (m_stringMeshName.GetLength () > 0)
  87. {
  88. // Get a pointer to the mesh object from the asset manager
  89. MeshClass *pCMesh = (MeshClass *)WW3DAssetManager::Get_Instance()->Create_Render_Obj (m_stringMeshName);
  90. ASSERT (pCMesh);
  91. if (pCMesh)
  92. {
  93. CString stringDesc;
  94. stringDesc.Format (IDS_MESH_PROP_DESC, m_stringMeshName);
  95. // Put the description onto the dialog
  96. SetDlgItemText (IDC_DESCRIPTION, stringDesc);
  97. // Put the polygon count onto the dialog
  98. SetDlgItemInt (IDC_POLYGON_COUNT, pCMesh->Get_Num_Polys ());
  99. MeshModelClass *pmeshmodel = pCMesh->Get_Model ();
  100. ASSERT (pmeshmodel);
  101. if (pmeshmodel)
  102. {
  103. // Put the vertex count onto the dialog
  104. SetDlgItemInt (IDC_VERTEX_COUNT, pmeshmodel->Get_Vertex_Count ());
  105. }
  106. // Put the user text onto the dialog
  107. SetDlgItemText (IDC_USER_TEXT, pCMesh->Get_User_Text ());
  108. // Get the flags for the mesh
  109. DWORD dwFlags = pCMesh->Get_W3D_Flags ();
  110. // Determine what type of mesh this is
  111. if ((dwFlags & W3D_MESH_FLAG_COLLISION_BOX) == W3D_MESH_FLAG_COLLISION_BOX)
  112. {
  113. SendDlgItemMessage (IDC_MESH_TYPE_COLLISION_BOX, BM_SETCHECK, (WPARAM)TRUE);
  114. }
  115. else if ((dwFlags & W3D_MESH_FLAG_SKIN) == W3D_MESH_FLAG_SKIN)
  116. {
  117. SendDlgItemMessage (IDC_MESH_TYPE_SKIN, BM_SETCHECK, (WPARAM)TRUE);
  118. }
  119. else if ((dwFlags & W3D_MESH_FLAG_SHADOW) == W3D_MESH_FLAG_SHADOW)
  120. {
  121. SendDlgItemMessage (IDC_MESH_TYPE_SHADOW, BM_SETCHECK, (WPARAM)TRUE);
  122. }
  123. else
  124. {
  125. SendDlgItemMessage (IDC_MESH_TYPE_NORMAL, BM_SETCHECK, (WPARAM)TRUE);
  126. }
  127. // Is this collision type physical?
  128. DWORD dwCollisionFlags = dwFlags & W3D_MESH_FLAG_COLLISION_TYPE_MASK;
  129. if ((dwCollisionFlags & W3D_MESH_FLAG_COLLISION_TYPE_PHYSICAL) == W3D_MESH_FLAG_COLLISION_TYPE_PHYSICAL)
  130. {
  131. SendDlgItemMessage (IDC_COLLISION_TYPE_PHYSICAL, BM_SETCHECK, (WPARAM)TRUE);
  132. }
  133. // Is this collision type projectile?
  134. if ((dwCollisionFlags & W3D_MESH_FLAG_COLLISION_TYPE_PROJECTILE) == W3D_MESH_FLAG_COLLISION_TYPE_PROJECTILE)
  135. {
  136. SendDlgItemMessage (IDC_COLLISION_TYPE_PROJECTILE, BM_SETCHECK, (WPARAM)TRUE);
  137. }
  138. // Is this a hidden mesh?
  139. if ((dwFlags & W3D_MESH_FLAG_HIDDEN) == W3D_MESH_FLAG_HIDDEN)
  140. {
  141. SendDlgItemMessage (IDC_HIDDEN, BM_SETCHECK, (WPARAM)TRUE);
  142. }
  143. // Free the object
  144. pCMesh->Release_Ref ();
  145. pCMesh = NULL;
  146. }
  147. }
  148. GetParent ()->GetDlgItem (IDOK)->ShowWindow (SW_HIDE);
  149. GetParent ()->GetDlgItem (IDCANCEL)->SetWindowText ("Close");
  150. return TRUE;
  151. }
  152. void CMeshPropPage::OnClose()
  153. {
  154. // TODO: Add your message handler code here and/or call default
  155. CPropertyPage::OnClose();
  156. return ;
  157. }