Source code of Windows XP (NT5)
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.

175 lines
5.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: d3drmprogressivemeshobj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // d3dRMProgressiveMeshObj.cpp : Implementation of CDirectApp and DLL registration.
  11. #include "stdafx.h"
  12. #include "Direct.h"
  13. #include "dms.h"
  14. #include "d3dRMProgressiveMeshObj.h"
  15. #include "d3dRMMeshObj.h"
  16. #include "d3drmTexture3Obj.h"
  17. extern HRESULT BSTRtoGUID(LPGUID,BSTR);
  18. CONSTRUCTOR( _dxj_Direct3dRMProgressiveMesh, {});
  19. DESTRUCTOR(_dxj_Direct3dRMProgressiveMesh, {});
  20. GETSET_OBJECT(_dxj_Direct3dRMProgressiveMesh);
  21. CLONE_R(_dxj_Direct3dRMProgressiveMesh,Direct3DRMProgressiveMesh);
  22. GETNAME_R(_dxj_Direct3dRMProgressiveMesh);
  23. SETNAME_R(_dxj_Direct3dRMProgressiveMesh);
  24. GETCLASSNAME_R(_dxj_Direct3dRMProgressiveMesh);
  25. ADDDESTROYCALLBACK_R(_dxj_Direct3dRMProgressiveMesh);
  26. DELETEDESTROYCALLBACK_R(_dxj_Direct3dRMProgressiveMesh);
  27. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMProgressiveMesh, setAppData, SetAppData, long,(DWORD));
  28. GET_DIRECT_R(_dxj_Direct3dRMProgressiveMesh, getAppData, GetAppData, long);
  29. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMProgressiveMesh, getBox,GetBox, D3dRMBox*, (_D3DRMBOX*));
  30. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMProgressiveMesh, getFaceDetail,GetFaceDetail, long*, (DWORD*));
  31. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMProgressiveMesh, getVertexDetail,GetVertexDetail, long*, (DWORD*));
  32. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMProgressiveMesh, setFaceDetail,SetFaceDetail, long, (DWORD));
  33. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMProgressiveMesh, setVertexDetail,SetVertexDetail, long, (DWORD));
  34. PASS_THROUGH_CAST_2_R(_dxj_Direct3dRMProgressiveMesh, getFaceDetailRange,GetFaceDetailRange, long*, (DWORD*),long*, (DWORD*));
  35. PASS_THROUGH_CAST_2_R(_dxj_Direct3dRMProgressiveMesh, getVertexDetailRange,GetVertexDetailRange, long*, (DWORD*),long*, (DWORD*));
  36. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMProgressiveMesh, getQuality, GetQuality, d3drmRenderQuality*, (D3DRMRENDERQUALITY*));
  37. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMProgressiveMesh, setQuality, SetQuality, d3drmRenderQuality, (D3DRMRENDERQUALITY));
  38. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMProgressiveMesh, setDetail,SetDetail, float, (float));
  39. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMProgressiveMesh, getDetail,GetDetail, float*, (float*));
  40. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMProgressiveMesh, setMinRenderDetail,SetMinRenderDetail, float, (float));
  41. //PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMProgressiveMesh, abort,Abort, long, (DWORD));
  42. //PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMProgressiveMesh, getLoadStatus,GetLoadStatus, long*, (D3DRMPMESHLOADSTATUS*));
  43. PASS_THROUGH_CAST_3_R(_dxj_Direct3dRMProgressiveMesh, registerEvents,RegisterEvents, long,(void*),long,(DWORD),long,(DWORD));
  44. STDMETHODIMP C_dxj_Direct3dRMProgressiveMeshObject::abort( ){
  45. HRESULT hr=m__dxj_Direct3dRMProgressiveMesh->Abort(0);
  46. return hr;
  47. }
  48. STDMETHODIMP C_dxj_Direct3dRMProgressiveMeshObject::getLoadStatus( D3DRMPMESHLOADSTATUS_CDESC *status){
  49. D3DRMPMESHLOADSTATUS *pstatus=(D3DRMPMESHLOADSTATUS*)status;
  50. HRESULT hr;
  51. pstatus->dwSize=sizeof(D3DRMPMESHLOADSTATUS);
  52. hr=m__dxj_Direct3dRMProgressiveMesh->GetLoadStatus(pstatus);
  53. return hr;
  54. }
  55. STDMETHODIMP C_dxj_Direct3dRMProgressiveMeshObject::loadFromFile(
  56. /* [in] */ BSTR filename,
  57. /* [in] */ VARIANT id,
  58. /* [in] */ long flags,
  59. /* [in] */ I_dxj_Direct3dRMLoadTextureCallback3 __RPC_FAR *callme,
  60. /* [in] */ IUnknown __RPC_FAR *useMe)
  61. {
  62. D3DRMLOADTEXTURECALLBACK d3dtcb = NULL;
  63. LPVOID pArgs = NULL;
  64. TextureCallback *tcb = NULL;
  65. HRESULT hr;
  66. if( callme )
  67. {
  68. tcb = new TextureCallback;
  69. if( tcb )
  70. {
  71. tcb->c = callme;
  72. tcb->pUser = useMe;
  73. tcb->next = TextureCallbacks;
  74. tcb->prev = (TextureCallback*)NULL;
  75. TextureCallbacks = tcb;
  76. d3dtcb = myLoadTextureCallback;
  77. pArgs = (void *)tcb;
  78. }
  79. else
  80. {
  81. DPF(1,"Callback object creation failed!\r\n");
  82. return E_FAIL;
  83. }
  84. }
  85. USES_CONVERSION;
  86. LPCTSTR pszName = W2T(filename);
  87. void *args=NULL;
  88. DWORD pos=0;
  89. GUID loadGuid;
  90. VARIANT var;
  91. VariantInit(&var);
  92. if ((flags & D3DRMLOAD_BYNAME)||(D3DRMLOAD_FROMURL & flags)) {
  93. hr=VariantChangeType(&var,&id,0,VT_BSTR);
  94. if FAILED(hr) return E_INVALIDARG;
  95. args=(void*)W2T(V_BSTR(&id));
  96. }
  97. else if(flags & D3DRMLOAD_BYPOSITION){
  98. hr=VariantChangeType(&var,&id,0,VT_I4);
  99. if FAILED(hr) return E_INVALIDARG;
  100. pos=V_I4(&id);
  101. args=&pos;
  102. }
  103. else if(flags & D3DRMLOAD_BYGUID){
  104. hr=VariantChangeType(&var,&id,0,VT_BSTR);
  105. if FAILED(hr) return E_INVALIDARG;
  106. hr=BSTRtoGUID(&loadGuid,V_BSTR(&id));
  107. if FAILED(hr) return E_INVALIDARG;
  108. args=&loadGuid;
  109. }
  110. VariantClear(&var);
  111. hr = m__dxj_Direct3dRMProgressiveMesh->Load((void *)pszName,(DWORD*) args,(DWORD) flags, d3dtcb, pArgs);
  112. // Remove ourselves in a thread-safe manner. Need unlock here
  113. if (tcb)
  114. UndoCallbackLink((GeneralCallback*)tcb,
  115. (GeneralCallback**)&TextureCallbacks);
  116. return hr;
  117. }
  118. STDMETHODIMP C_dxj_Direct3dRMProgressiveMeshObject::createMesh(
  119. /* [retval][out] */ I_dxj_Direct3dRMMesh __RPC_FAR *__RPC_FAR *mesh)
  120. {
  121. HRESULT hr;
  122. LPDIRECT3DRMMESH pMesh=NULL;
  123. hr = m__dxj_Direct3dRMProgressiveMesh->CreateMesh(&pMesh);
  124. if FAILED(hr) return hr;
  125. INTERNAL_CREATE(_dxj_Direct3dRMMesh,pMesh,mesh);
  126. return hr;
  127. }
  128. STDMETHODIMP C_dxj_Direct3dRMProgressiveMeshObject::duplicate(
  129. /* [retval][out] */ I_dxj_Direct3dRMProgressiveMesh __RPC_FAR *__RPC_FAR *mesh)
  130. {
  131. HRESULT hr;
  132. LPDIRECT3DRMPROGRESSIVEMESH pMesh=NULL;
  133. hr = m__dxj_Direct3dRMProgressiveMesh->Duplicate(&pMesh);
  134. if FAILED(hr) return hr;
  135. INTERNAL_CREATE(_dxj_Direct3dRMProgressiveMesh,pMesh,mesh);
  136. return hr;
  137. }