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.

176 lines
6.0 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 = NULL;
  87. __try { pszName = W2T(filename); /* Now convert to ANSI */ } __except(EXCEPTION_EXECUTE_HANDLER) { return E_FAIL; }
  88. void *args=NULL;
  89. DWORD pos=0;
  90. GUID loadGuid;
  91. VARIANT var;
  92. VariantInit(&var);
  93. if ((flags & D3DRMLOAD_BYNAME)||(D3DRMLOAD_FROMURL & flags)) {
  94. hr=VariantChangeType(&var,&id,0,VT_BSTR);
  95. if FAILED(hr) return E_INVALIDARG;
  96. __try { args=(void*)W2T(V_BSTR(&id)); } __except(EXCEPTION_EXECUTE_HANDLER) { return E_FAIL; }
  97. }
  98. else if(flags & D3DRMLOAD_BYPOSITION){
  99. hr=VariantChangeType(&var,&id,0,VT_I4);
  100. if FAILED(hr) return E_INVALIDARG;
  101. pos=V_I4(&id);
  102. args=&pos;
  103. }
  104. else if(flags & D3DRMLOAD_BYGUID){
  105. hr=VariantChangeType(&var,&id,0,VT_BSTR);
  106. if FAILED(hr) return E_INVALIDARG;
  107. hr=BSTRtoGUID(&loadGuid,V_BSTR(&id));
  108. if FAILED(hr) return E_INVALIDARG;
  109. args=&loadGuid;
  110. }
  111. VariantClear(&var);
  112. hr = m__dxj_Direct3dRMProgressiveMesh->Load((void *)pszName,(DWORD*) args,(DWORD) flags, d3dtcb, pArgs);
  113. // Remove ourselves in a thread-safe manner. Need unlock here
  114. if (tcb)
  115. UndoCallbackLink((GeneralCallback*)tcb,
  116. (GeneralCallback**)&TextureCallbacks);
  117. return hr;
  118. }
  119. STDMETHODIMP C_dxj_Direct3dRMProgressiveMeshObject::createMesh(
  120. /* [retval][out] */ I_dxj_Direct3dRMMesh __RPC_FAR *__RPC_FAR *mesh)
  121. {
  122. HRESULT hr;
  123. LPDIRECT3DRMMESH pMesh=NULL;
  124. hr = m__dxj_Direct3dRMProgressiveMesh->CreateMesh(&pMesh);
  125. if FAILED(hr) return hr;
  126. INTERNAL_CREATE(_dxj_Direct3dRMMesh,pMesh,mesh);
  127. return hr;
  128. }
  129. STDMETHODIMP C_dxj_Direct3dRMProgressiveMeshObject::duplicate(
  130. /* [retval][out] */ I_dxj_Direct3dRMProgressiveMesh __RPC_FAR *__RPC_FAR *mesh)
  131. {
  132. HRESULT hr;
  133. LPDIRECT3DRMPROGRESSIVEMESH pMesh=NULL;
  134. hr = m__dxj_Direct3dRMProgressiveMesh->Duplicate(&pMesh);
  135. if FAILED(hr) return hr;
  136. INTERNAL_CREATE(_dxj_Direct3dRMProgressiveMesh,pMesh,mesh);
  137. return hr;
  138. }