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.

152 lines
4.3 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: d3drmanimationset2obj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // d3drmAnimationSet2Obj.cpp : Implementation of CDirectApp and DLL registration.
  11. #include "stdafx.h"
  12. #include "Direct.h"
  13. #include "dms.h"
  14. #include "d3drmAnimationSet2Obj.h"
  15. #include "d3drmAnimation2Obj.h"
  16. #include "d3drmAnimationArrayObj.h"
  17. extern void *g_dxj_Direct3dRMAnimationArray;
  18. extern HRESULT BSTRtoGUID(LPGUID,BSTR);
  19. CONSTRUCTOR( _dxj_Direct3dRMAnimationSet2,{});
  20. DESTRUCTOR( _dxj_Direct3dRMAnimationSet2,{});
  21. GETSET_OBJECT(_dxj_Direct3dRMAnimationSet2);
  22. CLONE_R(_dxj_Direct3dRMAnimationSet2,Direct3DRMAnimationSet2);
  23. SETNAME_R(_dxj_Direct3dRMAnimationSet2);
  24. GETNAME_R(_dxj_Direct3dRMAnimationSet2);
  25. GETCLASSNAME_R(_dxj_Direct3dRMAnimationSet2);
  26. ADDDESTROYCALLBACK_R(_dxj_Direct3dRMAnimationSet2);
  27. DELETEDESTROYCALLBACK_R(_dxj_Direct3dRMAnimationSet2);
  28. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMAnimationSet2, setAppData, SetAppData, long,(DWORD));
  29. PASS_THROUGH1_R( _dxj_Direct3dRMAnimationSet2, setTime, SetTime, d3dvalue);
  30. GET_DIRECT_R(_dxj_Direct3dRMAnimationSet2, getAppData, GetAppData, long);
  31. DO_GETOBJECT_ANDUSEIT_R(_dxj_Direct3dRMAnimationSet2, addAnimation, AddAnimation, _dxj_Direct3dRMAnimation2);
  32. //DO_GETOBJECT_ANDUSEIT_R(_dxj_Direct3dRMAnimationSet2, deleteAnimation, DeleteAnimation, _dxj_Direct3dRMAnimation2);
  33. STDMETHODIMP C_dxj_Direct3dRMAnimationSet2Object::deleteAnimation(I_dxj_Direct3dRMAnimation2 *anim)
  34. {
  35. HRESULT hr;
  36. UINT i;
  37. if (!anim) return E_INVALIDARG;
  38. DO_GETOBJECT_NOTNULL(LPDIRECT3DRMANIMATION2,pRealAnim,anim);
  39. i=pRealAnim->AddRef();
  40. i=pRealAnim->Release();
  41. hr=m__dxj_Direct3dRMAnimationSet2->DeleteAnimation(pRealAnim);
  42. i=pRealAnim->AddRef();
  43. i=pRealAnim->Release();
  44. return hr;
  45. }
  46. /////////////////////////////////////////////////////////////////////////////
  47. //
  48. STDMETHODIMP C_dxj_Direct3dRMAnimationSet2Object::loadFromFile(BSTR filename,
  49. VARIANT id, long flags, I_dxj_Direct3dRMLoadTextureCallback3 *callme,
  50. IUnknown *useMe, I_dxj_Direct3dRMFrame3 *frame)
  51. {
  52. D3DRMLOADTEXTURE3CALLBACK d3dtcb = NULL;
  53. LPVOID pArgs = NULL;
  54. TextureCallback3 *tcb = NULL;
  55. HRESULT hr;
  56. if( callme ) {
  57. tcb = (TextureCallback3*)AddCallbackLink((void**)&TextureCallbacks3,
  58. (I_dxj_Direct3dRMCallback*)callme, (void*)useMe);
  59. if( tcb ) {
  60. d3dtcb = myLoadTextureCallback3;
  61. pArgs = (void *)tcb;
  62. } else {
  63. DPF(1,"Callback object creation failed!\r\n");
  64. return E_FAIL;
  65. }
  66. }
  67. USES_CONVERSION;
  68. LPCTSTR pszName = W2T(filename); // Now convert to ANSI
  69. DO_GETOBJECT_NOTNULL( LPDIRECT3DRMFRAME3, f, frame);
  70. void *args=NULL;
  71. DWORD pos=0;
  72. GUID loadGuid;
  73. VARIANT var;
  74. VariantInit(&var);
  75. if ((flags & D3DRMLOAD_BYNAME)||(D3DRMLOAD_FROMURL & flags)) {
  76. hr=VariantChangeType(&var,&id,0,VT_BSTR);
  77. if FAILED(hr) return E_INVALIDARG;
  78. args=(void*)W2T(V_BSTR(&id));
  79. }
  80. else if(flags & D3DRMLOAD_BYPOSITION){
  81. hr=VariantChangeType(&var,&id,0,VT_I4);
  82. if FAILED(hr) return E_INVALIDARG;
  83. pos=V_I4(&id);
  84. args=&pos;
  85. }
  86. else if(flags & D3DRMLOAD_BYGUID){
  87. hr=VariantChangeType(&var,&id,0,VT_BSTR);
  88. if FAILED(hr) return E_INVALIDARG;
  89. hr=BSTRtoGUID(&loadGuid,V_BSTR(&id));
  90. if FAILED(hr) return E_INVALIDARG;
  91. args=&loadGuid;
  92. }
  93. VariantClear(&var);
  94. if (flags &D3DRMLOAD_FROMRESOURCE){
  95. D3DRMLOADRESOURCE res;
  96. ZeroMemory(&res,sizeof(D3DRMLOADRESOURCE));
  97. res.lpName=pszName;
  98. res.lpType="XFILE";
  99. hr = m__dxj_Direct3dRMAnimationSet2->Load((void *)&res, (DWORD*)args, (DWORD)flags,
  100. d3dtcb, pArgs, (IDirect3DRMFrame3*)f);
  101. }
  102. else {
  103. hr = m__dxj_Direct3dRMAnimationSet2->Load((void *)pszName, (DWORD*)args, (DWORD)flags,
  104. d3dtcb, pArgs, (IDirect3DRMFrame3*)f);
  105. }
  106. //We are done with the callback so remove the linked entry
  107. if (tcb)
  108. UndoCallbackLink( (GeneralCallback*)tcb,
  109. (GeneralCallback**)&TextureCallbacks3 );
  110. return hr;
  111. }
  112. STDMETHODIMP C_dxj_Direct3dRMAnimationSet2Object::getAnimations(I_dxj_Direct3dRMAnimationArray **ppret)
  113. {
  114. HRESULT hr;
  115. LPDIRECT3DRMANIMATIONARRAY lpArray=NULL;
  116. hr=m__dxj_Direct3dRMAnimationSet2->GetAnimations(&lpArray);
  117. if FAILED(hr) return hr;
  118. INTERNAL_CREATE(_dxj_Direct3dRMAnimationArray, lpArray, ppret);
  119. return hr;
  120. }