Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

341 lines
10 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: d3drmmeshobj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // d3drmMeshObj.cpp : Implementation of CDirectApp and DLL registration.
  11. #include "stdafx.h"
  12. #include "Direct.h"
  13. #include "dms.h"
  14. #include "d3drmMeshObj.h"
  15. #include "d3drmMaterial2Obj.h"
  16. #include "d3drmTexture3Obj.h"
  17. CONSTRUCTOR( _dxj_Direct3dRMMesh, {});
  18. DESTRUCTOR(_dxj_Direct3dRMMesh, {});
  19. GETSET_OBJECT(_dxj_Direct3dRMMesh);
  20. CLONE_R(_dxj_Direct3dRMMesh,Direct3DRMMesh);
  21. GETNAME_R(_dxj_Direct3dRMMesh);
  22. SETNAME_R(_dxj_Direct3dRMMesh);
  23. GETCLASSNAME_R(_dxj_Direct3dRMMesh);
  24. ADDDESTROYCALLBACK_R(_dxj_Direct3dRMMesh);
  25. DELETEDESTROYCALLBACK_R(_dxj_Direct3dRMMesh);
  26. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMMesh, setAppData, SetAppData, long,(DWORD));
  27. PASS_THROUGH2_R(_dxj_Direct3dRMMesh, setGroupColor,SetGroupColor,d3drmGroupIndex, d3dcolor);
  28. PASS_THROUGH2_R(_dxj_Direct3dRMMesh, setGroupMapping,SetGroupMapping,d3drmGroupIndex,d3drmMappingFlags);
  29. PASS_THROUGH2_R(_dxj_Direct3dRMMesh, setGroupQuality,SetGroupQuality,d3drmGroupIndex,d3drmRenderQuality);
  30. PASS_THROUGH3_R(_dxj_Direct3dRMMesh, scaleMesh, Scale, d3dvalue, d3dvalue, d3dvalue);
  31. PASS_THROUGH3_R(_dxj_Direct3dRMMesh, translate, Translate, d3dvalue, d3dvalue, d3dvalue);
  32. PASS_THROUGH4_R(_dxj_Direct3dRMMesh, setGroupColorRGB,SetGroupColorRGB,d3drmGroupIndex,d3dvalue,d3dvalue,d3dvalue);
  33. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMMesh, getBox,GetBox, D3dRMBox*, (_D3DRMBOX*));
  34. GET_DIRECT_R(_dxj_Direct3dRMMesh, getAppData, GetAppData, long);
  35. GET_DIRECT_R(_dxj_Direct3dRMMesh, getGroupCount, GetGroupCount, long);
  36. GET_DIRECT1_R(_dxj_Direct3dRMMesh, getGroupColor, GetGroupColor, d3dcolor, d3drmGroupIndex);
  37. GET_DIRECT1_R(_dxj_Direct3dRMMesh, getGroupMapping, GetGroupMapping, d3drmMappingFlags, d3drmGroupIndex);
  38. GET_DIRECT1_R(_dxj_Direct3dRMMesh, getGroupQuality, GetGroupQuality, d3drmRenderQuality, d3drmGroupIndex);
  39. /////////////////////////////////////////////////////////////////////////////
  40. STDMETHODIMP C_dxj_Direct3dRMMeshObject::setVertex( d3drmGroupIndex id, long idx, D3dRMVertex *value)
  41. {
  42. return m__dxj_Direct3dRMMesh->SetVertices((DWORD)id, (DWORD)idx, 1, (struct _D3DRMVERTEX *)value);
  43. }
  44. /////////////////////////////////////////////////////////////////////////////
  45. STDMETHODIMP C_dxj_Direct3dRMMeshObject::setVertices( d3drmGroupIndex id, long idx, long cnt, SAFEARRAY **ppsa)
  46. {
  47. HRESULT hr;
  48. //
  49. // Go through and reformat all the float color values back
  50. // to long, so the array of floats now looks like an array
  51. // D3DRMVERTEXES
  52. //
  53. if (!ISSAFEARRAY1D(ppsa,(DWORD)cnt))
  54. return E_INVALIDARG;
  55. D3DRMVERTEX *values= (D3DRMVERTEX*)((SAFEARRAY*)*ppsa)->pvData;
  56. __try{
  57. hr=m__dxj_Direct3dRMMesh->SetVertices((DWORD)id, (DWORD)idx,(DWORD) cnt, (struct _D3DRMVERTEX *)values);
  58. }
  59. __except(1,1){
  60. return E_INVALIDARG;
  61. }
  62. return hr;
  63. }
  64. STDMETHODIMP C_dxj_Direct3dRMMeshObject::setVerticesJava( d3drmGroupIndex id, long idx, long cnt, float *vertData)
  65. {
  66. HRESULT hr;
  67. __try {
  68. hr=m__dxj_Direct3dRMMesh->SetVertices((DWORD)id, (DWORD)idx,(DWORD) cnt, (struct _D3DRMVERTEX *)vertData);
  69. }
  70. __except(1,1){
  71. return E_INVALIDARG;
  72. }
  73. return hr;
  74. }
  75. /////////////////////////////////////////////////////////////////////////////
  76. STDMETHODIMP C_dxj_Direct3dRMMeshObject::getGroupDataSize( d3drmGroupIndex id, long *cnt)
  77. {
  78. unsigned int *cnt1=0, *cnt2=0, *cnt3=0;
  79. return m__dxj_Direct3dRMMesh->GetGroup( (D3DRMGROUPINDEX)id, cnt1, cnt2,
  80. cnt3, (DWORD*)cnt, (unsigned int *)NULL);
  81. }
  82. /////////////////////////////////////////////////////////////////////////////
  83. STDMETHODIMP C_dxj_Direct3dRMMeshObject::getVertexCount( d3drmGroupIndex id, long *cnt)
  84. {
  85. unsigned int *cnt1=0, *cnt2=0;
  86. DWORD *cnt3=0;
  87. return m__dxj_Direct3dRMMesh->GetGroup( (D3DRMGROUPINDEX)id, (unsigned int*)cnt, (unsigned int*) cnt1,
  88. cnt2, cnt3, (unsigned int *)NULL);
  89. }
  90. /////////////////////////////////////////////////////////////////////////////
  91. STDMETHODIMP C_dxj_Direct3dRMMeshObject::getVertices(d3drmGroupIndex id, long idx, long count, SAFEARRAY **ppsa )
  92. {
  93. HRESULT hr;
  94. if (!ISSAFEARRAY1D(ppsa,(DWORD)count)) return E_INVALIDARG;
  95. D3DRMVERTEX *v=(D3DRMVERTEX *)((SAFEARRAY*)*ppsa)->pvData;
  96. __try {
  97. hr= m__dxj_Direct3dRMMesh->GetVertices((DWORD)id,(DWORD) idx, (DWORD)count, (struct _D3DRMVERTEX *)v);
  98. }
  99. __except(1,1){
  100. return E_INVALIDARG;
  101. }
  102. return hr;
  103. }
  104. /////////////////////////////////////////////////////////////////////////////
  105. STDMETHODIMP C_dxj_Direct3dRMMeshObject::getVerticesJava(d3drmGroupIndex id, long idx, long count, float *vertData)
  106. {
  107. HRESULT hr;
  108. __try {
  109. hr= m__dxj_Direct3dRMMesh->GetVertices((DWORD)id,(DWORD) idx, (DWORD)count, (struct _D3DRMVERTEX *)vertData);
  110. }
  111. __except(1,1){
  112. return E_INVALIDARG;
  113. }
  114. return hr;
  115. }
  116. /////////////////////////////////////////////////////////////////////////////
  117. STDMETHODIMP C_dxj_Direct3dRMMeshObject::getVertex(d3drmGroupIndex id, long idx, D3dRMVertex *v )
  118. {
  119. DWORD count = 1;
  120. HRESULT hr;
  121. hr= m__dxj_Direct3dRMMesh->GetVertices((DWORD)id,(DWORD) idx, (DWORD)count, (struct _D3DRMVERTEX *)v);
  122. return hr;
  123. }
  124. /////////////////////////////////////////////////////////////////////////////
  125. STDMETHODIMP C_dxj_Direct3dRMMeshObject::getGroupTexture( d3drmGroupIndex id, I_dxj_Direct3dRMTexture3 **tex){
  126. HRESULT hr;
  127. IDirect3DRMTexture *realtex1=NULL;
  128. IDirect3DRMTexture3 *realtex3=NULL;
  129. *tex=NULL;
  130. hr=m__dxj_Direct3dRMMesh->GetGroupTexture((D3DRMGROUPINDEX)id,&realtex1);
  131. if FAILED(hr) return hr;
  132. if (!realtex1) return hr;
  133. hr=realtex1->QueryInterface(IID_IDirect3DRMTexture3,(void**)&realtex3);
  134. if FAILED(hr) return hr;
  135. INTERNAL_CREATE(_dxj_Direct3dRMTexture3,(IDirect3DRMTexture3*)realtex3,tex);
  136. realtex1->Release();
  137. return hr;
  138. }
  139. STDMETHODIMP C_dxj_Direct3dRMMeshObject::setGroupTexture( d3drmGroupIndex id, I_dxj_Direct3dRMTexture3 *tex){
  140. HRESULT hr;
  141. IDirect3DRMTexture3 *realtex=NULL;
  142. IDirect3DRMTexture *realtex1=NULL;
  143. if (tex){
  144. tex->InternalGetObject((IUnknown**)&realtex); //does not addref
  145. hr=realtex->QueryInterface(IID_IDirect3DRMTexture,(void**)&realtex1);
  146. if FAILED(hr) return hr;
  147. }
  148. hr=m__dxj_Direct3dRMMesh->SetGroupTexture((D3DRMGROUPINDEX)id,realtex1);
  149. if (realtex1)
  150. realtex1->Release();
  151. return hr;
  152. }
  153. /////////////////////////////////////////////////////////////////////////////
  154. STDMETHODIMP C_dxj_Direct3dRMMeshObject::getSizes( d3drmGroupIndex id, long *cnt1,long *cnt2, long *cnt3, long *cnt4)
  155. {
  156. //were in 32 bits so we can do this
  157. HRESULT hr= m__dxj_Direct3dRMMesh->GetGroup( (D3DRMGROUPINDEX)id, (unsigned*)cnt1, (unsigned*)cnt2,
  158. (unsigned*)cnt3, (DWORD*)cnt4, (unsigned int *)NULL);
  159. return hr;
  160. }
  161. /////////////////////////////////////////////////////////////////////////////
  162. STDMETHODIMP C_dxj_Direct3dRMMeshObject::getGroupData( d3drmGroupIndex id, SAFEARRAY **ppsa)
  163. {
  164. DWORD s;
  165. //if (!ISSAFEARRAY1D(ppsa,(DWORD)size)) return E_INVALIDARG;
  166. if (!ppsa) return E_INVALIDARG;
  167. s= (*ppsa)->rgsabound->cElements;
  168. HRESULT hr;
  169. __try {
  170. hr= m__dxj_Direct3dRMMesh->GetGroup( (D3DRMGROUPINDEX)id, NULL, NULL, NULL,
  171. (DWORD*)&s, (unsigned*)((SAFEARRAY*)*ppsa)->pvData);
  172. }
  173. __except(1,1){
  174. return E_FAIL;
  175. }
  176. return hr;
  177. }
  178. /////////////////////////////////////////////////////////////////////////////
  179. STDMETHODIMP C_dxj_Direct3dRMMeshObject::getGroupDataJava( d3drmGroupIndex id, long size, long *pFaceData)
  180. {
  181. DWORD s=size;
  182. HRESULT hr;
  183. __try {
  184. hr= m__dxj_Direct3dRMMesh->GetGroup( (D3DRMGROUPINDEX)id, NULL, NULL, NULL,
  185. (DWORD*)&s, (unsigned*)pFaceData);
  186. }
  187. __except(1,1){
  188. return E_FAIL;
  189. }
  190. return hr;
  191. }
  192. /////////////////////////////////////////////////////////////////////////////
  193. STDMETHODIMP C_dxj_Direct3dRMMeshObject::addGroup(
  194. /* [in] */ long vcnt,
  195. /* [in] */ long fcnt,
  196. /* [in] */ long vPerFace,
  197. /* [in] */ SAFEARRAY __RPC_FAR * __RPC_FAR *ppsa,
  198. /* [retval][out] */ d3drmGroupIndex __RPC_FAR *pretId)
  199. {
  200. HRESULT hr;
  201. __try {
  202. hr= m__dxj_Direct3dRMMesh->AddGroup(
  203. (unsigned)vcnt,(unsigned)fcnt,(unsigned)vPerFace, (unsigned*)((SAFEARRAY*)*ppsa)->pvData, pretId);
  204. }
  205. __except(1,1){
  206. return E_FAIL;
  207. }
  208. return hr;
  209. }
  210. STDMETHODIMP C_dxj_Direct3dRMMeshObject::addGroupJava(
  211. /* [in] */ long vcnt,
  212. /* [in] */ long fcnt,
  213. /* [in] */ long vPerFace,
  214. /* [in] */ long *pFaceData,
  215. /* [retval][out] */ d3drmGroupIndex __RPC_FAR *pretId)
  216. {
  217. HRESULT hr;
  218. __try {
  219. hr= m__dxj_Direct3dRMMesh->AddGroup(
  220. (unsigned)vcnt,(unsigned)fcnt,(unsigned)vPerFace, (unsigned*)pFaceData, pretId);
  221. }
  222. __except(1,1){
  223. return E_INVALIDARG;
  224. }
  225. return hr;
  226. }
  227. /////////////////////////////////////////////////////////////////////////////
  228. STDMETHODIMP C_dxj_Direct3dRMMeshObject::getGroupMaterial( d3drmGroupIndex id, I_dxj_Direct3dRMMaterial2 **mat){
  229. HRESULT hr;
  230. IDirect3DRMMaterial *realmat1=NULL;
  231. IDirect3DRMMaterial2 *realmat2=NULL;
  232. *mat=NULL;
  233. hr=m__dxj_Direct3dRMMesh->GetGroupMaterial((D3DRMGROUPINDEX)id,&realmat1);
  234. if FAILED(hr) return hr;
  235. if (!realmat1) return S_OK;
  236. hr=realmat1->QueryInterface(IID_IDirect3DRMMaterial2,(void**)&realmat2);
  237. if FAILED(hr) return hr;
  238. INTERNAL_CREATE(_dxj_Direct3dRMMaterial2,realmat2,mat);
  239. realmat1->Release();
  240. return hr;
  241. }
  242. STDMETHODIMP C_dxj_Direct3dRMMeshObject::setGroupMaterial( d3drmGroupIndex id, I_dxj_Direct3dRMMaterial2 *mat){
  243. HRESULT hr;
  244. IDirect3DRMMaterial2 *realmat=NULL;
  245. IDirect3DRMMaterial *realmat1=NULL;
  246. if (mat){
  247. mat->InternalGetObject((IUnknown**)&realmat); //does not addref
  248. hr=realmat->QueryInterface(IID_IDirect3DRMMaterial,(void**)&realmat1);
  249. if FAILED(hr) return hr;
  250. }
  251. hr=m__dxj_Direct3dRMMesh->SetGroupMaterial((D3DRMGROUPINDEX)id,realmat1);
  252. if (realmat1) realmat1->Release();
  253. return hr;
  254. }