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.

516 lines
16 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: d3drmmeshbuilder3obj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // d3drmMeshBuilderObj.cpp : Implementation of CDirectApp and DLL registration.
  11. #include "stdafx.h"
  12. #include "Direct.h"
  13. #include "dms.h"
  14. #include "d3drmMeshBuilder3Obj.h"
  15. #include "d3drmMaterial2Obj.h"
  16. #include "d3drmMeshObj.h"
  17. #include "d3drmFrame3Obj.h"
  18. #include "d3drmFace2Obj.h"
  19. #include "d3drmFaceArrayObj.h"
  20. #include "d3drmTexture3Obj.h"
  21. #include "d3drmVisualObj.h"
  22. extern HRESULT BSTRtoGUID(LPGUID,BSTR);
  23. CONSTRUCTOR(_dxj_Direct3dRMMeshBuilder3, {});
  24. DESTRUCTOR(_dxj_Direct3dRMMeshBuilder3, {});
  25. GETSET_OBJECT(_dxj_Direct3dRMMeshBuilder3);
  26. CLONE_R(_dxj_Direct3dRMMeshBuilder3,Direct3DRMMeshBuilder3);
  27. GETNAME_R(_dxj_Direct3dRMMeshBuilder3);
  28. SETNAME_R(_dxj_Direct3dRMMeshBuilder3);
  29. GETCLASSNAME_R(_dxj_Direct3dRMMeshBuilder3);
  30. ADDDESTROYCALLBACK_R(_dxj_Direct3dRMMeshBuilder3);
  31. DELETEDESTROYCALLBACK_R(_dxj_Direct3dRMMeshBuilder3);
  32. //CLONETO_RX(_dxj_Direct3dRMMeshBuilder3, MeshBuilder3, IID_IDirect3DRMMeshBuilder3);
  33. PASS_THROUGH_CAST_2_R(_dxj_Direct3dRMMeshBuilder3, generateNormals, GenerateNormals, float,(float),long,(DWORD));
  34. PASS_THROUGH1_R(_dxj_Direct3dRMMeshBuilder3, setQuality, SetQuality, d3drmRenderQuality)
  35. PASS_THROUGH1_R(_dxj_Direct3dRMMeshBuilder3, setColor, SetColor, d3dcolor)
  36. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMMeshBuilder3, setAppData, SetAppData, long,(DWORD));
  37. PASS_THROUGH1_R(_dxj_Direct3dRMMeshBuilder3, setPerspective, SetPerspective, long); //BOOL
  38. PASS_THROUGH_CAST_2_R(_dxj_Direct3dRMMeshBuilder3, setVertexColor, SetVertexColor, long,(DWORD),d3dcolor,(DWORD));
  39. PASS_THROUGH3_R(_dxj_Direct3dRMMeshBuilder3, setColorRGB,SetColorRGB,d3dvalue,d3dvalue,d3dvalue)
  40. PASS_THROUGH3_R(_dxj_Direct3dRMMeshBuilder3, scaleMesh, Scale, d3dvalue, d3dvalue, d3dvalue);
  41. PASS_THROUGH3_R(_dxj_Direct3dRMMeshBuilder3, translate, Translate, d3dvalue, d3dvalue, d3dvalue);
  42. PASS_THROUGH2_R(_dxj_Direct3dRMMeshBuilder3, setTextureTopology, SetTextureTopology, long, long); //BOOL
  43. PASS_THROUGH_CAST_3_R(_dxj_Direct3dRMMeshBuilder3, setTextureCoordinates, SetTextureCoordinates, long,(DWORD), d3dvalue,(float), d3dvalue,(float));
  44. PASS_THROUGH_CAST_3_R(_dxj_Direct3dRMMeshBuilder3, getTextureCoordinates, GetTextureCoordinates, long,(DWORD), d3dvalue*,(float*), d3dvalue*,(float*));
  45. PASS_THROUGH_CAST_4_R(_dxj_Direct3dRMMeshBuilder3, setVertexColorRGB, SetVertexColorRGB, long,(DWORD), d3dvalue,(float), d3dvalue,(float), d3dvalue,(float));
  46. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMMeshBuilder3, setColorSource, SetColorSource, d3drmColorSource, (enum _D3DRMCOLORSOURCE));
  47. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMMeshBuilder3, getBox, GetBox, D3dRMBox *,(D3DRMBOX *))
  48. GET_DIRECT_R(_dxj_Direct3dRMMeshBuilder3, getAppData, GetAppData, long);
  49. GET_DIRECT_R(_dxj_Direct3dRMMeshBuilder3, getQuality, GetQuality, d3drmRenderQuality);
  50. GET_DIRECT_R(_dxj_Direct3dRMMeshBuilder3, getPerspective, GetPerspective, long);
  51. GET_DIRECT_R(_dxj_Direct3dRMMeshBuilder3, getVertexCount, GetVertexCount, int);
  52. GET_DIRECT_R(_dxj_Direct3dRMMeshBuilder3, getColorSource, GetColorSource, d3drmColorSource);
  53. GET_DIRECT1_R(_dxj_Direct3dRMMeshBuilder3, getVertexColor, GetVertexColor, d3dcolor, long);
  54. PASS_THROUGH_CAST_4_R(_dxj_Direct3dRMMeshBuilder3, setVertex, SetVertex, long,(DWORD), d3dvalue,(float), d3dvalue,(float), d3dvalue,(float));
  55. PASS_THROUGH_CAST_4_R(_dxj_Direct3dRMMeshBuilder3, setNormal, SetNormal, long,(DWORD), d3dvalue,(float), d3dvalue,(float), d3dvalue,(float));
  56. GET_DIRECT_R(_dxj_Direct3dRMMeshBuilder3, getFaceCount, GetFaceCount, int );
  57. DO_GETOBJECT_ANDUSEIT_R(_dxj_Direct3dRMMeshBuilder3, addMesh, AddMesh, _dxj_Direct3dRMMesh);
  58. DO_GETOBJECT_ANDUSEIT_R(_dxj_Direct3dRMMeshBuilder3, addFace, AddFace, _dxj_Direct3dRMFace2);
  59. DO_GETOBJECT_ANDUSEIT_R(_dxj_Direct3dRMMeshBuilder3, setMaterial, SetMaterial, _dxj_Direct3dRMMaterial2)
  60. RETURN_NEW_ITEM_R(_dxj_Direct3dRMMeshBuilder3, getFaces, GetFaces, _dxj_Direct3dRMFaceArray);
  61. RETURN_NEW_ITEM_R(_dxj_Direct3dRMMeshBuilder3, createMesh,CreateMesh,_dxj_Direct3dRMMesh)
  62. RETURN_NEW_ITEM_R(_dxj_Direct3dRMMeshBuilder3, createFace, CreateFace, _dxj_Direct3dRMFace2);
  63. /////////////////////////////////////////////////////////////////////////////
  64. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::addVertex(d3dvalue x, d3dvalue y, d3dvalue z, int *index)
  65. {
  66. *index = m__dxj_Direct3dRMMeshBuilder3->AddVertex(x,y,z);
  67. return S_OK;
  68. }
  69. /////////////////////////////////////////////////////////////////////////////
  70. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::addNormal(d3dvalue x, d3dvalue y, d3dvalue z, int *index)
  71. {
  72. *index = m__dxj_Direct3dRMMeshBuilder3->AddNormal(x,y,z);
  73. return S_OK;
  74. }
  75. /////////////////////////////////////////////////////////////////////////////
  76. //FOR JAVA
  77. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::addFacesJava(long vcount, float *vertices,
  78. long ncount, float *normals, long *data, I_dxj_Direct3dRMFaceArray **array)
  79. {
  80. HRESULT hr;
  81. LPDIRECT3DRMFACEARRAY lpArray;
  82. __try{
  83. hr = m__dxj_Direct3dRMMeshBuilder3->AddFaces((DWORD)vcount/3, (struct _D3DVECTOR *)vertices, ncount/3, (struct _D3DVECTOR *)normals, (unsigned long *)data, &lpArray);
  84. }
  85. __except(1,1){
  86. return E_INVALIDARG;
  87. }
  88. INTERNAL_CREATE(_dxj_Direct3dRMFaceArray, lpArray, array);
  89. return hr;
  90. }
  91. /////////////////////////////////////////////////////////////////////////////
  92. //STDMETHOD(Save)(BSTR fname, d3drmXofFormat format, d3dSaveOptions save);
  93. //
  94. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::save(BSTR Name, d3drmXofFormat ft, d3drmSaveFlags op)
  95. {
  96. USES_CONVERSION;
  97. LPCTSTR pszName = NULL;
  98. __try { pszName = W2T(Name); /* Now convert to ANSI */ } __except(EXCEPTION_EXECUTE_HANDLER) { return E_FAIL; }
  99. return m__dxj_Direct3dRMMeshBuilder3->Save(pszName, (enum _D3DRMXOFFORMAT)ft, (DWORD) op );
  100. }
  101. /////////////////////////////////////////////////////////////////////////////
  102. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::loadFromFile(BSTR filename, VARIANT id, long flags, I_dxj_Direct3dRMLoadTextureCallback3 *callme, IUnknown *useMe)
  103. {
  104. D3DRMLOADTEXTURE3CALLBACK d3dtcb = NULL;
  105. LPVOID pArgs = NULL;
  106. TextureCallback3 *tcb = NULL;
  107. HRESULT hr;
  108. if( callme )
  109. {
  110. tcb = new TextureCallback3;
  111. if( tcb )
  112. {
  113. tcb->c = callme;
  114. tcb->pUser = useMe;
  115. tcb->next = TextureCallbacks3;
  116. tcb->prev = (TextureCallback3*)NULL;
  117. TextureCallbacks3 = tcb;
  118. d3dtcb = myLoadTextureCallback3;
  119. pArgs = (void *)tcb;
  120. }
  121. else
  122. {
  123. DPF(1,"Callback object creation failed!\r\n");
  124. return E_FAIL;
  125. }
  126. }
  127. USES_CONVERSION;
  128. LPCTSTR pszName = NULL;
  129. __try { pszName = W2T(filename); /* Now convert to ANSI */ } __except(EXCEPTION_EXECUTE_HANDLER) { return E_FAIL; }
  130. void *args=NULL;
  131. DWORD pos=0;
  132. GUID loadGuid;
  133. VARIANT var;
  134. VariantInit(&var);
  135. if ((flags & D3DRMLOAD_BYNAME)||(D3DRMLOAD_FROMURL & flags)) {
  136. hr=VariantChangeType(&var,&id,0,VT_BSTR);
  137. if FAILED(hr) return E_INVALIDARG;
  138. __try { args=(void*)W2T(V_BSTR(&id)); } __except(EXCEPTION_EXECUTE_HANDLER) { return E_FAIL; }
  139. }
  140. else if(flags & D3DRMLOAD_BYPOSITION){
  141. hr=VariantChangeType(&var,&id,0,VT_I4);
  142. if FAILED(hr) return E_INVALIDARG;
  143. pos=V_I4(&id);
  144. args=&pos;
  145. }
  146. else if(flags & D3DRMLOAD_BYGUID){
  147. hr=VariantChangeType(&var,&id,0,VT_BSTR);
  148. if FAILED(hr) return E_INVALIDARG;
  149. hr=BSTRtoGUID(&loadGuid,V_BSTR(&id));
  150. if FAILED(hr) return E_INVALIDARG;
  151. args=&loadGuid;
  152. }
  153. VariantClear(&var);
  154. if (flags &D3DRMLOAD_FROMRESOURCE){
  155. D3DRMLOADRESOURCE res;
  156. ZeroMemory(&res,sizeof(D3DRMLOADRESOURCE));
  157. res.lpName=pszName;
  158. res.lpType="XFILE";
  159. hr = m__dxj_Direct3dRMMeshBuilder3->Load((void *)&res, (DWORD*)args,(DWORD) flags,d3dtcb, pArgs);
  160. }
  161. else {
  162. hr = m__dxj_Direct3dRMMeshBuilder3->Load((void *)pszName, (DWORD*)args,(DWORD) flags,d3dtcb, pArgs);
  163. }
  164. // Remove ourselves in a thread-safe manner.
  165. if (tcb)
  166. UndoCallbackLink((GeneralCallback*)tcb,
  167. (GeneralCallback**)&TextureCallbacks3);
  168. return hr;
  169. }
  170. /////////////////////////////////////////////////////////////////////////////
  171. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::getNormalCount(long *retval)
  172. {
  173. DWORD vc=0, nc=0, fsize=0;
  174. //Get facedata size only. The other tqo sizes are ignored.
  175. *retval= m__dxj_Direct3dRMMeshBuilder3->GetNormalCount();
  176. return S_OK;
  177. }
  178. /////////////////////////////////////////////////////////////////////////////
  179. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::getFaceDataSize(long *retval)
  180. {
  181. DWORD vc=0, nc=0, fsize=0;
  182. //Get facedata size only. The other tqo sizes are ignored.
  183. return m__dxj_Direct3dRMMeshBuilder3->GetGeometry(&vc, (struct _D3DVECTOR *)NULL,
  184. &nc, (struct _D3DVECTOR *)NULL, (DWORD*)retval, (DWORD*)NULL);
  185. }
  186. /////////////////////////////////////////////////////////////////////////////
  187. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::addFrame(I_dxj_Direct3dRMFrame3 *frame){
  188. DO_GETOBJECT_NOTNULL(LPDIRECT3DRMFRAME3,lpFrame,frame);
  189. return m__dxj_Direct3dRMMeshBuilder3->AddFrame(lpFrame);
  190. }
  191. /////////////////////////////////////////////////////////////////////////////
  192. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::setTexture(I_dxj_Direct3dRMTexture3 *tex){
  193. DO_GETOBJECT_NOTNULL(LPDIRECT3DRMTEXTURE3,lpTex,tex);
  194. return m__dxj_Direct3dRMMeshBuilder3->SetTexture(lpTex);
  195. }
  196. /////////////////////////////////////////////////////////////////////////////
  197. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::addMeshBuilder(I_dxj_Direct3dRMMeshBuilder3 *mb, long flags){
  198. DO_GETOBJECT_NOTNULL(LPDIRECT3DRMMESHBUILDER3,lpMb,mb);
  199. return m__dxj_Direct3dRMMeshBuilder3->AddMeshBuilder(lpMb,(DWORD)flags);
  200. }
  201. /////////////////////////////////////////////////////////////////////////////
  202. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::getGeometry( SAFEARRAY **ppv,
  203. SAFEARRAY **ppn, SAFEARRAY **ppfdata)
  204. {
  205. DWORD vc,nc,fsize;
  206. if (!ppv) return E_INVALIDARG;
  207. if (!ppn) return E_INVALIDARG;
  208. if (!ppfdata) return E_INVALIDARG;
  209. vc= (*ppv)->cbElements;
  210. nc= (*ppn)->cbElements;
  211. fsize= (*ppfdata)->cbElements;
  212. //if (!ISSAFEARRAY1D(ppv,(DWORD)vc)) return E_INVALIDARG;
  213. //if (!ISSAFEARRAY1D(ppn,(DWORD)nc)) return E_INVALIDARG;
  214. //if (!ISSAFEARRAY1D(ppfdata,(DWORD)fsize)) return E_INVALIDARG;
  215. return m__dxj_Direct3dRMMeshBuilder3->GetGeometry((DWORD*)&vc, (struct _D3DVECTOR *)((SAFEARRAY*)*ppv)->pvData, (DWORD*)&nc,
  216. (struct _D3DVECTOR *)((SAFEARRAY*)*ppn)->pvData, (unsigned long *)fsize, (unsigned long *) ((SAFEARRAY*)*ppfdata)->pvData);
  217. }
  218. /////////////////////////////////////////////////////////////////////////////
  219. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::addFaces(long vcount, SAFEARRAY **ppv,
  220. long ncount, SAFEARRAY **ppn, SAFEARRAY **ppfdata, I_dxj_Direct3dRMFaceArray **array)
  221. {
  222. HRESULT hr;
  223. LPDIRECT3DRMFACEARRAY lpArray;
  224. __try
  225. {
  226. hr = m__dxj_Direct3dRMMeshBuilder3->AddFaces(
  227. (DWORD)vcount, (struct _D3DVECTOR *)((SAFEARRAY*)*ppv)->pvData,
  228. (DWORD)ncount, (struct _D3DVECTOR *)((SAFEARRAY*)*ppn)->pvData,
  229. (unsigned long *)((SAFEARRAY*)*ppfdata)->pvData, &lpArray);
  230. }
  231. __except(1,1)
  232. {
  233. return E_INVALIDARG;
  234. }
  235. if FAILED(hr) return hr;
  236. INTERNAL_CREATE(_dxj_Direct3dRMFaceArray, lpArray, array);
  237. return hr;
  238. }
  239. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::addFacesIndexed(
  240. /* [in] */ long flags,
  241. /* [in] */ SAFEARRAY __RPC_FAR * __RPC_FAR *indexArray,
  242. /* [retval][out] */ long __RPC_FAR *newFaceIndex)
  243. {
  244. HRESULT hr;
  245. __try
  246. {
  247. hr = m__dxj_Direct3dRMMeshBuilder3->AddFacesIndexed(
  248. (DWORD)flags, (DWORD *)((SAFEARRAY*)*indexArray)->pvData,
  249. (DWORD*)newFaceIndex, NULL);
  250. }
  251. __except(1,1)
  252. {
  253. return E_INVALIDARG;
  254. }
  255. return hr;
  256. }
  257. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::addTriangles(
  258. /* [in] */ long format,
  259. /* [in] */ long vertexCount,
  260. /* [in] */ void *data)
  261. {
  262. HRESULT hr;
  263. __try
  264. {
  265. hr = m__dxj_Direct3dRMMeshBuilder3->AddTriangles(
  266. (DWORD)0, (DWORD) format, (DWORD) vertexCount,
  267. data);
  268. }
  269. __except(1,1)
  270. {
  271. return E_INVALIDARG;
  272. }
  273. return hr;
  274. }
  275. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::createSubMesh(
  276. I_dxj_Direct3dRMMeshBuilder3 **ret)
  277. {
  278. HRESULT hr;
  279. LPUNKNOWN pUnk=NULL;
  280. LPDIRECT3DRMMESHBUILDER3 pMesh3=NULL;
  281. *ret =NULL;
  282. hr = m__dxj_Direct3dRMMeshBuilder3->CreateSubMesh(&pUnk);
  283. if FAILED(hr) return hr;
  284. if (!pUnk) return E_FAIL;
  285. hr = pUnk->QueryInterface(IID_IDirect3DRMMeshBuilder3,(void**)&pMesh3);
  286. pUnk->Release();
  287. if FAILED(hr) return hr;
  288. INTERNAL_CREATE(_dxj_Direct3dRMMeshBuilder3,pMesh3,ret);
  289. return hr;
  290. }
  291. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::deleteFace( I_dxj_Direct3dRMFace2 *face)
  292. {
  293. HRESULT hr;
  294. if (!face) return E_INVALIDARG;
  295. DO_GETOBJECT_NOTNULL(LPDIRECT3DRMFACE2,pFace,face);
  296. __try {
  297. hr = m__dxj_Direct3dRMMeshBuilder3->DeleteFace(pFace);
  298. }
  299. __except(1,1){
  300. return E_FAIL;
  301. }
  302. return hr;
  303. }
  304. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::deleteNormals( long id, long count)
  305. {
  306. HRESULT hr;
  307. hr = m__dxj_Direct3dRMMeshBuilder3->DeleteNormals((DWORD)id,(DWORD)count);
  308. return hr;
  309. }
  310. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::deleteVertices(long id, long count)
  311. {
  312. HRESULT hr;
  313. __try {
  314. hr = m__dxj_Direct3dRMMeshBuilder3->DeleteVertices((DWORD)id,(DWORD) count);
  315. }
  316. __except(1,1){
  317. return E_FAIL;
  318. }
  319. return hr;
  320. }
  321. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::empty()
  322. {
  323. HRESULT hr;
  324. hr = m__dxj_Direct3dRMMeshBuilder3->Empty((DWORD)0);
  325. return hr;
  326. }
  327. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::enableMesh(long flags)
  328. {
  329. HRESULT hr;
  330. hr = m__dxj_Direct3dRMMeshBuilder3->Enable((DWORD)flags);
  331. return hr;
  332. }
  333. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::getEnable(long *flags)
  334. {
  335. HRESULT hr;
  336. hr = m__dxj_Direct3dRMMeshBuilder3->GetEnable((DWORD*)flags);
  337. return hr;
  338. }
  339. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::getFace(long index, I_dxj_Direct3dRMFace2 **face)
  340. {
  341. HRESULT hr;
  342. LPDIRECT3DRMFACE2 pFace=NULL;
  343. *face=NULL;
  344. hr = m__dxj_Direct3dRMMeshBuilder3->GetFace((DWORD)index,&pFace);
  345. if FAILED(hr) return hr;
  346. if (!pFace) return E_FAIL;
  347. INTERNAL_CREATE(_dxj_Direct3dRMFace2,pFace,face);
  348. return hr;
  349. }
  350. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::getNormal(long index, D3dVector *vec)
  351. {
  352. HRESULT hr;
  353. hr = m__dxj_Direct3dRMMeshBuilder3->GetNormal((DWORD)index,(D3DVECTOR*)vec);
  354. return hr;
  355. }
  356. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::getVertex(long index, D3dVector *vec)
  357. {
  358. HRESULT hr;
  359. hr = m__dxj_Direct3dRMMeshBuilder3->GetVertex((DWORD)index,(D3DVECTOR*)vec);
  360. return hr;
  361. }
  362. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::optimize()
  363. {
  364. HRESULT hr;
  365. hr = m__dxj_Direct3dRMMeshBuilder3->Optimize((DWORD)0);
  366. return hr;
  367. }
  368. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::deleteSubMesh(
  369. I_dxj_Direct3dRMMeshBuilder3 *mesh)
  370. {
  371. HRESULT hr;
  372. if (!mesh) return E_INVALIDARG;
  373. DO_GETOBJECT_NOTNULL(LPDIRECT3DRMMESHBUILDER3,pMesh,mesh);
  374. hr = m__dxj_Direct3dRMMeshBuilder3->DeleteSubMesh(pMesh);
  375. return hr;
  376. }
  377. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::getParentMesh(long flags,
  378. I_dxj_Direct3dRMMeshBuilder3 **mesh)
  379. {
  380. HRESULT hr;
  381. LPUNKNOWN pUnk=NULL;
  382. LPDIRECT3DRMMESHBUILDER3 pMesh=NULL;
  383. hr = m__dxj_Direct3dRMMeshBuilder3->GetParentMesh((DWORD)flags,&pUnk);
  384. if FAILED(hr) return hr;
  385. if (pUnk==NULL){
  386. *mesh=NULL;
  387. return S_OK;
  388. }
  389. hr= pUnk->QueryInterface(IID_IDirect3DRMMeshBuilder3,(void**)&pMesh);
  390. pUnk->Release();
  391. if FAILED(hr) return hr;
  392. INTERNAL_CREATE(_dxj_Direct3dRMMeshBuilder3,pMesh,mesh);
  393. return hr;
  394. }
  395. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::getSubMeshCount(long *count)
  396. {
  397. HRESULT hr;
  398. hr = m__dxj_Direct3dRMMeshBuilder3->GetSubMeshes((DWORD*)count,NULL);
  399. return hr;
  400. }
  401. STDMETHODIMP C_dxj_Direct3dRMMeshBuilder3Object::getSubMeshes(long count,SAFEARRAY **psa)
  402. {
  403. HRESULT hr;
  404. __try{
  405. hr = m__dxj_Direct3dRMMeshBuilder3->GetSubMeshes((DWORD*)&count,(IUnknown**)((SAFEARRAY*)*psa)->pvData);
  406. }
  407. __except(1,1){
  408. return E_INVALIDARG;
  409. }
  410. return hr;
  411. }