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.

299 lines
8.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: d3drmframeinterobj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // d3drmViewport2Obj.cpp : Implementation of CDirectApp and DLL registration.
  11. #include "stdafx.h"
  12. #include "Direct.h"
  13. #include "dms.h"
  14. #include "d3drmFrameInterObj.h"
  15. #include "d3drmObjectArrayObj.h"
  16. extern void *g_dxj_Direct3dRMFrameInterpolator;
  17. //CONSTRUCTOR(_dxj_Direct3dRMViewport2, {});
  18. //DESTRUCTOR(_dxj_Direct3dRMViewport2, {});
  19. C_dxj_Direct3dRMFrameInterpolatorObject::C_dxj_Direct3dRMFrameInterpolatorObject(){
  20. m__dxj_Direct3dRMFrameInterpolator=NULL;
  21. m__dxj_Direct3dRMFrame3=NULL;
  22. parent=NULL;
  23. pinterface=NULL;
  24. creationid = ++g_creationcount;
  25. DPF1(1,"Constructor Creation Direct3dRMFrameInterpolator[%d] \n",g_creationcount);
  26. nextobj = g_dxj_Direct3dRMFrameInterpolator;
  27. g_dxj_Direct3dRMFrameInterpolator = (void *)this;
  28. }
  29. C_dxj_Direct3dRMFrameInterpolatorObject::~C_dxj_Direct3dRMFrameInterpolatorObject(){
  30. DPF1(1,"Destructor Direct3dRMFrameInterpolator [%d] \n",creationid);
  31. C_dxj_Direct3dRMFrameInterpolatorObject *prev=NULL;
  32. for(C_dxj_Direct3dRMFrameInterpolatorObject *ptr=(C_dxj_Direct3dRMFrameInterpolatorObject *)g_dxj_Direct3dRMFrameInterpolator;
  33. ptr;
  34. ptr=(C_dxj_Direct3dRMFrameInterpolatorObject *)ptr->nextobj)
  35. {
  36. if(ptr == this)
  37. {
  38. if(prev)
  39. prev->nextobj = ptr->nextobj;
  40. else
  41. g_dxj_Direct3dRMFrameInterpolator = (void*)ptr->nextobj;
  42. break;
  43. }
  44. prev = ptr;
  45. }
  46. if(m__dxj_Direct3dRMFrameInterpolator){
  47. int count = IUNK(m__dxj_Direct3dRMFrameInterpolator)->Release();
  48. DPF1(1,"DirectX real IDirect3dRMFrameInterpolator Ref count [%d] \n",count);
  49. if(count==0){
  50. m__dxj_Direct3dRMFrameInterpolator = NULL;
  51. }
  52. }
  53. if (parent)
  54. IUNK(parent)->Release();
  55. if (m__dxj_Direct3dRMFrame3)
  56. m__dxj_Direct3dRMFrame3->Release();
  57. }
  58. DWORD C_dxj_Direct3dRMFrameInterpolatorObject::InternalAddRef(){
  59. DWORD i;
  60. i=CComObjectRoot::InternalAddRef();
  61. DPF2(1,"Direct3dRMFrameInterpolator[%d] AddRef %d \n",creationid,i);
  62. return i;
  63. }
  64. DWORD C_dxj_Direct3dRMFrameInterpolatorObject::InternalRelease(){
  65. DWORD i;
  66. i=CComObjectRoot::InternalRelease();
  67. DPF2(1,"Direct3dRMFrameInterpolator [%d] Release %d \n",creationid,i);
  68. return i;
  69. }
  70. HRESULT C_dxj_Direct3dRMFrameInterpolatorObject::InternalGetObject(IUnknown **pUnk){
  71. *pUnk=(IUnknown*)m__dxj_Direct3dRMFrameInterpolator;
  72. return S_OK;
  73. }
  74. HRESULT C_dxj_Direct3dRMFrameInterpolatorObject::InternalSetObject(IUnknown *pUnk){
  75. HRESULT hr;
  76. m__dxj_Direct3dRMFrameInterpolator=(LPDIRECT3DRMINTERPOLATOR)pUnk;
  77. hr=pUnk->QueryInterface(IID_IDirect3DRMFrame3,(void**)&m__dxj_Direct3dRMFrame3);
  78. return hr;
  79. }
  80. HRESULT C_dxj_Direct3dRMFrameInterpolatorObject::attachObject( /* [in] */ I_dxj_Direct3dRMObject __RPC_FAR *rmObject){
  81. HRESULT hr;
  82. if (!rmObject) return E_INVALIDARG;
  83. DO_GETOBJECT_NOTNULL(LPUNKNOWN,pUnk,rmObject);
  84. LPDIRECT3DRMOBJECT pObj=NULL;
  85. hr=pUnk->QueryInterface(IID_IDirect3DRMObject, (void**)&pObj);
  86. if FAILED(hr) return hr;
  87. hr=m__dxj_Direct3dRMFrameInterpolator->AttachObject(pObj);
  88. if (pObj) pObj->Release();
  89. return hr;
  90. }
  91. HRESULT C_dxj_Direct3dRMFrameInterpolatorObject::detachObject( /* [in] */ I_dxj_Direct3dRMObject __RPC_FAR *rmObject){
  92. HRESULT hr;
  93. if (!rmObject) return E_INVALIDARG;
  94. DO_GETOBJECT_NOTNULL(LPUNKNOWN,pUnk,rmObject);
  95. LPDIRECT3DRMOBJECT pObj=NULL;
  96. hr=pUnk->QueryInterface(IID_IDirect3DRMObject, (void**)&pObj);
  97. if FAILED(hr) return hr;
  98. hr=m__dxj_Direct3dRMFrameInterpolator->DetachObject(pObj);
  99. if (pObj) pObj->Release();
  100. return hr;
  101. }
  102. HRESULT C_dxj_Direct3dRMFrameInterpolatorObject::getAttachedObjects( /* [retval][out] */ I_dxj_Direct3dRMObjectArray __RPC_FAR *__RPC_FAR *rmArray)
  103. {
  104. HRESULT hr;
  105. IDirect3DRMObjectArray *pArray=NULL;
  106. hr=m__dxj_Direct3dRMFrameInterpolator->GetAttachedObjects(&pArray);
  107. if FAILED(hr) return hr;
  108. INTERNAL_CREATE(_dxj_Direct3dRMObjectArray,pArray,rmArray);
  109. return S_OK;
  110. }
  111. HRESULT C_dxj_Direct3dRMFrameInterpolatorObject::setIndex( /* [in] */ float val){
  112. return m__dxj_Direct3dRMFrameInterpolator->SetIndex(val);
  113. }
  114. HRESULT C_dxj_Direct3dRMFrameInterpolatorObject::getIndex( float *val){
  115. if (!val) return E_INVALIDARG;
  116. *val=m__dxj_Direct3dRMFrameInterpolator->GetIndex();
  117. return S_OK;
  118. }
  119. HRESULT C_dxj_Direct3dRMFrameInterpolatorObject::interpolate( float val,
  120. I_dxj_Direct3dRMObject __RPC_FAR *rmObject,
  121. long options){
  122. HRESULT hr;
  123. LPDIRECT3DRMOBJECT pObj=NULL;
  124. DO_GETOBJECT_NOTNULL(LPUNKNOWN,pUnk,rmObject);
  125. //we need to validate some options here or rm goes bezerk with invalid values
  126. //note valid flags are
  127. // one of
  128. // D3DRMINTERPOLATION_CLOSED
  129. // D3DRMINTERPOLATION_OPEN -default
  130. // one of
  131. // D3DRMINTERPOLATION_NEAREST
  132. // D3DRMINTERPOLATION_SPLINE
  133. // D3DRMINTERPOLATION_LINEAR -default
  134. // D3DRMINTERPOLATION_VERTEXCOLOR - only on MeshInterpolator
  135. // D3DRMINTERPOLATION_SLERPNORMALS - not implemented
  136. // VALIDATE FLAGS
  137. DWORD opt2=0;
  138. UINT i4;
  139. if (options & D3DRMINTERPOLATION_CLOSED)
  140. opt2=D3DRMINTERPOLATION_CLOSED;
  141. else
  142. opt2=D3DRMINTERPOLATION_OPEN;
  143. if (options & D3DRMINTERPOLATION_NEAREST)
  144. opt2=opt2 | D3DRMINTERPOLATION_NEAREST;
  145. else if (options & D3DRMINTERPOLATION_SPLINE)
  146. opt2=opt2 | D3DRMINTERPOLATION_SPLINE;
  147. else
  148. opt2=opt2 | D3DRMINTERPOLATION_LINEAR;
  149. if (pUnk){
  150. hr=pUnk->QueryInterface(IID_IDirect3DRMObject, (void**)&pObj);
  151. if FAILED(hr) return hr;
  152. }
  153. hr= m__dxj_Direct3dRMFrameInterpolator->Interpolate(val,pObj,(DWORD)opt2);
  154. if (pObj) i4=pObj->Release();
  155. return hr;
  156. }
  157. /////////////////////////////////////////////////////////////////////////////
  158. STDMETHODIMP C_dxj_Direct3dRMFrameInterpolatorObject::setVelocity( I_dxj_Direct3dRMFrame3 *reference, d3dvalue x, d3dvalue y,
  159. d3dvalue z, long with_rotation)
  160. {
  161. DO_GETOBJECT_NOTNULL( LPDIRECT3DRMFRAME3, lpf, reference);
  162. m__dxj_Direct3dRMFrame3->SetVelocity((LPDIRECT3DRMFRAME3)lpf, x, y, z, with_rotation);
  163. return S_OK;
  164. }
  165. /////////////////////////////////////////////////////////////////////////////
  166. STDMETHODIMP C_dxj_Direct3dRMFrameInterpolatorObject::setOrientation( I_dxj_Direct3dRMFrame3 *reference, d3dvalue dx,d3dvalue dy,d3dvalue dz, d3dvalue ux,d3dvalue uy,d3dvalue uz)
  167. {
  168. DO_GETOBJECT_NOTNULL( LPDIRECT3DRMFRAME3, f, reference);
  169. return m__dxj_Direct3dRMFrame3->SetOrientation((LPDIRECT3DRMFRAME3)f, dx, dy, dz, ux, uy, uz);
  170. }
  171. /////////////////////////////////////////////////////////////////////////////
  172. STDMETHODIMP C_dxj_Direct3dRMFrameInterpolatorObject::setPosition(I_dxj_Direct3dRMFrame3 *reference,d3dvalue x,d3dvalue y,d3dvalue z)
  173. {
  174. DO_GETOBJECT_NOTNULL( LPDIRECT3DRMFRAME3, f, reference);
  175. return m__dxj_Direct3dRMFrame3->SetPosition((LPDIRECT3DRMFRAME3)f, x, y, z);
  176. }
  177. /////////////////////////////////////////////////////////////////////////////
  178. STDMETHODIMP C_dxj_Direct3dRMFrameInterpolatorObject::setRotation(I_dxj_Direct3dRMFrame3 *reference,d3dvalue x,d3dvalue y,
  179. d3dvalue z,d3dvalue theta)
  180. {
  181. DO_GETOBJECT_NOTNULL( LPDIRECT3DRMFRAME3, f, reference);
  182. return m__dxj_Direct3dRMFrame3->SetRotation((LPDIRECT3DRMFRAME3)f, x, y, z, theta);
  183. }
  184. /////////////////////////////////////////////////////////////////////////////
  185. STDMETHODIMP C_dxj_Direct3dRMFrameInterpolatorObject::setQuaternion(I_dxj_Direct3dRMFrame3 *refer,D3dRMQuaternion *quat)
  186. {
  187. DO_GETOBJECT_NOTNULL(IDirect3DRMFrame3*, f, refer);
  188. HRESULT hr;
  189. hr= m__dxj_Direct3dRMFrame3->SetQuaternion(f,(D3DRMQUATERNION*)quat);
  190. return hr;
  191. }
  192. STDMETHODIMP C_dxj_Direct3dRMFrameInterpolatorObject::setColor(long color)
  193. {
  194. HRESULT hr;
  195. hr= m__dxj_Direct3dRMFrame3->SetColor((D3DCOLOR)color);
  196. return hr;
  197. }
  198. STDMETHODIMP C_dxj_Direct3dRMFrameInterpolatorObject::setColorRGB(float r, float g, float b)
  199. {
  200. HRESULT hr;
  201. hr= m__dxj_Direct3dRMFrame3->SetColorRGB(r,g,b);
  202. return hr;
  203. }
  204. STDMETHODIMP C_dxj_Direct3dRMFrameInterpolatorObject::setSceneBackground(long color)
  205. {
  206. HRESULT hr;
  207. hr= m__dxj_Direct3dRMFrame3->SetSceneBackground((D3DCOLOR)color);
  208. return hr;
  209. }
  210. STDMETHODIMP C_dxj_Direct3dRMFrameInterpolatorObject::setSceneBackgroundRGB(float r, float g, float b)
  211. {
  212. HRESULT hr;
  213. hr= m__dxj_Direct3dRMFrame3->SetSceneBackgroundRGB(r,g,b);
  214. return hr;
  215. }
  216. STDMETHODIMP C_dxj_Direct3dRMFrameInterpolatorObject::setSceneFogColor(long color)
  217. {
  218. HRESULT hr;
  219. hr= m__dxj_Direct3dRMFrame3->SetSceneFogColor((D3DCOLOR)color);
  220. return hr;
  221. }
  222. STDMETHODIMP C_dxj_Direct3dRMFrameInterpolatorObject::setSceneFogParams(float start, float end, float density)
  223. {
  224. HRESULT hr;
  225. hr= m__dxj_Direct3dRMFrame3->SetSceneFogParams(start,end,density);
  226. return hr;
  227. }