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.

175 lines
5.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: d3drmanimation2obj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // d3drmAnimationObj.cpp : Implementation of CDirectApp and DLL registration.
  11. #include "stdafx.h"
  12. #include "Direct.h"
  13. #include "dms.h"
  14. #include "d3drmAnimation2Obj.h"
  15. #include "d3drmFrame3Obj.h"
  16. CONSTRUCTOR(_dxj_Direct3dRMAnimation2, {});
  17. DESTRUCTOR(_dxj_Direct3dRMAnimation2, {});
  18. GETSET_OBJECT(_dxj_Direct3dRMAnimation2);
  19. CLONE_R(_dxj_Direct3dRMAnimation2,Direct3DRMAnimation2);
  20. SETNAME_R(_dxj_Direct3dRMAnimation2);
  21. GETNAME_R(_dxj_Direct3dRMAnimation2);
  22. GETCLASSNAME_R(_dxj_Direct3dRMAnimation2);
  23. ADDDESTROYCALLBACK_R(_dxj_Direct3dRMAnimation2);
  24. DELETEDESTROYCALLBACK_R(_dxj_Direct3dRMAnimation2);
  25. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMAnimation2, setAppData, SetAppData, long,(DWORD));
  26. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMAnimation2, setOptions, SetOptions, d3drmAnimationOptions,(DWORD));
  27. PASS_THROUGH1_R(_dxj_Direct3dRMAnimation2, deleteKey, DeleteKey, d3dvalue);
  28. PASS_THROUGH1_R(_dxj_Direct3dRMAnimation2, setTime, SetTime, d3dvalue);
  29. PASS_THROUGH4_R(_dxj_Direct3dRMAnimation2, addPositionKey, AddPositionKey, d3dvalue, d3dvalue, d3dvalue, d3dvalue);
  30. PASS_THROUGH4_R(_dxj_Direct3dRMAnimation2, addScaleKey, AddScaleKey, d3dvalue, d3dvalue, d3dvalue, d3dvalue);
  31. GET_DIRECT_R(_dxj_Direct3dRMAnimation2, getAppData, GetAppData, long);
  32. GET_DIRECT_R(_dxj_Direct3dRMAnimation2, getOptions, GetOptions, long);
  33. /////////////////////////////////////////////////////////////////////////////
  34. STDMETHODIMP C_dxj_Direct3dRMAnimation2Object::addRotateKey(D3DVALUE rvtime, D3dRMQuaternion *rqQuat)
  35. {
  36. return m__dxj_Direct3dRMAnimation2->AddRotateKey(rvtime,(_D3DRMQUATERNION*) rqQuat);
  37. }
  38. /////////////////////////////////////////////////////////////////////////////
  39. STDMETHODIMP C_dxj_Direct3dRMAnimation2Object::setFrame(I_dxj_Direct3dRMFrame3 *frame)
  40. {
  41. IDirect3DRMFrame3 *realframe=NULL;
  42. frame->InternalGetObject((IUnknown**) &realframe);
  43. return m__dxj_Direct3dRMAnimation2->SetFrame(realframe);
  44. }
  45. /////////////////////////////////////////////////////////////////////////////
  46. STDMETHODIMP C_dxj_Direct3dRMAnimation2Object::getFrame(I_dxj_Direct3dRMFrame3 **frame)
  47. {
  48. HRESULT hr;
  49. IDirect3DRMFrame3 *realframe=NULL;
  50. *frame=NULL;
  51. hr=m__dxj_Direct3dRMAnimation2->GetFrame((IDirect3DRMFrame3**)&realframe);
  52. if FAILED(hr) return hr;
  53. INTERNAL_CREATE(_dxj_Direct3dRMFrame3,realframe,frame);
  54. return hr;
  55. }
  56. STDMETHODIMP C_dxj_Direct3dRMAnimation2Object::addKey(D3DRMANIMATIONKEY_CDESC *key)
  57. {
  58. HRESULT hr;
  59. LPD3DRMANIMATIONKEY pKey=(LPD3DRMANIMATIONKEY)key;
  60. D3DRMANIMATIONKEY realkey;
  61. pKey->dwSize=sizeof(D3DRMANIMATIONKEY);
  62. if (!key) return E_INVALIDARG;
  63. if (pKey->dwKeyType==D3DRMANIMATION_ROTATEKEY )
  64. {
  65. realkey.dwSize=sizeof(D3DRMANIMATIONKEY);
  66. realkey.dwKeyType=D3DRMANIMATION_ROTATEKEY;
  67. realkey.dvTime=pKey->dvTime;
  68. realkey.dqRotateKey.v.x=key->dvX;
  69. realkey.dqRotateKey.v.y=key->dvY;
  70. realkey.dqRotateKey.v.z=key->dvZ;
  71. realkey.dqRotateKey.s=key->dvS;
  72. hr= m__dxj_Direct3dRMAnimation2->AddKey(&realkey);
  73. key->lID = realkey.dwID;
  74. }
  75. else {
  76. hr= m__dxj_Direct3dRMAnimation2->AddKey((LPD3DRMANIMATIONKEY)key);
  77. }
  78. return hr;
  79. }
  80. STDMETHODIMP C_dxj_Direct3dRMAnimation2Object::deleteKeyById(long id)
  81. {
  82. return m__dxj_Direct3dRMAnimation2->DeleteKeyByID((DWORD)id);
  83. }
  84. STDMETHODIMP C_dxj_Direct3dRMAnimation2Object::getKeys(
  85. /* [in] */ float timeMin,
  86. /* [in] */ float timeMax,
  87. /* [out][in] */ SAFEARRAY __RPC_FAR * __RPC_FAR *keyArray)
  88. {
  89. DWORD nKeys;
  90. HRESULT hr;
  91. //if (!ISSAFEARRAY1D(keyArray,count)) return E_INVALIDARG;
  92. if (!keyArray) return E_INVALIDARG;
  93. nKeys= (*keyArray)->cbElements;
  94. hr=m__dxj_Direct3dRMAnimation2->GetKeys(timeMin,timeMax,&nKeys,(D3DRMANIMATIONKEY*)((SAFEARRAY*)*keyArray)->pvData);
  95. if FAILED(hr) return hr;
  96. for (DWORD i=0;i<nKeys;i++)
  97. {
  98. D3DRMANIMATIONKEY_CDESC *pKey=&((D3DRMANIMATIONKEY_CDESC*)((SAFEARRAY*)*keyArray)->pvData)[i];
  99. if (pKey->lKeyType==D3DRMANIMATION_ROTATEKEY)
  100. {
  101. D3DRMANIMATIONKEY realkey;
  102. memcpy(&realkey,pKey,sizeof(D3DRMANIMATIONKEY));
  103. pKey->dvX=realkey.dqRotateKey.v.x;
  104. pKey->dvY=realkey.dqRotateKey.v.y;
  105. pKey->dvZ=realkey.dqRotateKey.v.z;
  106. pKey->dvS=realkey.dqRotateKey.s;
  107. }
  108. }
  109. return hr;
  110. }
  111. STDMETHODIMP C_dxj_Direct3dRMAnimation2Object::getKeysCount(
  112. /* [in] */ float timeMin,
  113. /* [in] */ float timeMax,
  114. /* [out,retval]*/ long *count)
  115. {
  116. HRESULT hr;
  117. hr=m__dxj_Direct3dRMAnimation2->GetKeys(timeMin,timeMax,(DWORD*)count,NULL);
  118. return hr;
  119. }
  120. STDMETHODIMP C_dxj_Direct3dRMAnimation2Object::modifyKey(D3DRMANIMATIONKEY_CDESC *key)
  121. {
  122. return m__dxj_Direct3dRMAnimation2->ModifyKey((LPD3DRMANIMATIONKEY)key);
  123. }
  124. DWORD C_dxj_Direct3dRMAnimation2Object::InternalAddRef(){
  125. DWORD i;
  126. i=CComObjectRoot::InternalAddRef();
  127. DPF2(1,"Direct3dRMAnimation2[%d] AddRef %d \n",creationid,i);
  128. return i;
  129. }
  130. DWORD C_dxj_Direct3dRMAnimation2Object::InternalRelease(){
  131. DWORD i;
  132. i=CComObjectRoot::InternalRelease();
  133. DPF2(1,"Direct3dRMAnimation2 [%d] Release %d \n",creationid,i);
  134. return i;
  135. }